/* This seems very dangerous to me, since there are several */
/* optimizations (for example, gcse) that don't notice the */
- /* cast hidden in this assignement and may simplify an */
+ /* cast hidden in this assignment and may simplify an */
/* iCode to use the original (uncasted) operand. */
/* Unfortunately, other things break when this cast is */
/* made explicit. Need to fix this someday. */
/*-----------------------------------------------------------------*/
-/* geniCodeBitwise - gen int code for bitWise operators */
+/* geniCodeBitwise - gen int code for bitWise operators */
/*-----------------------------------------------------------------*/
operand *
geniCodeBitwise (operand * left, operand * right,
/* geniCodeLogic- logic code */
/*-----------------------------------------------------------------*/
static operand *
-geniCodeLogic (operand * left, operand * right, int op)
+geniCodeLogic (operand * left, operand * right, int op, ast *tree)
{
iCode *ic;
- sym_link *ctype;
+ sym_link *ctype, *ttype;
sym_link *rtype = operandType (right);
sym_link *ltype = operandType (left);
ctype = usualBinaryConversions (&left, &right, RESULT_TYPE_BIT, 0);
ic = newiCode (op, left, right);
- IC_RESULT (ic) = newiTempOperand (newCharLink (), 1);
+ /* store 0 or 1 in result */
+ ttype = (tree && IS_BIT (tree->ftype)) ? newBoolLink() : newCharLink();
+ IC_RESULT (ic) = newiTempOperand (ttype, 1);
/* if comparing float
and not a '==' || '!=' || '&&' || '||' (these
ADDTOCHAIN (ic);
/* store 0 or 1 in result */
- type = (SPEC_NOUN(tree->ftype) == V_BIT) ? newBoolLink() : newCharLink();
+ type = (IS_BIT (tree->ftype)) ? newBoolLink() : newCharLink();
result = newiTempOperand (type, 1);
geniCodeLabel (falseLabel);
the condition is unsigned & minimum value is zero */
if (!(min == 0 && IS_UNSIGNED (cetype)))
{
- boundary = geniCodeLogic (cond, operandFromLit (min), '<');
+ boundary = geniCodeLogic (cond, operandFromLit (min), '<', NULL);
ic = newiCodeCondition (boundary, falseLabel, NULL);
ADDTOCHAIN (ic);
}
/* now for upper bounds */
- boundary = geniCodeLogic (cond, operandFromLit (max), '>');
+ boundary = geniCodeLogic (cond, operandFromLit (max), '>', NULL);
ic = newiCodeCondition (boundary, falseLabel, NULL);
ADDTOCHAIN (ic);
}
operand *compare = geniCodeLogic (cond,
operandFromValue (caseVals),
- EQ_OP);
+ EQ_OP, NULL);
SNPRINTF (buffer, sizeof(buffer), "_case_%d_%d",
tree->values.switchVals.swNum,
leftOp = geniCodeRValue (left , FALSE);
rightOp = geniCodeRValue (right, FALSE);
- return geniCodeLogic (leftOp, rightOp, tree->opval.op);
+ return geniCodeLogic (leftOp, rightOp, tree->opval.op, tree);
}
case '?':
return geniCodeConditional (tree,lvl);