int pushedDE;
} calleeSaves;
+ bool omitFramePtr;
int frameId;
int receiveOffset;
bool flushStatics;
_G.pairs[pairId].base = NULL;
}
+/* Given a register name, spill the pair (if any) the register is part of */
+static void
+spillPairReg (const char *regname)
+{
+ if (strlen(regname)==1)
+ {
+ switch (*regname)
+ {
+ case 'h':
+ case 'l':
+ spillPair(PAIR_HL);
+ break;
+ case 'd':
+ case 'e':
+ spillPair(PAIR_DE);
+ break;
+ case 'b':
+ case 'c':
+ spillPair(PAIR_BC);
+ break;
+ }
+ }
+}
+
/** Push a register pair onto the stack */
void
genPairPush (asmop * aop)
Normally everything is AOP_STK, but for offsets of < -128 or
> 127 on the Z80 an extended stack pointer is used.
*/
- if (IS_Z80 && (options.ommitFramePtr || sym->stack < INT8MIN || sym->stack > (int)(INT8MAX-getSize (sym->type))))
+ if (IS_Z80 && (_G.omitFramePtr || sym->stack < INT8MIN || sym->stack > (int)(INT8MAX-getSize (sym->type))))
{
emitDebug ("; AOP_EXSTK for %s", sym->rname);
sym->aop = aop = newAsmop (AOP_EXSTK);
else
emit2 ("ld %s,%s",
aop->aopu.aop_reg[offset]->name, s);
+ spillPairReg(aop->aopu.aop_reg[offset]->name);
break;
case AOP_IY:
{
emit2 ("ld %s,%s", aop->aopu.aop_str[offset], s);
}
+ spillPairReg(aop->aopu.aop_str[offset]);
break;
case AOP_ACC:
else
{
if (strcmp (aop->aopu.aop_str[offset], s))
- emit2 ("ld %s,%s", aop->aopu.aop_str[offset], s);
+ {
+ emit2 ("ld %s,%s", aop->aopu.aop_str[offset], s);
+ spillPairReg(aop->aopu.aop_str[offset]);
+ }
}
break;
case AOP_HLREG:
wassert (offset < 2);
emit2 ("ld %s,%s", aop->aopu.aop_str[offset], s);
+ spillPairReg(aop->aopu.aop_str[offset]);
break;
case AOP_PAIRPTR:
static void
genFunction (iCode * ic)
{
+ bool stackParm;
+
symbol *sym = OP_SYMBOL (IC_LEFT (ic));
sym_link *ftype;
/* adjust the stack for the function */
_G.stack.last = sym->stack;
-
- if (sym->stack && IS_GB && sym->stack > -INT8MIN)
+
+ stackParm = FALSE;
+ for (sym = setFirstItem (istack->syms); sym;
+ sym = setNextItem (istack->syms))
+ {
+ if (sym->_isparm && !IS_REGPARM (sym->etype))
+ {
+ stackParm = TRUE;
+ break;
+ }
+ }
+ sym = OP_SYMBOL (IC_LEFT (ic));
+
+ _G.omitFramePtr = options.ommitFramePtr;
+ if (IS_Z80 && !stackParm && !sym->stack)
+ {
+ /* When the conflicts between AOP_EXSTK && AOP_HLREG are fixed, */
+ /* the above !sym->stack condition can be removed. -- EEP */
+ if (sym->stack)
+ emit2 ("!ldaspsp", -sym->stack);
+ _G.omitFramePtr = TRUE;
+ }
+ else if (sym->stack && IS_GB && sym->stack > -INT8MIN)
emit2 ("!enterxl", sym->stack);
else if (sym->stack)
emit2 ("!enterx", sym->stack);
/* PENDING: calleeSave */
- if (_G.stack.offset && IS_GB && _G.stack.offset > INT8MAX)
+ if (IS_Z80 && _G.omitFramePtr)
+ {
+ if (_G.stack.offset)
+ emit2 ("!ldaspsp", _G.stack.offset);
+ }
+ else if (_G.stack.offset && IS_GB && _G.stack.offset > INT8MAX)
{
emit2 ("!leavexl", _G.stack.offset);
}