+2006-07-01 Bernhard Held <bernhard AT bernhardheld.de>
+
+ * 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 <bernhard AT bernhardheld.de>
* src/SDCCicode.h: removed buggy semicolon in unused macro
OutputByte((unsigned char)(value/0x100));
}
-void OutputName(unsigned char * name)
+void OutputName(char * name)
{
int k;
OutputByte((unsigned char)strlen(name));
OutputByte((unsigned char)(value/0x100));
}
-void OutputName(unsigned char * name)
+void OutputName(char * name)
{
int k;
OutputByte((unsigned char)strlen(name));
#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;
# ### 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"
# 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"
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"
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"
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"
/* 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;
/* 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, "/");
/* 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, "+-");
/* 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 ||
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));
}
/*-----------------------------------------------------------------*/
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 */
*/
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.
/* 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);
}
}
operandLitValue (right)));
break;
case '/':
- if ((TYPE_UDWORD) operandLitValue (right) == 0)
+ if ((TYPE_TARGET_ULONG) operandLitValue (right) == 0)
{
werror (E_DIVIDE_BY_ZERO);
retval = 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
{
}
break;
case '%':
- if ((TYPE_UDWORD) operandLitValue (right) == 0)
+ if ((TYPE_TARGET_ULONG) operandLitValue (right) == 0)
{
werror (E_DIVIDE_BY_ZERO);
retval = 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))
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
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);
}
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) &&
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));
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;
case '~':
retval = operandFromValue (valCastLiteral (type,
- ~((TYPE_UDWORD)
+ ~((TYPE_TARGET_ULONG)
operandLitValue (left))));
break;
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, '*');
!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 */
}
/* 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;
}
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
{
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 */
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 ();
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, ...)
{
/* 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 *, ...);
{
if (SPEC_USIGN (var))
{
- TYPE_UDWORD maxVal = 0xffffffffu >> (32 - varBits);
+ TYPE_TARGET_ULONG maxVal = 0xffffffffu >> (32 - varBits);
if ( litVal < 0
|| litVal > maxVal)
}
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)
{
/* 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)
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))
{
{
/* 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) */
else
{
/* signed operation */
- TYPE_DWORD minVal, maxVal;
+ TYPE_TARGET_LONG minVal, maxVal;
if (SPEC_USIGN (var))
{
{
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);
}
{
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;
}
}
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 */
/*------------------------------------------------------------------*/
/* 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);
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);
}
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);
}
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);
}
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);
}
'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 */
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
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);
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
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;
}
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
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;
}
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;
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;
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;
}
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;
} 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;
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 *);
/* aopPutUsesAcc - indicates ahead of time whether aopPut() will */
/* clobber the accumulator */
/*-----------------------------------------------------------------*/
+#if 0
static bool
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 */
asmLineNode *aln = ds390newAsmLineNode(currentDPS);
char *op, op1[256], op2[256];
int opsize;
- const unsigned char *p;
+ const char *p;
char inst[8];
ds390opcodedata *opdat;
/*-----------------------------------------------------------------*/
/* getRegBitNoSpil - get it cannot be spilt */
/*-----------------------------------------------------------------*/
+#if 0
static regs *getRegBitNoSpil()
{
regs *reg;
/* just to make the compiler happy */
return 0;
}
+#endif
/*-----------------------------------------------------------------*/
/* symHasReg - symbol has a given register */
/* 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 ();
asmLineNode *aln = newAsmLineNode();
char *op, op1[256], op2[256];
int opsize;
- const unsigned char *p;
+ const char *p;
char inst[8];
mcs51opcodedata *opdat;
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);
/* 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;
{
va_list ap;
char lb[INITIAL_INLINEASM];
- unsigned char *lbp = lb;
+ char *lbp = lb;
va_start (ap, fmt);
*/
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;
#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)
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 */
#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;
}