From: bernhardheld Date: Sat, 1 Jul 2006 20:59:37 +0000 (+0000) Subject: * as/hc08/lkaomf51.c (OutputName), X-Git-Url: https://git.gag.com/?p=fw%2Fsdcc;a=commitdiff_plain;h=90bdb43b342189fcb94a398855d43f3f47f96738 * as/hc08/lkaomf51.c (OutputName), * as/mcs51/lkaomf51.c (OutputName), * as/z80/asmain.c (asmbl), * src/ds390/main.c (asmLineNodeFromLineNode), * src/hc08/ralloc.c (hc08_assignRegisters), * src/mcs51/main.c (asmLineNodeFromLineNode), * src/xa51/ralloc.c (checkRegMask), * src/xa51/gen.c (emitcode), * src/z80/gen.c (_emit2), * src/SDCCast.c (searchLitOp), * src/SDCCglobl.h, * support/packihx/packihx.c, * support/Util/MySystem.c (split_command): fix gcc 4 warnings * src/ds390/gen.c (aopPutUsesAcc), * src/ds390/ralloc.c (getRegBitNoSpil): unused, therefore disabled * support/regression/tests/libmullong.c (mullong_wrapper), * src/SDCCsymt.c (powof2), * src/SDCCast.c, * src/SDCCicode.c: renamed TYPE_WORD by TYPE_TARGET_INT and so on * src/SDCCsymt.h: added TYPE_TARGET_* * src/SDCCutil.c (doubleFromFixed16x16, fixed16x16FromDouble), * src/SDCCutil.h (doubleFromFixed16x16, fixed16x16FromDouble): moved to SDCCast because 1) header problems 2) this is the right place * src/SDCCast.c (doubleFromFixed16x16, fixed16x16FromDouble): added * src/SDCCval.h (doubleFromFixed16x16, fixed16x16FromDouble): added prototype git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4254 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 168b52d7..8d5c6c3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2006-07-01 Bernhard Held + + * as/hc08/lkaomf51.c (OutputName), + * as/mcs51/lkaomf51.c (OutputName), + * as/z80/asmain.c (asmbl), + * src/ds390/main.c (asmLineNodeFromLineNode), + * src/hc08/ralloc.c (hc08_assignRegisters), + * src/mcs51/main.c (asmLineNodeFromLineNode), + * src/xa51/ralloc.c (checkRegMask), + * src/xa51/gen.c (emitcode), + * src/z80/gen.c (_emit2), + * src/SDCCast.c (searchLitOp), + * src/SDCCglobl.h, + * support/packihx/packihx.c, + * support/Util/MySystem.c (split_command): fix gcc 4 warnings + * src/ds390/gen.c (aopPutUsesAcc), + * src/ds390/ralloc.c (getRegBitNoSpil): unused, therefore disabled + * support/regression/tests/libmullong.c (mullong_wrapper), + * src/SDCCsymt.c (powof2), + * src/SDCCast.c, + * src/SDCCicode.c: renamed TYPE_WORD by TYPE_TARGET_INT and so on + * src/SDCCsymt.h: added TYPE_TARGET_* + * src/SDCCutil.c (doubleFromFixed16x16, fixed16x16FromDouble), + * src/SDCCutil.h (doubleFromFixed16x16, fixed16x16FromDouble): moved to + SDCCast because 1) header problems 2) this is the right place + * src/SDCCast.c (doubleFromFixed16x16, fixed16x16FromDouble): added + * src/SDCCval.h (doubleFromFixed16x16, fixed16x16FromDouble): added + prototype + 2006-06-29 Bernhard Held * src/SDCCicode.h: removed buggy semicolon in unused macro diff --git a/as/hc08/lkaomf51.c b/as/hc08/lkaomf51.c index f1477e79..f81a96a9 100644 --- a/as/hc08/lkaomf51.c +++ b/as/hc08/lkaomf51.c @@ -203,7 +203,7 @@ void OutputWord(int value) OutputByte((unsigned char)(value/0x100)); } -void OutputName(unsigned char * name) +void OutputName(char * name) { int k; OutputByte((unsigned char)strlen(name)); diff --git a/as/mcs51/lkaomf51.c b/as/mcs51/lkaomf51.c index 37462eb5..7e650317 100644 --- a/as/mcs51/lkaomf51.c +++ b/as/mcs51/lkaomf51.c @@ -209,7 +209,7 @@ void OutputWord(int value) OutputByte((unsigned char)(value/0x100)); } -void OutputName(unsigned char * name) +void OutputName(char * name) { int k; OutputByte((unsigned char)strlen(name)); diff --git a/as/z80/asmain.c b/as/z80/asmain.c index 3972b0df..50ccb2b2 100644 --- a/as/z80/asmain.c +++ b/as/z80/asmain.c @@ -493,7 +493,7 @@ asmbl() #ifdef SDK double f1, f2; unsigned int mantissa, exponent; - const signed char readbuffer[80]; + const char readbuffer[80]; #endif laddr = dot.s_addr; lmode = SLIST; diff --git a/sim/ucsim/libtool b/sim/ucsim/libtool index 0530d161..22321aa9 100755 --- a/sim/ucsim/libtool +++ b/sim/ucsim/libtool @@ -35,7 +35,7 @@ if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi # ### BEGIN LIBTOOL CONFIG -# Libtool was configured on host toto.private.network: +# Libtool was configured on host viktoria: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -54,7 +54,7 @@ fast_install=yes # The host system. host_alias= -host=x86_64-unknown-linux-gnu +host=i686-pc-linux-gnu # An echo program that does not interpret backslashes. echo="echo" @@ -70,7 +70,7 @@ CC="gcc" with_gcc=yes # The linker used to build libraries. -LD="/usr/bin/ld" +LD="/usr/i586-suse-linux/bin/ld" # Whether we need hard or soft links. LN_S="ln -s" @@ -82,7 +82,7 @@ NM="/usr/bin/nm -B" STRIP=strip # Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=/usr/bin/file +MAGIC_CMD=file # Used on cygwin: DLL creation program. DLLTOOL="dlltool" @@ -191,7 +191,7 @@ old_striplib="strip --strip-debug" striplib="strip --strip-unneeded" # Method to check whether dependent libraries are shared objects. -deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )" +deplibs_check_method="pass_all" # Command to use when deplibs_check_method == file_magic. file_magic_cmd="\$MAGIC_CMD" diff --git a/src/SDCCast.c b/src/SDCCast.c index d607641a..f57bc148 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -2123,7 +2123,7 @@ reverseLoop (ast * loop, symbol * sym, ast * init, ast * end) /* searchLitOp - search tree (*ops only) for an ast with literal */ /*-----------------------------------------------------------------*/ static ast * -searchLitOp (ast *tree, ast **parent, const unsigned char *ops) +searchLitOp (ast *tree, ast **parent, const char *ops) { ast *ret; @@ -3093,7 +3093,7 @@ decorateType (ast * tree, RESULT_TYPE resultType) /* rearrange the tree */ if (IS_LITERAL (RTYPE (tree)) /* avoid infinite loop */ - && (TYPE_UDWORD) floatFromVal (tree->right->opval.val) != 1) + && (TYPE_TARGET_ULONG) floatFromVal (tree->right->opval.val) != 1) { ast *parent; ast *litTree = searchLitOp (tree, &parent, "/"); @@ -3537,7 +3537,7 @@ decorateType (ast * tree, RESULT_TYPE resultType) /* rearrange the tree */ if (IS_LITERAL (RTYPE (tree)) /* avoid infinite loop */ - && (TYPE_UDWORD) floatFromVal (tree->right->opval.val) != 0) + && (TYPE_TARGET_ULONG) floatFromVal (tree->right->opval.val) != 0) { ast *litTree, *litParent; litTree = searchLitOp (tree, &litParent, "+-"); @@ -3759,7 +3759,7 @@ decorateType (ast * tree, RESULT_TYPE resultType) /* if only the right side is a literal & we are shifting more than size of the left operand then zero */ if (IS_LITERAL (RTYPE (tree)) && - ((TYPE_UDWORD) floatFromVal (valFromType (RETYPE (tree)))) >= + ((TYPE_TARGET_ULONG) floatFromVal (valFromType (RETYPE (tree)))) >= (getSize (TETYPE (tree)) * 8)) { if (tree->opval.op==LEFT_OP || @@ -5324,7 +5324,7 @@ isBitAndPow2 (ast * tree) if (!IS_AST_LIT_VALUE (tree->right)) return -1; - return powof2 ((TYPE_UDWORD)AST_LIT_VALUE (tree->right)); + return powof2 ((TYPE_TARGET_ULONG)AST_LIT_VALUE (tree->right)); } /*-----------------------------------------------------------------*/ @@ -6118,10 +6118,10 @@ void ast_print (ast * tree, FILE *outfile, int indent) if (IS_LITERAL (tree->opval.val->etype)) { fprintf(outfile,"CONSTANT (%p) value = ", tree); if (SPEC_USIGN (tree->opval.val->etype)) - fprintf(outfile,"%u", (TYPE_UDWORD) floatFromVal(tree->opval.val)); + fprintf(outfile,"%u", (TYPE_TARGET_ULONG) floatFromVal(tree->opval.val)); else - fprintf(outfile,"%d", (TYPE_DWORD) floatFromVal(tree->opval.val)); - fprintf(outfile,", 0x%x, %f", (TYPE_UDWORD) floatFromVal(tree->opval.val), + fprintf(outfile,"%d", (TYPE_TARGET_LONG) floatFromVal(tree->opval.val)); + fprintf(outfile,", 0x%x, %f", (TYPE_TARGET_ULONG) floatFromVal(tree->opval.val), floatFromVal(tree->opval.val)); } else if (tree->opval.val->sym) { /* if the undefined flag is set then give error message */ diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index 1b34d11a..48198eff 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -146,18 +146,18 @@ typedef int bool; */ struct optimize { - unsigned global_cse; - unsigned ptrArithmetic; - unsigned label1; - unsigned label2; - unsigned label3; - unsigned label4; - unsigned loopInvariant; - unsigned loopInduction; - unsigned noJTabBoundary; - unsigned noLoopReverse; - unsigned codeSpeed; - unsigned codeSize; + int global_cse; + int ptrArithmetic; + int label1; + int label2; + int label3; + int label4; + int loopInvariant; + int loopInduction; + int noJTabBoundary; + int noLoopReverse; + int codeSpeed; + int codeSize; }; /** Build model. diff --git a/src/SDCCicode.c b/src/SDCCicode.c index bc5bf842..4eeeab56 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -1156,26 +1156,26 @@ operandOperation (operand * left, operand * right, /* signed and unsigned mul are the same, as long as the precision of the result isn't bigger than the precision of the operands. */ retval = operandFromValue (valCastLiteral (type, - (TYPE_UDWORD) operandLitValue (left) * - (TYPE_UDWORD) operandLitValue (right))); + (TYPE_TARGET_ULONG) operandLitValue (left) * + (TYPE_TARGET_ULONG) operandLitValue (right))); else if (IS_UNSIGNED (type)) /* unsigned int */ { /* unsigned int is handled here in order to detect overflow */ - TYPE_UDWORD ul = (TYPE_UWORD) operandLitValue (left) * - (TYPE_UWORD) operandLitValue (right); + TYPE_TARGET_ULONG ul = (TYPE_TARGET_UINT) operandLitValue (left) * + (TYPE_TARGET_UINT) operandLitValue (right); - retval = operandFromValue (valCastLiteral (type, (TYPE_UWORD) ul)); - if (ul != (TYPE_UWORD) ul) + retval = operandFromValue (valCastLiteral (type, (TYPE_TARGET_UINT) ul)); + if (ul != (TYPE_TARGET_UINT) ul) werror (W_INT_OVL); } else /* signed int */ { /* signed int is handled here in order to detect overflow */ - TYPE_DWORD l = (TYPE_WORD) operandLitValue (left) * - (TYPE_WORD) operandLitValue (right); + TYPE_TARGET_LONG l = (TYPE_TARGET_INT) operandLitValue (left) * + (TYPE_TARGET_INT) operandLitValue (right); - retval = operandFromValue (valCastLiteral (type, (TYPE_WORD) l)); - if (l != (TYPE_WORD) l) + retval = operandFromValue (valCastLiteral (type, (TYPE_TARGET_INT) l)); + if (l != (TYPE_TARGET_INT) l) werror (W_INT_OVL); } } @@ -1186,7 +1186,7 @@ operandOperation (operand * left, operand * right, operandLitValue (right))); break; case '/': - if ((TYPE_UDWORD) operandLitValue (right) == 0) + if ((TYPE_TARGET_ULONG) operandLitValue (right) == 0) { werror (E_DIVIDE_BY_ZERO); retval = right; @@ -1199,8 +1199,8 @@ operandOperation (operand * left, operand * right, SPEC_USIGN (let) = 1; SPEC_USIGN (ret) = 1; retval = operandFromValue (valCastLiteral (type, - (TYPE_UDWORD) operandLitValue (left) / - (TYPE_UDWORD) operandLitValue (right))); + (TYPE_TARGET_ULONG) operandLitValue (left) / + (TYPE_TARGET_ULONG) operandLitValue (right))); } else { @@ -1211,7 +1211,7 @@ operandOperation (operand * left, operand * right, } break; case '%': - if ((TYPE_UDWORD) operandLitValue (right) == 0) + if ((TYPE_TARGET_ULONG) operandLitValue (right) == 0) { werror (E_DIVIDE_BY_ZERO); retval = right; @@ -1219,31 +1219,31 @@ operandOperation (operand * left, operand * right, else { if (IS_UNSIGNED (type)) - retval = operandFromLit ((TYPE_UDWORD) operandLitValue (left) % - (TYPE_UDWORD) operandLitValue (right)); + retval = operandFromLit ((TYPE_TARGET_ULONG) operandLitValue (left) % + (TYPE_TARGET_ULONG) operandLitValue (right)); else - retval = operandFromLit ((TYPE_DWORD) operandLitValue (left) % - (TYPE_DWORD) operandLitValue (right)); + retval = operandFromLit ((TYPE_TARGET_LONG) operandLitValue (left) % + (TYPE_TARGET_LONG) operandLitValue (right)); } break; case LEFT_OP: /* The number of left shifts is always unsigned. Signed doesn't make sense here. Shifting by a negative number is impossible. */ retval = operandFromValue (valCastLiteral (type, - ((TYPE_UDWORD) operandLitValue (left) << - (TYPE_UDWORD) operandLitValue (right)))); + ((TYPE_TARGET_ULONG) operandLitValue (left) << + (TYPE_TARGET_ULONG) operandLitValue (right)))); break; case RIGHT_OP: /* The number of right shifts is always unsigned. Signed doesn't make sense here. Shifting by a negative number is impossible. */ if (IS_UNSIGNED(let)) /* unsigned: logic shift right */ - retval = operandFromLit ((TYPE_UDWORD) operandLitValue (left) >> - (TYPE_UDWORD) operandLitValue (right)); + retval = operandFromLit ((TYPE_TARGET_ULONG) operandLitValue (left) >> + (TYPE_TARGET_ULONG) operandLitValue (right)); else /* signed: arithmetic shift right */ - retval = operandFromLit ((TYPE_DWORD ) operandLitValue (left) >> - (TYPE_UDWORD) operandLitValue (right)); + retval = operandFromLit ((TYPE_TARGET_LONG ) operandLitValue (left) >> + (TYPE_TARGET_ULONG) operandLitValue (right)); break; case EQ_OP: if (IS_FLOAT (let) || IS_FLOAT (ret)) @@ -1259,10 +1259,10 @@ operandOperation (operand * left, operand * right, else { /* this op doesn't care about signedness */ - TYPE_UDWORD l, r; + TYPE_TARGET_ULONG l, r; - l = (TYPE_UDWORD) operandLitValue (left); - r = (TYPE_UDWORD) operandLitValue (right); + l = (TYPE_TARGET_ULONG) operandLitValue (left); + r = (TYPE_TARGET_ULONG) operandLitValue (right); /* In order to correctly compare 'signed int' and 'unsigned int' it's neccessary to strip them to 16 bit. Literals are reduced to their cheapest type, therefore left and @@ -1271,8 +1271,8 @@ operandOperation (operand * left, operand * right, if (!IS_LONG (let) && !IS_LONG (ret)) { - r = (TYPE_UWORD) r; - l = (TYPE_UWORD) l; + r = (TYPE_TARGET_UINT) r; + l = (TYPE_TARGET_UINT) l; } retval = operandFromLit (l == r); } @@ -1299,18 +1299,18 @@ operandOperation (operand * left, operand * right, break; case BITWISEAND: retval = operandFromValue (valCastLiteral (type, - (TYPE_UDWORD)operandLitValue(left) & - (TYPE_UDWORD)operandLitValue(right))); + (TYPE_TARGET_ULONG)operandLitValue(left) & + (TYPE_TARGET_ULONG)operandLitValue(right))); break; case '|': retval = operandFromValue (valCastLiteral (type, - (TYPE_UDWORD)operandLitValue(left) | - (TYPE_UDWORD)operandLitValue(right))); + (TYPE_TARGET_ULONG)operandLitValue(left) | + (TYPE_TARGET_ULONG)operandLitValue(right))); break; case '^': retval = operandFromValue (valCastLiteral (type, - (TYPE_UDWORD)operandLitValue(left) ^ - (TYPE_UDWORD)operandLitValue(right))); + (TYPE_TARGET_ULONG)operandLitValue(left) ^ + (TYPE_TARGET_ULONG)operandLitValue(right))); break; case AND_OP: retval = operandFromLit (operandLitValue (left) && @@ -1322,7 +1322,7 @@ operandOperation (operand * left, operand * right, break; case RRC: { - TYPE_UDWORD i = (TYPE_UDWORD) operandLitValue (left); + TYPE_TARGET_ULONG i = (TYPE_TARGET_ULONG) operandLitValue (left); retval = operandFromLit ((i >> (getSize (operandType (left)) * 8 - 1)) | (i << 1)); @@ -1330,27 +1330,27 @@ operandOperation (operand * left, operand * right, break; case RLC: { - TYPE_UDWORD i = (TYPE_UDWORD) operandLitValue (left); + TYPE_TARGET_ULONG i = (TYPE_TARGET_ULONG) operandLitValue (left); retval = operandFromLit ((i << (getSize (operandType (left)) * 8 - 1)) | (i >> 1)); } break; case GETABIT: - retval = operandFromLit (((TYPE_UDWORD)operandLitValue(left) >> - (TYPE_UDWORD)operandLitValue(right)) & 1); + retval = operandFromLit (((TYPE_TARGET_ULONG)operandLitValue(left) >> + (TYPE_TARGET_ULONG)operandLitValue(right)) & 1); break; case GETBYTE: - retval = operandFromLit (((TYPE_UDWORD)operandLitValue(left) >> - (TYPE_UDWORD)operandLitValue(right)) & 0xFF); + retval = operandFromLit (((TYPE_TARGET_ULONG)operandLitValue(left) >> + (TYPE_TARGET_ULONG)operandLitValue(right)) & 0xFF); break; case GETWORD: - retval = operandFromLit (((TYPE_UDWORD)operandLitValue(left) >> - (TYPE_UDWORD)operandLitValue(right)) & 0xFFFF); + retval = operandFromLit (((TYPE_TARGET_ULONG)operandLitValue(left) >> + (TYPE_TARGET_ULONG)operandLitValue(right)) & 0xFFFF); break; case GETHBIT: - retval = operandFromLit (((TYPE_UDWORD)operandLitValue(left) >> + retval = operandFromLit (((TYPE_TARGET_ULONG)operandLitValue(left) >> ((getSize (let) * 8) - 1)) & 1); break; @@ -1361,7 +1361,7 @@ operandOperation (operand * left, operand * right, case '~': retval = operandFromValue (valCastLiteral (type, - ~((TYPE_UDWORD) + ~((TYPE_TARGET_ULONG) operandLitValue (left)))); break; @@ -2098,7 +2098,7 @@ geniCodeMultiply (operand * left, operand * right, RESULT_TYPE resultType) right->operand.valOperand)); if (IS_LITERAL(retype)) { - p2 = powof2 ((TYPE_UDWORD) floatFromVal (right->operand.valOperand)); + p2 = powof2 ((TYPE_TARGET_ULONG) floatFromVal (right->operand.valOperand)); } resType = usualBinaryConversions (&left, &right, resultType, '*'); @@ -2165,7 +2165,7 @@ geniCodeDivision (operand * left, operand * right, RESULT_TYPE resultType) !IS_FLOAT (letype) && !IS_FIXED (letype) && IS_UNSIGNED(letype) && - ((p2 = powof2 ((TYPE_UDWORD) + ((p2 = powof2 ((TYPE_TARGET_ULONG) floatFromVal (right->operand.valOperand))) > 0)) { ic = newiCode (RIGHT_OP, left, operandFromLit (p2)); /* right shift */ } diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 6e2b7aed..e86314e2 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -3125,7 +3125,7 @@ printTypeChainRaw (sym_link * start, FILE * of) /* powof2 - returns power of two for the number if number is pow 2 */ /*-----------------------------------------------------------------*/ int -powof2 (TYPE_UDWORD num) +powof2 (TYPE_TARGET_ULONG num) { int nshifts = 0; int n1s = 0; diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 1d54708f..aae73278 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -136,6 +136,13 @@ typedef enum } STORAGE_CLASS; +#define TYPE_TARGET_CHAR TYPE_BYTE +#define TYPE_TARGET_INT TYPE_WORD +#define TYPE_TARGET_LONG TYPE_DWORD +#define TYPE_TARGET_UCHAR TYPE_UBYTE +#define TYPE_TARGET_UINT TYPE_UWORD +#define TYPE_TARGET_ULONG TYPE_UDWORD + /* specifier is the last in the type-chain */ typedef struct specifier { @@ -161,14 +168,14 @@ typedef struct specifier int argreg; /* reg no for regparm */ union { /* Values if constant or enum */ - TYPE_WORD v_int; /* 2 bytes: int and char values */ - char *v_char; /* character string */ - TYPE_UWORD v_uint; /* 2 bytes: unsigned int const value */ - TYPE_DWORD v_long; /* 4 bytes: long constant value */ - TYPE_UDWORD v_ulong; /* 4 bytes: unsigned long constant value */ - double v_float; /* floating point constant value */ - TYPE_UDWORD v_fixed16x16; /* 4 bytes: fixed floating point constant value */ - struct symbol *v_enum; /* ptr to enum_list if enum==1 */ + TYPE_TARGET_INT v_int; /* 2 bytes: int and char values */ + TYPE_TARGET_CHAR *v_char; /* character string */ + TYPE_TARGET_UINT v_uint; /* 2 bytes: unsigned int const value */ + TYPE_TARGET_LONG v_long; /* 4 bytes: long constant value */ + TYPE_TARGET_ULONG v_ulong; /* 4 bytes: unsigned long constant value */ + double v_float; /* floating point constant value */ + TYPE_TARGET_ULONG v_fixed16x16; /* 4 bytes: fixed floating point constant value */ + struct symbol *v_enum; /* ptr to enum_list if enum==1 */ } const_val; struct structdef *v_struct; /* structure pointer */ @@ -601,7 +608,7 @@ sym_link *computeType (sym_link *, sym_link *, RESULT_TYPE, int); void processFuncPtrArgs (sym_link *); void processFuncArgs (symbol *); int isSymbolEqual (symbol *, symbol *); -int powof2 (TYPE_UDWORD); +int powof2 (TYPE_TARGET_ULONG); void printTypeChain (sym_link *, FILE *); void printTypeChainRaw (sym_link *, FILE *); void initCSupport (); diff --git a/src/SDCCutil.c b/src/SDCCutil.c index a08cd115..da0223f6 100644 --- a/src/SDCCutil.c +++ b/src/SDCCutil.c @@ -298,57 +298,6 @@ const char *getBuildNumber(void) return (SDCC_BUILD_NUMBER); } -/*-----------------------------------------------------------------*/ -/* doubleFromFixed16x16 - convert a fixed16x16 to double */ -/*-----------------------------------------------------------------*/ -double doubleFromFixed16x16(TYPE_UDWORD value) -{ -#if 0 - /* This version is incorrect negative values. */ - double tmp=0, exp=2; - - tmp = (value & 0xffff0000) >> 16; - - while(value) { - value &= 0xffff; - if(value & 0x8000)tmp += 1/exp; - exp *= 2; - value <<= 1; - } - - return (tmp); -#else - return ((double)(value * 1.0) / (double)(1UL << 16)); -#endif -} - -TYPE_UDWORD fixed16x16FromDouble(double value) -{ -#if 0 - /* This version is incorrect negative values. */ - unsigned int tmp=0, pos=16; - TYPE_UDWORD res; - - tmp = floor( value ); - res = tmp << 16; - value -= tmp; - - tmp = 0; - while(pos--) { - value *= 2; - if(value >= 1.0)tmp |= (1 << pos); - value -= floor( value ); - } - - res |= tmp; - - return (res); -#else - return (TYPE_UDWORD)(value * (double)(1UL << 16)); -#endif -} - - #if defined(HAVE_VSNPRINTF) || defined(HAVE_VSPRINTF) size_t SDCCsnprintf(char *dst, size_t n, const char *fmt, ...) { diff --git a/src/SDCCutil.h b/src/SDCCutil.h index c939868a..d8956d49 100644 --- a/src/SDCCutil.h +++ b/src/SDCCutil.h @@ -88,12 +88,6 @@ char *strncatz(char *dest, const char *src, size_t n); /* return SDCC build number */ const char *getBuildNumber(void); -/* convert a fixed16x16 type to double */ -double doubleFromFixed16x16(TYPE_UDWORD value); - -/* convert a double type to fixed16x16 */ -TYPE_UDWORD fixed16x16FromDouble(double value); - /* snprintf, by hook or by crook. */ size_t SDCCsnprintf(char *, size_t, const char *, ...); diff --git a/src/SDCCval.c b/src/SDCCval.c index d8271ba8..e0821e1e 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -400,7 +400,7 @@ checkConstantRange (sym_link *var, sym_link *lit, int op, bool exchangeLeftRight { if (SPEC_USIGN (var)) { - TYPE_UDWORD maxVal = 0xffffffffu >> (32 - varBits); + TYPE_TARGET_ULONG maxVal = 0xffffffffu >> (32 - varBits); if ( litVal < 0 || litVal > maxVal) @@ -409,8 +409,8 @@ checkConstantRange (sym_link *var, sym_link *lit, int op, bool exchangeLeftRight } else { - TYPE_DWORD minVal = 0xffffffff << (varBits - 1); - TYPE_DWORD maxVal = 0x7fffffff >> (32 - varBits); + TYPE_TARGET_LONG minVal = 0xffffffff << (varBits - 1); + TYPE_TARGET_LONG maxVal = 0x7fffffff >> (32 - varBits); if ( litVal < minVal || litVal > maxVal) @@ -422,8 +422,8 @@ checkConstantRange (sym_link *var, sym_link *lit, int op, bool exchangeLeftRight { /* ignore signedness, e.g. allow everything from -127...+255 for (unsigned) char */ - TYPE_DWORD minVal = 0xffffffff << (varBits - 1); - TYPE_UDWORD maxVal = 0xffffffffu >> (32 - varBits); + TYPE_TARGET_LONG minVal = 0xffffffff << (varBits - 1); + TYPE_TARGET_ULONG maxVal = 0xffffffffu >> (32 - varBits); if ( litVal < minVal || litVal > maxVal) @@ -449,8 +449,8 @@ checkConstantRange (sym_link *var, sym_link *lit, int op, bool exchangeLeftRight if (SPEC_USIGN (reType)) { /* unsigned operation */ - TYPE_UDWORD minValP, maxValP, minValM, maxValM; - TYPE_UDWORD opBitsMask = 0xffffffffu >> (32 - bitsForType (reType)); + TYPE_TARGET_ULONG minValP, maxValP, minValM, maxValM; + TYPE_TARGET_ULONG opBitsMask = 0xffffffffu >> (32 - bitsForType (reType)); if (SPEC_USIGN (lit) && SPEC_USIGN (var)) { @@ -480,7 +480,7 @@ checkConstantRange (sym_link *var, sym_link *lit, int op, bool exchangeLeftRight { /* make signed literal unsigned and limit no of bits to size of return type */ - litVal = (TYPE_UDWORD) litVal & opBitsMask; + litVal = (TYPE_TARGET_ULONG) litVal & opBitsMask; } } else /* SPEC_USIGN (lit) */ @@ -560,7 +560,7 @@ checkConstantRange (sym_link *var, sym_link *lit, int op, bool exchangeLeftRight else { /* signed operation */ - TYPE_DWORD minVal, maxVal; + TYPE_TARGET_LONG minVal, maxVal; if (SPEC_USIGN (var)) { @@ -627,9 +627,9 @@ valueFromLit (double lit) { char buffer[50]; - if ((((TYPE_DWORD) lit) - lit) == 0) + if ((((TYPE_TARGET_LONG) lit) - lit) == 0) { - SNPRINTF (buffer, sizeof(buffer), "%d", (TYPE_DWORD) lit); + SNPRINTF (buffer, sizeof(buffer), "%d", (TYPE_TARGET_LONG) lit); return constVal (buffer); } @@ -783,22 +783,22 @@ value *constVal (char *s) { if (SPEC_USIGN (val->type)) { - SPEC_CVAL (val->type).v_ulong = (TYPE_UDWORD)dval; + SPEC_CVAL (val->type).v_ulong = (TYPE_TARGET_ULONG)dval; } else { - SPEC_CVAL (val->type).v_long = (TYPE_DWORD)dval; + SPEC_CVAL (val->type).v_long = (TYPE_TARGET_LONG)dval; } } else { if (SPEC_USIGN (val->type)) { - SPEC_CVAL (val->type).v_uint = (TYPE_UWORD)dval; + SPEC_CVAL (val->type).v_uint = (TYPE_TARGET_UINT)dval; } else { - SPEC_CVAL (val->type).v_int = (TYPE_WORD)dval; + SPEC_CVAL (val->type).v_int = (TYPE_TARGET_INT)dval; } } @@ -1215,6 +1215,56 @@ floatFromVal (value * val) return 0; } +/*-----------------------------------------------------------------*/ +/* doubleFromFixed16x16 - convert a fixed16x16 to double */ +/*-----------------------------------------------------------------*/ +double doubleFromFixed16x16(TYPE_TARGET_ULONG value) +{ +#if 0 + /* This version is incorrect negative values. */ + double tmp=0, exp=2; + + tmp = (value & 0xffff0000) >> 16; + + while(value) { + value &= 0xffff; + if(value & 0x8000)tmp += 1/exp; + exp *= 2; + value <<= 1; + } + + return (tmp); +#else + return ((double)(value * 1.0) / (double)(1UL << 16)); +#endif +} + +TYPE_TARGET_ULONG fixed16x16FromDouble(double value) +{ +#if 0 + /* This version is incorrect negative values. */ + unsigned int tmp=0, pos=16; + TYPE_TARGET_ULONG res; + + tmp = floor( value ); + res = tmp << 16; + value -= tmp; + + tmp = 0; + while(pos--) { + value *= 2; + if(value >= 1.0)tmp |= (1 << pos); + value -= floor( value ); + } + + res |= tmp; + + return (res); +#else + return (TYPE_TARGET_ULONG)(value * (double)(1UL << 16)); +#endif +} + /*------------------------------------------------------------------*/ /* valUnaryPM - does the unary +/- operation on a constant */ /*------------------------------------------------------------------*/ @@ -1340,24 +1390,24 @@ valMult (value * lval, value * rval) /* signed and unsigned mul are the same, as long as the precision of the result isn't bigger than the precision of the operands. */ else if (SPEC_LONG (val->type)) - SPEC_CVAL (val->type).v_ulong = (TYPE_UDWORD) floatFromVal (lval) * - (TYPE_UDWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_ulong = (TYPE_TARGET_ULONG) floatFromVal (lval) * + (TYPE_TARGET_ULONG) floatFromVal (rval); else if (SPEC_USIGN (val->type)) /* unsigned int */ { - TYPE_UDWORD ul = (TYPE_UWORD) floatFromVal (lval) * - (TYPE_UWORD) floatFromVal (rval); + TYPE_TARGET_ULONG ul = (TYPE_TARGET_UINT) floatFromVal (lval) * + (TYPE_TARGET_UINT) floatFromVal (rval); - SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) ul; - if (ul != (TYPE_UWORD) ul) + SPEC_CVAL (val->type).v_uint = (TYPE_TARGET_UINT) ul; + if (ul != (TYPE_TARGET_UINT) ul) werror (W_INT_OVL); } else /* signed int */ { - TYPE_DWORD l = (TYPE_WORD) floatFromVal (lval) * - (TYPE_WORD) floatFromVal (rval); + TYPE_TARGET_LONG l = (TYPE_TARGET_INT) floatFromVal (lval) * + (TYPE_TARGET_INT) floatFromVal (rval); - SPEC_CVAL (val->type).v_int = (TYPE_WORD) l; - if (l != (TYPE_WORD) l) + SPEC_CVAL (val->type).v_int = (TYPE_TARGET_INT) l; + if (l != (TYPE_TARGET_INT) l) werror (W_INT_OVL); } return cheapestVal (val); @@ -1393,20 +1443,20 @@ valDiv (value * lval, value * rval) else if (SPEC_LONG (val->type)) { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_ulong = (TYPE_UDWORD) floatFromVal (lval) / - (TYPE_UDWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_ulong = (TYPE_TARGET_ULONG) floatFromVal (lval) / + (TYPE_TARGET_ULONG) floatFromVal (rval); else - SPEC_CVAL (val->type).v_long = (TYPE_DWORD) floatFromVal (lval) / - (TYPE_DWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_long = (TYPE_TARGET_LONG) floatFromVal (lval) / + (TYPE_TARGET_LONG) floatFromVal (rval); } else { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) floatFromVal (lval) / - (TYPE_UWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_uint = (TYPE_TARGET_UINT) floatFromVal (lval) / + (TYPE_TARGET_UINT) floatFromVal (rval); else - SPEC_CVAL (val->type).v_int = (TYPE_WORD) floatFromVal (lval) / - (TYPE_WORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_int = (TYPE_TARGET_INT) floatFromVal (lval) / + (TYPE_TARGET_INT) floatFromVal (rval); } return cheapestVal (val); } @@ -1430,20 +1480,20 @@ valMod (value * lval, value * rval) if (SPEC_LONG (val->type)) { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_ulong = (TYPE_UDWORD) floatFromVal (lval) % - (TYPE_UDWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_ulong = (TYPE_TARGET_ULONG) floatFromVal (lval) % + (TYPE_TARGET_ULONG) floatFromVal (rval); else - SPEC_CVAL (val->type).v_long = (TYPE_DWORD) floatFromVal (lval) % - (TYPE_DWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_long = (TYPE_TARGET_LONG) floatFromVal (lval) % + (TYPE_TARGET_LONG) floatFromVal (rval); } else { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) floatFromVal (lval) % - (TYPE_UWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_uint = (TYPE_TARGET_UINT) floatFromVal (lval) % + (TYPE_TARGET_UINT) floatFromVal (rval); else - SPEC_CVAL (val->type).v_int = (TYPE_WORD) floatFromVal (lval) % - (TYPE_WORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_int = (TYPE_TARGET_INT) floatFromVal (lval) % + (TYPE_TARGET_INT) floatFromVal (rval); } return cheapestVal (val); } @@ -1472,20 +1522,20 @@ valPlus (value * lval, value * rval) else if (SPEC_LONG (val->type)) { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_ulong = (TYPE_UDWORD) floatFromVal (lval) + - (TYPE_UDWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_ulong = (TYPE_TARGET_ULONG) floatFromVal (lval) + + (TYPE_TARGET_ULONG) floatFromVal (rval); else - SPEC_CVAL (val->type).v_long = (TYPE_DWORD) floatFromVal (lval) + - (TYPE_DWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_long = (TYPE_TARGET_LONG) floatFromVal (lval) + + (TYPE_TARGET_LONG) floatFromVal (rval); } else { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) floatFromVal (lval) + - (TYPE_UWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_uint = (TYPE_TARGET_UINT) floatFromVal (lval) + + (TYPE_TARGET_UINT) floatFromVal (rval); else - SPEC_CVAL (val->type).v_int = (TYPE_WORD) floatFromVal (lval) + - (TYPE_WORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_int = (TYPE_TARGET_INT) floatFromVal (lval) + + (TYPE_TARGET_INT) floatFromVal (rval); } return cheapestVal (val); } @@ -1514,20 +1564,20 @@ valMinus (value * lval, value * rval) else if (SPEC_LONG (val->type)) { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_ulong = (TYPE_UDWORD) floatFromVal (lval) - - (TYPE_UDWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_ulong = (TYPE_TARGET_ULONG) floatFromVal (lval) - + (TYPE_TARGET_ULONG) floatFromVal (rval); else - SPEC_CVAL (val->type).v_long = (TYPE_DWORD) floatFromVal (lval) - - (TYPE_DWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_long = (TYPE_TARGET_LONG) floatFromVal (lval) - + (TYPE_TARGET_LONG) floatFromVal (rval); } else { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) floatFromVal (lval) - - (TYPE_UWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_uint = (TYPE_TARGET_UINT) floatFromVal (lval) - + (TYPE_TARGET_UINT) floatFromVal (rval); else - SPEC_CVAL (val->type).v_int = (TYPE_WORD) floatFromVal (lval) - - (TYPE_WORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_int = (TYPE_TARGET_INT) floatFromVal (lval) - + (TYPE_TARGET_INT) floatFromVal (rval); } return cheapestVal (val); } @@ -1548,7 +1598,7 @@ valShift (value * lval, value * rval, int lr) 'S'); SPEC_SCLS (val->etype) = S_LITERAL; /* will remain literal */ - if (getSize (val->type) * 8 <= (TYPE_UDWORD) floatFromVal (rval) && + if (getSize (val->type) * 8 <= (TYPE_TARGET_ULONG) floatFromVal (rval) && /* left shift */ (lr || /* right shift and unsigned */ @@ -1562,14 +1612,14 @@ valShift (value * lval, value * rval, int lr) if (SPEC_USIGN (val->type)) { SPEC_CVAL (val->type).v_ulong = lr ? - (TYPE_UDWORD) floatFromVal (lval) << (TYPE_UDWORD) floatFromVal (rval) : \ - (TYPE_UDWORD) floatFromVal (lval) >> (TYPE_UDWORD) floatFromVal (rval); + (TYPE_TARGET_ULONG) floatFromVal (lval) << (TYPE_TARGET_ULONG) floatFromVal (rval) : \ + (TYPE_TARGET_ULONG) floatFromVal (lval) >> (TYPE_TARGET_ULONG) floatFromVal (rval); } else { SPEC_CVAL (val->type).v_long = lr ? - (TYPE_DWORD) floatFromVal (lval) << (TYPE_UDWORD) floatFromVal (rval) : \ - (TYPE_DWORD) floatFromVal (lval) >> (TYPE_UDWORD) floatFromVal (rval); + (TYPE_TARGET_LONG) floatFromVal (lval) << (TYPE_TARGET_ULONG) floatFromVal (rval) : \ + (TYPE_TARGET_LONG) floatFromVal (lval) >> (TYPE_TARGET_ULONG) floatFromVal (rval); } } else @@ -1577,14 +1627,14 @@ valShift (value * lval, value * rval, int lr) if (SPEC_USIGN (val->type)) { SPEC_CVAL (val->type).v_uint = lr ? - (TYPE_UWORD) floatFromVal (lval) << (TYPE_UDWORD) floatFromVal (rval) : \ - (TYPE_UWORD) floatFromVal (lval) >> (TYPE_UDWORD) floatFromVal (rval); + (TYPE_TARGET_UINT) floatFromVal (lval) << (TYPE_TARGET_ULONG) floatFromVal (rval) : \ + (TYPE_TARGET_UINT) floatFromVal (lval) >> (TYPE_TARGET_ULONG) floatFromVal (rval); } else { SPEC_CVAL (val->type).v_int = lr ? - (TYPE_WORD) floatFromVal (lval) << (TYPE_UDWORD) floatFromVal (rval) : \ - (TYPE_WORD) floatFromVal (lval) >> (TYPE_UDWORD) floatFromVal (rval); + (TYPE_TARGET_INT) floatFromVal (lval) << (TYPE_TARGET_ULONG) floatFromVal (rval) : \ + (TYPE_TARGET_INT) floatFromVal (lval) >> (TYPE_TARGET_ULONG) floatFromVal (rval); } } return cheapestVal (val); @@ -1639,10 +1689,10 @@ valCompare (value * lval, value * rval, int ctype) else { /* integrals: ignore signedness */ - TYPE_UDWORD l, r; + TYPE_TARGET_ULONG l, r; - l = (TYPE_UDWORD) floatFromVal (lval); - r = (TYPE_UDWORD) floatFromVal (rval); + l = (TYPE_TARGET_ULONG) floatFromVal (lval); + r = (TYPE_TARGET_ULONG) floatFromVal (rval); /* In order to correctly compare 'signed int' and 'unsigned int' it's neccessary to strip them to 16 bit. Literals are reduced to their cheapest type, therefore left and @@ -1651,8 +1701,8 @@ valCompare (value * lval, value * rval, int ctype) if (!IS_LONG (lval->etype) && !IS_LONG (rval->etype)) { - r = (TYPE_UWORD) r; - l = (TYPE_UWORD) l; + r = (TYPE_TARGET_UINT) r; + l = (TYPE_TARGET_UINT) l; } SPEC_CVAL (val->type).v_int = l == r; } @@ -1672,10 +1722,10 @@ valCompare (value * lval, value * rval, int ctype) else { /* integrals: ignore signedness */ - TYPE_UDWORD l, r; + TYPE_TARGET_ULONG l, r; - l = (TYPE_UDWORD) floatFromVal (lval); - r = (TYPE_UDWORD) floatFromVal (rval); + l = (TYPE_TARGET_ULONG) floatFromVal (lval); + r = (TYPE_TARGET_ULONG) floatFromVal (rval); /* In order to correctly compare 'signed int' and 'unsigned int' it's neccessary to strip them to 16 bit. Literals are reduced to their cheapest type, therefore left and @@ -1684,8 +1734,8 @@ valCompare (value * lval, value * rval, int ctype) if (!IS_LONG (lval->etype) && !IS_LONG (rval->etype)) { - r = (TYPE_UWORD) r; - l = (TYPE_UWORD) l; + r = (TYPE_TARGET_UINT) r; + l = (TYPE_TARGET_UINT) l; } SPEC_CVAL (val->type).v_int = l != r; } @@ -1716,19 +1766,20 @@ valBitwise (value * lval, value * rval, int op) if (SPEC_LONG (val->type)) { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_ulong = (TYPE_UDWORD) floatFromVal (lval) & - (TYPE_UDWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_ulong = (TYPE_TARGET_ULONG) floatFromVal (lval) & + (TYPE_TARGET_ULONG) floatFromVal (rval); else - SPEC_CVAL (val->type).v_long = (TYPE_DWORD) floatFromVal (lval) & - (TYPE_DWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_long = (TYPE_TARGET_LONG) floatFromVal (lval) & + (TYPE_TARGET_LONG) floatFromVal (rval); } else { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) floatFromVal (lval) & - (TYPE_UWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_uint = (TYPE_TARGET_UINT) floatFromVal (lval) & + (TYPE_TARGET_UINT) floatFromVal (rval); else - SPEC_CVAL (val->type).v_int = (TYPE_WORD) floatFromVal (lval) & (TYPE_WORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_int = (TYPE_TARGET_INT) floatFromVal (lval) & + (TYPE_TARGET_INT) floatFromVal (rval); } break; @@ -1736,20 +1787,20 @@ valBitwise (value * lval, value * rval, int op) if (SPEC_LONG (val->type)) { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_ulong = (TYPE_UDWORD) floatFromVal (lval) | - (TYPE_UDWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_ulong = (TYPE_TARGET_ULONG) floatFromVal (lval) | + (TYPE_TARGET_ULONG) floatFromVal (rval); else - SPEC_CVAL (val->type).v_long = (TYPE_DWORD) floatFromVal (lval) | - (TYPE_DWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_long = (TYPE_TARGET_LONG) floatFromVal (lval) | + (TYPE_TARGET_LONG) floatFromVal (rval); } else { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) floatFromVal (lval) | - (TYPE_UWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_uint = (TYPE_TARGET_UINT) floatFromVal (lval) | + (TYPE_TARGET_UINT) floatFromVal (rval); else SPEC_CVAL (val->type).v_int = - (TYPE_WORD) floatFromVal (lval) | (TYPE_WORD) floatFromVal (rval); + (TYPE_TARGET_INT) floatFromVal (lval) | (TYPE_TARGET_INT) floatFromVal (rval); } break; @@ -1758,20 +1809,20 @@ valBitwise (value * lval, value * rval, int op) if (SPEC_LONG (val->type)) { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_ulong = (TYPE_UDWORD) floatFromVal (lval) ^ - (TYPE_UDWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_ulong = (TYPE_TARGET_ULONG) floatFromVal (lval) ^ + (TYPE_TARGET_ULONG) floatFromVal (rval); else - SPEC_CVAL (val->type).v_long = (TYPE_DWORD) floatFromVal (lval) ^ - (TYPE_DWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_long = (TYPE_TARGET_LONG) floatFromVal (lval) ^ + (TYPE_TARGET_LONG) floatFromVal (rval); } else { if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) floatFromVal (lval) ^ - (TYPE_UWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_uint = (TYPE_TARGET_UINT) floatFromVal (lval) ^ + (TYPE_TARGET_UINT) floatFromVal (rval); else SPEC_CVAL (val->type).v_int = - (TYPE_WORD) floatFromVal (lval) ^ (TYPE_WORD) floatFromVal (rval); + (TYPE_TARGET_INT) floatFromVal (lval) ^ (TYPE_TARGET_INT) floatFromVal (rval); } break; } @@ -1816,7 +1867,7 @@ value * valCastLiteral (sym_link * dtype, double fval) { value *val; - TYPE_UDWORD l = (TYPE_UDWORD)fval; + TYPE_TARGET_ULONG l = (TYPE_TARGET_ULONG)fval; if (!dtype) return NULL; @@ -1856,14 +1907,14 @@ valCastLiteral (sym_link * dtype, double fval) } else { if (SPEC_LONG (val->etype)) { if (SPEC_USIGN (val->etype)) - SPEC_CVAL (val->etype).v_ulong = (TYPE_UDWORD) l; + SPEC_CVAL (val->etype).v_ulong = (TYPE_TARGET_ULONG) l; else - SPEC_CVAL (val->etype).v_long = (TYPE_DWORD) l; + SPEC_CVAL (val->etype).v_long = (TYPE_TARGET_LONG) l; } else { if (SPEC_USIGN (val->etype)) - SPEC_CVAL (val->etype).v_uint = (TYPE_UWORD)l; + SPEC_CVAL (val->etype).v_uint = (TYPE_TARGET_UINT)l; else - SPEC_CVAL (val->etype).v_int = (TYPE_WORD)l; + SPEC_CVAL (val->etype).v_int = (TYPE_TARGET_INT)l; } } return val; diff --git a/src/SDCCval.h b/src/SDCCval.h index 70054028..27950882 100644 --- a/src/SDCCval.h +++ b/src/SDCCval.h @@ -95,6 +95,13 @@ value *charVal (char *); value *symbolVal (symbol *); void printVal (value *); double floatFromVal (value *); + +/* convert a fixed16x16 type to double */ +double doubleFromFixed16x16(TYPE_TARGET_ULONG value); + +/* convert a double type to fixed16x16 */ +TYPE_TARGET_ULONG fixed16x16FromDouble(double value); + CCR_RESULT checkConstantRange (sym_link *var, sym_link *lit, int op, bool exchangeOps); value *array2Ptr (value *); value *valUnaryPM (value *); diff --git a/src/ds390/gen.c b/src/ds390/gen.c index ae25d329..64b0109a 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -1662,6 +1662,7 @@ aopGet (operand * oper, /* aopPutUsesAcc - indicates ahead of time whether aopPut() will */ /* clobber the accumulator */ /*-----------------------------------------------------------------*/ +#if 0 static bool aopPutUsesAcc (operand * oper, const char *s, int offset) { @@ -1700,6 +1701,7 @@ aopPutUsesAcc (operand * oper, const char *s, int offset) return FALSE; } } +#endif /*-----------------------------------------------------------------*/ /* aopPut - puts a string for a aop and indicates if acc is in use */ diff --git a/src/ds390/main.c b/src/ds390/main.c index f39dbc62..d05c2ad0 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -707,7 +707,7 @@ asmLineNodeFromLineNode (lineNode *ln, int currentDPS) asmLineNode *aln = ds390newAsmLineNode(currentDPS); char *op, op1[256], op2[256]; int opsize; - const unsigned char *p; + const char *p; char inst[8]; ds390opcodedata *opdat; diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index 7cd5870c..f69b12c2 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -959,6 +959,7 @@ static regs *getRegGprNoSpil() /*-----------------------------------------------------------------*/ /* getRegBitNoSpil - get it cannot be spilt */ /*-----------------------------------------------------------------*/ +#if 0 static regs *getRegBitNoSpil() { regs *reg; @@ -976,6 +977,7 @@ static regs *getRegBitNoSpil() /* just to make the compiler happy */ return 0; } +#endif /*-----------------------------------------------------------------*/ /* symHasReg - symbol has a given register */ diff --git a/src/hc08/ralloc.c b/src/hc08/ralloc.c index 2c40c925..995b7876 100644 --- a/src/hc08/ralloc.c +++ b/src/hc08/ralloc.c @@ -3141,8 +3141,8 @@ hc08_assignRegisters (ebbIndex * ebbi) /* free up any _G.stackSpil locations allocated */ applyToSet (_G.stackSpil, deallocStackSpil); _G.slocNum = 0; - setToNull ((void **) &_G.stackSpil); - setToNull ((void **) &_G.spiltSet); + setToNull ((void *) &_G.stackSpil); + setToNull ((void *) &_G.spiltSet); /* mark all registers as free */ freeAllRegs (); diff --git a/src/mcs51/main.c b/src/mcs51/main.c index 40dcc69e..71277b9a 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -590,7 +590,7 @@ asmLineNodeFromLineNode (lineNode *ln) asmLineNode *aln = newAsmLineNode(); char *op, op1[256], op2[256]; int opsize; - const unsigned char *p; + const char *p; char inst[8]; mcs51opcodedata *opdat; diff --git a/src/xa51/gen.c b/src/xa51/gen.c index ecd1867c..508d890f 100755 --- a/src/xa51/gen.c +++ b/src/xa51/gen.c @@ -97,7 +97,7 @@ void bailOut (char *mesg) { static void emitcode (char *inst, char *fmt,...) { va_list ap; char lb[INITIAL_INLINEASM]; - unsigned char *lbp = lb; + char *lbp = lb; va_start (ap, fmt); diff --git a/src/xa51/ralloc.c b/src/xa51/ralloc.c index c9e326c6..ac0d124b 100755 --- a/src/xa51/ralloc.c +++ b/src/xa51/ralloc.c @@ -127,7 +127,7 @@ regs *xa51_regWithMask (unsigned long mask) { /* checkRegsMask - check the consistancy of the regMask redundancy */ /*-----------------------------------------------------------------*/ -void checkRegMask(char *f) { // for debugging purposes only +void checkRegMask(const char *f) { // for debugging purposes only int i; unsigned long regMask=0; diff --git a/src/z80/gen.c b/src/z80/gen.c index f1c6a241..30d500eb 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -463,7 +463,7 @@ _emit2 (const char *inst, const char *fmt,...) { va_list ap; char lb[INITIAL_INLINEASM]; - unsigned char *lbp = lb; + char *lbp = lb; va_start (ap, fmt); diff --git a/support/Util/MySystem.c b/support/Util/MySystem.c index 004a2f7c..b78d99aa 100644 --- a/support/Util/MySystem.c +++ b/support/Util/MySystem.c @@ -45,9 +45,9 @@ set *binPathSet = NULL; /* set of binary paths */ */ static void -split_command(const unsigned char *cmd_line, char **command, char **params) +split_command(const char *cmd_line, char **command, char **params) { - const unsigned char *p, *cmd_start; + const char *p, *cmd_start; char delim; char *str; unsigned len; diff --git a/support/packihx/packihx.c b/support/packihx/packihx.c index 779966a5..5e41925e 100644 --- a/support/packihx/packihx.c +++ b/support/packihx/packihx.c @@ -261,7 +261,7 @@ int writeRecord(unsigned len, unsigned offset, unsigned type, #define OUTPUT_CHUNK 16 static unsigned pendingLen = 0; static unsigned pendingOffset = 0; -static char pending[MAX_INPUT_COOKED + OUTPUT_CHUNK]; +static Uint8 pending[MAX_INPUT_COOKED + OUTPUT_CHUNK]; /* Buffer up a data record. */ int bufferOutput(Line *line) diff --git a/support/regression/tests/libmullong.c b/support/regression/tests/libmullong.c index a469b93a..2445c4f3 100644 --- a/support/regression/tests/libmullong.c +++ b/support/regression/tests/libmullong.c @@ -36,8 +36,8 @@ struct char c2; } pack_test; -TYPE_DWORD -mullong_wrapper (TYPE_DWORD a, TYPE_DWORD b) +TYPE_TARGET_LONG +mullong_wrapper (TYPE_TARGET_LONG a, TYPE_TARGET_LONG b) { if (sizeof(pack_test) == 4) /* length of struct ok: use SDCC library */ @@ -51,8 +51,8 @@ mullong_wrapper (TYPE_DWORD a, TYPE_DWORD b) #else -TYPE_DWORD -mullong_wrapper (TYPE_DWORD a, TYPE_DWORD b) +TYPE_TARGET_LONG +mullong_wrapper (TYPE_TARGET_LONG a, TYPE_TARGET_LONG b) { return a * b; }