+2003-10-02 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+ * src/z80/gen.c (genRet): fixed bug #524753
+ * src/z80/gen.c (genCast): fixed internal error on cast from
+ pointer to long
+ * src/z80/gen.c (_saveRegsForCall, emitCall): adapted Johan's
+ fix for bug #477835 to the z80
+ * src/z80/gen.c (genZ80code, _vemit2, _emit2): added support
+ for tracking iCodes in the peephole optimizer for z80
+
+
2003-10-01 Erik Petrich <epetrich@ivorytower.norman.ok.us>
* src/SDCCicode.c (geniCodeJumpTable, geniCodeSwitch): fixed
bool flushStatics;
bool in_home;
const char *lastFunctionName;
+ iCode *current_iCode;
set *sendSet;
(_G.lines.head = _newLineNode (buffer)));
_G.lines.current->isInline = _G.lines.isInline;
+ _G.lines.current->ic = _G.current_iCode;
}
static void
(_G.lines.head = _newLineNode (lb)));
}
_G.lines.current->isInline = _G.lines.isInline;
+ _G.lines.current->ic = _G.current_iCode;
va_end (ap);
}
bool bcInRet = FALSE, deInRet = FALSE;
bitVect *rInUse;
- rInUse = bitVectCplAnd (bitVectCopy (ic->rMask), ic->rUsed);
+ rInUse = bitVectCplAnd (bitVectCopy (ic->rMask),
+ z80_rUmaskForOp (IC_RESULT(ic)));
deInUse = bitVectBitValue (rInUse, D_IDX) || bitVectBitValue(rInUse, E_IDX);
bcInUse = bitVectBitValue (rInUse, B_IDX) || bitVectBitValue(rInUse, C_IDX);
static void
emitCall (iCode * ic, bool ispcall)
{
+ bool bInRet, cInRet, dInRet, eInRet;
sym_link *dtype = operandType (IC_LEFT (ic));
/* if caller saves & we have not saved then */
}
spillCached ();
+ if (IC_RESULT (ic))
+ {
+ bitVect *result = z80_rUmaskForOp (IC_RESULT (ic));
+ bInRet = bitVectBitValue(result, B_IDX);
+ cInRet = bitVectBitValue(result, C_IDX);
+ dInRet = bitVectBitValue(result, D_IDX);
+ eInRet = bitVectBitValue(result, E_IDX);
+ }
+ else
+ {
+ bInRet = FALSE;
+ cInRet = FALSE;
+ dInRet = FALSE;
+ eInRet = FALSE;
+ }
if (_G.stack.pushedDE)
{
- bool dInRet = bitVectBitValue(ic->rUsed, D_IDX);
- bool eInRet = bitVectBitValue(ic->rUsed, E_IDX);
-
if (dInRet && eInRet)
{
wassertl (0, "Shouldn't push DE if it's wiped out by the return");
if (_G.stack.pushedBC)
{
- bool bInRet = bitVectBitValue(ic->rUsed, B_IDX);
- bool cInRet = bitVectBitValue(ic->rUsed, C_IDX);
-
if (bInRet && cInRet)
{
wassertl (0, "Shouldn't push BC if it's wiped out by the return");
aopOp (IC_LEFT (ic), ic, FALSE, FALSE);
size = AOP_SIZE (IC_LEFT (ic));
+ aopDump("IC_LEFT", AOP(IC_LEFT(ic)));
+
+ #if 0
if ((size == 2) && ((l = aopGetWord (AOP (IC_LEFT (ic)), 0))))
{
if (IS_GB)
emit2 ("ld hl,%s", l);
}
}
+ #endif
+ if (size==2)
+ {
+ fetchPair(IS_GB ? PAIR_DE : PAIR_HL, AOP (IC_LEFT (ic)));
+ }
else
{
if (IS_GB && size == 4 && requiresHL (AOP (IC_LEFT (ic))))
l = aopGet (AOP (IC_LEFT (ic)), offset,
FALSE);
if (strcmp (_fReturn[offset], l))
- emit2 ("ld %s,%s", _fReturn[offset++], l);
+ emit2 ("ld %s,%s", _fReturn[offset], l);
+ offset++;
}
}
}
/* now depending on the sign of the destination */
size = AOP_SIZE (result) - AOP_SIZE (right);
/* Unsigned or not an integral type - right fill with zeros */
- if (SPEC_USIGN (rtype) || !IS_SPEC (rtype) || AOP_TYPE(right)==AOP_CRY)
+ if (!IS_SPEC (rtype) || SPEC_USIGN (rtype) || AOP_TYPE(right)==AOP_CRY)
{
while (size--)
aopPut (AOP (result), "!zero", offset++);
for (ic = lic; ic; ic = ic->next)
{
+ _G.current_iCode = ic;
if (cln != ic->lineno)
{