{ARRAYINIT, "arrayInit", picGenericOne, NULL},
};
+// this makes it more easy to catch bugs
+struct bitVect *OP_DEFS(struct operand *op) {
+ assert (IS_SYMOP(op));
+ return OP_SYMBOL(op)->defs;
+}
+struct bitVect *OP_DEFS_SET(struct operand *op, struct bitVect *bv) {
+ assert (IS_SYMOP(op));
+ OP_SYMBOL(op)->defs=bv;
+ return bv;
+}
+struct bitVect *OP_USES(struct operand *op) {
+ assert (IS_SYMOP(op));
+ return OP_SYMBOL(op)->uses;
+}
+struct bitVect *OP_USES_SET(struct operand *op, struct bitVect *bv) {
+ assert (IS_SYMOP(op));
+ OP_SYMBOL(op)->uses=bv;
+ return bv;
+}
+
/*-----------------------------------------------------------------*/
/* checkConstantRange: check a constant against the type */
/*-----------------------------------------------------------------*/
(unsigned long) operandLitValue (right) :
(long) operandLitValue (right)));
break;
- case RIGHT_OP:
- retval = operandFromLit ((SPEC_USIGN(let) ?
- (unsigned long) operandLitValue (left) :
- (long) operandLitValue (left)) >>
- (SPEC_USIGN(ret) ?
- (unsigned long) operandLitValue (right) :
- (long) operandLitValue (right)));
+ case RIGHT_OP: {
+ double lval = operandLitValue(left), rval = operandLitValue(right);
+ double res=0;
+ switch ((SPEC_USIGN(let) ? 2 : 0) + (SPEC_USIGN(ret) ? 1 : 0))
+ {
+ case 0: // left=unsigned right=unsigned
+ res=(unsigned long)lval >> (unsigned long)rval;
+ break;
+ case 1: // left=unsigned right=signed
+ res=(unsigned long)lval >> (signed long)rval;
+ break;
+ case 2: // left=signed right=unsigned
+ res=(signed long)lval >> (unsigned long)rval;
+ break;
+ case 3: // left=signed right=signed
+ res=(signed long)lval >> (signed long)rval;
+ break;
+ }
+ retval = operandFromLit (res);
break;
+ }
case EQ_OP:
retval = operandFromLit (operandLitValue (left) ==
operandLitValue (right));
sym_link *ltype = operandType (*op1);
ctype = computeType (ltype, rtype);
+
*op1 = geniCodeCast (ctype, *op1, TRUE);
*op2 = geniCodeCast (ctype, *op2, TRUE);
if (IS_SPEC (type) &&
IS_TRUE_SYMOP (op) &&
(!IN_FARSPACE (SPEC_OCLS (etype)) ||
- /* TARGET_IS_DS390)) */
(options.model == MODEL_FLAT24) ))
{
op = operandFromOperand (op);
resType = usualBinaryConversions (&left, &right);
- /* if the right is a literal & power of 2 */
- /* then make it a right shift */
+ /* if the right is a literal & power of 2
+ and left is unsigned then make it a
+ right shift */
if (IS_LITERAL (retype) &&
!IS_FLOAT (letype) &&
+ SPEC_USIGN(letype) &&
(p2 = powof2 ((unsigned long)
floatFromVal (right->operand.valOperand)))) {
ic = newiCode (RIGHT_OP, left, operandFromLit (p2)); /* right shift */
ADDTOCHAIN (ic);
subtractExit:
+ if (IS_VOID(ltype->next) || IS_VOID(rtype->next)) {
+ return result;
+ }
+
+ // should we really do this? is this ANSI?
return geniCodeDivision (result,
operandFromLit (getSize (ltype->next)));
}
int isarray = 0;
LRTYPE;
+#if 0
/* if left is an array then array access */
if (IS_ARRAY (ltype))
return geniCodeArray (left, right,lvl);
+#endif
/* if the right side is LITERAL zero */
/* return the left side */
return right;
/* if left is a pointer then size */
- if (IS_PTR (ltype))
+ if (IS_PTR (ltype) || IS_ARRAY(ltype))
{
isarray = left->isaddr;
// there is no need to multiply with 1
geniCodeRValue (ast2iCode (parms,lvl+1), FALSE);
parms->type = EX_OPERAND;
- AST_ARGREG(parms) = SPEC_ARGREG(parms->etype);
+ AST_ARGREG(parms) = parms->etype ? SPEC_ARGREG(parms->etype) :
+ SPEC_ARGREG(parms->ftype);
}
/*-----------------------------------------------------------------*/
/* assign */
operand *top = operandFromSymbol (argVals->sym);
/* clear useDef and other bitVectors */
- OP_USES (top) = OP_DEFS (top) = OP_SYMBOL(top)->clashes = NULL;
+ OP_USES_SET ((top), OP_DEFS_SET ((top), OP_SYMBOL(top)->clashes = NULL));
geniCodeAssign (top, pval, 1);
}
else
if (IN_FARSPACE (SPEC_OCLS (sym->etype)) &&
options.stackAuto == 0 &&
- /* !TARGET_IS_DS390) */
(!(options.model == MODEL_FLAT24)) )
{
}
/* create a proc icode */
ic = newiCode (FUNCTION, func, NULL);
- ic->lineno = OP_SYMBOL (func)->lineDef;
+ lineno=ic->lineno = OP_SYMBOL (func)->lineDef;
ADDTOCHAIN (ic);
operand *right = NULL;
if (!tree)
return NULL;
+
/* set the global variables for filename & line number */
if (tree->filename)
filename = tree->filename;