operand *geniCodeArray2Ptr (operand *);
operand *geniCodeRValue (operand *, bool);
operand *geniCodeDerefPtr (operand *,int);
+int isLvaluereq(int lvl);
#define PRINTFUNC(x) void x (FILE *of, iCode *ic, char *s)
/* forward definition of ic print functions */
operandOperation (operand * left, operand * right,
int op, sym_link * type)
{
+ sym_link *let , *ret=NULL;
operand *retval = (operand *) 0;
-
+
assert (isOperandLiteral (left));
- if (right)
+ let = getSpec(operandType(left));
+ if (right) {
assert (isOperandLiteral (right));
+ ret = getSpec(operandType(left));
+ }
switch (op)
{
operandLitValue (right)));
break;
case '%':
- if ((unsigned long) operandLitValue (right) == 0)
- {
+ if ((unsigned long) operandLitValue (right) == 0) {
werror (E_DIVIDE_BY_ZERO);
retval = right;
- }
- else
- retval = operandFromLit ((unsigned long) operandLitValue (left) %
- (unsigned long) operandLitValue (right));
+ }
+ else
+ retval = operandFromLit ((SPEC_USIGN(let) ?
+ (unsigned long) operandLitValue (left) :
+ (long) operandLitValue (left)) %
+ (SPEC_USIGN(ret) ?
+ (unsigned long) operandLitValue (right) :
+ (long) operandLitValue (right)));
+
break;
case LEFT_OP:
- retval = operandFromLit ((unsigned long) operandLitValue (left) <<
- (unsigned long) operandLitValue (right));
+ retval = operandFromLit (((SPEC_USIGN(let) ?
+ (unsigned long) operandLitValue (left) :
+ (long) operandLitValue (left)) <<
+ (SPEC_USIGN(ret) ?
+ (unsigned long) operandLitValue (right) :
+ (long) operandLitValue (right))));
break;
case RIGHT_OP:
- retval = operandFromLit ((unsigned long) operandLitValue (left) >>
- (unsigned long) operandLitValue (right));
+ retval = operandFromLit (((SPEC_USIGN(let) ?
+ (unsigned long) operandLitValue (left) :
+ (long) operandLitValue (left)) >>
+ (SPEC_USIGN(ret) ?
+ (unsigned long) operandLitValue (right) :
+ (long) operandLitValue (right))));
break;
case EQ_OP:
retval = operandFromLit (operandLitValue (left) ==
break;
case RRC:
{
- long i = operandLitValue (left);
+ long i = (long) operandLitValue (left);
retval = operandFromLit ((i >> (getSize (operandType (left)) * 8 - 1)) |
(i << 1));
break;
case RLC:
{
- long i = operandLitValue (left);
+ long i = (long) operandLitValue (left);
retval = operandFromLit ((i << (getSize (operandType (left)) * 8 - 1)) |
(i >> 1));
/* operandFromLit - makes an operand from a literal value */
/*-----------------------------------------------------------------*/
operand *
-operandFromLit (float i)
+operandFromLit (double i)
{
return operandFromValue (valueFromLit (i));
}
{
if (IS_INTEGRAL (operandType (op)))
{
- if (getSize (operandType (op)) < INTSIZE)
+ if (getSize (operandType (op)) < (unsigned int) INTSIZE)
{
/* Widen to int. */
return geniCodeCast (INTTYPE, op, TRUE);
if (IS_LITERAL (retype) &&
!IS_FLOAT (letype) &&
(p2 = powof2 ((unsigned long)
- floatFromVal (right->operand.valOperand))))
- ic = newiCode (RIGHT_OP, left, operandFromLit (p2)); /* right shift */
+ floatFromVal (right->operand.valOperand)))) {
+ ic = newiCode (RIGHT_OP, left, operandFromLit (p2)); /* right shift */
+ }
else
{
ic = newiCode ('/', left, right); /* normal division */
if (IS_INTEGRAL (ltype) && IS_LITERAL (rtype))
{
int nbits = bitsForType (ltype);
- long v = operandLitValue (right);
+ long v = (long) operandLitValue (right);
if (v > ((LONG_LONG) 1 << nbits) && v > 0)
werror (W_CONST_RANGE, " compare operation ");
if (IS_INTEGRAL (ltype) && right->type == VALUE && IS_LITERAL (rtype))
{
int nbits = bitsForType (ltype);
- long v = operandLitValue (right);
+ long v = (long) operandLitValue (right);
if (v > ((LONG_LONG) 1 << nbits) && v > 0)
werror (W_CONST_RANGE, " = operation");