return rc;
}
+
+/* labelRefCountChange:
+ * takes two parameters: a variable (bound to a label name)
+ * and a signed int for changing the reference count.
+ *
+ * Please note, this function is not a conditional. It unconditionally
+ * changes the label. It should be passed as the 'last' function
+ * so it only is applied if all other conditions have been met.
+ *
+ * should always return TRUE
+ */
+FBYNAME (labelRefCountChange)
+{
+ int varNumber, RefCountDelta;
+ bool rc = FALSE;
+
+ /* If we don't have the label hash table yet, build it. */
+ if (!labelHash)
+ {
+ buildLabelRefCountHash (head);
+ }
+
+ if (sscanf (cmdLine, "%*[ \t%]%d %i", &varNumber, &RefCountDelta) == 2)
+ {
+ char *label = hTabItemWithKey (vars, varNumber);
+
+ if (label)
+ {
+ labelHashEntry *entry;
+
+ entry = hTabFirstItemWK (labelHash, hashSymbolName (label));
+
+ while (entry)
+ {
+ if (!strcmp (label, entry->name))
+ {
+ break;
+ }
+ entry = hTabNextItemWK (labelHash);
+ }
+ if (entry)
+ {
+ if (0 <= entry->refCount + RefCountDelta)
+ {
+ entry->refCount += RefCountDelta;
+ rc = TRUE;
+ }
+ else
+ {
+ fprintf (stderr, "*** internal error: label %s may not get"
+ " negative refCount in %s peephole.\n",
+ label, __FUNCTION__);
+ }
+ }
+ else
+ {
+ fprintf (stderr, "*** internal error: no label has entry for"
+ " %s in %s peephole.\n",
+ label, __FUNCTION__);
+ }
+ }
+ else
+ {
+ fprintf (stderr, "*** internal error: var %d not bound"
+ " in peephole %s rule.\n",
+ varNumber, __FUNCTION__);
+ }
+ }
+ else
+ {
+ fprintf (stderr,
+ "*** internal error: labelRefCount peephole restriction"
+ " malformed: %s\n", cmdLine);
+ }
+ return rc;
+}
+
+
/* Within the context of the lines currPl through endPl, determine
** if the variable var contains a symbol that is volatile. Returns
** TRUE only if it is certain that this was not volatile (the symbol
/*------------------------------------------------------------------*/
/* setFromConditionArgs - parse a peephole condition's arguments */
/* to produce a set of strings, one per argument. Variables %x will */
-/* be replaced with their values. String literals (in single or */
-/* double quotes) are accepted an return in unquoted form. */
+/* be replaced with their values. String literals (in single quotes)*/
+/* are accepted and return in unquoted form. */
/*------------------------------------------------------------------*/
static set *
setFromConditionArgs (char *cmdLine, hTab * vars)
else
goto error;
}
- else if (*cmdLine == '"' || *cmdLine == '\'' )
+ else if (*cmdLine == '\'' )
{
char quote = *cmdLine;
if (!operands)
{
fprintf (stderr,
- "*** internal error: operandsUnrelated peephole restriction"
+ "*** internal error: operandsNotRelated peephole restriction"
" malformed: %s\n", cmdLine);
return FALSE;
}
},
{
"operandsNotRelated", operandsNotRelated
+ },
+ {
+ "labelRefCountChange", labelRefCountChange
}
};
int i;