aop->aopu.aop_immd.from_cast_remat = 1;
ic = OP_SYMBOL (IC_RIGHT (ic))->rematiCode;
ptr_type = DCL_TYPE(from_type);
+ if (ptr_type == IPOINTER) {
+ // bug #481053
+ ptr_type = POINTER;
+ }
continue ;
} else break;
}
/* if already has a asmop then continue */
- if (op->aop)
+ if (op->aop )
return;
/* if the underlying symbol has a aop */
}
/* else spill location */
+ if (sym->usl.spillLoc && getSize(sym->type) != getSize(sym->usl.spillLoc->type)) {
+ /* force a new aop if sizes differ */
+ sym->usl.spillLoc->aop = NULL;
+ }
sym->aop = op->aop = aop =
aopForSym (ic, sym->usl.spillLoc, result);
aop->size = getSize (sym->type);
the same register bank then we need to save the
destination registers on the stack */
dtype = operandType (IC_LEFT (ic));
- if (dtype && !IFFUNC_ISNAKED(dtype) &&
+ if (currFunc && dtype && !IFFUNC_ISNAKED(dtype) &&
(FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype)) &&
IFFUNC_ISISR (currFunc->type))
{
the same register bank then we need to save the
destination registers on the stack */
dtype = operandType (IC_LEFT (ic));
- if (dtype && !FUNC_ISNAKED(dtype) &&
+ if (currFunc && dtype && !FUNC_ISNAKED(dtype) &&
IFFUNC_ISISR (currFunc->type) &&
(FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype))) {
saveRBank (FUNC_REGBANK (dtype), ic, TRUE);
symbol *sym;
sym_link *ftype;
bool switchedPSW = FALSE;
+ int calleesaves_saved_register = -1;
_G.nRegsSaved = 0;
/* create the function header */
if (bitVectBitValue (sym->regsUsed, i) ||
(mcs51_ptrRegReq && (i == R0_IDX || i == R1_IDX)))
{
+ /* remember one saved register for later usage */
+ if (calleesaves_saved_register < 0)
+ calleesaves_saved_register = i;
emitcode ("push", "%s", mcs51_regWithIdx (i)->dname);
_G.nRegsSaved++;
}
emitcode ("mov", "sp,a");
}
+ else if (i > 5)
+ {
+ if (IFFUNC_CALLEESAVES(sym->type))
+ {
+ /* if it's a callee-saves function we need a saved register */
+ if (calleesaves_saved_register >= 0)
+ {
+ emitcode ("mov", "%s,a", mcs51_regWithIdx (calleesaves_saved_register)->dname);
+ emitcode ("mov", "a,sp");
+ emitcode ("add", "a,#0x%02x", ((char) sym->stack & 0xff));
+ emitcode ("mov", "sp,a");
+ emitcode ("mov", "a,%s", mcs51_regWithIdx (calleesaves_saved_register)->dname);
+ }
+ else
+ /* do it the hard way */
+ while (i--)
+ emitcode ("inc", "sp");
+ }
+ else
+ {
+ /* not callee-saves, we can clobber ar0 */
+ emitcode ("mov", "ar0,a");
+ emitcode ("mov", "a,sp");
+ emitcode ("add", "a,#0x%02x", ((char) sym->stack & 0xff));
+ emitcode ("mov", "sp,a");
+ emitcode ("mov", "a,ar0");
+ }
+ }
else
while (i--)
emitcode ("inc", "sp");
emitcode ("setb", "ea");
/* if debug then send end of function */
- /* if (options.debug && currFunc) */
if (options.debug && currFunc)
{
_G.debugLine = 1;
{
int size, offset = 0, pushed = 0;
+ D(emitcode (";", "genRet"));
+
/* if we have no return value then
just generate the "ret" */
if (!IC_LEFT (ic))
if (bitVectBitValue(OP_USES(op),lic->key) || (unsigned) lic->defKey == op->key) {
return NULL;
}
+ /* if GOTO or IFX */
+ if (lic->op == IFX || lic->op == GOTO) break;
lic = lic->next;
}
return NULL;
if (sym->stack)
{
emitcode ("mov", "a,_bp");
- emitcode ("add", "a,#0x%02x", ((char) sym->stack & 0xff));
+ emitcode ("add", "a,#0x%02x", ((sym->stack < 0) ?
+ ((char) (sym->stack - _G.nRegsSaved)) :
+ ((char) sym->stack)) & 0xff);
aopPut (AOP (IC_RESULT (ic)), "a", 0);
}
else
if (allocInfo)
printAllocInfo (currFunc, codeOutFile);
/* if debug information required */
- /* if (options.debug && currFunc) { */
if (options.debug && currFunc)
{
cdbSymbol (currFunc, cdbFile, FALSE, TRUE);