static sym_link *
usualBinaryConversions (operand ** op1, operand ** op2,
- RESULT_TYPE resultType, char op)
+ RESULT_TYPE resultType, int op)
{
sym_link *ctype;
sym_link *rtype = operandType (*op2);
sym_link *ltype = operandType (*op1);
-#define OLDONEBYTEOPS 1
-
-#ifdef OLDONEBYTEOPS
- bool oldOneByteOps = FALSE;
- static bool saidHello = FALSE;
-
- if (strcmp (port->target, "pic14") == 0)
- oldOneByteOps = TRUE;
- if (getenv ("SDCC_NEWONEBYTEOPS"))
- {
- if (!saidHello)
- {
- fprintf (stderr, "Override: oldOneByteOps = FALSE\n");
- saidHello = TRUE;
- }
- oldOneByteOps = FALSE;
- }
- else if (getenv ("SDCC_OLDONEBYTEOPS"))
- {
- if (!saidHello)
- {
- fprintf (stderr, "Override: oldOneByteOps = TRUE\n");
- saidHello = TRUE;
- }
- oldOneByteOps = TRUE;
- }
-
-
- if ( oldOneByteOps
- && ( (IS_CHAR (getSpec (ltype)) && !IS_UNSIGNED (getSpec (ltype)))
- || (IS_CHAR (getSpec (rtype)) && !IS_UNSIGNED (getSpec (rtype)))))
- /* one or two signed char operands: promote to int */
- resultType = RESULT_TYPE_INT;
-#endif
-
ctype = computeType (ltype, rtype, resultType, op);
-#ifdef OLDONEBYTEOPS
-
- if (oldOneByteOps)
- {
- if ( op == '*'
- && IS_CHAR (getSpec (ltype)) && IS_UNSIGNED (getSpec (ltype))
- && IS_CHAR (getSpec (rtype)) && IS_UNSIGNED (getSpec (rtype)))
- {
- /* two unsigned char operands and Mult: no promotion */
- return ctype;
- }
- *op1 = geniCodeCast (ctype, *op1, TRUE);
- *op2 = geniCodeCast (ctype, *op2, TRUE);
-
- return ctype;
- }
-
-#endif
-
switch (op)
{
case '*':
/* preserve the storage class & output class */
/* of the original variable */
restype = getSpec (operandType (IC_RESULT (ic)));
- if (!IS_LITERAL(opetype))
+ if (!IS_LITERAL(opetype) &&
+ !IS_BIT(opetype))
SPEC_SCLS (restype) = SPEC_SCLS (opetype);
SPEC_OCLS (restype) = SPEC_OCLS (opetype);
/* geniCodeLeftShift - gen i code for left shift */
/*-----------------------------------------------------------------*/
operand *
-geniCodeLeftShift (operand * left, operand * right)
+geniCodeLeftShift (operand * left, operand * right, RESULT_TYPE resultType)
{
iCode *ic;
+ sym_link *resType;
ic = newiCode (LEFT_OP, left, right);
- IC_RESULT (ic) = newiTempOperand (operandType (left), 0);
+
+ resType = usualBinaryConversions (&left, &right, resultType, LEFT_OP);
+ IC_RESULT (ic) = newiTempOperand (resType, 0);
ADDTOCHAIN (ic);
return IC_RESULT (ic);
}
}
}
- ctype = usualBinaryConversions (&left, &right, RESULT_TYPE_NONE, ' ');
+ ctype = usualBinaryConversions (&left, &right, RESULT_TYPE_NOPROM, 0);
ic = newiCode (op, left, right);
IC_RESULT (ic) = newiTempOperand (newCharLink (), 1);
case LEFT_OP:
return geniCodeLeftShift (geniCodeRValue (left, FALSE),
- geniCodeRValue (right, FALSE));
+ geniCodeRValue (right, FALSE),
+ getResultTypeFromType (tree->ftype));
case RIGHT_OP:
return geniCodeRightShift (geniCodeRValue (left, FALSE),
geniCodeAssign (left,
geniCodeLeftShift (geniCodeRValue (operandFromOperand (left)
,FALSE),
- geniCodeRValue (right, FALSE)), 0);
+ geniCodeRValue (right, FALSE),
+ getResultTypeFromType (tree->ftype)),
+ 0);
case RIGHT_ASSIGN:
return
geniCodeAssign (left,
computeTypeOr (sym_link * etype1, sym_link * etype2, sym_link * reType)
{
/* sanity check */
- assert (IS_CHAR (etype1) && IS_CHAR (etype2));
+ assert ( (IS_CHAR (etype1) || IS_BIT (etype1))
+ && (IS_CHAR (etype2) || IS_BIT (etype2)));
if (SPEC_USIGN (etype1) == SPEC_USIGN (etype2))
{
{
if (SPEC_USIGN (dest) == SPEC_USIGN (src) &&
IS_INTEGRAL (dest) && IS_INTEGRAL (src) &&
- getSize (dest) == getSize (src))
+ /* I would prefer
+ bitsForType (dest) == bitsForType (src))
+ instead of the next two lines, but the regression tests fail with
+ them; I guess it's a problem with replaceCheaperOp */
+ getSize (dest) == getSize (src) &&
+ !(!IS_BIT (dest) && IS_BIT (src)))
return 1;
else if (IS_ARITHMETIC (dest) && IS_ARITHMETIC (src))
return -1;