* device/lib/pic16/**: build pic16 library using autotools for
[fw/sdcc] / src / SDCCpeeph.c
index 7a1f3f258f5531de16371a58fd1f0e28f986a412..e413d49930edb78bdfff6292ef757c5aa3eae650 100644 (file)
@@ -402,6 +402,28 @@ FBYNAME (deadMove)
   return FALSE;
 }
 
+/*-----------------------------------------------------------------*/
+/* notUsed - Check, if value in register is not read again         */
+/*-----------------------------------------------------------------*/
+FBYNAME (notUsed)
+{
+  const char *what;
+
+  if(cmdLine[0] != '\'')
+    what = hTabItemWithKey (vars, 1);
+  else
+  {
+    cmdLine[strlen(cmdLine) - 1] = 0;
+    what = cmdLine + 1;
+  }
+
+  if (port->peep.notUsed)
+    return port->peep.notUsed (what, endPl, head);
+
+  fprintf (stderr, "Function notUsed not initialized in port structure\n");
+  return FALSE;
+}
+
 /*-----------------------------------------------------------------*/
 /* operandsNotSame - check if %1 & %2 are the same                 */
 /*-----------------------------------------------------------------*/
@@ -1200,6 +1222,9 @@ ftab[] =                                // sorted on the number of times used
   },
   {
     "useAcallAjmp", useAcallAjmp
+  },
+  {
+    "notUsed", notUsed
   }
 };
 /*-----------------------------------------------------------------*/
@@ -1244,9 +1269,18 @@ callFuncByName (char *fname,
       /* and there can be no additional conditions.             */
       if (c == '(')
         {
-          cmdTerm = funcArgs;
-          while ((c = *cmdTerm) && c != ')')
-            cmdTerm++;
+
+          int num_parenthesis = 0;
+          cmdTerm = funcArgs;          
+
+          while ((c = *cmdTerm) && (c != ')' || num_parenthesis))
+            {
+              if (c == '(')
+                num_parenthesis++;
+              else if (c == ')')
+                num_parenthesis--;
+              cmdTerm++;
+            }
           *cmdTerm = '\0';  /* terminate the arguments */
           if (c == ')')
             {