X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCpeeph.c;h=c38627dc2a7e76bfb81779ad823aead57d3c2198;hb=bb939d05cb3f6e3e8f8d5cb10a63b8d48e07a085;hp=b227cf0a0a9cd5a52c6865dd66d06dfc6240cd2c;hpb=13bce9be22334b2b96daea87f24d4cf65803e2d6;p=fw%2Fsdcc diff --git a/src/SDCCpeeph.c b/src/SDCCpeeph.c index b227cf0a..c38627dc 100644 --- a/src/SDCCpeeph.c +++ b/src/SDCCpeeph.c @@ -238,6 +238,10 @@ FBYNAME (labelIsReturnOnly) int len; char * retInst; + /* Don't optimize jumps in a jump table; a more generic test */ + if (currPl->ic && currPl->ic->op == JUMPTABLE) + return FALSE; + label = hTabItemWithKey (vars, 5); if (!label) return FALSE; len = strlen(label); @@ -963,6 +967,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 +1083,9 @@ callFuncByName (char *fname, { "operandsNotRelated", operandsNotRelated }, + { + "operandsLiteral", operandsLiteral + }, { "labelRefCountChange", labelRefCountChange } @@ -2243,13 +2283,18 @@ initPeepHole () char *s; /* read in the default rules */ - readRules (port->peep.default_rules); + if (!options.nopeep) + { + readRules (port->peep.default_rules); + } /* if we have any additional file read it too */ if (options.peep_file) { readRules (s = readFileIntoBuffer (options.peep_file)); setToNull ((void *) &s); + /* override nopeep setting, default rules have not been read */ + options.nopeep = 0; }