}
LRVAL (tree) = RRVAL (tree) = 1;
- TETYPE (tree) = getSpec (TTYPE (tree) =
- computeType (LTYPE (tree),
- RTYPE (tree)));
+ /* promote result to int if left & right are char / short
+ this will facilitate hardware multiplies 8bit x 8bit = 16bit */
+ if ((IS_CHAR(LETYPE(tree)) || IS_SHORT(LETYPE(tree))) &&
+ (IS_CHAR(RETYPE(tree)) || IS_SHORT(RETYPE(tree)))) {
+ TETYPE (tree) = getSpec (TTYPE (tree) =
+ computeType (LTYPE (tree),
+ RTYPE (tree)));
+ SPEC_NOUN(TETYPE(tree)) = V_INT;
+ SPEC_SHORT(TETYPE(tree))=0;
+ } else {
+ TETYPE (tree) = getSpec (TTYPE (tree) =
+ computeType (LTYPE (tree),
+ RTYPE (tree)));
+ }
return tree;
/*------------------------------------------------------------------*/
/* geniCodeMultiply - gen intermediate code for multiplication */
/*-----------------------------------------------------------------*/
operand *
-geniCodeMultiply (operand * left, operand * right, bool ptrSizeCalculation)
+geniCodeMultiply (operand * left, operand * right, bool ptrSizeCalculation,
+ int resultIsInt)
{
iCode *ic;
int p2 = 0;
options.ANSIint = saveOption;
}
else {
- resType = usualBinaryConversions (&left, &right);
- if (IS_DS390_PORT) {
- /* jwk char*char=int
- Now be can use the 16bit result of "mul a,b" instead of explicit
- casts and support function calls as with --ansiint
- */
- if ((IS_CHAR(letype) || IS_SHORT(letype)) &&
- (IS_CHAR(retype) || IS_SHORT(retype))) {
- SPEC_NOUN(getSpec(resType))=V_INT;
- SPEC_SHORT(getSpec(resType))=0;
- }
- }
+ resType = usualBinaryConversions (&left, &right);
+ /* if (IS_DS390_PORT) { */
+ /* jwk char*char=int
+ Now be can use the 16bit result of "mul a,b" instead of explicit
+ casts and support function calls as with --ansiint
+ */
+ /* if ((IS_CHAR(letype) || IS_SHORT(letype)) && */
+ /* (IS_CHAR(retype) || IS_SHORT(retype))) { */
+ if (resultIsInt) {
+ SPEC_NOUN(getSpec(resType))=V_INT;
+ SPEC_SHORT(getSpec(resType))=0;
+ }
}
+/* } */
/* if the right is a literal & power of 2 */
/* then make it a left shift */
{
isarray = left->isaddr;
right = geniCodeMultiply (right,
- operandFromLit (getSize (ltype->next)), TRUE);
+ operandFromLit (getSize (ltype->next)), TRUE, FALSE);
resType = copyLinkChain (IS_ARRAY (ltype) ? ltype->next : ltype);
}
else
size =
operandFromLit (getSize (ltype->next));
- right = geniCodeMultiply (right, size, (getSize (ltype) != 1));
+ right = geniCodeMultiply (right, size, (getSize (ltype) != 1),FALSE);
resType = copyLinkChain (ltype);
}
/* array access */
right = geniCodeMultiply (right,
- operandFromLit (getSize (ltype->next)), TRUE);
+ operandFromLit (getSize (ltype->next)), TRUE,FALSE);
/* we can check for limits here */
if (isOperandLiteral (right) &&
case '*':
if (right)
return geniCodeMultiply (geniCodeRValue (left, FALSE),
- geniCodeRValue (right, FALSE), FALSE);
+ geniCodeRValue (right, FALSE), FALSE,IS_INT(tree->ftype));
else
return geniCodeDerefPtr (geniCodeRValue (left, FALSE));
geniCodeAssign (left,
geniCodeMultiply (geniCodeRValue (operandFromOperand (left),
FALSE),
- geniCodeRValue (right, FALSE), FALSE), 0);
+ geniCodeRValue (right, FALSE), FALSE,FALSE), 0);
case DIV_ASSIGN:
return