* src/SDCCcse.c (ifxOptimize),
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 4 Nov 2003 06:46:48 +0000 (06:46 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 4 Nov 2003 06:46:48 +0000 (06:46 +0000)
* src/SDCClabel.c (labelIfx, deleteIfx): When the condition to
an IFX iCode is volatile, convert to DUMMY_READ_VOLATILE instead
deleting the IFX iCode.
* src/hc08/ralloc.c: reduced unneeded slocs
* src/hc08/gen.c: fixed bug in asmopToBoolean

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2990 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCcse.c
src/SDCClabel.c
src/hc08/gen.c
src/hc08/ralloc.c

index e9b2d87eb8be7fd9cd3f453d25077f3cdf388269..87b5c1c8bfcbbefae1c1091a71d3c64244b30459 100644 (file)
@@ -1347,18 +1347,36 @@ ifxOptimize (iCode * ic, set * cseSet,
       isinSet (ebb->succList, eBBWithEntryLabel (ebbs, label, count)))
     {
 
-      remiCodeFromeBBlock (ebb, ic);
-      computeControlFlow (ebbs, count, 1);
       if (!options.lessPedantic) {
        werror (W_CONTROL_FLOW, ic->filename, ic->lineno);
       }
-      return;
+      if (IS_OP_VOLATILE (IC_COND (ic)))
+       {
+         IC_RIGHT (ic) = IC_COND (ic);
+         IC_LEFT (ic) = NULL;
+         IC_RESULT (ic) = NULL;
+         ic->op = DUMMY_READ_VOLATILE;
+       }
+      else
+        {
+         remiCodeFromeBBlock (ebb, ic);
+         computeControlFlow (ebbs, count, 1);
+         return;
+       }      
     }
 
 
   /* if it remains an IFX the update the use Set */
-  OP_USES(IC_COND (ic))=bitVectSetBit (OP_USES (IC_COND (ic)), ic->key);
-  setUsesDefs (IC_COND (ic), ebb->defSet, ebb->outDefs, &ebb->usesDefs);
+  if (ic->op == IFX)
+    {
+      OP_USES(IC_COND (ic))=bitVectSetBit (OP_USES (IC_COND (ic)), ic->key);
+      setUsesDefs (IC_COND (ic), ebb->defSet, ebb->outDefs, &ebb->usesDefs);
+    }
+  else if (ic->op == DUMMY_READ_VOLATILE)
+    {
+      OP_USES(IC_RIGHT (ic))=bitVectSetBit (OP_USES (IC_RIGHT (ic)), ic->key);
+      setUsesDefs (IC_RIGHT (ic), ebb->defSet, ebb->outDefs, &ebb->usesDefs);
+    }
   return;
 }
 
index 04ce55681ec77c2e601c4fd080186f97a2534650..d31f69d031d453e72303a9024b5c28ea5091dfb7 100644 (file)
@@ -95,6 +95,36 @@ labelGotoNext (iCode * ic)
   return change;
 }
 
+/*-------------------------------------------------------------------*/
+/* deleteIfx - delete an IFX iCode or convert to DUMMY_READ_VOLATILE */
+/*-------------------------------------------------------------------*/
+static void
+deleteIfx (iCode * loop, int key)
+{
+  if (!options.lessPedantic)
+    {
+      werror (W_CONTROL_FLOW, loop->filename, loop->lineno);
+    }
+  hTabDeleteItem (&labelRef, key, loop, DELETE_ITEM, NULL);
+             
+  /* If the condition was volatile, convert IFX to */
+  /* DUMMY_READ_VOLATILE. Otherwise just delete the */
+  /* IFX iCode */
+  if (IS_OP_VOLATILE (IC_COND (loop)))
+    {
+      IC_RIGHT (loop) = IC_COND (loop);
+      IC_LEFT (loop) = NULL;
+      IC_RESULT (loop) = NULL;
+      loop->op = DUMMY_READ_VOLATILE;
+    }
+  else
+    {
+      loop->prev->next = loop->next;
+      loop->next->prev = loop->prev;
+    }
+}
+
+
 /*-----------------------------------------------------------------*/
 /* labelIfx - special case Ifx elimination                         */
 /*-----------------------------------------------------------------*/
@@ -119,33 +149,16 @@ labelIfx (iCode * ic)
          if (IC_TRUE (loop) &&
              IC_TRUE (loop)->key == IC_LABEL (loop->next)->key)
            {
-
-             /* get rid of this if */
-             if (!options.lessPedantic) {
-               werror (W_CONTROL_FLOW, loop->filename, loop->lineno);
-             }
-             loop->prev->next = loop->next;
-             loop->next->prev = loop->prev;
-             hTabDeleteItem (&labelRef,
-                             (IC_TRUE (loop))->key,
-                             loop, DELETE_ITEM, NULL);
+             deleteIfx (loop, IC_TRUE (loop)->key);
              change++;
-             continue;
+              continue;
            }
          else
            {
              if (IC_FALSE (loop) &&
                  IC_FALSE (loop)->key == IC_LABEL (loop->next)->key)
                {
-                 /* get rid of this if */
-                 if (!options.lessPedantic) {
-                   werror (W_CONTROL_FLOW, loop->filename, loop->lineno);
-                 }
-                 loop->prev->next = loop->next;
-                 loop->next->prev = loop->prev;
-                 hTabDeleteItem (&labelRef,
-                                 (IC_FALSE (loop))->key,
-                                 loop, DELETE_ITEM, NULL);
+                 deleteIfx (loop, IC_FALSE (loop)->key);
                  change++;
                  continue;
                }
@@ -160,14 +173,7 @@ labelIfx (iCode * ic)
          ((IC_TRUE (loop) && IC_TRUE (loop)->key == IC_LABEL (loop->next)->key) ||
           (IC_FALSE (loop) && IC_FALSE (loop)->key == IC_LABEL (loop->next)->key)))
        {
-         if (!options.lessPedantic) {
-           werror (W_CONTROL_FLOW, loop->filename, loop->lineno);
-         }
-         loop->prev->next = loop->next;
-         loop->next->prev = loop->prev;
-         hTabDeleteItem (&labelRef,
-                         IC_LABEL (loop->next)->key,
-                         loop, DELETE_ITEM, NULL);
+         deleteIfx (loop, IC_LABEL (loop->next)->key);
          change++;
          continue;
        }
index 04dafb2e6a94a6cd2fa08cdd33593f6bdcbb6114..284fa042d70e201f2c92d3d8cc7d8e7ce1aa3c53 100644 (file)
@@ -2080,9 +2080,12 @@ asmopToBool (asmop *aop, bool resultInA)
             emitcode ("", "%05d$:", (tlbl->key + 100));
           }
         else
-          werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
-                  "Bad rIdx in asmToBool");
-          return;
+          {
+            werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+                    "Bad rIdx in asmToBool");
+            return;
+          }
+        break;
       case AOP_EXT:
         if (resultInA)
           needpula = FALSE;
index f70c369b36420e7232c2d8ee5d43ac937fa667e2..4a911dc13b1e3759e6b9a7ab5c52f28ff2cedfde 100644 (file)
@@ -1987,6 +1987,7 @@ pack:
   return 1;
 }
 
+
 /*------------------------------------------------------------------*/
 /* findAssignToSym : scanning backwards looks for first assig found */
 /*------------------------------------------------------------------*/
@@ -2124,6 +2125,7 @@ static int
 packRegsForSupport (iCode * ic, eBBlock * ebp)
 {
   iCode *dic;
+  int changes = 0;
   
   /* for the left & right operand :- look to see if the
      left was assigned a true symbol in far space in that
@@ -2138,7 +2140,7 @@ packRegsForSupport (iCode * ic, eBBlock * ebp)
        {
          /* found it we need to remove it from the block */
          reassignAliasedSym (ebp, dic, ic, IC_LEFT(ic));
-         return 1;
+         changes++;
        }
     }
 
@@ -2150,25 +2152,13 @@ packRegsForSupport (iCode * ic, eBBlock * ebp)
 
       if (dic)
        {
-         /* if this is a subtraction & the result
-            is a true symbol in far space then don't pack */
-#if 0
-         if (ic->op == '-' && IS_TRUE_SYMOP (IC_RESULT (dic)))
-           {
-             sym_link *etype = getSpec (operandType (IC_RESULT (dic)));
-             if (IN_FARSPACE (SPEC_OCLS (etype)))
-               return 0;
-           }
-#endif
-         /* found it we need to remove it from the
-            block */
+         /* found it we need to remove it from the block */
          reassignAliasedSym (ebp, dic, ic, IC_RIGHT(ic));
-         
-         return 1;
+         changes++;
        }
     }
 
-  return 0;
+  return changes;
 }
 
 #define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly)
@@ -2502,7 +2492,10 @@ packRegsForAccUse (iCode * ic)
       !IS_BITWISE_OP (uic) &&
       (uic->op != LEFT_OP) &&
       (uic->op != RIGHT_OP) &&
-      (uic->op != GETHBIT))
+      (uic->op != GETHBIT) &&
+      (uic->op != RETURN) &&
+      (uic->op != '~') &&
+      (uic->op != '!'))
     return;
 
 #if 0
@@ -2793,7 +2786,7 @@ packRegisters (eBBlock ** ebpp, int blockno)
        }
 
       /* reduce for support function calls */
-      if (ic->supportRtn || ic->op == '+' || ic->op == '-')
+      if (ic->supportRtn || (ic->op != IFX && ic->op != JUMPTABLE))
        packRegsForSupport (ic, ebp);
 
       #if 0
@@ -2905,6 +2898,8 @@ packRegisters (eBBlock ** ebpp, int blockno)
           || IS_CONDITIONAL(ic)
           || IS_BITWISE_OP (ic)
           || ic->op == '='
+           || ic->op == '!'
+           || ic->op == '~'
           || ic->op == GETHBIT
           || ic->op == LEFT_OP || ic->op == RIGHT_OP || ic->op == CALL
           || (ic->op == ADDRESS_OF && isOperandOnStack (IC_LEFT (ic)))