From b8cb898246f67ac1c93c2053842d70c8d4a6828c Mon Sep 17 00:00:00 2001 From: epetrich Date: Sat, 21 Aug 2004 21:10:18 +0000 Subject: [PATCH] * src/mcs51/ralloc.c (packRegsForOneuse): fixed bug #1012650 and some related problems git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3447 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 7 ++++- src/mcs51/ralloc.c | 64 +++++++++++++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 896e6ea0..c472b265 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-08-21 Erik Petrich + + * src/mcs51/ralloc.c (packRegsForOneuse): fixed bug #1012650 and some + related problems + 2004-08-21 Bernhard Held * sim/ucsim/cmd.src/Makefile.in: run lex only if $(PRJDIR)/devel exists @@ -6496,4 +6501,4 @@ * as/mcs51/lklex.c: accept everything as symbol name in rel-files, bug fix ID 452601 * as/mcs51/lksym.c: accept everything as symbol name in rel-files, bug fix ID 452601 -$Revision$ \ No newline at end of file +$Revision$ diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index ec01a646..671ef9e3 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -2310,11 +2310,14 @@ packRegsForSupport (iCode * ic, eBBlock * ebp) static iCode * packRegsForOneuse (iCode * ic, operand * op, eBBlock * ebp) { - bitVect *uses; iCode *dic, *sic; /* if returning a literal then do nothing */ - if (!IS_SYMOP (op)) + if (!IS_ITEMP (op)) + return NULL; + + /* if rematerializable or already return use then do nothing */ + if (OP_SYMBOL(op)->remat || OP_SYMBOL(op)->ruonly) return NULL; /* only upto 2 bytes since we cannot predict @@ -2336,9 +2339,7 @@ packRegsForOneuse (iCode * ic, operand * op, eBBlock * ebp) that definiion is either a return value from a function or does not contain any variables in far space */ - uses = bitVectCopy (OP_USES (op)); - bitVectUnSetBit (uses, ic->key); /* take away this iCode */ - if (!bitVectIsZero (uses)) /* has other uses */ + if (bitVectnBitsOn (OP_USES (op)) > 1) return NULL; /* if it has only one defintion */ @@ -2376,29 +2377,46 @@ packRegsForOneuse (iCode * ic, operand * op, eBBlock * ebp) OP_SYMBOL (op)->ruonly = 1; return dic; } - dic = dic->next; } + else + { + /* otherwise check that the definition does + not contain any symbols in far space */ + if (isOperandInFarSpace (IC_LEFT (dic)) || + isOperandInFarSpace (IC_RIGHT (dic)) || + IS_OP_RUONLY (IC_LEFT (ic)) || + IS_OP_RUONLY (IC_RIGHT (ic))) + { + return NULL; + } + /* if pointer set then make sure the pointer + is one byte */ + if (POINTER_SET (dic) && + !IS_DATA_PTR (aggrToPtr (operandType (IC_RESULT (dic)), FALSE))) + return NULL; - /* otherwise check that the definition does - not contain any symbols in far space */ - if (isOperandInFarSpace (IC_LEFT (dic)) || - isOperandInFarSpace (IC_RIGHT (dic)) || - IS_OP_RUONLY (IC_LEFT (ic)) || - IS_OP_RUONLY (IC_RIGHT (ic))) - { - return NULL; + if (POINTER_GET (dic) && + !IS_DATA_PTR (aggrToPtr (operandType (IC_LEFT (dic)), FALSE))) + return NULL; } + + /* Make sure no overlapping liverange is already assigned to DPTR */ + if (OP_SYMBOL(op)->clashes) + { + symbol *sym; + int i; - /* if pointer set then make sure the pointer - is one byte */ - if (POINTER_SET (dic) && - !IS_DATA_PTR (aggrToPtr (operandType (IC_RESULT (dic)), FALSE))) - return NULL; - - if (POINTER_GET (dic) && - !IS_DATA_PTR (aggrToPtr (operandType (IC_LEFT (dic)), FALSE))) - return NULL; + for (i = 0 ; i < OP_SYMBOL(op)->clashes->size ; i++ ) + { + if (bitVectBitValue(OP_SYMBOL(op)->clashes,i)) + { + sym = hTabItemWithKey(liveRanges,i); + if (sym->ruonly) + return NULL ; + } + } + } sic = dic; -- 2.30.2