From: epetrich Date: Tue, 4 Nov 2003 06:46:48 +0000 (+0000) Subject: * src/SDCCcse.c (ifxOptimize), X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=55f47f8fb5c237801d250b90f5d067b471656c0c;p=fw%2Fsdcc * src/SDCCcse.c (ifxOptimize), * src/SDCClabel.c (labelIfx, deleteIfx): When the condition to an IFX iCode is volatile, convert to DUMMY_READ_VOLATILE instead deleting the IFX iCode. * src/hc08/ralloc.c: reduced unneeded slocs * src/hc08/gen.c: fixed bug in asmopToBoolean git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2990 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCcse.c b/src/SDCCcse.c index e9b2d87e..87b5c1c8 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -1347,18 +1347,36 @@ ifxOptimize (iCode * ic, set * cseSet, isinSet (ebb->succList, eBBWithEntryLabel (ebbs, label, count))) { - remiCodeFromeBBlock (ebb, ic); - computeControlFlow (ebbs, count, 1); if (!options.lessPedantic) { werror (W_CONTROL_FLOW, ic->filename, ic->lineno); } - return; + if (IS_OP_VOLATILE (IC_COND (ic))) + { + IC_RIGHT (ic) = IC_COND (ic); + IC_LEFT (ic) = NULL; + IC_RESULT (ic) = NULL; + ic->op = DUMMY_READ_VOLATILE; + } + else + { + remiCodeFromeBBlock (ebb, ic); + computeControlFlow (ebbs, count, 1); + return; + } } /* if it remains an IFX the update the use Set */ - OP_USES(IC_COND (ic))=bitVectSetBit (OP_USES (IC_COND (ic)), ic->key); - setUsesDefs (IC_COND (ic), ebb->defSet, ebb->outDefs, &ebb->usesDefs); + if (ic->op == IFX) + { + OP_USES(IC_COND (ic))=bitVectSetBit (OP_USES (IC_COND (ic)), ic->key); + setUsesDefs (IC_COND (ic), ebb->defSet, ebb->outDefs, &ebb->usesDefs); + } + else if (ic->op == DUMMY_READ_VOLATILE) + { + OP_USES(IC_RIGHT (ic))=bitVectSetBit (OP_USES (IC_RIGHT (ic)), ic->key); + setUsesDefs (IC_RIGHT (ic), ebb->defSet, ebb->outDefs, &ebb->usesDefs); + } return; } diff --git a/src/SDCClabel.c b/src/SDCClabel.c index 04ce5568..d31f69d0 100644 --- a/src/SDCClabel.c +++ b/src/SDCClabel.c @@ -95,6 +95,36 @@ labelGotoNext (iCode * ic) return change; } +/*-------------------------------------------------------------------*/ +/* deleteIfx - delete an IFX iCode or convert to DUMMY_READ_VOLATILE */ +/*-------------------------------------------------------------------*/ +static void +deleteIfx (iCode * loop, int key) +{ + if (!options.lessPedantic) + { + werror (W_CONTROL_FLOW, loop->filename, loop->lineno); + } + hTabDeleteItem (&labelRef, key, loop, DELETE_ITEM, NULL); + + /* If the condition was volatile, convert IFX to */ + /* DUMMY_READ_VOLATILE. Otherwise just delete the */ + /* IFX iCode */ + if (IS_OP_VOLATILE (IC_COND (loop))) + { + IC_RIGHT (loop) = IC_COND (loop); + IC_LEFT (loop) = NULL; + IC_RESULT (loop) = NULL; + loop->op = DUMMY_READ_VOLATILE; + } + else + { + loop->prev->next = loop->next; + loop->next->prev = loop->prev; + } +} + + /*-----------------------------------------------------------------*/ /* labelIfx - special case Ifx elimination */ /*-----------------------------------------------------------------*/ @@ -119,33 +149,16 @@ labelIfx (iCode * ic) if (IC_TRUE (loop) && IC_TRUE (loop)->key == IC_LABEL (loop->next)->key) { - - /* get rid of this if */ - if (!options.lessPedantic) { - werror (W_CONTROL_FLOW, loop->filename, loop->lineno); - } - loop->prev->next = loop->next; - loop->next->prev = loop->prev; - hTabDeleteItem (&labelRef, - (IC_TRUE (loop))->key, - loop, DELETE_ITEM, NULL); + deleteIfx (loop, IC_TRUE (loop)->key); change++; - continue; + continue; } else { if (IC_FALSE (loop) && IC_FALSE (loop)->key == IC_LABEL (loop->next)->key) { - /* get rid of this if */ - if (!options.lessPedantic) { - werror (W_CONTROL_FLOW, loop->filename, loop->lineno); - } - loop->prev->next = loop->next; - loop->next->prev = loop->prev; - hTabDeleteItem (&labelRef, - (IC_FALSE (loop))->key, - loop, DELETE_ITEM, NULL); + deleteIfx (loop, IC_FALSE (loop)->key); change++; continue; } @@ -160,14 +173,7 @@ labelIfx (iCode * ic) ((IC_TRUE (loop) && IC_TRUE (loop)->key == IC_LABEL (loop->next)->key) || (IC_FALSE (loop) && IC_FALSE (loop)->key == IC_LABEL (loop->next)->key))) { - if (!options.lessPedantic) { - werror (W_CONTROL_FLOW, loop->filename, loop->lineno); - } - loop->prev->next = loop->next; - loop->next->prev = loop->prev; - hTabDeleteItem (&labelRef, - IC_LABEL (loop->next)->key, - loop, DELETE_ITEM, NULL); + deleteIfx (loop, IC_LABEL (loop->next)->key); change++; continue; } diff --git a/src/hc08/gen.c b/src/hc08/gen.c index 04dafb2e..284fa042 100644 --- a/src/hc08/gen.c +++ b/src/hc08/gen.c @@ -2080,9 +2080,12 @@ asmopToBool (asmop *aop, bool resultInA) emitcode ("", "%05d$:", (tlbl->key + 100)); } else - werror (E_INTERNAL_ERROR, __FILE__, __LINE__, - "Bad rIdx in asmToBool"); - return; + { + werror (E_INTERNAL_ERROR, __FILE__, __LINE__, + "Bad rIdx in asmToBool"); + return; + } + break; case AOP_EXT: if (resultInA) needpula = FALSE; diff --git a/src/hc08/ralloc.c b/src/hc08/ralloc.c index f70c369b..4a911dc1 100644 --- a/src/hc08/ralloc.c +++ b/src/hc08/ralloc.c @@ -1987,6 +1987,7 @@ pack: return 1; } + /*------------------------------------------------------------------*/ /* findAssignToSym : scanning backwards looks for first assig found */ /*------------------------------------------------------------------*/ @@ -2124,6 +2125,7 @@ static int packRegsForSupport (iCode * ic, eBBlock * ebp) { iCode *dic; + int changes = 0; /* for the left & right operand :- look to see if the left was assigned a true symbol in far space in that @@ -2138,7 +2140,7 @@ packRegsForSupport (iCode * ic, eBBlock * ebp) { /* found it we need to remove it from the block */ reassignAliasedSym (ebp, dic, ic, IC_LEFT(ic)); - return 1; + changes++; } } @@ -2150,25 +2152,13 @@ packRegsForSupport (iCode * ic, eBBlock * ebp) if (dic) { - /* if this is a subtraction & the result - is a true symbol in far space then don't pack */ -#if 0 - if (ic->op == '-' && IS_TRUE_SYMOP (IC_RESULT (dic))) - { - sym_link *etype = getSpec (operandType (IC_RESULT (dic))); - if (IN_FARSPACE (SPEC_OCLS (etype))) - return 0; - } -#endif - /* found it we need to remove it from the - block */ + /* found it we need to remove it from the block */ reassignAliasedSym (ebp, dic, ic, IC_RIGHT(ic)); - - return 1; + changes++; } } - return 0; + return changes; } #define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly) @@ -2502,7 +2492,10 @@ packRegsForAccUse (iCode * ic) !IS_BITWISE_OP (uic) && (uic->op != LEFT_OP) && (uic->op != RIGHT_OP) && - (uic->op != GETHBIT)) + (uic->op != GETHBIT) && + (uic->op != RETURN) && + (uic->op != '~') && + (uic->op != '!')) return; #if 0 @@ -2793,7 +2786,7 @@ packRegisters (eBBlock ** ebpp, int blockno) } /* reduce for support function calls */ - if (ic->supportRtn || ic->op == '+' || ic->op == '-') + if (ic->supportRtn || (ic->op != IFX && ic->op != JUMPTABLE)) packRegsForSupport (ic, ebp); #if 0 @@ -2905,6 +2898,8 @@ packRegisters (eBBlock ** ebpp, int blockno) || IS_CONDITIONAL(ic) || IS_BITWISE_OP (ic) || ic->op == '=' + || ic->op == '!' + || ic->op == '~' || ic->op == GETHBIT || ic->op == LEFT_OP || ic->op == RIGHT_OP || ic->op == CALL || (ic->op == ADDRESS_OF && isOperandOnStack (IC_LEFT (ic)))