for (sym = setFirstItem (itmpStack); sym;
sym = setNextItem (itmpStack))
{
- if (sym->liveTo > fsym->liveFrom)
- return 0;
+ if (sym->liveFrom < fsym->liveTo &&
+ sym->liveTo > fsym->liveTo) return 0;
+ if (sym->liveFrom < fsym->liveFrom &&
+ sym->liveTo > fsym->liveFrom) return 0;
}
return 1;
then mark it */
if (POINTER_GET (ic) && IS_SYMOP (IC_LEFT (ic))
&& getSize (OP_SYMBOL (IC_LEFT (ic))->type)
- <= PTRSIZE)
+ <= (unsigned int) PTRSIZE)
{
mcs51_ptrRegReq++;
ptrRegSet = 1;
symbol on the right */
for (dic = ic->prev; dic; dic = dic->prev)
{
-
/* if the definition is a call then no */
if ((dic->op == CALL || dic->op == PCALL) &&
IC_RESULT (dic)->key == IC_RIGHT (ic)->key)
/* if the true symbol is defined in far space or on stack
then we should not since this will increase register pressure */
+#if 0
if (isOperandInFarSpace (IC_RESULT (ic)))
{
if ((dic = farSpacePackable (ic)))
goto pack;
else
return 0;
-
}
+#else
+ if (isOperandInFarSpace(IC_RESULT(ic)) && !farSpacePackable(ic)) {
+ return 0;
+ }
+#endif
+
/* find the definition of iTempNN scanning backwards if we find a
a use of the true symbol in before we find the definition then
we cannot */
for (dic = ic->prev; dic; dic = dic->prev)
{
-
+#if 0 // jwk 20010410
/* if there is a function call and this is
a parameter & not my parameter then don't pack it */
if ((dic->op == CALL || dic->op == PCALL) &&
dic = NULL;
break;
}
+#else
+ /* if there is a function call then don't pack it */
+ if ((dic->op == CALL || dic->op == PCALL))
+ {
+ dic = NULL;
+ break;
+ }
+#endif
if (SKIP_IC2 (dic))
continue;
/* for the left & right operand :- look to see if the
left was assigned a true symbol in far space in that
case replace them */
+
if (IS_ITEMP (IC_LEFT (ic)) &&
OP_SYMBOL (IC_LEFT (ic))->liveTo <= ic->seq)
{
}
/* do the same for the right operand */
-right:
+ right:
if (!change &&
IS_ITEMP (IC_RIGHT (ic)) &&
OP_SYMBOL (IC_RIGHT (ic))->liveTo <= ic->seq)
/* only upto 2 bytes since we cannot predict
the usage of b, & acc */
- if (getSize (operandType (op)) > (fReturnSize - 2) &&
+ if (getSize (operandType (op)) > (fReturnSizeMCS51 - 2) &&
ic->op != RETURN &&
ic->op != SEND &&
!POINTER_SET (ic) &&
if (bitVectnBitsOn (OP_DEFS (op)) > 1)
return NULL; /* has more than one definition */
- /* get the that definition */
+ /* get that definition */
if (!(dic =
hTabItemWithKey (iCodehTab,
bitVectFirstBit (OP_DEFS (op)))))
{
return NULL;
}
+ /* if left or right or result is on stack */
+ if (isOperandOnStack(IC_LEFT(dic)) ||
+ isOperandOnStack(IC_RIGHT(dic)) ||
+ isOperandOnStack(IC_RESULT(dic))) {
+ return NULL;
+ }
}
OP_SYMBOL (op)->ruonly = 1;
isBitwiseOptimizable (iCode * ic)
{
sym_link *ltype = getSpec (operandType (IC_LEFT (ic)));
- sym_link *rtype = getSpec (operandType (IC_RIGHT (ic)));
/* bitwise operations are considered optimizable
under the following conditions (Jean-Louis VERN)
- x & lit
bit & bit
bit & x
bit ^ bit
bit ^ x
- x ^ lit
- x | lit
bit | bit
bit | x
*/
- if (IS_LITERAL (rtype) ||
- (IS_BITVAR (ltype) && IN_BITSPACE (SPEC_OCLS (ltype))))
+ if ((IS_BITVAR (ltype) && IN_BITSPACE (SPEC_OCLS (ltype))))
return TRUE;
else
return FALSE;
static void
packForPush (iCode * ic, eBBlock * ebp)
{
- iCode *dic;
+ iCode *dic, *lic;
+ bitVect *dbv;
if (ic->op != IPUSH || !IS_ITEMP (IC_LEFT (ic)))
return;
if (dic->op != '=' || POINTER_SET (dic))
return;
+ /* make sure the right side does not have any definitions
+ inbetween */
+ dbv = OP_DEFS(IC_RIGHT(dic));
+ for (lic = ic; lic && lic != dic ; lic = lic->prev) {
+ if (bitVectBitValue(dbv,lic->key))
+ return ;
+ }
/* we now we know that it has one & only one def & use
and the that the definition is an assignment */
IC_LEFT (ic) = IC_RIGHT (dic);
/* TrueSym := iTempNN:1 */
for (ic = ebp->sch; ic; ic = ic->next)
{
-
-
/* find assignment of the form TrueSym := iTempNN:1 */
if (ic->op == '=' && !POINTER_SET (ic))
change += packRegsForAssign (ic, ebp);
for (ic = ebp->sch; ic; ic = ic->next)
{
-
/* if this is an itemp & result of a address of a true sym
then mark this as rematerialisable */
if (ic->op == ADDRESS_OF &&
bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 &&
IS_OP_LITERAL (IC_RIGHT (ic))))
{
-
- //int i = operandLitValue (IC_RIGHT (ic));
OP_SYMBOL (IC_RESULT (ic))->remat = 1;
OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
is defined in the previous instruction then
mark the itemp as a conditional */
if ((IS_CONDITIONAL (ic) ||
- ((ic->op == BITWISEAND ||
- ic->op == '|' ||
- ic->op == '^') &&
- isBitwiseOptimizable (ic))) &&
+ (IS_BITWISE_OP(ic) && isBitwiseOptimizable (ic))) &&
ic->next && ic->next->op == IFX &&
isOperandEqual (IC_RESULT (ic), IC_COND (ic->next)) &&
OP_SYMBOL (IC_RESULT (ic))->liveTo <= ic->next->seq)
{
-
OP_SYMBOL (IC_RESULT (ic))->regType = REG_CND;
continue;
}
can be eliminated for return statements */
if ((ic->op == RETURN || ic->op == SEND) &&
!isOperandInFarSpace (IC_LEFT (ic)) &&
- options.model == MODEL_SMALL)
- packRegsForOneuse (ic, IC_LEFT (ic), ebp);
+ options.model == MODEL_SMALL) {
+ if (0 && options.stackAuto) {
+ /* we should check here if acc will be clobbered for stack
+ offset calculations */
+ } else {
+ packRegsForOneuse (ic, IC_LEFT (ic), ebp);
+ }
+ }
/* if pointer set & left has a size more than
one and right is not in far space */
getSize (operandType (IC_RESULT (ic))) <= 2)
packRegsForAccUse (ic);
-
}
}
if (options.dump_rassgn)
{
dumpEbbsToFileExt (".dumprassgn", ebbs, count);
- dumpLiveRanges (".lrange", liveRanges);
+ dumpLiveRanges (".dumplrange", liveRanges);
}
/* do the overlaysegment stuff SDCCmem.c */