From: sandeep Date: Wed, 30 Jan 2002 04:12:38 +0000 (+0000) Subject: added function findbackward def (to be used in upcoming optimization) X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=c6dacaa60503208dcaf4756be76d412ff1c59905;p=fw%2Fsdcc added function findbackward def (to be used in upcoming optimization) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1862 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 23dece62..7f439dc7 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -571,6 +571,20 @@ DEFSETFUNC (ifDiCodeIsX) } +/*-----------------------------------------------------------------*/ +/* findBackwardDef - scan backwards to find deinition of operand */ +/*-----------------------------------------------------------------*/ +iCode *findBackwardDef(operand *op,iCode *ic) +{ + iCode *lic; + + for (lic = ic; lic ; lic = lic->prev) { + if (IC_RESULT(lic) && isOperandEqual(op,IC_RESULT(lic))) + return lic; + } + return NULL; +} + /*-----------------------------------------------------------------*/ /* algebraicOpts - does some algebraic optimizations */ /*-----------------------------------------------------------------*/ @@ -896,6 +910,14 @@ updateSpillLocation (iCode * ic, int induction) IC_RESULT (ic)->operand.symOperand; } +#if 0 /* this needs furthur investigation can save a lot of code */ + if (ASSIGN_SYM_TO_ITEMP(ic) && + !SPIL_LOC(IC_RESULT(ic))) { + if (!OTHERS_PARM (OP_SYMBOL (IC_RIGHT (ic)))) + SPIL_LOC (IC_RESULT (ic)) = + IC_RIGHT (ic)->operand.symOperand; + } +#endif if (ASSIGN_ITEMP_TO_ITEMP (ic)) { if (!SPIL_LOC (IC_RIGHT (ic)) && @@ -1109,7 +1131,7 @@ constFold (iCode * ic, set * cseSet) /* this check is a hueristic to prevent live ranges from becoming too long */ if (IS_PTR (operandType (IC_RESULT (ic)))) - return 0; + return 0; /* check if operation with a literal */ if (!IS_OP_LITERAL (IC_RIGHT (ic))) diff --git a/src/SDCCcse.h b/src/SDCCcse.h index 5eaf9cf2..023afd1a 100644 --- a/src/SDCCcse.h +++ b/src/SDCCcse.h @@ -57,4 +57,5 @@ void unsetDefsAndUses (iCode *); void updateSpillLocation (iCode * ic,int); void setUsesDefs (operand *, bitVect *, bitVect *, bitVect **); void replaceAllSymBySym (iCode *, operand *, operand *, bitVect **); +iCode *findBackwardDef(operand *,iCode *); #endif