oops
[fw/sdcc] / src / SDCCicode.c
index 57ee76fcebb16b8489ac664b49cb627ee45353d0..ccc9ec6632b69d6d210034047db8d3d043a9beed 100644 (file)
@@ -229,7 +229,8 @@ printOperand (operand * op, FILE * file)
               op->key,
               OP_LIVEFROM (op), OP_LIVETO (op),
               OP_SYMBOL (op)->stack,
-              op->isaddr, OP_SYMBOL (op)->isreqv, OP_SYMBOL (op)->remat,OP_SYMBOL(op)->noSpilLoc,
+              op->isaddr, OP_SYMBOL (op)->isreqv, 
+              OP_SYMBOL (op)->remat,OP_SYMBOL(op)->noSpilLoc,
               OP_SYMBOL(op)->ruonly
        );
       {
@@ -917,12 +918,11 @@ isOperandInDirSpace (operand * op)
   return (IN_DIRSPACE (SPEC_OCLS (etype)) ? TRUE : FALSE);
 }
 
-/*-----------------------------------------------------------------*/
-/* isOperandOnStack - will return true if operand is on stack      */
-/*-----------------------------------------------------------------*/
-#if 0
+/*--------------------------------------------------------------------*/
+/* isOperandInCodeSpace - will return true if operand is in codeSpace */
+/*--------------------------------------------------------------------*/
 bool 
-isOperandOnStack (operand * op)
+isOperandInCodeSpace (operand * op)
 {
   sym_link *etype;
 
@@ -932,11 +932,23 @@ isOperandOnStack (operand * op)
   if (!IS_SYMOP (op))
     return FALSE;
 
-  etype = getSpec (operandType (op));
-
-  return ((IN_STACK (etype)) ? TRUE : FALSE);
+  if (!IS_TRUE_SYMOP (op))
+    {
+      if (SPIL_LOC (op))
+       etype = SPIL_LOC (op)->etype;
+      else
+       return FALSE;
+    }
+  else
+    {
+      etype = getSpec (operandType (op));
+    }
+  return (IN_CODESPACE (SPEC_OCLS (etype)) ? TRUE : FALSE);
 }
-#else
+
+/*-----------------------------------------------------------------*/
+/* isOperandOnStack - will return true if operand is on stack      */
+/*-----------------------------------------------------------------*/
 bool 
 isOperandOnStack (operand * op)
 {
@@ -956,7 +968,6 @@ isOperandOnStack (operand * op)
 
   return FALSE;
 }
-#endif
 
 /*-----------------------------------------------------------------*/
 /* operandLitValue - literal value of an operand                   */
@@ -1685,7 +1696,7 @@ geniCodeCast (sym_link * type, operand * op, bool implicit)
   if (IS_PTR(type)) { // to a pointer
     if (!IS_PTR(optype) && !IS_FUNC(optype) && !IS_AGGREGATE(optype)) { // from a non pointer
       if (IS_INTEGRAL(optype)) { 
-       // maybe this is NULL, than it's ok.
+       // maybe this is NULL, than it's ok. 
        if (!(IS_LITERAL(optype) && (SPEC_CVAL(optype).v_ulong ==0))) {
          if (!TARGET_IS_Z80 && !TARGET_IS_GBZ80 && IS_GENPTR(type)) {
            // no way to set the storage
@@ -2004,7 +2015,7 @@ geniCodeSubtract (operand * left, operand * right)
 /* geniCodeAdd - generates iCode for addition                      */
 /*-----------------------------------------------------------------*/
 operand *
-geniCodeAdd (operand * left, operand * right,int lvl)
+geniCodeAdd (operand * left, operand * right, int lvl)
 {
   iCode *ic;
   sym_link *resType;
@@ -2025,7 +2036,7 @@ geniCodeAdd (operand * left, operand * right,int lvl)
   if (IS_LITERAL (letype) && left->isLiteral && !floatFromVal (valFromType (letype)))
     return right;
 
-  /* if left is an array or pointer then size */
+  /* if left is a pointer then size */
   if (IS_PTR (ltype))
     {
       isarray = left->isaddr;
@@ -2037,7 +2048,7 @@ geniCodeAdd (operand * left, operand * right,int lvl)
       resType = copyLinkChain (ltype);
     }
   else
-    {                          /* make them the same size */
+    { // make them the same size
       resType = usualBinaryConversions (&left, &right);
     }
 
@@ -2137,7 +2148,7 @@ geniCodeArray (operand * left, operand * right,int lvl)
        {
          left = geniCodeRValue (left, FALSE);
        }
-      return geniCodeDerefPtr (geniCodeAdd (left, right,lvl),lvl);
+      return geniCodeDerefPtr (geniCodeAdd (left, right, lvl), lvl);
     }
 
   right = geniCodeMultiply (right,
@@ -2871,10 +2882,11 @@ geniCodeCall (operand * left, ast * parms,int lvl)
   geniCodeParms (parms, NULL, &stack, getSpec (operandType (left)), OP_SYMBOL (left),lvl);
 
   /* now call : if symbol then pcall */
-  if (IS_OP_POINTER (left) || IS_ITEMP(left))
+  if (IS_OP_POINTER (left) || IS_ITEMP(left)) {
     ic = newiCode (PCALL, left, NULL);
-  else
+  } else {
     ic = newiCode (CALL, left, NULL);
+  }
 
   type = copyLinkChain (operandType (left)->next);
   etype = getSpec (type);