(callFuncByName): inserted operandsLiteral
* src/mcs51/peeph.def: reenabled 132.e, added extra check to 132.x
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4076
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2006-03-29 Maarten Brock <sourceforge.brock AT dse.nl>
+
+ * src/SDCCpeeph.c (operandsLiteral): new, added,
+ (callFuncByName): inserted operandsLiteral
+ * src/mcs51/peeph.def: reenabled 132.e, added extra check to 132.x
+
2006-03-28 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
* doc/sdccman.lyx: added paragraph "Use of SDCC in Education"
* src/mcs51/peeph.def: disabled rule 132.e fixing bug #1453093
-2006-03-23 Maarten Brock <sourceforge.brock AT dse.nl>
+2006-03-24 Maarten Brock <sourceforge.brock AT dse.nl>
* src/z80/gen.c (genFunction, genEndFunction): fixed bug 1160666,
implemented patch 1120823 Thanks to Willy De la Court (normal
}
+/*-------------------------------------------------------------------*/
+/* 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 */
/*-----------------------------------------------------------------*/
{
"operandsNotRelated", operandsNotRelated
},
+ {
+ "operandsLiteral", operandsLiteral
+ },
{
"labelRefCountChange", labelRefCountChange
}
mov a,%2
add a,#0xff - %1
mov %3,c
-}
+} if operandsLiteral(%1)
replace {
clr c
mov a,%2
add a,#0xff - %1
jnc %5
-}
+} if operandsLiteral(%1)
replace {
clr c
mov a,%2
add a,#0xff - %1
jc %5
-}
+} if operandsLiteral(%1)
replace {
clr c
mov a,#0x100 - %2
add a,%1
mov %3,c
-} if operandsNotRelated('0x00' %2)
+} if operandsNotRelated('0x00' %2), operandsLiteral(%2)
-//This peephole caused bug #1453093
-//replace {
-// clr c
-// mov a,%1
-// subb a,#%2
-// jnc %5
-//} by {
-// ; Peephole 132.e optimized genCmpLt by inverse logic (carry differs)
-// mov a,#0x100 - %2
-// add a,%1
-// jc %5
-//} if operandsNotRelated('0x00' %2)
+replace {
+ clr c
+ mov a,%1
+ subb a,#%2
+ jnc %5
+} by {
+ ; Peephole 132.e optimized genCmpLt by inverse logic (carry differs)
+ mov a,#0x100 - %2
+ add a,%1
+ jc %5
+} if operandsNotRelated('0x00' %2), operandsLiteral(%2)
replace {
clr c
mov a,#0x100 - %2
add a,%1
jnc %5
-} if operandsNotRelated('0x00' %2)
+} if operandsNotRelated('0x00' %2), operandsLiteral(%2)
replace {