2008-03-30 Philipp Klaus Krause <pkk AT spth.de>
- * src/z80/ralloc (serialRegAssign, allocReg, tryAllocatingRegPair):
- Implemented #1921450, changed some Debug messages.
+ * src/z80/gen.c (emitDebug, assignResultValue, genPlus, genMinus, genMult, genJumpTab):
+ Use 16-bit instructions for addition in some additional cases,
+ implemented RFEs #1914251, #1914245, #1922090, #1921382, #1918323.
+
+2008-03-30 Philipp Klaus Krause <pkk AT spth.de>
+ * src/z80/ralloc.c (serialRegAssign, allocReg, tryAllocatingRegPair):
+ Implemented RFE #1921450, changed some debug messages.
2008-03-30 Borut Razem <borut.razem AT siol.net>
static void
emitDebug (const char *szFormat,...)
{
+ if (!options.verboseAsm)
+ return;
if (!DISABLE_DEBUG)
{
va_list ap;
assignResultValue (operand * oper)
{
int size = AOP_SIZE (oper);
+ int i;
bool topInA = 0;
wassertl (size <= 4, "Got a result that is bigger than four bytes");
else
{
if ((AOP_TYPE (oper) == AOP_REG) && (AOP_SIZE (oper) == 4) &&
- !strcmp (AOP (oper)->aopu.aop_reg[size-1]->name, _fReturn[size-2]))
+ !strcmp (AOP (oper)->aopu.aop_reg[size-2]->name, _fReturn[size-1]))
{
size--;
_emitMove ("a", _fReturn[size-1]);
aopPut (AOP (oper), _fReturn[size], size-1);
size--;
}
- while (size--)
+ for (i = 0; i < size; i++)
{
- aopPut (AOP (oper), _fReturn[size], size);
+ aopPut (AOP (oper), _fReturn[i], i);
}
}
}
/* Mark the registers as restored. */
_G.saves.saved = FALSE;
- /* if we need assign a result value */
- if ((IS_ITEMP (IC_RESULT (ic)) &&
- (OP_SYMBOL (IC_RESULT (ic))->nRegs ||
- OP_SYMBOL (IC_RESULT (ic))->spildir)) ||
- IS_TRUE_SYMOP (IC_RESULT (ic)))
- {
- aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
-
- assignResultValue (IC_RESULT (ic));
-
- freeAsmop (IC_RESULT (ic), NULL, ic);
- }
-
/* adjust the stack for parameters if required */
if (ic->parmBytes)
{
}
}
+ /* if we need assign a result value */
+ if ((IS_ITEMP (IC_RESULT (ic)) &&
+ (OP_SYMBOL (IC_RESULT (ic))->nRegs ||
+ OP_SYMBOL (IC_RESULT (ic))->spildir)) ||
+ IS_TRUE_SYMOP (IC_RESULT (ic)))
+ {
+ aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
+
+ assignResultValue (IC_RESULT (ic));
+
+ freeAsmop (IC_RESULT (ic), NULL, ic);
+ }
+
spillCached ();
if (IC_RESULT (ic))
{
else if (sym->stack && IS_GB && sym->stack > -INT8MIN)
emit2 ("!enterxl", sym->stack);
else if (sym->stack)
- emit2 ("!enterx", sym->stack);
+ {
+ if (optimize.codeSize && sym->stack <= 8 || sym->stack <= 4)
+ {
+ int stack = sym->stack;
+ emit2 ("!enter");
+ while (stack > 1)
+ {
+ emit2 ("push af");
+ stack -= 2;
+ }
+ if(stack > 0)
+ emit2 ("dec sp");
+ }
+ else
+ emit2 ("!enterx", sym->stack);
+ }
else
emit2 ("!enter");
{
fetchPair (PAIR_HL, AOP (IC_LEFT (ic)));
emit2 ("add hl,%s", getPairName (AOP (IC_RIGHT (ic))));
- spillCached();
+ spillPair (PAIR_HL);
+ commitPair ( AOP (IC_RESULT (ic)), PAIR_HL);
+ goto release;
+ }
+
+ if (isPair (AOP (IC_LEFT (ic))) && AOP_TYPE (IC_RIGHT (ic)) == AOP_LIT && getPairId (AOP (IC_LEFT (ic))) != PAIR_HL)
+ {
+ fetchPair (PAIR_HL, AOP (IC_RIGHT (ic)));
+ emit2 ("add hl,%s", getPairName (AOP (IC_LEFT (ic))));
+ spillPair (PAIR_HL);
commitPair ( AOP (IC_RESULT (ic)), PAIR_HL);
goto release;
}
{
/* first add without previous c */
if (!offset)
- emit2 ("add a,!immedbyte", (unsigned int) (lit & 0x0FFL));
+ {
+ if (size == 0 && (unsigned int) (lit & 0x0FFL) == 0xFF)
+ emit2 ("dec a");
+ else
+ emit2 ("add a,!immedbyte", (unsigned int) (lit & 0x0FFL));
+ }
else
emit2 ("adc a,!immedbyte", (unsigned int) ((lit >> (offset * 8)) & 0x0FFL));
}
i <<= 1;
}
- spillCached();
+ spillPair(PAIR_HL);
if (IS_Z80 && _G.stack.pushedDE)
{
{
if (sym->onStack)
{
- spillCached ();
+ spillPair (PAIR_HL);
if (sym->stack <= 0)
{
setupPairFromSP (PAIR_HL, sym->stack + _G.stack.pushed + _G.stack.offset);
}
else
{
- spillCached ();
+ spillPair (PAIR_HL);
if (sym->onStack)
{
/* if it has an offset then we need to compute it */
emit2 ("ld e,%s", l);
emit2 ("ld d,!zero");
jtab = newiTempLabel (NULL);
- spillCached ();
+ spillPair (PAIR_HL);
emit2 ("ld hl,!immed!tlabel", jtab->key + 100);
emit2 ("add hl,de");
emit2 ("add hl,de");