-------------------------------------------------------------------------*/
#include "common.h"
-#include "newalloc.h"
int eBBNum = 0;
set *graphEdges = NULL; /* list of edges in this flow graph */
{
eBBlock *ebb;
- ebb = Safe_calloc (1, sizeof (eBBlock));
+ ebb = Safe_alloc (sizeof (eBBlock));
return ebb;
}
{
edge *ep;
- ep = Safe_calloc (1, sizeof (edge));
+ ep = Safe_alloc (sizeof (edge));
ep->from = from;
ep->to = to;
}
/*-----------------------------------------------------------------*/
-/* appendDumpFile - if not already created, create the dump file */
+/* createDumpFile - create the dump file */
/*-----------------------------------------------------------------*/
-FILE *appendDumpFile (int id) {
+FILE *createDumpFile (int id) {
struct _dumpFiles *dumpFilesPtr=dumpFiles;
while (dumpFilesPtr->id) {
}
if (!dumpFilesPtr->id) {
- fprintf (stdout, "internal error: appendDumpFile: unknown dump file.\n");
+ fprintf (stdout, "internal error: createDumpFile: unknown dump file.\n");
exit (1);
}
if (!dumpFilesPtr->filePtr) {
// not used before, create it
- strcpy (scratchFileName, srcFileName);
- strcat (scratchFileName, dumpFilesPtr->ext);
+ strncpyz (scratchFileName, dstFileName, PATH_MAX);
+ strncatz (scratchFileName, dumpFilesPtr->ext, PATH_MAX);
if (!(dumpFilesPtr->filePtr = fopen (scratchFileName, "w"))) {
werror (E_FILE_OPEN_ERR, scratchFileName);
exit (1);
for (dumpFilesPtr=dumpFiles; dumpFilesPtr->id; dumpFilesPtr++) {
if (dumpFilesPtr->filePtr) {
fclose (dumpFilesPtr->filePtr);
- //dprintf ("closed %s\n", dumpFilesPtr->ext);
}
}
}
int k;
if (id) {
- file=appendDumpFile(id);
+ file=createDumpFile(id);
} else {
file = stdout;
}
-
+
+ if (currFunc)
+ fprintf(file,"------------- Func %s -------------\n",currFunc->name);
for (sym = hTabFirstItem (liveRanges, &k); sym;
sym = hTabNextItem (liveRanges, &k))
{
{
fprintf (file, "}{ sir@ %s", sym->usl.spillLoc->rname);
}
- fprintf (file, "}");
-
- /* if assigned to registers */
- if (sym->nRegs)
- {
- if (sym->isspilt)
- {
- if (!sym->remat)
- if (sym->usl.spillLoc)
- fprintf (file, "[%s]", (sym->usl.spillLoc->rname[0] ?
- sym->usl.spillLoc->rname :
- sym->usl.spillLoc->name));
- else
- fprintf (file, "[err]");
- else
- fprintf (file, "[remat]");
- }
- else
- {
- int i;
- fprintf (file, "[");
- for (i = 0; i < sym->nRegs; i++)
- fprintf (file, "%s ", port->getRegName (sym->regs[i]));
- fprintf (file, "]");
- }
- }
+ fprintf (file, "} clashes with ");
+ bitVectDebugOn(sym->clashes,file);
fprintf (file, "\n");
}
{
FILE *of;
int i;
+ eBBlock *bb;
if (id) {
- of=appendDumpFile(id);
+ of=createDumpFile(id);
} else {
of = stdout;
}
for (i = 0; i < count; i++)
{
fprintf (of, "\n----------------------------------------------------------------\n");
- fprintf (of, "Basic Block %s : loop Depth = %d noPath = %d , lastinLoop = %d\n",
+ fprintf (of, "Basic Block %s (df:%d bb:%d lvl:%d): loop Depth = %d noPath = %d lastinLoop = %d\n",
ebbs[i]->entryLabel->name,
+ ebbs[i]->dfnum, ebbs[i]->bbnum, ebbs[i]->entryLabel->level,
ebbs[i]->depth,
ebbs[i]->noPath,
ebbs[i]->isLastInLoop);
+
+ // a --nolabelopt makes this more readable
+ fprintf (of, "\nsuccessors: ");
+ for (bb=setFirstItem(ebbs[i]->succList);
+ bb;
+ bb=setNextItem(ebbs[i]->succList)) {
+ fprintf (of, "%s ", bb->entryLabel->name);
+ }
+ fprintf (of, "\npredecessors: ");
+ for (bb=setFirstItem(ebbs[i]->predList);
+ bb;
+ bb=setNextItem(ebbs[i]->predList)) {
+ fprintf (of, "%s ", bb->entryLabel->name);
+ }
+ {
+ int d;
+ fprintf (of, "\ndominators: ");
+ for (d=0; d<ebbs[i]->domVect->size; d++) {
+ if (bitVectBitValue(ebbs[i]->domVect, d)) {
+ fprintf (of, "%s ", ebbs[d]->entryLabel->name);
+ }
+ }
+ }
+ fprintf (of, "\n");
+
fprintf (of, "\ndefines bitVector :");
bitVectDebugOn (ebbs[i]->defSet, of);
fprintf (of, "\nlocal defines bitVector :");
bitVectDebugOn (ebbs[i]->ldefs, of);
fprintf (of, "\npointers Set bitvector :");
bitVectDebugOn (ebbs[i]->ptrsSet, of);
+ if (ebbs[i]->isLastInLoop) {
+ fprintf (of, "\nInductions Set bitvector :");
+ bitVectDebugOn (ebbs[i]->linds, of);
+ }
fprintf (of, "\n----------------------------------------------------------------\n");
printiCChain (ebbs[i]->sch, of);
}
iCode2eBBlock (iCode * ic)
{
iCode *loop;
- eBBlock *ebb = neweBBlock (); /* a llocate an entry */
+ eBBlock *ebb = neweBBlock (); /* allocate an entry */
/* put the first one unconditionally */
ebb->sch = ic;
/* if this is a label then */
if (ic->op == LABEL)
- ebb->entryLabel = ic->argLabel.label;
+ ebb->entryLabel = ic->label;
else
{
- sprintf (buffer, "_eBBlock%d", eBBNum++);
+ SNPRINTF (buffer, sizeof(buffer), "_eBBlock%d", eBBNum++);
ebb->entryLabel = newSymbol (buffer, 1);
ebb->entryLabel->key = labelKey++;
}
{
ebb->hasFcall = 1;
if (currFunc)
- currFunc->hasFcall = 1;
+ FUNC_HASFCALL(currFunc->type) = 1;
}
/* if the next one is a label */
void
remiCodeFromeBBlock (eBBlock * ebb, iCode * ic)
{
+ wassert (ic->seq>=ebb->fSeq && ic->seq<=ebb->lSeq);
if (ic->prev)
ic->prev->next = ic->next;
else
/* allocate for the first entry */
- ebbs = Safe_calloc (1, sizeof (eBBlock **));
+ ebbs = Safe_alloc (sizeof (eBBlock **));
while (loop)
{
{
bitVectUnSetBit (OP_USES (IC_COND (ic)), ic->key);
IC_COND (ic) = operandFromOperand (dest);
- OP_USES (dest) = bitVectSetBit (OP_USES (dest), ic->key);
+ OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key);
continue;
}
bitVectUnSetBit (OP_USES (IC_RIGHT (ic)), ic->key);
IC_RIGHT (ic) = operandFromOperand (dest);
IC_RIGHT (ic)->isaddr = 0;
- OP_USES (dest) = bitVectSetBit (OP_USES (dest), ic->key);
+ OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key);
}
if (isOperandEqual (IC_LEFT (ic), src))
IC_LEFT (ic) = operandFromOperand (dest);
IC_LEFT (ic)->isaddr = 0;
}
- OP_USES (dest) = bitVectSetBit (OP_USES (dest), ic->key);
+ OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key);
}
/* special case for pointer sets */
bitVectUnSetBit (OP_USES (IC_RESULT (ic)), ic->key);
IC_RESULT (ic) = operandFromOperand (dest);
IC_RESULT (ic)->isaddr = 1;
- OP_USES (dest) = bitVectSetBit (OP_USES (dest), ic->key);
+ OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key);
}
}
}