* src/mcs51/ralloc.c (packRegsForAssign): fixed bug #930931, fixed check for bitfields
[fw/sdcc] / src / mcs51 / ralloc.c
index 88f13108d823b9f569591bb8f07927123fb3f252..c81c2158f936d2bedde3858c3a8e060df9f9ac66 100644 (file)
@@ -1988,6 +1988,21 @@ packRegsForAssign (iCode * ic, eBBlock * ebp)
   if (!dic)
     return 0;                  /* did not find */
 
+  /* if assignment then check that right is not a bit */
+  if (ASSIGNMENT (ic) && !POINTER_SET (ic))
+    {
+      sym_link *etype = operandType (IC_RESULT (dic));
+      if (IS_BITFIELD (etype))
+        {
+          /* if result is a bit too then it's ok */
+          etype = operandType (IC_RESULT (ic));
+          if (!IS_BITFIELD (etype))
+            {
+              return 0;
+            }
+       }
+    }
+#if 0
   /* if assignment then check that right is not a bit */
   if (ASSIGNMENT (dic) && !POINTER_SET (dic))
     {
@@ -1995,11 +2010,12 @@ packRegsForAssign (iCode * ic, eBBlock * ebp)
       if (IS_BITFIELD (etype))
         {
           /* if result is a bit too then it's ok */
-         etype = operandType (IC_RESULT (dic));
+          etype = operandType (IC_RESULT (dic));
           if (!IS_BITFIELD (etype))
-           return 0;
-       }
+            return 0;
+        }
     }
+#endif
   /* if the result is on stack or iaccess then it must be
      the same atleast one of the operands */
   if (OP_SYMBOL (IC_RESULT (ic))->onStack ||
@@ -3033,6 +3049,14 @@ mcs51_assignRegisters (eBBlock ** ebbs, int count)
     redoStackOffsets ();
   }
 
+  /* make sure r0 & r1 are flagged as used if they might be used */
+  /* as pointers */
+  if (currFunc && mcs51_ptrRegReq)
+    {
+      currFunc->regsUsed = bitVectSetBit (currFunc->regsUsed, R0_IDX);
+      currFunc->regsUsed = bitVectSetBit (currFunc->regsUsed, R1_IDX);
+    }
+
   if (options.dump_rassgn)
     {
       dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count);