switch (size)
{
- // TODO: gaps should be filled for dwords too
+ // TODO: gaps could be filled for dwords too
case 1:
// let's see if we can fill a gap
for (i=0; i<xa51_nRegs; i++) {
/*-----------------------------------------------------------------*/
/* isFree - will return 1 if the a free spil location is found */
/*-----------------------------------------------------------------*/
-static
-DEFSETFUNC (isFree)
-{
+static DEFSETFUNC (isFree) {
symbol *sym = item;
V_ARG (symbol **, sloc);
V_ARG (symbol *, fsym);
-
+
/* if already found */
if (*sloc)
return 0;
-
+
/* if it is free && and the itmp assigned to
this does not have any overlapping live ranges
with the one currently being assigned and
the size can be accomodated */
if (sym->isFree &&
noOverLap (sym->usl.itmpStack, fsym) &&
- getSize (sym->type) >= getSize (fsym->type))
- {
- *sloc = sym;
- return 1;
- }
-
+ /* TODO: this is a waste but causes to many problems
+ getSize (sym->type) >= getSize (fsym->type)) {
+ */
+ getSize (sym->type) == getSize (fsym->type)) {
+ *sloc = sym;
+ return 1;
+ }
+
return 0;
}
createStackSpil (symbol * sym)
{
symbol *sloc = NULL;
- int useXstack, model;
-
char slocBuffer[30];
D(fprintf (stderr, " createStackSpil: %s\n", sym->name));
return sym;
}
- /* could not then have to create one , this is the hard part
- we need to allocate this on the stack : this is really a
- hack!! but cannot think of anything better at this time */
-
- if (sprintf (slocBuffer, "sloc%d", _G.slocNum++) >= sizeof (slocBuffer))
- {
- fprintf (stderr, "***Internal error: slocBuffer overflowed: %s:%d\n",
- __FILE__, __LINE__);
- exit (1);
- }
-
+ sprintf (slocBuffer, "sloc%d", _G.slocNum++);
sloc = newiTemp (slocBuffer);
/* set the type to the spilling symbol */
SPEC_VOLATILE(sloc->etype) = 0;
SPEC_ABSA(sloc->etype) = 0;
- /* we don't allow it to be allocated`
- onto the external stack since : so we
- temporarily turn it off ; we also
- turn off memory model to prevent
- the spil from going to the external storage
- */
-
- useXstack = options.useXstack;
- model = options.model;
-/* noOverlay = options.noOverlay; */
-/* options.noOverlay = 1; */
- options.model = options.useXstack = 0;
-
allocLocal (sloc);
- options.useXstack = useXstack;
- options.model = model;
-/* options.noOverlay = noOverlay; */
sloc->isref = 1; /* to prevent compiler warning */
- /* if it is on the stack then update the stack */
- if (IN_STACK (sloc->etype))
- {
- currFunc->stack += getSize (sloc->type);
- _G.stackExtend += getSize (sloc->type);
- }
- else
- _G.dataExtend += getSize (sloc->type);
+ currFunc->stack += getSize (sloc->type);
+ _G.stackExtend += getSize (sloc->type);
/* add it to the _G.stackSpil set */
addSetHead (&_G.stackSpil, sloc);
/* if result is present && is a true symbol */
if (IC_RESULT (ic) && ic->op != IFX &&
- IS_TRUE_SYMOP (IC_RESULT (ic)))
- OP_SYMBOL (IC_RESULT (ic))->allocreq++;
+ IS_TRUE_SYMOP (IC_RESULT (ic))) {
+ OP_SYMBOL (IC_RESULT (ic))->allocreq++;
+ }
/* take away registers from live
ranges that end at this instruction */
(IC_RESULT (ic) && POINTER_SET (ic)))
continue;
+#if 0
+ /* xa51 has advance compare instructions */
+ if (ic->op == '<' || ic->op == '>' ||
+ ic->op == LE_OP || ic->op == GE_OP ||
+ ic->op == NE_OP || ic->op == EQ_OP) {
+ /* if this result is only used for an ifx, we don't
+ need registers nor the ifx */
+ int used=bitVectnBitsOn(OP_SYMBOL(IC_RESULT(ic))->uses);
+ iCode *nic;
+ if (used!=1) {
+ fprintf (stderr, "unexpected \"used\" for cmp:%d\n", ic->op);
+ exit (1);
+ }
+ // find the ifx
+ for (nic=ic->next; nic; nic=nic->next) {
+ if (nic->op == IFX) {
+ break;
+ }
+ }
+ if (!nic) {
+ // we are in big trouble
+ fprintf (stderr, "No ifx found for %d\n",
+ ic->op);
+ exit (1);
+ }
+ // remove the ifx
+ nic->prev->next=nic->next;
+ if (nic->next) {
+ nic->next->prev=nic->prev;
+ }
+ }
+#endif
+
/* now we need to allocate registers
only for the result */
if (IC_RESULT (ic)) {
/* if it has a spillocation & is used less than
all other live ranges then spill this */
if (willCS) {
- if (sym->usl.spillLoc) {
- symbol *leastUsed = leastUsedLR (liveRangesWith (spillable,
- allLRs, ebbs[i], ic));
- if (leastUsed && leastUsed->used > sym->used) {
- spillThis (sym);
- continue;
- }
- } else {
- /* if none of the liveRanges have a spillLocation then better
- to spill this one than anything else already assigned to registers */
- if (liveRangesWith(spillable,noSpilLoc,ebbs[i],ic)) {
- /* if this is local to this block then we might find a block spil */
- if (!(sym->liveFrom >= ebbs[i]->fSeq && sym->liveTo <= ebbs[i]->lSeq)) {
- spillThis (sym);
- continue;
- }
- }
+ if (sym->usl.spillLoc) {
+ symbol *leastUsed = leastUsedLR (liveRangesWith (spillable,
+ allLRs, ebbs[i], ic));
+ if (leastUsed && leastUsed->used > sym->used) {
+ spillThis (sym);
+ continue;
}
+ } else {
+ /* if none of the liveRanges have a spillLocation then better
+ to spill this one than anything else already assigned to registers */
+ if (liveRangesWith(spillable,noSpilLoc,ebbs[i],ic)) {
+ /* if this is local to this block then we might find a block spil */
+ if (!(sym->liveFrom >= ebbs[i]->fSeq && sym->liveTo <= ebbs[i]->lSeq)) {
+ spillThis (sym);
+ continue;
+ }
+ }
+ }
}
/* else we assign registers to it */
#endif
/* if the symbol has only one definition &
- that definition is a get_pointer and the
- pointer we are getting is rematerializable and
- in "data" space */
-
+ that definition is a get_pointer */
if (bitVectnBitsOn (sym->defs) == 1 &&
(ic = hTabItemWithKey (iCodehTab,
bitVectFirstBit (sym->defs))) &&
!sym->noSpilLoc &&
!IS_BITVAR (sym->etype))
{
-
-
- /* if remat in data space */
+ /* and that pointer is remat in data space */
if (OP_SYMBOL (IC_LEFT (ic))->remat &&
!IS_CAST_ICODE(OP_SYMBOL (IC_LEFT (ic))->rematiCode) &&
- DCL_TYPE (aggrToPtr (sym->type, FALSE)) == POINTER)
+ DCL_TYPE (aggrToPtr (operandType(IC_LEFT(ic)), FALSE)) == POINTER)
{
/* create a psuedo symbol & force a spil */
symbol *psym = newSymbol (rematStr (OP_SYMBOL (IC_LEFT (ic))), 1);
iCode *ic;
int change = 0;
+ return; // that's it for now
+
while (1) {
change = 0;
if (!change)
break;
}
- return; // that's it for now
for (ic = ebp->sch; ic; ic = ic->next)
{