From cf7d00ac6acd181f85f8ecaf4d88d8d188429435 Mon Sep 17 00:00:00 2001 From: epetrich Date: Sun, 20 Mar 2005 19:31:19 +0000 Subject: [PATCH] * src/port.h (struct PORT), * src/avr/ralloc.c (avr_assignRegisters), * src/avr/main.c, * src/ds390/ralloc.c (ds390_assignRegisters), * src/ds390/main.c, * src/hc08/ralloc.c (hc08_assignRegisters), * src/hc08/main.c, * src/mcs51/ralloc.c (mcs51_assignRegisters), * src/mcs51/main.c, * src/pic/ralloc.c (pic14_assignRegisters), * src/pic/main.c, * src/pic16/ralloc.c (pic16_assignRegisters), * src/pic16/main.c, * src/xa51/ralloc.c (xa51_assignRegisters), * src/xa51/main.c, * src/z80/ralloc.c (z80_assignRegisters), * src/z80/ralloc.h, * src/SDCCopt.c (eBBlockFromiCode, replaceRegEqv, killDeadCode), * src/SDCCcse.c (ifxOptimize, cseBBlock, cseAllBlocks), * src/SDCCcse.h, * src/SDCCdflow.c (computeDataFlow), * src/SDCCdflow.h, * src/SDCCloop.c (addDefInExprs, loopInvariants, loopOptimizations), * src/SDCCloop.h, * src/SDCCcflow.c (*), * src/SDCCcflow.h, * src/SDCCBBlock.c (iCodeBreakDown, dumpEbbsToFileExt, eBBWithEntryLabel), * src/SDCCBBlock.h (struct ebbIndex): new struct that keeps two copies of the eBBlock list, sorted by both bbnum and dfnum. (fixes bug with immedDom() returning wrong block; probably fixes bug #1160833) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3703 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 33 ++++++++++++ src/SDCCBBlock.c | 63 +++++++++++++---------- src/SDCCBBlock.h | 19 +++++-- src/SDCCcflow.c | 122 +++++++++++++++++++-------------------------- src/SDCCcflow.h | 15 ++---- src/SDCCcse.c | 20 +++++--- src/SDCCcse.h | 5 +- src/SDCCdflow.c | 11 ++-- src/SDCCdflow.h | 2 +- src/SDCCloop.c | 23 +++++---- src/SDCCloop.h | 5 +- src/SDCCopt.c | 98 +++++++++++++++++++----------------- src/avr/main.c | 2 +- src/avr/ralloc.c | 8 +-- src/ds390/main.c | 2 +- src/ds390/ralloc.c | 8 +-- src/hc08/main.c | 2 +- src/hc08/ralloc.c | 8 +-- src/mcs51/main.c | 2 +- src/mcs51/ralloc.c | 8 +-- src/pic/main.c | 2 +- src/pic/ralloc.c | 8 +-- src/pic16/main.c | 2 +- src/pic16/ralloc.c | 8 +-- src/port.h | 4 +- src/xa51/main.c | 2 +- src/xa51/ralloc.c | 8 +-- src/z80/ralloc.c | 8 +-- src/z80/ralloc.h | 2 +- 29 files changed, 279 insertions(+), 221 deletions(-) diff --git a/ChangeLog b/ChangeLog index 436ffeb3..2eefe5e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2005-03-20 Erik Petrich + + * src/port.h (struct PORT), + * src/avr/ralloc.c (avr_assignRegisters), + * src/avr/main.c, + * src/ds390/ralloc.c (ds390_assignRegisters), + * src/ds390/main.c, + * src/hc08/ralloc.c (hc08_assignRegisters), + * src/hc08/main.c, + * src/mcs51/ralloc.c (mcs51_assignRegisters), + * src/mcs51/main.c, + * src/pic/ralloc.c (pic14_assignRegisters), + * src/pic/main.c, + * src/pic16/ralloc.c (pic16_assignRegisters), + * src/pic16/main.c, + * src/xa51/ralloc.c (xa51_assignRegisters), + * src/xa51/main.c, + * src/z80/ralloc.c (z80_assignRegisters), + * src/z80/ralloc.h, + * src/SDCCopt.c (eBBlockFromiCode, replaceRegEqv, killDeadCode), + * src/SDCCcse.c (ifxOptimize, cseBBlock, cseAllBlocks), + * src/SDCCcse.h, + * src/SDCCdflow.c (computeDataFlow), + * src/SDCCdflow.h, + * src/SDCCloop.c (addDefInExprs, loopInvariants, loopOptimizations), + * src/SDCCloop.h, + * src/SDCCcflow.c (*), + * src/SDCCcflow.h, + * src/SDCCBBlock.c (iCodeBreakDown, dumpEbbsToFileExt, eBBWithEntryLabel), + * src/SDCCBBlock.h (struct ebbIndex): new struct that keeps two copies + of the eBBlock list, sorted by both bbnum and dfnum. (fixes bug with + immedDom() returning wrong block; probably fixes bug #1160833) + 2005-03-20 Borut Razem * support/scripts/inc2h.pl: WIN32 port diff --git a/src/SDCCBBlock.c b/src/SDCCBBlock.c index 931fefcd..1156434e 100644 --- a/src/SDCCBBlock.c +++ b/src/SDCCBBlock.c @@ -182,16 +182,19 @@ dumpLiveRanges (int id, hTab * liveRanges) fflush(file); } + /*-----------------------------------------------------------------*/ /* dumpEbbsToFileExt - writeall the basic blocks to a file */ /*-----------------------------------------------------------------*/ void -dumpEbbsToFileExt (int id, eBBlock ** ebbs, int count) +dumpEbbsToFileExt (int id, ebbIndex * ebbi) { FILE *of; int i; eBBlock *bb; set *cseSet; + eBBlock ** ebbs = ebbi->dfOrder ? ebbi->dfOrder : ebbi->bbOrder; + int count = ebbi->count; if (id) { of=createDumpFile(id); @@ -228,7 +231,7 @@ dumpEbbsToFileExt (int id, eBBlock ** ebbs, int count) fprintf (of, "\ndominators: "); for (d=0; ddomVect->size; d++) { if (bitVectBitValue(ebbs[i]->domVect, d)) { - fprintf (of, "%s ", ebbs[d]->entryLabel->name); + fprintf (of, "%s ", ebbi->bbOrder[d]->entryLabel->name); //ebbs[d]->entryLabel->name); } } } @@ -353,8 +356,10 @@ iCode2eBBlock (iCode * ic) /* eBBWithEntryLabel - finds the basic block with the entry label */ /*-----------------------------------------------------------------*/ eBBlock * -eBBWithEntryLabel (eBBlock ** ebbs, symbol * eLabel, int count) +eBBWithEntryLabel (ebbIndex * ebbi, symbol * eLabel) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; int i; for (i = 0; i < count; i++) @@ -506,17 +511,21 @@ remiCodeFromeBBlock (eBBlock * ebb, iCode * ic) /*-----------------------------------------------------------------*/ /* iCodeBreakDown : breakDown iCode chain to blocks */ /*-----------------------------------------------------------------*/ -eBBlock ** -iCodeBreakDown (iCode * ic, int *count) +ebbIndex * +iCodeBreakDown (iCode * ic) { eBBlock **ebbs = NULL; iCode *loop = ic; - - *count = 0; + ebbIndex *ebbi; + + ebbi = Safe_alloc (sizeof (ebbIndex *)); + ebbi->count = 0; + ebbi->dfOrder = NULL; /* no depth first order information yet */ /* allocate for the first entry */ ebbs = Safe_alloc (sizeof (eBBlock **)); + ebbi->bbOrder = ebbs; while (loop) { @@ -528,36 +537,37 @@ iCodeBreakDown (iCode * ic, int *count) ebb->ech->next = NULL; /* mark the end of this chain */ if (loop) loop->prev = NULL; - ebb->bbnum = *count; /* save this block number */ + ebb->bbnum = ebbi->count; /* save this block number */ /* put it in the array */ - ebbs[(*count)++] = ebb; + ebbs[(ebbi->count)++] = ebb; /* allocate for the next one. Remember to clear the new */ /* pointer at the end, that was created by realloc. */ - ebbs = Safe_realloc (ebbs, (*count + 1) * sizeof (eBBlock **)); + ebbs = Safe_realloc (ebbs, (ebbi->count + 1) * sizeof (eBBlock **)); + ebbi->bbOrder = ebbs; - ebbs[*count] = 0; + ebbs[ebbi->count] = 0; /* if this one ends in a goto or a conditional */ /* branch then check if the block it is going */ /* to already exists, if yes then this could */ /* be a loop, add a preheader to the block it */ /* goes to if it does not already have one */ - if (ebbs[(*count) - 1]->ech && - (ebbs[(*count) - 1]->ech->op == GOTO || - ebbs[(*count) - 1]->ech->op == IFX)) + if (ebbs[(ebbi->count) - 1]->ech && + (ebbs[(ebbi->count) - 1]->ech->op == GOTO || + ebbs[(ebbi->count) - 1]->ech->op == IFX)) { symbol *label; eBBlock *destBlock; - if (ebbs[(*count) - 1]->ech->op == GOTO) - label = IC_LABEL (ebbs[(*count) - 1]->ech); - else if (!(label = IC_TRUE (ebbs[(*count) - 1]->ech))) - label = IC_FALSE (ebbs[(*count) - 1]->ech); + if (ebbs[(ebbi->count) - 1]->ech->op == GOTO) + label = IC_LABEL (ebbs[(ebbi->count) - 1]->ech); + else if (!(label = IC_TRUE (ebbs[(ebbi->count) - 1]->ech))) + label = IC_FALSE (ebbs[(ebbi->count) - 1]->ech); - if ((destBlock = eBBWithEntryLabel (ebbs, label, (*count))) && + if ((destBlock = eBBWithEntryLabel (ebbi, label)) && destBlock->preHeader == NULL && otherPathsPresent (ebbs, destBlock)) { @@ -568,24 +578,25 @@ iCodeBreakDown (iCode * ic, int *count) /* go thru all block replacing the entryLabel with new label */ /* till we reach the block , then we insert a new ebblock */ - for (i = 0; i < (*count); i++) + for (i = 0; i < (ebbi->count); i++) { if (ebbs[i] == destBlock) break; replaceLabel (ebbs[i], label, preHeaderLabel); } - (*count)++; + (ebbi->count)++; /* if we have stopped at the block , allocate for an extra one */ - ebbs = Safe_realloc (ebbs, (*count + 1) * sizeof (eBBlock **)); + ebbs = Safe_realloc (ebbs, (ebbi->count + 1) * sizeof (eBBlock **)); + ebbi->bbOrder = ebbs; - ebbs[*count] = 0; + ebbs[ebbi->count] = 0; /* then move the block down one count */ pBlock = ebbs[j = i]; - for (i += 1; i < (*count); i++) + for (i += 1; i < (ebbi->count); i++) { eBBlock *xBlock; @@ -605,9 +616,9 @@ iCodeBreakDown (iCode * ic, int *count) } /* mark the end */ - ebbs[*count] = NULL; + ebbs[ebbi->count] = NULL; - return ebbs; + return ebbi; } /*-----------------------------------------------------------------*/ diff --git a/src/SDCCBBlock.h b/src/SDCCBBlock.h index 8f0429c7..1f853df8 100644 --- a/src/SDCCBBlock.h +++ b/src/SDCCBBlock.h @@ -49,9 +49,9 @@ typedef struct eBBlock /* control flow analysis */ set *succList; /* list eBBlocks which are successors */ - bitVect *succVect; /* bitVector of successors */ + bitVect *succVect; /* bitVector of successors (index is bbnum) */ set *predList; /* predecessors of this basic block */ - bitVect *domVect; /* list of nodes this is dominated by */ + bitVect *domVect; /* list of nodes this is dominated by (index is bbnum) */ /* data flow analysis */ set *inExprs; /* in coming common expressions */ @@ -71,6 +71,14 @@ typedef struct eBBlock } eBBlock; +typedef struct ebbIndex + { + int count; /* number of blocks in the index */ + eBBlock **bbOrder; /* blocks in bbnum order */ + eBBlock **dfOrder; /* blocks in dfnum (depth first) order */ + } +ebbIndex; + typedef struct edge { @@ -79,6 +87,7 @@ typedef struct edge } edge; + extern int eBBNum; extern set *graphEdges; @@ -86,17 +95,17 @@ extern set *graphEdges; DEFSETFUNC (printEntryLabel); eBBlock *neweBBlock (); edge *newEdge (eBBlock *, eBBlock *); -eBBlock *eBBWithEntryLabel (eBBlock **, symbol *, int); +eBBlock *eBBWithEntryLabel (ebbIndex *, symbol *); DEFSETFUNC (ifFromIs); set *edgesTo (eBBlock *); void remiCodeFromeBBlock (eBBlock *, iCode *); void addiCodeToeBBlock (eBBlock *, iCode *, iCode *); -eBBlock **iCodeBreakDown (iCode *, int *); +ebbIndex *iCodeBreakDown (iCode *); void replaceSymBySym (set *, operand *, operand *); iCode *iCodeFromeBBlock (eBBlock **, int); int otherPathsPresent (eBBlock **, eBBlock *); void replaceLabel (eBBlock *, symbol *, symbol *); -void dumpEbbsToFileExt (int, eBBlock **, int); +void dumpEbbsToFileExt (int, ebbIndex *); void dumpLiveRanges (int, hTab * liveRanges); void closeDumpFiles(); diff --git a/src/SDCCcflow.c b/src/SDCCcflow.c index 0b307797..cb6bf7a6 100644 --- a/src/SDCCcflow.c +++ b/src/SDCCcflow.c @@ -25,11 +25,13 @@ #include "common.h" +static void computeDFOrdering (eBBlock *, int *); + /*-----------------------------------------------------------------*/ /* domSetFromVect - creates a domset from the vector */ /*-----------------------------------------------------------------*/ -set * -domSetFromVect (eBBlock ** ebbs, bitVect * domVect) +static set * +domSetFromVect (ebbIndex *ebbi, bitVect * domVect) { int i = 0; set *domSet = NULL; @@ -39,7 +41,7 @@ domSetFromVect (eBBlock ** ebbs, bitVect * domVect) for (i = 0; i < domVect->size; i++) if (bitVectBitValue (domVect, i)) - addSet (&domSet, ebbs[i]); + addSet (&domSet, ebbi->bbOrder[i]); return domSet; } @@ -48,7 +50,7 @@ domSetFromVect (eBBlock ** ebbs, bitVect * domVect) /* addSuccessor - will add bb to succ also add it to the pred of */ /* the next one : */ /*-----------------------------------------------------------------*/ -void +static void addSuccessor (eBBlock * thisBlock, eBBlock * succ) { /* check for boundary conditions */ @@ -68,9 +70,11 @@ addSuccessor (eBBlock * thisBlock, eBBlock * succ) /*-----------------------------------------------------------------*/ /* eBBPredecessors - find the predecessors for each block */ /*-----------------------------------------------------------------*/ -void -eBBPredecessors (eBBlock ** ebbs, int count) +static void +eBBPredecessors (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; int i = 0, j; /* for each block do */ @@ -96,9 +100,11 @@ eBBPredecessors (eBBlock ** ebbs, int count) /*-----------------------------------------------------------------*/ /* eBBSuccessors- find out the successors of all the nodes */ /*-----------------------------------------------------------------*/ -void -eBBSuccessors (eBBlock ** ebbs, int count) +static void +eBBSuccessors (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; int i = 0; /* for all the blocks do */ @@ -156,7 +162,7 @@ eBBSuccessors (eBBlock ** ebbs, int count) for (lbl = setFirstItem (IC_JTLABELS (ic)); lbl; lbl = setNextItem (IC_JTLABELS (ic))) addSuccessor (ebbs[i], - eBBWithEntryLabel (ebbs, lbl, count)); + eBBWithEntryLabel (ebbi, lbl)); } else { @@ -166,19 +172,19 @@ eBBSuccessors (eBBlock ** ebbs, int count) switch (ic->op) { case GOTO: /* goto has edge to label */ - succ = eBBWithEntryLabel (ebbs, ic->label, count); + succ = eBBWithEntryLabel (ebbi, ic->label); break; case IFX: /* conditional jump */ /* if true label is present */ if (IC_TRUE (ic)) - succ = eBBWithEntryLabel (ebbs, IC_TRUE (ic), count); + succ = eBBWithEntryLabel (ebbi, IC_TRUE (ic)); else - succ = eBBWithEntryLabel (ebbs, IC_FALSE (ic), count); + succ = eBBWithEntryLabel (ebbi, IC_FALSE (ic)); break; case RETURN: /* block with return */ - succ = eBBWithEntryLabel (ebbs, returnLabel, count); + succ = eBBWithEntryLabel (ebbi, returnLabel); break; } @@ -195,9 +201,11 @@ eBBSuccessors (eBBlock ** ebbs, int count) /* computeDominance - computes the dominance graph */ /* for algorithm look at Dragon book section 10.10, algo 10.16 */ /*-----------------------------------------------------------------*/ -void -computeDominance (eBBlock ** ebbs, int count) +static void +computeDominance (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; int i, j; /* now do the initialisation */ @@ -259,16 +267,17 @@ computeDominance (eBBlock ** ebbs, int count) if (!change) break; } + } /*-----------------------------------------------------------------*/ /* immedDom - returns the immediate dominator of a block */ /*-----------------------------------------------------------------*/ eBBlock * -immedDom (eBBlock ** ebbs, eBBlock * ebp) +immedDom (ebbIndex * ebbi, eBBlock * ebp) { /* first delete self from the list */ - set *iset = domSetFromVect (ebbs, ebp->domVect); + set *iset = domSetFromVect (ebbi, ebp->domVect); eBBlock *loop; eBBlock *idom = NULL; @@ -306,7 +315,7 @@ DEFSETFUNC (DFOrdering) /* computeDFOrdering - computes the depth first ordering of the */ /* flowgraph */ /*-----------------------------------------------------------------*/ -void +static void computeDFOrdering (eBBlock * ebbp, int *count) { @@ -323,22 +332,23 @@ computeDFOrdering (eBBlock * ebbp, int *count) /* disconBBlock - removes all control flow links for a block */ /*-----------------------------------------------------------------*/ void -disconBBlock (eBBlock * ebp, eBBlock ** ebbs, int count) +disconBBlock (eBBlock * ebp, ebbIndex * ebbi) { /* mark this block as noPath & recompute control flow */ ebp->noPath = 1; - computeControlFlow (ebbs, count, TRUE); + computeControlFlow (ebbi); } /*-----------------------------------------------------------------*/ /* markNoPath - marks those blocks which cannot be reached from top */ /*-----------------------------------------------------------------*/ -void -markNoPath (eBBlock ** ebbs, int count) +static void +markNoPath (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; int i; - /* for all blocks if the visited flag is not set : then there */ /* is no path from _entry to this block push them down in the */ /* depth first order */ @@ -346,55 +356,20 @@ markNoPath (eBBlock ** ebbs, int count) if (!ebbs[i]->visited) ebbs[i]->noPath = 1; } -/*-----------------------------------------------------------------*/ -/* dfNumCompare - used by qsort to sort by dfNumber */ -/*-----------------------------------------------------------------*/ -int -dfNumCompare (const void *a, const void *b) -{ - const eBBlock *const *i = a; - const eBBlock *const *j = b; - - if ((*i)->dfnum > (*j)->dfnum) - return 1; - - if ((*i)->dfnum < (*j)->dfnum) - return -1; - - return 0; -} - -/*-----------------------------------------------------------------*/ -/* bbNumCompare - used by qsort to sort by bbNumber */ -/*-----------------------------------------------------------------*/ -int -bbNumCompare (const void *a, const void *b) -{ - const eBBlock *const *i = a; - const eBBlock *const *j = b; - - if ((*i)->bbnum > (*j)->bbnum) - return 1; - - if ((*i)->bbnum < (*j)->bbnum) - return -1; - - return 0; -} - /*-----------------------------------------------------------------*/ /* computeControlFlow - does the control flow computation */ /*-----------------------------------------------------------------*/ void -computeControlFlow (eBBlock ** ebbs, int count, int reSort) +computeControlFlow (ebbIndex * ebbi) { - int saveCount = count; + eBBlock ** ebbs = ebbi->bbOrder; + int dfCount = ebbi->count; int i; /* initialise some things */ - for (i = 0; i < count; i++) + for (i = 0; i < ebbi->count; i++) { setToNull ((void *) &ebbs[i]->predList); setToNull ((void *) &ebbs[i]->domVect); @@ -404,30 +379,33 @@ computeControlFlow (eBBlock ** ebbs, int count, int reSort) ebbs[i]->dfnum = 0; } - if (reSort) - /* sort it back by block number */ - qsort (ebbs, saveCount, sizeof (eBBlock *), bbNumCompare); - setToNull ((void *) &graphEdges); /* this will put in the */ /* successor information for each blk */ - eBBSuccessors (ebbs, count); + eBBSuccessors (ebbi); /* compute the depth first ordering */ - computeDFOrdering (ebbs[0], &count); + computeDFOrdering (ebbi->bbOrder[0], &dfCount); /* mark blocks with no paths to them */ - markNoPath (ebbs, saveCount); + markNoPath (ebbi); /* with the depth first info in place */ /* add the predecessors for the blocks */ - eBBPredecessors (ebbs, saveCount); + eBBPredecessors (ebbi); /* compute the dominance graph */ - computeDominance (ebbs, saveCount); + computeDominance (ebbi); /* sort it by dfnumber */ - qsort (ebbs, saveCount, sizeof (eBBlock *), dfNumCompare); + if (!ebbi->dfOrder) + ebbi->dfOrder = Safe_alloc ((ebbi->count+1) * sizeof (eBBlock *)); + for (i = 0; i < (ebbi->count+1); i++) + { + ebbi->dfOrder[i] = ebbi->bbOrder[i]; + } + + qsort (ebbi->dfOrder, ebbi->count, sizeof (eBBlock *), dfNumCompare); } diff --git a/src/SDCCcflow.h b/src/SDCCcflow.h index 4d6af9f5..ef0b3302 100644 --- a/src/SDCCcflow.h +++ b/src/SDCCcflow.h @@ -28,17 +28,8 @@ #ifndef SDCCCFLOW_H #define SDCCCFLOW_H 1 -void computeDFOrdering (eBBlock *, int *); -set *domSetFromVect (eBBlock **, bitVect *); -void addSuccessor (eBBlock *, eBBlock *); -void eBBSuccessors (eBBlock **, int); -void eBBPredecessors (eBBlock **, int); -eBBlock *immedDom (eBBlock **, eBBlock *); -DEFSETFUNC (DFOrdering); -void markNoPath (eBBlock **, int); -void computeControlFlow (eBBlock **, int, int); -int dfNumCompare (const void *, const void *); -int bbNumCompare (const void *, const void *); -void disconBBlock (eBBlock *, eBBlock **, int); +eBBlock *immedDom (ebbIndex *, eBBlock *); +void computeControlFlow (ebbIndex *); +void disconBBlock (eBBlock *, ebbIndex *); int returnAtEnd (eBBlock *) ; #endif diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 05c6e2e6..ad94b3a5 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -1393,7 +1393,7 @@ void ifxOptimize (iCode * ic, set * cseSet, int computeOnly, eBBlock * ebb, int *change, - eBBlock ** ebbs, int count) + ebbIndex * ebbi) { operand *pdop; symbol *label; @@ -1445,7 +1445,7 @@ ifxOptimize (iCode * ic, set * cseSet, /* this is very expensive but it does not happen */ /* too often, if it does happen then the user pays */ /* the price */ - computeControlFlow (ebbs, count, 1); + computeControlFlow (ebbi); if (!options.lessPedantic) { werrorfl (ic->filename, ic->lineno, W_CONTROL_FLOW); } @@ -1457,7 +1457,7 @@ ifxOptimize (iCode * ic, set * cseSet, we can remove this conditional statement */ label = (IC_TRUE (ic) ? IC_TRUE (ic) : IC_FALSE (ic)); if (elementsInSet (ebb->succList) == 1 && - isinSet (ebb->succList, eBBWithEntryLabel (ebbs, label, count))) + isinSet (ebb->succList, eBBWithEntryLabel (ebbi, label))) { if (!options.lessPedantic) { @@ -1473,7 +1473,7 @@ ifxOptimize (iCode * ic, set * cseSet, else { remiCodeFromeBBlock (ebb, ic); - computeControlFlow (ebbs, count, 1); + computeControlFlow (ebbi); return; } } @@ -1768,8 +1768,10 @@ dumpCseSet(set *cseSet) /*-----------------------------------------------------------------*/ int cseBBlock (eBBlock * ebb, int computeOnly, - eBBlock ** ebbs, int count) + ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; set *cseSet; iCode *ic; int change = 0; @@ -1957,7 +1959,7 @@ cseBBlock (eBBlock * ebb, int computeOnly, { ifxOptimize (ic, cseSet, computeOnly, ebb, &change, - ebbs, count); + ebbi); continue; } @@ -2225,15 +2227,17 @@ cseBBlock (eBBlock * ebb, int computeOnly, /* cseAllBlocks - will sequentially go thru & do cse for all blocks */ /*-----------------------------------------------------------------*/ int -cseAllBlocks (eBBlock ** ebbs, int count, int computeOnly) +cseAllBlocks (ebbIndex * ebbi, int computeOnly) { + eBBlock ** ebbs = ebbi->dfOrder; + int count = ebbi->count; int i; int change = 0; /* if optimization turned off */ for (i = 0; i < count; i++) - change += cseBBlock (ebbs[i], computeOnly, ebbs, count); + change += cseBBlock (ebbs[i], computeOnly, ebbi); return change; } diff --git a/src/SDCCcse.h b/src/SDCCcse.h index 0e7c9c8a..1926dd84 100644 --- a/src/SDCCcse.h +++ b/src/SDCCcse.h @@ -52,9 +52,8 @@ int ifDefSymIs (set *, operand *); DEFSETFUNC (findPrevIc); DEFSETFUNC (ifOperandsHave); DEFSETFUNC (findCheaperOp); -int cseBBlock (eBBlock *, int, eBBlock **, int); -int cseAllBlocks (eBBlock **, int, int computeOnly); -void ifxOptimize (iCode *, set *, int, eBBlock *, int *, eBBlock **, int); +int cseBBlock (eBBlock *, int, ebbIndex *); +int cseAllBlocks (ebbIndex *, int computeOnly); void unsetDefsAndUses (iCode *); void updateSpillLocation (iCode * ic,int); void setUsesDefs (operand *, bitVect *, bitVect *, bitVect **); diff --git a/src/SDCCdflow.c b/src/SDCCdflow.c index 8fa4f0c1..a45eb174 100644 --- a/src/SDCCdflow.c +++ b/src/SDCCdflow.c @@ -123,6 +123,9 @@ DEFSETFUNC (mergeInExprs) } else { + //if (dest != ebp) + // dest->inExprs = intersectSets (dest->inExprs, ebp->outExprs, THROW_DEST); + /* delete only if killed in this block*/ deleteItemIf (&dest->inExprs, ifKilledInBlock, ebp); /* union the ndompset with pointers set in this block */ @@ -162,8 +165,10 @@ DEFSETFUNC (mergeInDefs) /* computeDataFlow - does computations for data flow accross blocks */ /*-----------------------------------------------------------------*/ void -computeDataFlow (eBBlock ** ebbs, int count) +computeDataFlow (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->dfOrder; + int count = ebbi->count; int i; int change = 1; @@ -222,7 +227,7 @@ computeDataFlow (eBBlock ** ebbs, int count) /* get the immediate dominator and put it there */ if (!pBlock) { - eBBlock *idom = immedDom (ebbs, ebbs[i]); + eBBlock *idom = immedDom (ebbi, ebbs[i]); if (idom) addSetHead (&pred, idom); } @@ -239,7 +244,7 @@ computeDataFlow (eBBlock ** ebbs, int count) /* do cse with computeOnly flag set to TRUE */ /* this by far the quickest way of computing */ - cseBBlock (ebbs[i], TRUE, ebbs, count); + cseBBlock (ebbs[i], TRUE, ebbi); /* if it change we will need to iterate */ if (optimize.global_cse) diff --git a/src/SDCCdflow.h b/src/SDCCdflow.h index 02fafaaf..6e484d45 100644 --- a/src/SDCCdflow.h +++ b/src/SDCCdflow.h @@ -31,7 +31,7 @@ DEFSETFUNC (mergeInExprs); DEFSETFUNC (ifKilledInBlock); -void computeDataFlow (eBBlock **, int); +void computeDataFlow (ebbIndex *); DEFSETFUNC (mergeInDefs); DEFSETFUNC (isDefAlive); iCode *usedInRemaining (operand *, iCode *); diff --git a/src/SDCCloop.c b/src/SDCCloop.c index 476554a6..0ecfe944 100644 --- a/src/SDCCloop.c +++ b/src/SDCCloop.c @@ -302,11 +302,10 @@ DEFSETFUNC (addDefInExprs) { eBBlock *ebp = item; V_ARG (cseDef *, cdp); - V_ARG (eBBlock **, ebbs); - V_ARG (int, count); + V_ARG (ebbIndex *, ebbi); addSetHead (&ebp->inExprs, cdp); - cseBBlock (ebp, optimize.global_cse, ebbs, count); + cseBBlock (ebp, optimize.global_cse, ebbi); return 0; } @@ -417,8 +416,10 @@ DEFSETFUNC (hasNonPtrUse) /* loopInvariants - takes loop invariants out of region */ /*-----------------------------------------------------------------*/ int -loopInvariants (region * theLoop, eBBlock ** ebbs, int count) +loopInvariants (region * theLoop, ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->dfOrder; + int count = ebbi->count; eBBlock *lBlock; set *lInvars = NULL; @@ -616,7 +617,7 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count) bitVectUnSetBit (lBlock->defSet, ic->key); bitVectUnSetBit (lBlock->ldefs, ic->key); ivar = newCseDef (IC_RESULT (ic), ic); - applyToSet (theLoop->regBlocks, addDefInExprs, ivar, ebbs, count); + applyToSet (theLoop->regBlocks, addDefInExprs, ivar, ebbi); addSet (&lInvars, ivar); } } @@ -984,8 +985,10 @@ basicInduction (region * loopReg, eBBlock ** ebbs, int count) /* loopInduction - remove induction variables from a loop */ /*-----------------------------------------------------------------*/ int -loopInduction (region * loopReg, eBBlock ** ebbs, int count) +loopInduction (region * loopReg, ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->dfOrder; + int count = ebbi->count; int change = 0; eBBlock *lBlock, *owner, *lastBlock = NULL; set *indVars = NULL; @@ -1231,7 +1234,7 @@ DEFSETFUNC (mergeInnerLoops) /* createLoopRegions - will detect and create a set of natural loops */ /*-----------------------------------------------------------------*/ hTab * -createLoopRegions (eBBlock ** ebbs, int count) +createLoopRegions (ebbIndex * ebbi) { set *allRegion = NULL; /* set of all loops */ hTab *orderedLoops = NULL; @@ -1279,7 +1282,7 @@ createLoopRegions (eBBlock ** ebbs, int count) /* loopOptimizations - identify region & remove invariants & ind */ /*-----------------------------------------------------------------*/ int -loopOptimizations (hTab * orderedLoops, eBBlock ** ebbs, int count) +loopOptimizations (hTab * orderedLoops, ebbIndex * ebbi) { region *lp; int change = 0; @@ -1299,10 +1302,10 @@ loopOptimizations (hTab * orderedLoops, eBBlock ** ebbs, int count) { if (optimize.loopInvariant) - change += loopInvariants (lp, ebbs, count); + change += loopInvariants (lp, ebbi); if (optimize.loopInduction) - change += loopInduction (lp, ebbs, count); + change += loopInduction (lp, ebbi); } return change; diff --git a/src/SDCCloop.h b/src/SDCCloop.h index 65f35731..e2393370 100644 --- a/src/SDCCloop.h +++ b/src/SDCCloop.h @@ -54,12 +54,11 @@ induction; DEFSETFUNC (backEdges); DEFSETFUNC (pregion); DEFSETFUNC (pinduction); -int loopOptimizations (hTab *, eBBlock **, int); +int loopOptimizations (hTab *, ebbIndex *); int addressTaken (set *, operand *); -hTab *createLoopRegions (eBBlock **, int); +hTab *createLoopRegions (ebbIndex *); iCode *findDefInRegion (set *, operand *, eBBlock **); int hasIncomingDefs (region *, operand *); int findLoopEndSeq (region *); -void addLoopBlocks (eBBlock ** ebbs, int count); #endif diff --git a/src/SDCCopt.c b/src/SDCCopt.c index ed0ef8a7..b837e935 100644 --- a/src/SDCCopt.c +++ b/src/SDCCopt.c @@ -645,15 +645,17 @@ isLocalWithoutDef (symbol * sym) /* replaceRegEqv - replace all local variables with their reqv */ /*-----------------------------------------------------------------*/ static void -replaceRegEqv (eBBlock ** ebbs, int count) +replaceRegEqv (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; int i; /* Update the symbols' def bitvector so we know if there is */ /* a defining iCode or not. Only replace a local variable */ /* with its register equivalent if there is a defining iCode; */ /* otherwise, the port's register allocater may choke. */ - cseAllBlocks (ebbs, count, TRUE); + cseAllBlocks (ebbi, TRUE); for (i = 0; i < count; i++) { @@ -828,8 +830,10 @@ findReqv (symbol * prereqv, eBBlock ** ebbs, int count) /* killDeadCode - eliminates dead assignments */ /*-----------------------------------------------------------------*/ int -killDeadCode (eBBlock ** ebbs, int count) +killDeadCode (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->dfOrder; + int count = ebbi->count; int change = 1; int gchange = 0; int i = 0; @@ -936,6 +940,11 @@ killDeadCode (eBBlock ** ebbs, int count) /* a dead address-of operation should die, even if volatile */ if (ic->op == ADDRESS_OF) volLeft = FALSE; + + //if (ic->op == CAST && isOperandVolatile (IC_LEFT (ic), FALSE)) + // { + // volRight = IS_SYMOP (IC_RIGHT (ic)); + // } if (ic->next && ic->seqPoint == ic->next->seqPoint && (ic->next->op == '+' || ic->next->op == '-')) @@ -957,7 +966,7 @@ killDeadCode (eBBlock ** ebbs, int count) } continue; } - + change = 1; gchange++; @@ -1023,7 +1032,7 @@ killDeadCode (eBBlock ** ebbs, int count) } /* end of all instructions */ if (!ebbs[i]->sch && !ebbs[i]->noPath) - disconBBlock (ebbs[i], ebbs, count); + disconBBlock (ebbs[i], ebbi); } /* end of for all blocks */ @@ -1160,9 +1169,10 @@ optimizeCastCast (eBBlock ** ebbs, int count) eBBlock ** eBBlockFromiCode (iCode * ic) { - eBBlock **ebbs = NULL; - int count = 0; - int saveCount = 0; + ebbIndex *ebbi = NULL; + //eBBlock **ebbs = NULL; + //int count = 0; + //int saveCount = 0; int change = 1; int lchange = 0; int kchange = 0; @@ -1172,7 +1182,7 @@ eBBlockFromiCode (iCode * ic) if (!ic) return NULL; - count = 0; + //count = 0; eBBNum = 0; /* optimize the chain for labels & gotos @@ -1181,73 +1191,72 @@ eBBlockFromiCode (iCode * ic) ic = iCodeLabelOptimize (ic); /* break it down into basic blocks */ - ebbs = iCodeBreakDown (ic, &count); - saveCount = count; - + ebbi = iCodeBreakDown (ic); + /* hash the iCode keys so that we can quickly index */ /* them in the rest of the optimization steps */ setToNull ((void *) &iCodehTab); iCodehTab = newHashTable (iCodeKey); - hashiCodeKeys (ebbs, count); + hashiCodeKeys (ebbi->bbOrder, ebbi->count); /* compute the control flow */ - computeControlFlow (ebbs, count, 0); + computeControlFlow (ebbi); /* dumpraw if asked for */ if (options.dump_raw) - dumpEbbsToFileExt (DUMP_RAW0, ebbs, count); + dumpEbbsToFileExt (DUMP_RAW0, ebbi); /* replace the local variables with their register equivalents : the liveRange computation along with the register allocation will determine if it finally stays in the registers */ - replaceRegEqv (ebbs, count); + replaceRegEqv (ebbi); /* create loop regions */ - loops = createLoopRegions (ebbs, count); + loops = createLoopRegions (ebbi); /* dumpraw if asked for */ if (options.dump_raw) - dumpEbbsToFileExt (DUMP_RAW1, ebbs, count); + dumpEbbsToFileExt (DUMP_RAW1, ebbi); - optimizeCastCast (ebbs, saveCount); + optimizeCastCast (ebbi->bbOrder, ebbi->count); /* do common subexpression elimination for each block */ - change = cseAllBlocks (ebbs, saveCount, FALSE); + change = cseAllBlocks (ebbi, FALSE); /* dumpraw if asked for */ if (options.dump_raw) - dumpEbbsToFileExt (DUMP_CSE, ebbs, count); + dumpEbbsToFileExt (DUMP_CSE, ebbi); /* compute the data flow */ - computeDataFlow (ebbs, saveCount); + computeDataFlow (ebbi); /* dumpraw if asked for */ if (options.dump_raw) - dumpEbbsToFileExt (DUMP_DFLOW, ebbs, count); + dumpEbbsToFileExt (DUMP_DFLOW, ebbi); /* global common subexpression elimination */ if (optimize.global_cse) { - change += cseAllBlocks (ebbs, saveCount, FALSE); + change += cseAllBlocks (ebbi, FALSE); if (options.dump_gcse) - dumpEbbsToFileExt (DUMP_GCSE, ebbs, saveCount); + dumpEbbsToFileExt (DUMP_GCSE, ebbi); } else { // compute the dataflow only - assert(cseAllBlocks (ebbs, saveCount, TRUE)==0); + assert(cseAllBlocks (ebbi, TRUE)==0); } /* kill dead code */ - kchange = killDeadCode (ebbs, saveCount); + kchange = killDeadCode (ebbi); if (options.dump_kill) - dumpEbbsToFileExt (DUMP_DEADCODE, ebbs, count); + dumpEbbsToFileExt (DUMP_DEADCODE, ebbi); /* do loop optimizations */ - change += (lchange = loopOptimizations (loops, ebbs, count)); + change += (lchange = loopOptimizations (loops, ebbi)); if (options.dump_loop) - dumpEbbsToFileExt (DUMP_LOOP, ebbs, count); + dumpEbbsToFileExt (DUMP_LOOP, ebbi); /* recompute the data flow and apply global cse again if loops optimizations or dead code caused a change: @@ -1258,24 +1267,24 @@ eBBlockFromiCode (iCode * ic) subexpression once more */ if (lchange || kchange) { - computeDataFlow (ebbs, saveCount); - change += cseAllBlocks (ebbs, saveCount, FALSE); + computeDataFlow (ebbi); + change += cseAllBlocks (ebbi, FALSE); if (options.dump_loop) - dumpEbbsToFileExt (DUMP_LOOPG, ebbs, count); + dumpEbbsToFileExt (DUMP_LOOPG, ebbi); /* if loop optimizations caused a change then do dead code elimination once more : this will get rid of the extra assignments to the induction variables created during loop optimizations */ - killDeadCode (ebbs, saveCount); + killDeadCode (ebbi); if (options.dump_loop) - dumpEbbsToFileExt (DUMP_LOOPD, ebbs, count); + dumpEbbsToFileExt (DUMP_LOOPD, ebbi); } /* sort it back by block number */ - qsort (ebbs, saveCount, sizeof (eBBlock *), bbNumCompare); + //qsort (ebbs, saveCount, sizeof (eBBlock *), bbNumCompare); if (!options.lessPedantic) { // this is a good place to check missing return values @@ -1285,9 +1294,9 @@ eBBlockFromiCode (iCode * ic) && !FUNC_ISNAKED(currFunc->type)) { eBBlock *bp; // make sure all predecessors of the last block end in a return - for (bp=setFirstItem(ebbs[saveCount-1]->predList); + for (bp=setFirstItem(ebbi->bbOrder[ebbi->count-1]->predList); bp; - bp=setNextItem(ebbs[saveCount-1]->predList)) { + bp=setNextItem(ebbi->bbOrder[ebbi->count-1]->predList)) { if (bp->ech->op != RETURN) { werrorfl (bp->ech->filename, bp->ech->lineno, W_VOID_FUNC, currFunc->name); @@ -1299,31 +1308,30 @@ eBBlockFromiCode (iCode * ic) /* if cyclomatic info requested then print it */ if (options.cyclomatic) - printCyclomatic (ebbs, saveCount); + printCyclomatic (ebbi->bbOrder, ebbi->count); /* convert operations with support routines written in C to function calls : Iam doing this at this point since I want all the operations to be as they are for optimzations */ - convertToFcall (ebbs, count); + convertToFcall (ebbi->bbOrder, ebbi->count); /* compute the live ranges */ - computeLiveRanges (ebbs, count); + computeLiveRanges (ebbi->bbOrder, ebbi->count); if (options.dump_range) - dumpEbbsToFileExt (DUMP_RANGE, ebbs, count); + dumpEbbsToFileExt (DUMP_RANGE, ebbi); /* Now that we have the live ranges, discard parameter * receives for unused parameters. */ - discardDeadParamReceives (ebbs, count); + discardDeadParamReceives (ebbi->bbOrder, ebbi->count); /* allocate registers & generate code */ - port->assignRegisters (ebbs, count); + port->assignRegisters (ebbi); /* throw away blocks */ setToNull ((void *) &graphEdges); - ebbs = NULL; return NULL; } diff --git a/src/avr/main.c b/src/avr/main.c index c5ff3622..5c499e9e 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -69,7 +69,7 @@ _avr_regparm (sym_link * l) return 0; } -void avr_assignRegisters (eBBlock ** ebbs, int count); +void avr_assignRegisters (ebbIndex *); static bool _avr_parseOptions (int *pargc, char **argv, int *i) diff --git a/src/avr/ralloc.c b/src/avr/ralloc.c index 96426bb4..9f0ab65b 100644 --- a/src/avr/ralloc.c +++ b/src/avr/ralloc.c @@ -2236,8 +2236,10 @@ setDefaultRegs (eBBlock ** ebbs, int count) /* assignRegisters - assigns registers to each live range as need */ /*-----------------------------------------------------------------*/ void -avr_assignRegisters (eBBlock ** ebbs, int count) +avr_assignRegisters (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; iCode *ic; int i; @@ -2254,7 +2256,7 @@ avr_assignRegisters (eBBlock ** ebbs, int count) recomputeLiveRanges (ebbs, count); if (options.dump_pack) - dumpEbbsToFileExt (DUMP_PACK, ebbs, count); + dumpEbbsToFileExt (DUMP_PACK, ebbi); /* first determine for each live range the number of registers & the type of registers required for each */ @@ -2287,7 +2289,7 @@ avr_assignRegisters (eBBlock ** ebbs, int count) redoStackOffsets (); if (options.dump_rassgn) - dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count); + dumpEbbsToFileExt (DUMP_RASSGN, ebbi); /* now get back the chain */ ic = iCodeLabelOptimize (iCodeFromeBBlock (ebbs, count)); diff --git a/src/ds390/main.c b/src/ds390/main.c index 17b52ae0..9d41bf26 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -59,7 +59,7 @@ static builtins __ds390_builtins[] = { { "__builtin_memcmp_c2x","c",3,{"cx*","cp*","i"}}, /* void __builtin_memcmp_c2x (xdata char *,code char *,int) */ { NULL , NULL,0, {NULL}} /* mark end of table */ }; -void ds390_assignRegisters (eBBlock ** ebbs, int count); +void ds390_assignRegisters (ebbIndex * ebbi); static int regParmFlg = 0; /* determine if we can register a parameter */ diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index 627cc475..3e39ee75 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -3124,8 +3124,10 @@ packRegisters (eBBlock * ebp) /* assignRegisters - assigns registers to each live range as need */ /*-----------------------------------------------------------------*/ void -ds390_assignRegisters (eBBlock ** ebbs, int count) +ds390_assignRegisters (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; iCode *ic; int i; @@ -3146,7 +3148,7 @@ ds390_assignRegisters (eBBlock ** ebbs, int count) recomputeLiveRanges (ebbs, count); if (options.dump_pack) - dumpEbbsToFileExt (DUMP_PACK, ebbs, count); + dumpEbbsToFileExt (DUMP_PACK, ebbi); /* first determine for each live range the number of registers & the type of registers required for each */ @@ -3192,7 +3194,7 @@ ds390_assignRegisters (eBBlock ** ebbs, int count) } if (options.dump_rassgn) { - dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count); + dumpEbbsToFileExt (DUMP_RASSGN, ebbi); dumpLiveRanges (DUMP_LRANGE, liveRanges); } diff --git a/src/hc08/main.c b/src/hc08/main.c index 13a23d68..a4399cfc 100644 --- a/src/hc08/main.c +++ b/src/hc08/main.c @@ -51,7 +51,7 @@ static char *_hc08_keywords[] = }; -void hc08_assignRegisters (eBBlock ** ebbs, int count); +void hc08_assignRegisters (ebbIndex *); static int regParmFlg = 0; /* determine if we can register a parameter */ diff --git a/src/hc08/ralloc.c b/src/hc08/ralloc.c index 97a6cdaf..13a4e2fc 100644 --- a/src/hc08/ralloc.c +++ b/src/hc08/ralloc.c @@ -3055,8 +3055,10 @@ packRegisters (eBBlock ** ebpp, int blockno) /* assignRegisters - assigns registers to each live range as need */ /*-----------------------------------------------------------------*/ void -hc08_assignRegisters (eBBlock ** ebbs, int count) +hc08_assignRegisters (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; iCode *ic; int i; @@ -3083,7 +3085,7 @@ hc08_assignRegisters (eBBlock ** ebbs, int count) recomputeLiveRanges (ebbs, count); if (options.dump_pack) - dumpEbbsToFileExt (DUMP_PACK, ebbs, count); + dumpEbbsToFileExt (DUMP_PACK, ebbi); /* first determine for each live range the number of registers & the type of registers required for each */ @@ -3123,7 +3125,7 @@ hc08_assignRegisters (eBBlock ** ebbs, int count) if (options.dump_rassgn) { - dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count); + dumpEbbsToFileExt (DUMP_RASSGN, ebbi); dumpLiveRanges (DUMP_LRANGE, liveRanges); } diff --git a/src/mcs51/main.c b/src/mcs51/main.c index 6112bee3..0ea349c4 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -47,7 +47,7 @@ static char *_mcs51_keywords[] = -void mcs51_assignRegisters (eBBlock ** ebbs, int count); +void mcs51_assignRegisters (ebbIndex *); static int regParmFlg = 0; /* determine if we can register a parameter */ diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index f606f076..7d065b27 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -3132,8 +3132,10 @@ packRegisters (eBBlock ** ebpp, int blockno) /* assignRegisters - assigns registers to each live range as need */ /*-----------------------------------------------------------------*/ void -mcs51_assignRegisters (eBBlock ** ebbs, int count) +mcs51_assignRegisters (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; iCode *ic; int i; @@ -3154,7 +3156,7 @@ mcs51_assignRegisters (eBBlock ** ebbs, int count) recomputeLiveRanges (ebbs, count); if (options.dump_pack) - dumpEbbsToFileExt (DUMP_PACK, ebbs, count); + dumpEbbsToFileExt (DUMP_PACK, ebbi); /* first determine for each live range the number of registers & the type of registers required for each */ @@ -3202,7 +3204,7 @@ mcs51_assignRegisters (eBBlock ** ebbs, int count) if (options.dump_rassgn) { - dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count); + dumpEbbsToFileExt (DUMP_RASSGN, ebbi); dumpLiveRanges (DUMP_LRANGE, liveRanges); } diff --git a/src/pic/main.c b/src/pic/main.c index e8eaaacb..34784358 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -49,7 +49,7 @@ static char *_pic14_keywords[] = void pCodeInitRegisters(void); -void pic14_assignRegisters (eBBlock ** ebbs, int count); +void pic14_assignRegisters (ebbIndex *); /* Also defined in gen.h, but the #include is commented out */ /* for an unknowned reason. - EEP */ diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index d836a168..44b0c500 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -4126,8 +4126,10 @@ dumpEbbsToDebug (eBBlock ** ebbs, int count) /* assignRegisters - assigns registers to each live range as need */ /*-----------------------------------------------------------------*/ void -pic14_assignRegisters (eBBlock ** ebbs, int count) +pic14_assignRegisters (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; iCode *ic; int i; @@ -4160,7 +4162,7 @@ pic14_assignRegisters (eBBlock ** ebbs, int count) } if (options.dump_pack) - dumpEbbsToFileExt (DUMP_PACK, ebbs, count); + dumpEbbsToFileExt (DUMP_PACK, ebbi); /* first determine for each live range the number of registers & the type of registers required for each */ @@ -4192,7 +4194,7 @@ pic14_assignRegisters (eBBlock ** ebbs, int count) redoStackOffsets (); if (options.dump_rassgn) - dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count); + dumpEbbsToFileExt (DUMP_RASSGN, ebbi); /* now get back the chain */ ic = iCodeLabelOptimize (iCodeFromeBBlock (ebbs, count)); diff --git a/src/pic16/main.c b/src/pic16/main.c index 606eea41..53af64d4 100644 --- a/src/pic16/main.c +++ b/src/pic16/main.c @@ -80,7 +80,7 @@ extern char *pic16_processor_base_name(void); void pic16_pCodeInitRegisters(void); -void pic16_assignRegisters (eBBlock ** ebbs, int count); +void pic16_assignRegisters (ebbIndex *); static int regParmFlg = 0; /* determine if we can register a parameter */ diff --git a/src/pic16/ralloc.c b/src/pic16/ralloc.c index 1ffe9863..829ba99d 100644 --- a/src/pic16/ralloc.c +++ b/src/pic16/ralloc.c @@ -4263,8 +4263,10 @@ dumpEbbsToDebug (eBBlock ** ebbs, int count) /* pic16_assignRegisters - assigns registers to each live range as need */ /*-----------------------------------------------------------------*/ void -pic16_assignRegisters (eBBlock ** ebbs, int count) +pic16_assignRegisters (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; iCode *ic; int i; @@ -4304,7 +4306,7 @@ pic16_assignRegisters (eBBlock ** ebbs, int count) recomputeLiveRanges (ebbs, count); if (options.dump_pack) - dumpEbbsToFileExt (DUMP_PACK, ebbs, count); + dumpEbbsToFileExt (DUMP_PACK, ebbi); /* first determine for each live range the number of registers & the type of registers required for each */ @@ -4346,7 +4348,7 @@ pic16_assignRegisters (eBBlock ** ebbs, int count) redoStackOffsets (); if (options.dump_rassgn) - dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count); + dumpEbbsToFileExt (DUMP_RASSGN, ebbi); /* now get back the chain */ ic = iCodeLabelOptimize (iCodeFromeBBlock (ebbs, count)); diff --git a/src/port.h b/src/port.h index a93a2edb..06210e57 100644 --- a/src/port.h +++ b/src/port.h @@ -44,6 +44,8 @@ typedef struct builtins char *parm_types[MAX_BUILTIN_ARGS]; /* each parm type as string : see typeFromStr */ } builtins ; +struct ebbIndex; + /* Processor specific names */ typedef struct { @@ -246,7 +248,7 @@ typedef struct options are parsed. */ void (*setDefaultOptions) (void); /** Does the dirty work. */ - void (*assignRegisters) (struct eBBlock **, int); + void (*assignRegisters) (struct ebbIndex *); /** Returns the register name of a symbol. Used so that 'regs' can be an incomplete type. */ diff --git a/src/xa51/main.c b/src/xa51/main.c index 3c1d73fb..37bf599e 100755 --- a/src/xa51/main.c +++ b/src/xa51/main.c @@ -53,7 +53,7 @@ void _xa51_genAssemblerEnd (FILE * of) //rewinds==1 ? '\0' : 's'); } -void xa51_assignRegisters (eBBlock ** ebbs, int count); +void xa51_assignRegisters (ebbIndex *); static int regParmFlg = 0; /* determine if we can register a parameter */ diff --git a/src/xa51/ralloc.c b/src/xa51/ralloc.c index e53ea595..e9fc42f5 100755 --- a/src/xa51/ralloc.c +++ b/src/xa51/ralloc.c @@ -2059,8 +2059,10 @@ static void packRegisters (eBBlock * ebp) { /* assignRegisters - assigns registers to each live range as need */ /*-----------------------------------------------------------------*/ void -xa51_assignRegisters (eBBlock ** ebbs, int count) +xa51_assignRegisters (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; iCode *ic; int i; @@ -2078,7 +2080,7 @@ xa51_assignRegisters (eBBlock ** ebbs, int count) recomputeLiveRanges (ebbs, count); if (options.dump_pack) - dumpEbbsToFileExt (DUMP_PACK, ebbs, count); + dumpEbbsToFileExt (DUMP_PACK, ebbi); /* first determine for each live range the number of registers & the type of registers required for each */ @@ -2106,7 +2108,7 @@ xa51_assignRegisters (eBBlock ** ebbs, int count) if (options.dump_rassgn) { - dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count); + dumpEbbsToFileExt (DUMP_RASSGN, ebbi); dumpLiveRanges (DUMP_LRANGE, liveRanges); } diff --git a/src/z80/ralloc.c b/src/z80/ralloc.c index 2b44c0e0..ca66aa9a 100644 --- a/src/z80/ralloc.c +++ b/src/z80/ralloc.c @@ -3101,8 +3101,10 @@ joinPushes (iCode *lic) /* assignRegisters - assigns registers to each live range as need */ /*-----------------------------------------------------------------*/ void -z80_assignRegisters (eBBlock ** ebbs, int count) +z80_assignRegisters (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; iCode *ic; int i; @@ -3134,7 +3136,7 @@ z80_assignRegisters (eBBlock ** ebbs, int count) recomputeLiveRanges (ebbs, count); if (options.dump_pack) - dumpEbbsToFileExt (DUMP_PACK, ebbs, count); + dumpEbbsToFileExt (DUMP_PACK, ebbi); /* first determine for each live range the number of registers & the type of registers required for each */ @@ -3162,7 +3164,7 @@ z80_assignRegisters (eBBlock ** ebbs, int count) } if (options.dump_rassgn) { - dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count); + dumpEbbsToFileExt (DUMP_RASSGN, ebbi); dumpLiveRanges (DUMP_LRANGE, liveRanges); } diff --git a/src/z80/ralloc.h b/src/z80/ralloc.h index fb93bdc9..b0714af9 100644 --- a/src/z80/ralloc.h +++ b/src/z80/ralloc.h @@ -74,7 +74,7 @@ extern regs *regsZ80; void assignRegisters (eBBlock **, int); regs *regWithIdx (int); -void z80_assignRegisters (eBBlock ** ebbs, int count); +void z80_assignRegisters (ebbIndex *); bitVect *z80_rUmaskForOp (operand * op); #endif -- 2.30.2