* src/SDCCpeeph.c (operandsLiteral): new, added,
[fw/sdcc] / src / SDCCpeeph.c
index b227cf0a0a9cd5a52c6865dd66d06dfc6240cd2c..478178c6675cd4148b36b14f5d80c539195a06d9 100644 (file)
@@ -963,6 +963,39 @@ FBYNAME (operandsNotRelated)
 }
 
 
+/*-------------------------------------------------------------------*/
+/* operandsLiteral - returns true of the condition's operands are    */
+/* literals.                                                         */
+/*-------------------------------------------------------------------*/
+FBYNAME (operandsLiteral)
+{
+  set *operands;
+  const char *op;
+
+  operands = setFromConditionArgs (cmdLine, vars);
+
+  if (!operands)
+    {
+      fprintf (stderr,
+               "*** internal error: operandsLiteral peephole restriction"
+               " malformed: %s\n", cmdLine);
+      return FALSE;
+    }
+
+  for (op = setFirstItem (operands); op; op = setNextItem (operands))
+    {
+      if (!isdigit(*op))
+        {
+          deleteSet (&operands);
+          return FALSE;
+        }
+    }
+
+  deleteSet (&operands);
+  return TRUE;
+}
+
+
 /*-----------------------------------------------------------------*/
 /* callFuncByName - calls a function as defined in the table       */
 /*-----------------------------------------------------------------*/
@@ -1046,6 +1079,9 @@ callFuncByName (char *fname,
     {
       "operandsNotRelated", operandsNotRelated
     },
+    {
+      "operandsLiteral", operandsLiteral
+    },
     {
       "labelRefCountChange", labelRefCountChange
     }