/* since the pack the registers depending strictly on the MCU */
/*-----------------------------------------------------------------*/
-#define D(x) x
+#define D(x)
/* Global data */
static struct
if (sym->uptr && !sym->ruonly && getSize(sym->type) < 4) {
if (packRegsDPTRuse(operandFromSymbol(sym))) {
- D (printf ("FILL GAPS: found more DPTR use for %s in func %s\n",sym->name, currFunc ? currFunc->name : "UNKNOWN"));
+ D (fprintf (stderr, "FILL GAPS: found more DPTR use for "
+ "%s in func %s\n",
+ sym->name, currFunc ? currFunc->name : "UNKNOWN"));
/* if this was ssigned to registers then */
if (bitVectBitValue(_G.totRegAssigned,sym->key)) {
sym->regs[i] = getRegGprNoSpil ();
}
- /* for all its definitions check if the registers
+ /* for all its definitions & uses check if the registers
allocated needs positioning NOTE: we can position
only ONCE if more than One positioning required
then give up */
if (pdone > 1) break;
}
}
+ for (i = 0 ; i < sym->uses->size ; i++ ) {
+ if (bitVectBitValue(sym->uses,i)) {
+ iCode *ic;
+ if (!(ic = hTabItemWithKey(iCodehTab,i))) continue ;
+ if (SKIP_IC(ic)) continue;
+ if (!IS_ASSIGN_ICODE(ic)) continue ;
+
+ /* if result is assigned to registers */
+ if (IS_SYMOP(IC_RESULT(ic)) &&
+ bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RESULT(ic))->key)) {
+ pdone += positionRegs(sym,OP_SYMBOL(IC_RESULT(ic)));
+ }
+ if (pdone > 1) break;
+ }
+ }
/* had to position more than once GIVE UP */
if (pdone > 1) {
/* UNDO all the changes we made to try this */
- sym->isspilt = 0;
+ sym->isspilt = 1;
for (i=0; i < sym->nRegs ; i++ ) {
sym->regs[i] = NULL;
}
freeAllRegs();
- D (printf ("Fill Gap gave up due to positioning for %s in function %s\n",sym->name, currFunc ? currFunc->name : "UNKNOWN"));
+ D (fprintf (stderr, "Fill Gap gave up due to positioning for "
+ "%s in function %s\n",
+ sym->name, currFunc ? currFunc->name : "UNKNOWN"));
continue ;
}
- D (printf ("FILLED GAP for %s in function %s\n",sym->name, currFunc ? currFunc->name : "UNKNOWN"));
+ D (fprintf (stderr, "FILLED GAP for %s in function %s\n",
+ sym->name, currFunc ? currFunc->name : "UNKNOWN"));
_G.totRegAssigned = bitVectSetBit(_G.totRegAssigned,sym->key);
sym->isspilt = sym->spillA = 0 ;
sym->usl.spillLoc->allocreq--;
/*-----------------------------------------------------------------*/
static int
packRegsForSupport (iCode * ic, eBBlock * ebp)
-{
+{
int change = 0;
+
/* for the left & right operand :- look to see if the
left was assigned a true symbol in far space in that
case replace them */
if (OP_SYMBOL(IC_RESULT(ic))->liveTo ==
OP_SYMBOL(IC_RESULT(ic))->liveFrom) continue ;
etype = getSpec(type = operandType(IC_RESULT(ic)));
+#if 0
if (getSize(type) == 0 || isOperandEqual(op,IC_RESULT(ic)))
- continue ;
+#endif
+ if (getSize(type) == 0)
+ continue ;
return NULL ;
}
}
#endif
+#if 0 /* unsafe */
/* reduce for support function calls */
if (ic->supportRtn || ic->op == '+' || ic->op == '-')
packRegsForSupport (ic, ebp);
+#endif
/* some cases the redundant moves can
can be eliminated for return statements */
packRegsDPTRuse (IC_LEFT (ic));
}
- if ((ic->op == CALL && getSize(operandType(IC_RESULT(ic))) <= 4)) {
- packRegsDPTRuse (IC_RESULT (ic));
+ if (ic->op == CALL) {
+ sym_link *ftype = operandType(IC_LEFT(ic));
+ if (getSize(operandType(IC_RESULT(ic))) <= 4 &&
+ !IFFUNC_ISBUILTIN(ftype)) {
+ packRegsDPTRuse (IC_RESULT (ic));
+ }
}
/* if pointer set & left has a size more than