extern int allocInfo;
static int pushReg (regs *reg, bool freereg);
static void pullReg (regs *reg);
extern int allocInfo;
static int pushReg (regs *reg, bool freereg);
static void pullReg (regs *reg);
//static void saveRBank (int, iCode *, bool);
static bool operandsEqu (operand * op1, operand * op2);
static void loadRegFromConst (regs *reg, char *c);
//static void saveRBank (int, iCode *, bool);
static bool operandsEqu (operand * op1, operand * op2);
static void loadRegFromConst (regs *reg, char *c);
- D(emitcode ("", "; transferRegReg(%s,%s)",
+ DD(emitcode ("", "; transferRegReg(%s,%s)",
- D(emitcode ("", "; loadRegFromAop (%s, %s, %d)",
+ DD(emitcode ("", "; loadRegFromAop (%s, %s, %d)",
reg->name, aopName (aop), loffset));
/* If operand is volatile, we cannot optimize. */
reg->name, aopName (aop), loffset));
/* If operand is volatile, we cannot optimize. */
&& operandsEqu(hc08_reg_h->aop->op,aop->op)
&& (hc08_reg_h->aopofs == loffset))
{
&& operandsEqu(hc08_reg_h->aop->op,aop->op)
&& (hc08_reg_h->aopofs == loffset))
{
&& operandsEqu(hc08_reg_x->aop->op,aop->op)
&& (hc08_reg_x->aopofs == loffset))
{
&& operandsEqu(hc08_reg_x->aop->op,aop->op)
&& (hc08_reg_x->aopofs == loffset))
{
&& operandsEqu(hc08_reg_a->aop->op,aop->op)
&& (hc08_reg_a->aopofs == loffset))
{
&& operandsEqu(hc08_reg_a->aop->op,aop->op)
&& (hc08_reg_a->aopofs == loffset))
{
/*--------------------------------------------------------------------------*/
/* forceStackedAop - Reserve space on the stack for asmop aop; when */
/* freeAsmop is called with aop, the stacked data will */
/*--------------------------------------------------------------------------*/
/* forceStackedAop - Reserve space on the stack for asmop aop; when */
/* freeAsmop is called with aop, the stacked data will */
int loffset;
asmop *newaop = newAsmop (aop->type);
memcpy (newaop, aop, sizeof(*newaop));
int loffset;
asmop *newaop = newAsmop (aop->type);
memcpy (newaop, aop, sizeof(*newaop));
- D(emitcode("", "; forcedStackAop %s", aopName(aop)));
+ DD(emitcode("", "; forcedStackAop %s", aopName(aop)));
+
+ if (copyOrig && hc08_reg_a->isFree)
+ reg = hc08_reg_a;
+ else if (copyOrig && hc08_reg_x->isFree)
+ reg = hc08_reg_x;
+ else
+ reg = NULL;
+
- aopsof->aopu.aop_stk = pushReg (hc08_reg_a, FALSE);
+ if (copyOrig && reg)
+ {
+ loadRegFromAop (reg, aop, loffset);
+ aopsof->aopu.aop_stk = pushReg (reg, FALSE);
+ }
+ else
+ {
+ aopsof->aopu.aop_stk = pushReg (hc08_reg_a, FALSE);
+ }
- D(emitcode ("", "; storeRegToAop (%s, %s, %d), stacked=%d, isaddr=%d",
+ DD(emitcode ("", "; storeRegToAop (%s, %s, %d), stacked=%d, isaddr=%d",
reg->name, aopName (aop), loffset, aop->stacked, aop->isaddr));
if ((reg->rIdx == HX_IDX) && aop->stacked
reg->name, aopName (aop), loffset, aop->stacked, aop->isaddr));
if ((reg->rIdx == HX_IDX) && aop->stacked
&& operandsEqu(otherreg->aop->op,aop->op)
&& (otherreg->aopofs == loffset))
{
&& operandsEqu(otherreg->aop->op,aop->op)
&& (otherreg->aopofs == loffset))
{
-// D(emitcode ("", "; transferAopAop (%s, %d, %s, %d)",
+// DD(emitcode ("", "; transferAopAop (%s, %d, %s, %d)",
// aopName (srcaop), srcofs, aopName (dstaop), dstofs));
// aopName (srcaop), srcofs, aopName (dstaop), dstofs));
-// D(emitcode ("", "; srcaop->type = %d", srcaop->type));
-// D(emitcode ("", "; dstaop->type = %d", dstaop->type));
+// DD(emitcode ("", "; srcaop->type = %d", srcaop->type));
+// DD(emitcode ("", "; dstaop->type = %d", dstaop->type));
emitcode ("tst", "%s", aopAdrStr (aop, 0, FALSE));
emitcode ("bne", "%05d$", (tlbl->key + 100));
emitcode ("tst", "%s", aopAdrStr (aop, 1, FALSE));
emitcode ("tst", "%s", aopAdrStr (aop, 0, FALSE));
emitcode ("bne", "%05d$", (tlbl->key + 100));
emitcode ("tst", "%s", aopAdrStr (aop, 1, FALSE));
emitBranch ("bsr", tlbl);
emitBranch ("bra", rlbl);
emitLabel (tlbl);
emitBranch ("bsr", tlbl);
emitBranch ("bra", rlbl);
emitLabel (tlbl);
/* Push the function's address */
aopOp (IC_LEFT (ic), ic, FALSE);
/* Push the function's address */
aopOp (IC_LEFT (ic), ic, FALSE);
/*-----------------------------------------------------------------*/
/* inExcludeList - return 1 if the string is in exclude Reg list */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* inExcludeList - return 1 if the string is in exclude Reg list */
/*-----------------------------------------------------------------*/
emitcode (";", "-----------------------------------------");
emitcode ("", "%s:", sym->rname);
emitcode (";", "-----------------------------------------");
emitcode ("", "%s:", sym->rname);
- D(emitcode ("", "; icount = %d, sameRegs=%d", icount,
+ DD(emitcode ("", "; icount = %d, sameRegs=%d", icount,
sameRegs (AOP (left), AOP (result))));
if ((icount > 255) || (icount<0))
sameRegs (AOP (left), AOP (result))));
if ((icount > 255) || (icount<0))
- D(emitcode("","; left size = %d", getDataSize (IC_LEFT(ic))));
- D(emitcode("","; right size = %d", getDataSize (IC_RIGHT(ic))));
- D(emitcode("","; result size = %d", getDataSize (IC_RESULT(ic))));
+ DD(emitcode("","; left size = %d", getDataSize (IC_LEFT(ic))));
+ DD(emitcode("","; right size = %d", getDataSize (IC_RIGHT(ic))));
+ DD(emitcode("","; result size = %d", getDataSize (IC_RESULT(ic))));
loadRegFromAop (hc08_reg_a, AOP (left), 0);
loadRegFromAop (hc08_reg_x, AOP (right), 0);
loadRegFromAop (hc08_reg_a, AOP (left), 0);
loadRegFromAop (hc08_reg_x, AOP (right), 0);
- D(emitcode("","; pset=%d, pget=%d",pset,pget));
+ DD(emitcode("","; pset=%d, pget=%d",pset,pget));
- D(emitcode ("; shift left ", "result %d, left %d", size,
+ DD(emitcode ("; shift left ", "result %d, left %d", size,
only the lower order byte since shifting
more that 32 bits make no sense anyway, ( the
largest size of an object can be only 32 bits ) */
aopOp (result, ic, FALSE);
aopOp (left, ic, FALSE);
only the lower order byte since shifting
more that 32 bits make no sense anyway, ( the
largest size of an object can be only 32 bits ) */
aopOp (result, ic, FALSE);
aopOp (left, ic, FALSE);
- if (sameRegs(AOP (right), AOP (result)) || IS_AOP_XA (AOP (result)))
- AOP (result) = forceStackedAop (AOP (result));
+ if (sameRegs(AOP (right), AOP (result)) || IS_AOP_XA (AOP (result))
+ || isOperandVolatile (result, FALSE))
+ aopResult = forceStackedAop (AOP (result), sameRegs ( AOP (left), AOP (result)));
- transferAopAop (AOP (left), offset, AOP (result), offset);
+ transferAopAop (AOP (left), offset, aopResult, offset);
offset++;
}
}
freeAsmop (left, NULL, ic, TRUE);
offset++;
}
}
freeAsmop (left, NULL, ic, TRUE);
- D(emitcode ("; shift right ", "result %d, left %d", AOP_SIZE (result),
+ DD(emitcode ("; shift right ", "result %d, left %d", AOP_SIZE (result),
+ aopResult = AOP (result);
+
+ if (sameRegs(AOP (right), AOP (result)) || IS_AOP_XA (AOP (result))
+ || isOperandVolatile (result, FALSE))
+ aopResult = forceStackedAop (AOP (result), sameRegs ( AOP (left), AOP (result)));
- {
- transferAopAop (AOP (left), offset, AOP (result), offset);
- offset++;
- }
+ {
+ transferAopAop (AOP (left), offset, aopResult, offset);
+ offset++;
+ }
}
freeAsmop (left, NULL, ic, TRUE);
}
freeAsmop (left, NULL, ic, TRUE);
emitcode("", "; [%s] ic:%d: %s", regsInUse, ic->seq, printILine(ic));
emitcode("", "; [%s] ic:%d: %s", regsInUse, ic->seq, printILine(ic));