* src/SDCCsymt.h,
[fw/sdcc] / src / SDCCpeeph.c
index 921642b1db2becacc19ab061365b8430e111b085..2c493e2528aaabffc331b7da307ded3e7ae01cb4 100644 (file)
@@ -279,6 +279,10 @@ FBYNAME (labelInRange)
   if (!lbl)
     return FALSE;
 
+  /* Don't optimize jumps in a jump table; a more generic test */
+  if (currPl->ic && currPl->ic->op == JUMPTABLE)
+    return FALSE;
+    
   /* if the previous two instructions are "ljmp"s then don't
      do it since it can be part of a jump table */
   if (currPl->prev && currPl->prev->prev &&
@@ -704,15 +708,27 @@ notVolatileVariable(char *var, lineNode *currPl, lineNode *endPl)
     if (cl->ic && (cl->ic!=last_ic))
       {
         last_ic = cl->ic;
-        op = IC_LEFT (cl->ic);
-        if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) )
-          return !op->isvolatile;
-        op = IC_RIGHT (cl->ic);
-        if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) )
-          return !op->isvolatile;
-        op = IC_RESULT (cl->ic);
-        if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) )
-          return !op->isvolatile;
+        switch (cl->ic->op)
+          {
+          case IFX:
+            op = IC_COND (cl->ic);
+            if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) )
+              return !op->isvolatile;
+          case JUMPTABLE:
+            op = IC_JTCOND (cl->ic);
+            if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) )
+              return !op->isvolatile;
+          default:
+            op = IC_LEFT (cl->ic);
+            if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) )
+              return !op->isvolatile;
+            op = IC_RIGHT (cl->ic);
+            if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) )
+              return !op->isvolatile;
+            op = IC_RESULT (cl->ic);
+            if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) )
+              return !op->isvolatile;
+          }
       }
   }
   
@@ -750,15 +766,27 @@ FBYNAME (notVolatile)
       {
         if (cl->ic)
           {
-            op = IC_LEFT (cl->ic);
-            if (IS_SYMOP (op) && op->isvolatile)
-              return FALSE;
-            op = IC_RIGHT (cl->ic);
-            if (IS_SYMOP (op) && op->isvolatile)
-              return FALSE;
-            op = IC_RESULT (cl->ic);
-            if (IS_SYMOP (op) && op->isvolatile)
-              return FALSE;
+            switch (cl->ic->op)
+              {
+              case IFX:
+                op = IC_COND (cl->ic);
+                if (IS_SYMOP (op) && op->isvolatile)
+                  return FALSE;
+              case JUMPTABLE:
+                op = IC_JTCOND (cl->ic);
+                if (IS_SYMOP (op) && op->isvolatile)
+                  return FALSE;
+              default:
+                op = IC_LEFT (cl->ic);
+                if (IS_SYMOP (op) && op->isvolatile)
+                  return FALSE;
+                op = IC_RIGHT (cl->ic);
+                if (IS_SYMOP (op) && op->isvolatile)
+                  return FALSE;
+                op = IC_RESULT (cl->ic);
+                if (IS_SYMOP (op) && op->isvolatile)
+                  return FALSE;
+              }
           }
       }
       return TRUE;
@@ -1340,7 +1368,7 @@ matchRule (lineNode * pl,
   lineNode *spl;               /* source pl */
   lineNode *rpl;               /* rule peep line */
 
-/*     setToNull((void **) &pr->vars);    */
+/*     setToNull((void *) &pr->vars);    */
 /*     pr->vars = newHashTable(100); */
 
   /* for all the lines defined in the rule */
@@ -1984,7 +2012,7 @@ initPeepHole ()
   if (options.peep_file)
     {
       readRules (s = readFileIntoBuffer (options.peep_file));
-      setToNull ((void **) &s);
+      setToNull ((void *) &s);
     }