#include "common.h"
#include "ralloc.h"
+#include "gen.h"
/*-----------------------------------------------------------------*/
/* At this point we start getting processor specific although */
static int notUsedInRemaining (symbol *sym, eBBlock *ebp, iCode *ic)
{
return ((usedInRemaining (operandFromSymbol(sym),ic) ? 0 : 1) &&
- allDefsOutOfRange (sym->defs,ic->seq,ebp->lSeq));
+ allDefsOutOfRange (sym->defs,ebp->fSeq,ebp->lSeq));
}
/*-----------------------------------------------------------------*/
{
symbol *sloc= NULL;
int useXstack, model, noOverlay;
- int stackAuto;
+
+ char slocBuffer[30];
/* first go try and find a free one that is already
existing on the stack */
we need to allocate this on the stack : this is really a
hack!! but cannot think of anything better at this time */
- sprintf(buffer,"sloc%d",_G.slocNum++);
- sloc = newiTemp(buffer);
+ if (sprintf(slocBuffer,"sloc%d",_G.slocNum++) >= sizeof(slocBuffer))
+ {
+ fprintf(stderr, "***Internal error: slocBuffer overflowed: %s:%d\n",
+ __FILE__, __LINE__);
+ exit(1);
+ }
+
+ sloc = newiTemp(slocBuffer);
/* set the type to the spilling symbol */
sloc->type = copyLinkChain(sym->type);
sloc->etype = getSpec(sloc->type);
- SPEC_SCLS(sloc->etype) = S_AUTO ;
+ SPEC_SCLS(sloc->etype) = S_DATA ;
SPEC_EXTR(sloc->etype) = 0;
/* we don't allow it to be allocated`
useXstack = options.useXstack;
model = options.model;
noOverlay = options.noOverlay;
- stackAuto = options.stackAuto;
options.noOverlay = 1;
options.model = options.useXstack = 0;
options.useXstack = useXstack;
options.model = model;
options.noOverlay = noOverlay;
- options.stackAuto = stackAuto;
sloc->isref = 1; /* to prevent compiler warning */
/* if it is on the stack then update the stack */
return sym;
}
- /* if the symbol is local to the block then */
- if (forSym->liveTo < ebp->lSeq ) {
+ /* if the symbol is local to the block then */
+ if (forSym->liveTo < ebp->lSeq) {
/* check if there are any live ranges allocated
to registers that are not used in this block */
/*-----------------------------------------------------------------*/
/* getRegPtr - will try for PTR if not a GPR type if not spil */
/*-----------------------------------------------------------------*/
-regs *getRegPtr (iCode *ic, eBBlock *ebp, symbol *sym)
+static regs *getRegPtr (iCode *ic, eBBlock *ebp, symbol *sym)
{
regs *reg;
rumask = newBitVect(mcs51_nRegs);
- for (j = 0; j < sym->nRegs; j++) {
+ for (j = 0; j < sym->nRegs; j++) {
rumask = bitVectSetBit(rumask,
sym->regs[j]->rIdx);
}
{
iCode *dic, *sic;
- if (
-/* !IS_TRUE_SYMOP(IC_RESULT(ic)) || */
- !IS_ITEMP(IC_RIGHT(ic)) ||
- OP_LIVETO(IC_RIGHT(ic)) > ic->seq ||
- OP_SYMBOL(IC_RIGHT(ic))->isind)
+ if (!IS_ITEMP(IC_RIGHT(ic)) ||
+ OP_SYMBOL(IC_RIGHT(ic))->isind ||
+ OP_LIVETO(IC_RIGHT(ic)) > ic->seq) {
return 0;
-
+ }
+
/* if the true symbol is defined in far space or on stack
then we should not since this will increase register pressure */
if (isOperandInFarSpace(IC_RESULT(ic))) {
remiCodeFromeBBlock(ebp,ic);
hTabDeleteItem (&iCodehTab,ic->key,ic,DELETE_ITEM,NULL);
+ OP_DEFS(IC_RESULT(dic)) = bitVectSetBit(OP_DEFS(IC_RESULT(dic)),dic->key);
return 1;
}
/* only upto 2 bytes since we cannot predict
the usage of b, & acc */
- if (getSize(operandType(op)) > 2 &&
+ if (getSize(operandType(op)) > (fReturnSize - 2) &&
ic->op != RETURN &&
ic->op != SEND)
return NULL;
getSize(operandType(IC_RESULT(ic))) > 1))
return ;
+ if (IS_BITWISE_OP(ic) &&
+ getSize(operandType(IC_RESULT(ic))) > 1)
+ return ;
+
/* has only one definition */
if (bitVectnBitsOn(OP_DEFS(IC_RESULT(ic))) > 1)
}
/* if this is a +/- operation with a rematerizable
- then mark this as rematerializable as well only
- if the literal value is within the range -255 and + 255
- the assembler cannot handle it other wise */
+ then mark this as rematerializable as well */
if ((ic->op == '+' || ic->op == '-') &&
-
(IS_SYMOP(IC_LEFT(ic)) &&
IS_ITEMP(IC_RESULT(ic)) &&
OP_SYMBOL(IC_LEFT(ic))->remat &&
IS_OP_LITERAL(IC_RIGHT(ic))) ) {
int i = operandLitValue(IC_RIGHT(ic));
- if ( i < 255 && i > -255) {
- OP_SYMBOL(IC_RESULT(ic))->remat = 1;
- OP_SYMBOL(IC_RESULT(ic))->rematiCode = ic;
- OP_SYMBOL(IC_RESULT(ic))->usl.spillLoc = NULL;
- }
+ OP_SYMBOL(IC_RESULT(ic))->remat = 1;
+ OP_SYMBOL(IC_RESULT(ic))->rematiCode = ic;
+ OP_SYMBOL(IC_RESULT(ic))->usl.spillLoc = NULL;
}
/* mark the pointer usages */
IC_RESULT(dic) = IC_RESULT(ic);
remiCodeFromeBBlock(ebp,ic);
hTabDeleteItem (&iCodehTab,ic->key,ic,DELETE_ITEM,NULL);
+ OP_DEFS(IC_RESULT(dic)) = bitVectSetBit(OP_DEFS(IC_RESULT(dic)),dic->key);
ic = ic->prev;
} else
OP_SYMBOL(IC_RIGHT(ic))->ruonly = 0;
IC_RESULT(dic) = IC_RESULT(ic);
remiCodeFromeBBlock(ebp,ic);
hTabDeleteItem (&iCodehTab,ic->key,ic,DELETE_ITEM,NULL);
+ OP_DEFS(IC_RESULT(dic)) = bitVectSetBit(OP_DEFS(IC_RESULT(dic)),dic->key);
ic = ic->prev;
}
}