2008-02-13 Borut Razem <borut.razem AT siol.net>
* src/SDCCmain.c, src/SDCCglue.c: fixed --c1mode
+ * src/pic16/glue.c, src/SDCCast.c, src/SDCCast.h, src/SDCCBBlock.c,
+ src/SDCCcse.c, src/SDCCglue.c, src/SDCCicode.c, src/SDCCloop.c,
+ src/SDCCopt.c, src/SDCCval.c:
+ fixed bug #1890273: SDCC Warning 154 shows wrong filename
2008-02-12 Maarten Brock <sourceforge.brock AT dse.nl>
#include "common.h"
int eBBNum = 0;
-set *graphEdges = NULL; /* list of edges in this flow graph */
+set *graphEdges = NULL; /* list of edges in this flow graph */
struct _dumpFiles dumpFiles[] = {
{DUMP_RAW0, ".dumpraw0", NULL},
struct _dumpFiles *dumpFilesPtr=dumpFiles;
static int dumpIndex=0;
static char dumpIndexStr[32];
-
+
while (dumpFilesPtr->id) {
if (dumpFilesPtr->id==id)
break;
werror (E_FILE_OPEN_ERR, scratchFileName);
exit (1);
}
- }
+ }
#if 0
fprintf(dumpFilesPtr->filePtr, "Dump file index: %d\n", dumpIndex);
/*-----------------------------------------------------------------*/
/* dumpLiveRanges - dump liverange information into a file */
/*-----------------------------------------------------------------*/
-void
+void
dumpLiveRanges (int id, hTab * liveRanges)
{
FILE *file;
} else {
file = stdout;
}
-
- if (currFunc)
+
+ if (currFunc)
fprintf(file,"------------- Func %s -------------\n",currFunc->name);
for (sym = hTabFirstItem (liveRanges, &k); sym;
sym = hTabNextItem (liveRanges, &k))
{
fprintf (file, "%s [k%d lr%d:%d so:%d]{ re%d rm%d}",
- (sym->rname[0] ? sym->rname : sym->name),
- sym->key,
- sym->liveFrom, sym->liveTo,
- sym->stack,
- sym->isreqv, sym->remat
- );
+ (sym->rname[0] ? sym->rname : sym->name),
+ sym->key,
+ sym->liveFrom, sym->liveTo,
+ sym->stack,
+ sym->isreqv, sym->remat
+ );
fprintf (file, "{");
printTypeChain (sym->type, file);
if (sym->usl.spillLoc)
- {
- fprintf (file, "}{ sir@ %s", sym->usl.spillLoc->rname);
- }
+ {
+ fprintf (file, "}{ sir@ %s", sym->usl.spillLoc->rname);
+ }
fprintf (file, "} clashes with ");
bitVectDebugOn(sym->clashes,file);
fprintf (file, "\n");
/*-----------------------------------------------------------------*/
/* dumpEbbsToFileExt - writeall the basic blocks to a file */
/*-----------------------------------------------------------------*/
-void
+void
dumpEbbsToFileExt (int id, ebbIndex * ebbi)
{
FILE *of;
{
fprintf (of, "\n----------------------------------------------------------------\n");
fprintf (of, "Basic Block %s (df:%d bb:%d lvl:%d): loopDepth=%d%s%s%s\n",
- ebbs[i]->entryLabel->name,
- ebbs[i]->dfnum, ebbs[i]->bbnum, ebbs[i]->entryLabel->level,
- ebbs[i]->depth,
- ebbs[i]->noPath ? " noPath" : "",
- ebbs[i]->partOfLoop ? " partOfLoop" : "",
- ebbs[i]->isLastInLoop ? " isLastInLoop" : "");
+ ebbs[i]->entryLabel->name,
+ ebbs[i]->dfnum, ebbs[i]->bbnum, ebbs[i]->entryLabel->level,
+ ebbs[i]->depth,
+ ebbs[i]->noPath ? " noPath" : "",
+ ebbs[i]->partOfLoop ? " partOfLoop" : "",
+ ebbs[i]->isLastInLoop ? " 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);
+ 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);
+ 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 ", ebbi->bbOrder[d]->entryLabel->name); //ebbs[d]->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 ", ebbi->bbOrder[d]->entryLabel->name); //ebbs[d]->entryLabel->name);
+ }
+ }
}
fprintf (of, "\n");
-
+
fprintf (of, "\ndefines bitVector :");
bitVectDebugOn (ebbs[i]->defSet, of);
fprintf (of, "\nlocal defines bitVector :");
#endif
if (ebbs[i]->isLastInLoop) {
- fprintf (of, "\nInductions Set bitvector :");
- bitVectDebugOn (ebbs[i]->linds, of);
+ fprintf (of, "\nInductions Set bitvector :");
+ bitVectDebugOn (ebbs[i]->linds, of);
}
-
+
fprintf (of, "\ninExprs:");
for (cseSet = ebbs[i]->inExprs; cseSet; cseSet=cseSet->next) {
cseDef *item=cseSet->item;
if (item->fromGlobal)
fprintf (of, "g");
}
-
+
fprintf (of, "\n----------------------------------------------------------------\n");
printiCChain (ebbs[i]->sch, of);
}
iCode2eBBlock (iCode * ic)
{
iCode *loop;
- eBBlock *ebb = neweBBlock (); /* allocate an entry */
+ eBBlock *ebb = neweBBlock (); /* allocate an entry */
/* put the first one unconditionally */
ebb->sch = ic;
ebb->ech = ebb->sch;
return ebb;
}
-
+
/* if this is a function call */
if (ic->op == CALL || ic->op == PCALL)
{
ebb->hasFcall = 1;
if (currFunc)
- FUNC_HASFCALL(currFunc->type) = 1;
+ FUNC_HASFCALL(currFunc->type) = 1;
}
if ((ic->next && ic->next->op == LABEL) ||
/* if this is the last one */
if (!loop->next)
- break;
+ break;
/* if this is a function call */
if (loop->op == CALL || loop->op == PCALL)
- {
- ebb->hasFcall = 1;
- if (currFunc)
- FUNC_HASFCALL(currFunc->type) = 1;
- }
+ {
+ ebb->hasFcall = 1;
+ if (currFunc)
+ FUNC_HASFCALL(currFunc->type) = 1;
+ }
/* if the next one is a label */
/* if this is a goto or ifx */
if (loop->next->op == LABEL ||
- loop->op == GOTO ||
- loop->op == JUMPTABLE ||
- loop->op == IFX)
- break;
+ loop->op == GOTO ||
+ loop->op == JUMPTABLE ||
+ loop->op == IFX)
+ break;
}
/* mark the end of the chain */
for (i = 0; i < count; i++)
{
if (isSymbolEqual (ebbs[i]->entryLabel, eLabel))
- return ebbs[i];
+ return ebbs[i];
}
return NULL;
/*-----------------------------------------------------------------*/
/* addiCodeToeBBlock - will add an iCode to the end of a block */
/*-----------------------------------------------------------------*/
-void
+void
addiCodeToeBBlock (eBBlock * ebp, iCode * ic, iCode * ip)
{
ic->prev = ic->next = NULL;
/* if the insert point is given */
if (ip)
{
+ ic->filename = ip->filename;
ic->lineno = ip->lineno;
ic->prev = ip->prev;
ip->prev = ic;
ic->next = ip;
if (!ic->prev)
- ebp->sch = ic;
+ ebp->sch = ic;
else
- ic->prev->next = ic;
+ ic->prev->next = ic;
return;
}
if (ebp->ech->op == GOTO || ebp->ech->op == JUMPTABLE
|| ebp->ech->op == RETURN)
{
+ ic->filename = ebp->ech->filename;
ic->lineno = ebp->ech->lineno;
ic->prev = ebp->ech->prev;
ebp->ech->prev = ic;
ic->next = ebp->ech;
- if (!ic->prev) /* was the last only on in the block */
- ebp->sch = ic;
+ if (!ic->prev) /* was the last only on in the block */
+ ebp->sch = ic;
else
- ic->prev->next = ic;
+ ic->prev->next = ic;
return;
}
/* else */
/* ipoint = ebp->ech ; */
ipoint = ebp->ech;
+ ic->filename = ipoint->filename;
ic->lineno = ipoint->lineno;
ic->prev = ipoint->prev;
ipoint->prev = ic;
ic->next = ipoint;
if (!ic->prev)
- ebp->sch = ic;
+ ebp->sch = ic;
else
- ic->prev->next = ic;
+ ic->prev->next = ic;
return;
}
/*-----------------------------------------------------------------*/
/* remiCodeFromeBBlock - remove an iCode from BBlock */
/*-----------------------------------------------------------------*/
-void
+void
remiCodeFromeBBlock (eBBlock * ebb, iCode * ic)
{
wassert (ic->seq>=ebb->fSeq && ic->seq<=ebb->lSeq);
eBBlock **ebbs = NULL;
iCode *loop = ic;
ebbIndex *ebbi;
-
+
ebbi = Safe_alloc (sizeof (ebbIndex));
ebbi->count = 0;
ebbi->dfOrder = NULL; /* no depth first order information yet */
eBBlock *ebb = iCode2eBBlock (loop);
loop = ebb->ech->next;
- ebb->ech->next = NULL; /* mark the end of this chain */
+ ebb->ech->next = NULL; /* mark the end of this chain */
if (loop)
- loop->prev = NULL;
- ebb->bbnum = ebbi->count; /* save this block number */
+ loop->prev = NULL;
+ ebb->bbnum = ebbi->count; /* save this block number */
/* put it in the array */
ebbs[(ebbi->count)++] = ebb;
/* be a loop, add a preheader to the block it */
/* goes to if it does not already have one */
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[(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 (ebbi, label)) &&
- destBlock->preHeader == NULL &&
- otherPathsPresent (ebbs, destBlock))
- {
-
- symbol *preHeaderLabel = newiTempLoopHeaderLabel (1);
- int i, j;
- eBBlock *pBlock;
-
- /* 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 < (ebbi->count); i++)
- {
- if (ebbs[i] == destBlock)
- break;
- replaceLabel (ebbs[i], label, preHeaderLabel);
- }
-
- (ebbi->count)++;
-
- /* if we have stopped at the block , allocate for an extra one */
-
- ebbs = Safe_realloc (ebbs, (ebbi->count + 1) * sizeof (eBBlock *));
- ebbi->bbOrder = ebbs;
-
- ebbs[ebbi->count] = 0;
-
- /* then move the block down one count */
- pBlock = ebbs[j = i];
- for (i += 1; i < (ebbi->count); i++)
- {
- eBBlock *xBlock;
-
- xBlock = ebbs[i];
- ebbs[i] = pBlock;
- ebbs[i]->bbnum = i;
- pBlock = xBlock;
- }
-
- destBlock->preHeader = ebbs[j] = neweBBlock ();
- ebbs[j]->bbnum = j;
- ebbs[j]->entryLabel = preHeaderLabel;
- ebbs[j]->sch = ebbs[j]->ech = newiCodeLabelGoto (LABEL, preHeaderLabel);
- ebbs[j]->sch->lineno = destBlock->sch->lineno;
- }
- }
+ (ebbs[(ebbi->count) - 1]->ech->op == GOTO ||
+ ebbs[(ebbi->count) - 1]->ech->op == IFX))
+ {
+
+ symbol *label;
+ eBBlock *destBlock;
+
+ 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 (ebbi, label)) &&
+ destBlock->preHeader == NULL &&
+ otherPathsPresent (ebbs, destBlock))
+ {
+
+ symbol *preHeaderLabel = newiTempLoopHeaderLabel (1);
+ int i, j;
+ eBBlock *pBlock;
+
+ /* 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 < (ebbi->count); i++)
+ {
+ if (ebbs[i] == destBlock)
+ break;
+ replaceLabel (ebbs[i], label, preHeaderLabel);
+ }
+
+ (ebbi->count)++;
+
+ /* if we have stopped at the block , allocate for an extra one */
+
+ ebbs = Safe_realloc (ebbs, (ebbi->count + 1) * sizeof (eBBlock *));
+ ebbi->bbOrder = ebbs;
+
+ ebbs[ebbi->count] = 0;
+
+ /* then move the block down one count */
+ pBlock = ebbs[j = i];
+ for (i += 1; i < (ebbi->count); i++)
+ {
+ eBBlock *xBlock;
+
+ xBlock = ebbs[i];
+ ebbs[i] = pBlock;
+ ebbs[i]->bbnum = i;
+ pBlock = xBlock;
+ }
+
+ destBlock->preHeader = ebbs[j] = neweBBlock ();
+ ebbs[j]->bbnum = j;
+ ebbs[j]->entryLabel = preHeaderLabel;
+ ebbs[j]->sch = ebbs[j]->ech = newiCodeLabelGoto (LABEL, preHeaderLabel);
+ ebbs[j]->sch->filename = destBlock->sch->filename;
+ ebbs[j]->sch->lineno = destBlock->sch->lineno;
+ }
+ }
}
/* mark the end */
/* replaceSymBySym : - replace operand by operand in blocks */
/* replaces only left & right in blocks */
/*-----------------------------------------------------------------*/
-void
+void
replaceSymBySym (set * sset, operand * src, operand * dest)
{
set *loop;
rBlock = loop->item;
/* for all instructions in this block do */
for (ic = rBlock->sch; ic; ic = ic->next)
- {
-
- /* if we find usage */
- if (ic->op == IFX && isOperandEqual (src, IC_COND (ic)))
- {
- bitVectUnSetBit (OP_USES (IC_COND (ic)), ic->key);
- IC_COND (ic) = operandFromOperand (dest);
- OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key);
- continue;
- }
-
- if (isOperandEqual (IC_RIGHT (ic), src))
- {
- 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);
- }
-
- if (isOperandEqual (IC_LEFT (ic), src))
- {
- bitVectUnSetBit (OP_USES (IC_LEFT (ic)), ic->key);
- if (POINTER_GET (ic) && IS_ITEMP (dest))
- {
- IC_LEFT (ic) = operandFromOperand (dest);
- IC_LEFT (ic)->isaddr = 1;
- }
- else
- {
- IC_LEFT (ic) = operandFromOperand (dest);
- IC_LEFT (ic)->isaddr = 0;
- }
- OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key);
- }
-
- /* special case for pointer sets */
- if (POINTER_SET (ic) &&
- isOperandEqual (IC_RESULT (ic), src))
- {
- 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);
- }
- }
+ {
+
+ /* if we find usage */
+ if (ic->op == IFX && isOperandEqual (src, IC_COND (ic)))
+ {
+ bitVectUnSetBit (OP_USES (IC_COND (ic)), ic->key);
+ IC_COND (ic) = operandFromOperand (dest);
+ OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key);
+ continue;
+ }
+
+ if (isOperandEqual (IC_RIGHT (ic), src))
+ {
+ 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);
+ }
+
+ if (isOperandEqual (IC_LEFT (ic), src))
+ {
+ bitVectUnSetBit (OP_USES (IC_LEFT (ic)), ic->key);
+ if (POINTER_GET (ic) && IS_ITEMP (dest))
+ {
+ IC_LEFT (ic) = operandFromOperand (dest);
+ IC_LEFT (ic)->isaddr = 1;
+ }
+ else
+ {
+ IC_LEFT (ic) = operandFromOperand (dest);
+ IC_LEFT (ic)->isaddr = 0;
+ }
+ OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key);
+ }
+
+ /* special case for pointer sets */
+ if (POINTER_SET (ic) &&
+ isOperandEqual (IC_RESULT (ic), src))
+ {
+ 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);
+ }
+ }
}
}
/*-----------------------------------------------------------------*/
/* replaceLabel - replace reference to one label by another */
/*-----------------------------------------------------------------*/
-void
+void
replaceLabel (eBBlock * ebp, symbol * fromLbl, symbol * toLbl)
{
iCode *ic;
for (ic = ebp->sch; ic; ic = ic->next)
{
switch (ic->op)
- {
-
- case GOTO:
- if (isSymbolEqual (IC_LABEL (ic), fromLbl))
- IC_LABEL (ic) = toLbl;
- break;
-
- case IFX:
- if (IC_TRUE (ic) && isSymbolEqual (IC_TRUE (ic), fromLbl))
- IC_TRUE (ic) = toLbl;
- else if (isSymbolEqual (IC_FALSE (ic), fromLbl))
- IC_FALSE (ic) = toLbl;
- break;
- }
+ {
+
+ case GOTO:
+ if (isSymbolEqual (IC_LABEL (ic), fromLbl))
+ IC_LABEL (ic) = toLbl;
+ break;
+
+ case IFX:
+ if (IC_TRUE (ic) && isSymbolEqual (IC_TRUE (ic), fromLbl))
+ IC_TRUE (ic) = toLbl;
+ else if (isSymbolEqual (IC_FALSE (ic), fromLbl))
+ IC_FALSE (ic) = toLbl;
+ break;
+ }
}
return;
for (; i < count; i++)
{
if (ebbs[i]->sch == NULL)
- continue;
+ continue;
if (ebbs[i]->noPath &&
- (ebbs[i]->entryLabel != entryLabel &&
- ebbs[i]->entryLabel != returnLabel))
- {
+ (ebbs[i]->entryLabel != entryLabel &&
+ ebbs[i]->entryLabel != returnLabel))
+ {
iCode *ic = NULL;
bool foundNonlabel = 0;
ic=ebbs[i]->sch;
while (ic);
if (foundNonlabel && ic)
{
- werrorfl (ic->filename, ic->lineno, W_CODE_UNREACH);
+ werrorfl (ic->filename, ic->lineno, W_CODE_UNREACH);
continue;
}
- }
+ }
lic->next = ebbs[i]->sch;
lic->next->prev = lic;
/* otherPathsPresent - determines if there is a path from _entry */
/* to this block in a half constructed set of blocks */
/*-----------------------------------------------------------------*/
-int
+int
otherPathsPresent (eBBlock ** ebbs, eBBlock * this)
{
int i;
/* if there is a reference to the entry label of this block */
for (ic = ebbs[i]->sch; ic; ic = ic->next)
- {
- switch (ic->op)
- {
- case GOTO:
- if (IC_LABEL (ic)->key == this->entryLabel->key)
- return 1;
- break;
-
- case IFX:
- if (IC_TRUE (ic))
- {
- if (IC_TRUE (ic)->key == this->entryLabel->key)
- return 1;
- }
- else if (IC_FALSE (ic)->key == this->entryLabel->key)
- return 1;
- break;
- }
- }
+ {
+ switch (ic->op)
+ {
+ case GOTO:
+ if (IC_LABEL (ic)->key == this->entryLabel->key)
+ return 1;
+ break;
+
+ case IFX:
+ if (IC_TRUE (ic))
+ {
+ if (IC_TRUE (ic)->key == this->entryLabel->key)
+ return 1;
+ }
+ else if (IC_FALSE (ic)->key == this->entryLabel->key)
+ return 1;
+ break;
+ }
+ }
}
/* comes here means we have not found it yet */
newAst_ (unsigned type)
{
ast *ex;
- static int oldLineno = 0;
ex = Safe_alloc ( sizeof (ast));
ex->type = type;
- ex->lineno = (noLineno ? oldLineno : lexLineno);
+ ex->lineno = (noLineno ? 0 : lexLineno);
ex->filename = lexFilename;
ex->level = NestLevel;
ex->block = currBlockno;
dest = Safe_alloc ( sizeof (ast));
dest->type = src->type;
+ dest->filename = src->filename;
dest->lineno = src->lineno;
dest->level = src->level;
dest->funcName = src->funcName;
return tree;
}
-/*-----------------------------------------------------------------*/
-/* setAstLineno - walks a ast tree & sets the line number */
-/*-----------------------------------------------------------------*/
-int setAstLineno (ast * tree, int lineno)
+/*------------------------------------------------------------------------*/
+/* setAstFileLine - walks a ast tree & sets the file name and line number */
+/*------------------------------------------------------------------------*/
+int setAstFileLine (ast * tree, char *filename, int lineno)
{
if (!tree)
return 0;
+ tree->filename = filename;
tree->lineno = lineno;
- setAstLineno (tree->left, lineno);
- setAstLineno (tree->right, lineno);
+ setAstFileLine (tree->left, filename, lineno);
+ setAstFileLine (tree->right, filename, lineno);
return 0;
}
/* cast required; change this op to a cast. */
(*actParm)->decorated = 0;
*actParm = newNode (CAST, newType, *actParm);
+ (*actParm)->filename = (*actParm)->right->filename;
(*actParm)->lineno = (*actParm)->right->lineno;
decorateType (*actParm, RESULT_TYPE_NONE);
list2expr (sym->ival));
}
- setAstLineno (work, sym->lineDef);
+ setAstFileLine (work, sym->fileDef, sym->lineDef);
sym->ival = NULL;
if (staticAutos)
}
/* update lineno for error msg */
+ filename = sym->fileDef;
lineno = sym->lineDef;
- setAstLineno (ilist->init.node, sym->lineDef);
+ setAstFileLine (ilist->init.node, sym->fileDef, sym->lineDef);
if (IS_AGGREGATE (sym->type)) {
work = initAggregates (sym, sym->ival, NULL);
}
// just to be sure
- setAstLineno (work, sym->lineDef);
+ setAstFileLine (work, sym->fileDef, sym->lineDef);
sym->ival = NULL;
if (init)
unsigned int size;
// have we heard this before?
- for (sp=statsg->syms; sp; sp=sp->next) {
- sym=sp->item;
- size = getSize (sym->type);
- if (sym->isstrlit && size == getSize (val->type) &&
- !memcmp(SPEC_CVAL(sym->etype).v_char, SPEC_CVAL(val->etype).v_char, size)) {
- // yes, this is old news. Don't publish it again.
- sym->isstrlit++; // but raise the usage count
- return symbolVal(sym);
+ for (sp = statsg->syms; sp; sp = sp->next)
+ {
+ sym = sp->item;
+ size = getSize (sym->type);
+ if (sym->isstrlit && size == getSize (val->type) &&
+ !memcmp (SPEC_CVAL (sym->etype).v_char, SPEC_CVAL (val->etype).v_char, size))
+ {
+ // yes, this is old news. Don't publish it again.
+ sym->isstrlit++; // but raise the usage count
+ return symbolVal (sym);
+ }
}
- }
SNPRINTF (name, sizeof(name), "_str_%d", charLbl++);
sym = newSymbol (name, 0); /* make it @ level 0 */
end));
replLoopSym (loop->left, sym);
- setAstLineno (rloop, init->lineno);
+ setAstFileLine (rloop, init->filename, init->lineno);
rloop = newNode (NULLOP,
newNode ('=',
}
tree->decorated = 0;
tree = newNode (CAST, newAst_LINK (newLink), tree);
+ tree->filename = tree->right->filename;
tree->lineno = tree->right->lineno;
/* keep unsigned type during cast to smaller type,
but not when promoting from char to int */
/*----------------------------*/
/* leaf has been reached */
/*----------------------------*/
+ filename = tree->filename;
lineno = tree->lineno;
/* if this is of type value */
/* just get the type */
litTree->right = newNode ('*',
litTree->right,
copyAst (tree->right));
+ litTree->right->filename = tree->filename;
litTree->right->lineno = tree->lineno;
tree->right->opval.val = constCharVal (1);
tree->right = newNode (':',
newAst_VALUE (constCharVal (1)),
newAst_VALUE (constCharVal (0)));
+ tree->right->filename = tree->filename;
tree->right->lineno = tree->lineno;
tree->decorated = 0;
return decorateType (tree, resultType);
allocGlobal (sym);
newTree->left = newAst_VALUE(symbolVal(sym));
+ newTree->left->filename = tree->filename;
newTree->left->lineno = tree->lineno;
LTYPE (newTree) = sym->type;
LETYPE (newTree) = sym->etype;
tree->right = newNode (':',
newAst_VALUE (constCharVal (1)),
tree->right); /* val 0 */
+ tree->right->filename = tree->filename;
tree->right->lineno = tree->lineno;
+ tree->right->left->filename = tree->filename;
tree->right->left->lineno = tree->lineno;
tree->decorated = 0;
return decorateType (tree, resultType);
tree->opval.op = transformedOp;
tree->decorated = 0;
tree = newNode ('!', tree, NULL);
+ tree->filename = tree->left->filename;
tree->lineno = tree->left->lineno;
return decorateType (tree, resultType);
}
ex->values.sym = decl;
ex->level++;
+ ex->filename = NULL;
ex->lineno = 0;
return ex;
}
label->islbl = 1;
label->key = labelKey++;
rValue = newNode (LABEL, newAst_VALUE (symbolVal (label)), stmnt);
+ rValue->filename = NULL;
rValue->lineno = 0;
return rValue;
(int) ulFromVal (caseVal->opval.val));
rexpr = createLabel (newSymbol (caseLbl, 0), stmnt);
+ rexpr->filename = 0;
rexpr->lineno = 0;
return rexpr;
}
/* put the continue label */
condExpr = backPatchLabels (condExpr, trueLabel, falseLabel);
condExpr = createLabel (continueLabel, condExpr);
+ condExpr->filename = NULL;
condExpr->lineno = 0;
/* put the body label in front of the body */
whileBody = createLabel (trueLabel, whileBody);
+ whileBody->filename = NULL;
whileBody->lineno = 0;
/* put a jump to continue at the end of the body */
/* and put break label at the end of the body */
static void
copyAstLoc (ast * dest, ast * src)
{
- dest->lineno = src->lineno;
dest->filename = src->filename;
+ dest->lineno = src->lineno;
dest->level = src->level;
dest->block = src->block;
dest->seqPoint = src->seqPoint;
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
- what you give them. Help stamp out software-hoarding!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
#ifndef SDCCEXPR_H
unsigned lvalue:1;
unsigned initMode:1;
unsigned reversed:1;
- int level; /* level for expr */
- int block; /* block number */
- int seqPoint; /* sequence point */
+ int level; /* level for expr */
+ int block; /* block number */
+ int seqPoint; /* sequence point */
/* union of values expression can have */
union
{
- value *val; /* value if type = EX_VALUE */
- sym_link *lnk; /* sym_link * if type= EX_LINK */
- struct operand *oprnd; /* used only for side effecting function calls */
- unsigned op; /* operator if type= EX_OP */
+ value *val; /* value if type = EX_VALUE */
+ sym_link *lnk; /* sym_link * if type= EX_LINK */
+ struct operand *oprnd; /* used only for side effecting function calls */
+ unsigned op; /* operator if type= EX_OP */
}
opval;
/* union for special processing */
union
{
- char *inlineasm; /* pointer to inline assembler code */
- literalList *constlist; /* init list for array initializer. */
- symbol *sym; /* if block then -> symbols */
- value *args; /* if function then args */
- /* if switch then switch values */
- struct
- {
- value *swVals; /* switch comparison values */
- int swDefault; /* default if present */
- int swNum; /* switch number */
- }
- switchVals;
- /* if for then for values */
- struct
- {
- struct ast *initExpr; /* init portion */
- struct ast *condExpr; /* conditional portion */
- struct ast *loopExpr; /* iteration portion */
- symbol *trueLabel; /* entry point into body */
- symbol *falseLabel; /* exit point */
- symbol *continueLabel; /* conditional check */
- symbol *condLabel; /* conditional label */
- }
- forVals;
- unsigned literalFromCast; /* true if this is an EX_VALUE of LITERAL
- * type resulting from a typecast.
- */
- int argreg; /* argreg number when operand type == EX_OPERAND */
+ char *inlineasm; /* pointer to inline assembler code */
+ literalList *constlist; /* init list for array initializer. */
+ symbol *sym; /* if block then -> symbols */
+ value *args; /* if function then args */
+ /* if switch then switch values */
+ struct
+ {
+ value *swVals; /* switch comparison values */
+ int swDefault; /* default if present */
+ int swNum; /* switch number */
+ }
+ switchVals;
+ /* if for then for values */
+ struct
+ {
+ struct ast *initExpr; /* init portion */
+ struct ast *condExpr; /* conditional portion */
+ struct ast *loopExpr; /* iteration portion */
+ symbol *trueLabel; /* entry point into body */
+ symbol *falseLabel; /* exit point */
+ symbol *continueLabel; /* conditional check */
+ symbol *condLabel; /* conditional label */
+ }
+ forVals;
+ unsigned literalFromCast; /* true if this is an EX_VALUE of LITERAL
+ * type resulting from a typecast.
+ */
+ int argreg; /* argreg number when operand type == EX_OPERAND */
}
values;
- int lineno; /* source file line number */
- char *filename; /* filename of the source file */
+ int lineno; /* source file line number */
+ char *filename; /* filename of the source file */
- sym_link *ftype; /* start of type chain for this subtree */
- sym_link *etype; /* end of type chain for this subtree */
+ sym_link *ftype; /* start of type chain for this subtree */
+ sym_link *etype; /* end of type chain for this subtree */
- struct ast *left; /* pointer to left tree */
- struct ast *right; /* pointer to right tree */
- symbol *trueLabel; /* if statement trueLabel */
- symbol *falseLabel; /* if statement falseLabel */
+ struct ast *left; /* pointer to left tree */
+ struct ast *right; /* pointer to right tree */
+ symbol *trueLabel; /* if statement trueLabel */
+ symbol *falseLabel; /* if statement falseLabel */
}
ast;
#define IS_LEFT_OP(x) (IS_AST_OP(x) && x->opval.op == LEFT_OP)
#define IS_RIGHT_OP(x) (IS_AST_OP(x) && x->opval.op == RIGHT_OP)
#define IS_AST_VALUE(x) ((x) && (x)->type == EX_VALUE && (x)->opval.val)
-#define IS_AST_LINK(x) (x->type == EX_LINK)
-#define IS_AST_NOT_OPER(x) (x && IS_AST_OP(x) && x->opval.op == '!')
+#define IS_AST_LINK(x) (x->type == EX_LINK)
+#define IS_AST_NOT_OPER(x) (x && IS_AST_OP(x) && x->opval.op == '!')
#define IS_ARRAY_OP(x) (IS_AST_OP(x) && x->opval.op == '[')
-#define IS_COMPARE_OP(x) (IS_AST_OP(x) && \
- (x->opval.op == '>' || \
- x->opval.op == '<' || \
- x->opval.op == LE_OP || \
- x->opval.op == GE_OP || \
- x->opval.op == EQ_OP || \
- x->opval.op == NE_OP ))
+#define IS_COMPARE_OP(x) (IS_AST_OP(x) && \
+ (x->opval.op == '>' || \
+ x->opval.op == '<' || \
+ x->opval.op == LE_OP || \
+ x->opval.op == GE_OP || \
+ x->opval.op == EQ_OP || \
+ x->opval.op == NE_OP ))
#define IS_CAST_OP(x) (IS_AST_OP(x) && (x)->opval.op == CAST)
#define IS_TERNARY_OP(x) (IS_AST_OP(x) && x->opval.op == '?')
#define IS_COLON_OP(x) (IS_AST_OP(x) && x->opval.op == ':')
#define IS_AST_PARAM(x) (IS_AST_OP(x) && x->opval.op == PARAM)
-#define CAN_EVAL(x) ( x == '[' || x == '.' || x == PTR_OP || \
- x == '&' || x == '|' || x == '^' || x == '*' || \
- x == '-' || x == '+' || x == '~' || \
- x == '!' || x == LEFT_OP || x == RIGHT_OP || \
- x == '/' || x == '%' || x == '>' || x == '<' || \
- x == LE_OP || x == GE_OP || x == EQ_OP || x == NE_OP || \
- x == AND_OP || x == OR_OP || x == '=' )
+#define CAN_EVAL(x) ( x == '[' || x == '.' || x == PTR_OP || \
+ x == '&' || x == '|' || x == '^' || x == '*' || \
+ x == '-' || x == '+' || x == '~' || \
+ x == '!' || x == LEFT_OP || x == RIGHT_OP || \
+ x == '/' || x == '%' || x == '>' || x == '<' || \
+ x == LE_OP || x == GE_OP || x == EQ_OP || x == NE_OP || \
+ x == AND_OP || x == OR_OP || x == '=' )
-#define LEFT_FIRST(x) ( x == AND_OP || x == OR_OP )
+#define LEFT_FIRST(x) ( x == AND_OP || x == OR_OP )
-#define SIDE_EFFECTS_CHECK(op,rVal) if (!sideEffects) { \
- werror(W_NO_SIDE_EFFECTS,op); \
- return rVal ; \
- }
+#define SIDE_EFFECTS_CHECK(op,rVal) if (!sideEffects) { \
+ werror(W_NO_SIDE_EFFECTS,op); \
+ return rVal ; \
+ }
#define IS_MODIFYING_OP(x) ( x == INC_OP || x == DEC_OP || x == '=' || \
- x == AND_ASSIGN || x== OR_ASSIGN || x == XOR_ASSIGN )
+ x == AND_ASSIGN || x== OR_ASSIGN || x == XOR_ASSIGN )
#define IS_ASSIGN_OP(x) ( x == '=' || x == ADD_ASSIGN || x == SUB_ASSIGN ||\
- x == MUL_ASSIGN || x == DIV_ASSIGN || x == XOR_ASSIGN ||\
- x == AND_ASSIGN || x == OR_ASSIGN || x == INC_OP || x == DEC_OP)
+ x == MUL_ASSIGN || x == DIV_ASSIGN || x == XOR_ASSIGN ||\
+ x == AND_ASSIGN || x == OR_ASSIGN || x == INC_OP || x == DEC_OP)
#define IS_DEREF_OP(x) (( x->opval.op == '*' && x->right == NULL) || x->opval.op == '.')
/* forward declarations for global variables */
void eval2icode (ast *);
value *constExprValue (ast *, int);
bool constExprTree (ast *);
-int setAstLineno (ast *, int);
+int setAstFileLine (ast *, char *, int);
symbol *funcOfType (char *, sym_link *, sym_link *, int, int);
symbol * funcOfTypeVarg (char *, char * , int , char **);
ast *initAggregates (symbol *, initList *, ast *);
int astErrors(ast *);
RESULT_TYPE getResultTypeFromType (sym_link *);
-// exported variables
+// exported variables
extern set *operKeyReset;
extern int noAlloc;
extern int inInitMode;
{
iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic));
IC_RESULT (newic) = IC_LEFT (ic);
+ newic->filename = ic->filename;
newic->lineno = ic->lineno;
addiCodeToeBBlock (ebp, newic, ic->next);
}
{
iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic));
IC_RESULT (newic) = IC_LEFT (ic);
+ newic->filename = ic->filename;
newic->lineno = ic->lineno;
addiCodeToeBBlock (ebp, newic, ic->next);
}
{
iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic));
IC_RESULT (newic) = IC_LEFT (ic);
+ newic->filename = ic->filename;
newic->lineno = ic->lineno;
addiCodeToeBBlock (ebp, newic, ic->next);
}
{
iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic));
IC_RESULT (newic) = IC_LEFT (ic);
+ newic->filename = ic->filename;
newic->lineno = ic->lineno;
addiCodeToeBBlock (ebp, newic, ic->next);
}
{
iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic));
IC_RESULT (newic) = IC_LEFT (ic);
+ newic->filename = ic->filename;
newic->lineno = ic->lineno;
addiCodeToeBBlock (ebp, newic, ic->next);
newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic));
IC_RESULT (newic) = IC_LEFT (ic);
+ newic->filename = ic->filename;
newic->lineno = ic->lineno;
addiCodeToeBBlock (ebp, newic, ic->next);
}
if (ival) {
// set ival's lineno to where the symbol was defined
- setAstLineno (ival, lineno=sym->lineDef);
+ setAstFileLine (ival, filename = sym->fileDef, lineno = sym->lineDef);
// check if this is not a constant expression
if (!constExprTree(ival)) {
werror (E_CONST_EXPECTED, "found expression");
ic = Safe_alloc ( sizeof (iCode));
ic->seqPoint = seqPoint;
- ic->lineno = lineno;
ic->filename = filename;
+ ic->lineno = lineno;
ic->block = block;
ic->level = scopeLevel;
ic->op = op;
{
iCode *nic = newiCode (ic->op, NULL, NULL);
- nic->lineno = ic->lineno;
nic->filename = ic->filename;
+ nic->lineno = ic->lineno;
nic->block = ic->block;
nic->level = ic->level;
nic->parmBytes = ic->parmBytes;
/*-----------------------------------------------------------------*/
/* operandSize - returns size of an operand in bytes */
/*-----------------------------------------------------------------*/
-unsigned int
+unsigned int
operandSize (operand * op)
{
sym_link *type;
iCode *ic;
operand *func;
sym_link *fetype;
+ char *savefilename;
int savelineno;
/* reset the auto generation */
func = ast2iCode (tree->left,lvl+1);
fetype = getSpec (operandType (func));
+ savefilename = filename;
savelineno = lineno;
+ filename = OP_SYMBOL (func)->fileDef;
lineno = OP_SYMBOL (func)->lineDef;
/* create an entry label */
geniCodeLabel (entryLabel);
+ filename = savefilename;
lineno = savelineno;
/* create a proc icode */
ic = newiCode (FUNCTION, func, NULL);
- lineno=ic->lineno = OP_SYMBOL (func)->lineDef;
+ filename = ic->filename = OP_SYMBOL (func)->fileDef;
+ lineno = ic->lineno = OP_SYMBOL (func)->lineDef;
ic->tree = tree;
ADDTOCHAIN (ic);
/*-----------------------------------------------------------------*/
static induction *
newInduction (operand * sym, unsigned int op,
- long constVal, iCode * ic, operand * asym)
+ long constVal, iCode * ic, operand * asym)
{
induction *ip;
exit = setNextItem (lexits))
{
succVect = bitVectIntersect (succVect,
- exit->succVect);
+ exit->succVect);
}
return succVect;
block = setNextItem (lreg->regBlocks))
{
if (block != lblock && block->lSeq > lblock->lSeq)
- lblock = block;
+ lblock = block;
}
return lblock->lSeq;
block = STACK_POP (regionStack);
/* if block != entry */
if (block != ep->to)
- applyToSet (block->predList, insertIntoLoop, &aloop->regBlocks);
+ applyToSet (block->predList, insertIntoLoop, &aloop->regBlocks);
}
aloop->entry = ep->to;
if (op)
{
if (IS_OP_LITERAL (op))
- opin = 1;
+ opin = 1;
else if (IS_SYMOP (op) &&
- OP_SYMBOL (op)->addrtaken)
- opin = 0;
+ OP_SYMBOL (op)->addrtaken)
+ opin = 0;
else if (ifDefSymIs (theLoop->entry->inExprs, op))
- opin = 1;
+ opin = 1;
else if (ifDefSymIs (lInvars, op))
- opin = 1;
+ opin = 1;
else if (IS_SYMOP (op) &&
- !IS_OP_GLOBAL (op) &&
- !IS_OP_VOLATILE (op) &&
- assignmentsToSym (theLoop->regBlocks, op) == 0)
- opin = 1;
+ !IS_OP_GLOBAL (op) &&
+ !IS_OP_VOLATILE (op) &&
+ assignmentsToSym (theLoop->regBlocks, op) == 0)
+ opin = 1;
}
else
opin++;
/* mark the dominates all exits flag */
domsAllExits = (applyToSet (theLoop->exits, dominatedBy, lBlock) ==
- elementsInSet (theLoop->exits));
+ elementsInSet (theLoop->exits));
/* find out if we have a function call in this block */
for (ic = lBlock->sch, fCallsInBlock=0; ic; ic = ic->next) {
- if (SKIP_IC(ic)) {
- fCallsInBlock++;
- }
+ if (SKIP_IC(ic)) {
+ fCallsInBlock++;
+ }
}
/* now we go thru the instructions of this block and */
/* collect those instructions with invariant operands */
for (ic = lBlock->sch; ic; ic = ic->next)
- {
-
- int lin, rin;
- cseDef *ivar;
-
- /* TODO this is only needed if the call is between
- here and the definition, but I am too lazy to do that now */
-
- /* if there are function calls in this block */
- if (fCallsInBlock) {
-
- /* if this is a pointer get */
- if (POINTER_GET(ic)) {
- continue;
- }
-
- /* if this is an assignment from a global */
- if (ic->op=='=' && isOperandGlobal(IC_RIGHT(ic))) {
- continue;
- }
- }
-
- if (SKIP_IC (ic) || POINTER_SET (ic) || ic->op == IFX)
- continue;
-
- /* iTemp assignment from a literal may be invariant, but it
- will needlessly increase register pressure if the
- iCode(s) that use this iTemp are not also invariant */
- if (ic->op=='=' && IS_ITEMP (IC_RESULT (ic))
- && IS_OP_LITERAL (IC_RIGHT (ic)))
- continue;
-
- /* if result is volatile then skip */
- if (IC_RESULT (ic) &&
- (isOperandVolatile (IC_RESULT (ic), TRUE) ||
- IS_OP_PARM (IC_RESULT (ic))))
- continue;
-
- /* if result depends on a volatile then skip */
- if ((IC_LEFT(ic) && isOperandVolatile(IC_LEFT(ic), TRUE)) ||
- (IC_RIGHT(ic) && isOperandVolatile(IC_RIGHT(ic), TRUE)))
- continue;
-
- lin = rin = 0;
-
- /* special case */
- /* if address of then it is an invariant */
- if (ic->op == ADDRESS_OF &&
- IS_SYMOP (IC_LEFT (ic)) &&
- IS_AGGREGATE (operandType (IC_LEFT (ic))))
- lin++;
- else {
- /* check if left operand is an invariant */
- if ((lin = isOperandInvariant (IC_LEFT (ic), theLoop, lInvars)))
- /* if this is a pointer get then make sure
- that the pointer set does not exist in
- any of the blocks */
- if (POINTER_GET (ic) &&
- (applyToSet (theLoop->regBlocks,
- pointerAssigned, IC_LEFT (ic))))
- lin = 0;
- }
-
- /* do the same for right */
- rin = isOperandInvariant (IC_RIGHT (ic), theLoop, lInvars);
-
- /* if this is a POINTER_GET then special case, make sure all
- usages within the loop are POINTER_GET any other usage
- would mean that this is not an invariant , since the pointer
- could then be passed as a parameter */
- if (POINTER_GET (ic) &&
- applyToSet (theLoop->regBlocks, hasNonPtrUse, IC_LEFT (ic)))
- continue;
+ {
+
+ int lin, rin;
+ cseDef *ivar;
+
+ /* TODO this is only needed if the call is between
+ here and the definition, but I am too lazy to do that now */
+
+ /* if there are function calls in this block */
+ if (fCallsInBlock) {
+
+ /* if this is a pointer get */
+ if (POINTER_GET(ic)) {
+ continue;
+ }
+
+ /* if this is an assignment from a global */
+ if (ic->op=='=' && isOperandGlobal(IC_RIGHT(ic))) {
+ continue;
+ }
+ }
+
+ if (SKIP_IC (ic) || POINTER_SET (ic) || ic->op == IFX)
+ continue;
+
+ /* iTemp assignment from a literal may be invariant, but it
+ will needlessly increase register pressure if the
+ iCode(s) that use this iTemp are not also invariant */
+ if (ic->op=='=' && IS_ITEMP (IC_RESULT (ic))
+ && IS_OP_LITERAL (IC_RIGHT (ic)))
+ continue;
+
+ /* if result is volatile then skip */
+ if (IC_RESULT (ic) &&
+ (isOperandVolatile (IC_RESULT (ic), TRUE) ||
+ IS_OP_PARM (IC_RESULT (ic))))
+ continue;
+
+ /* if result depends on a volatile then skip */
+ if ((IC_LEFT(ic) && isOperandVolatile(IC_LEFT(ic), TRUE)) ||
+ (IC_RIGHT(ic) && isOperandVolatile(IC_RIGHT(ic), TRUE)))
+ continue;
+
+ lin = rin = 0;
+
+ /* special case */
+ /* if address of then it is an invariant */
+ if (ic->op == ADDRESS_OF &&
+ IS_SYMOP (IC_LEFT (ic)) &&
+ IS_AGGREGATE (operandType (IC_LEFT (ic))))
+ lin++;
+ else {
+ /* check if left operand is an invariant */
+ if ((lin = isOperandInvariant (IC_LEFT (ic), theLoop, lInvars)))
+ /* if this is a pointer get then make sure
+ that the pointer set does not exist in
+ any of the blocks */
+ if (POINTER_GET (ic) &&
+ (applyToSet (theLoop->regBlocks,
+ pointerAssigned, IC_LEFT (ic))))
+ lin = 0;
+ }
+
+ /* do the same for right */
+ rin = isOperandInvariant (IC_RIGHT (ic), theLoop, lInvars);
+
+ /* if this is a POINTER_GET then special case, make sure all
+ usages within the loop are POINTER_GET any other usage
+ would mean that this is not an invariant , since the pointer
+ could then be passed as a parameter */
+ if (POINTER_GET (ic) &&
+ applyToSet (theLoop->regBlocks, hasNonPtrUse, IC_LEFT (ic)))
+ continue;
/* if both the left & right are invariants : then check that */
- /* this definition exists in the out definition of all the */
- /* blocks, this will ensure that this is not assigned any */
- /* other value in the loop, and not used in this block */
- /* prior to this definition which means only this definition */
- /* is used in this loop */
- if (lin && rin && IC_RESULT (ic))
- {
- eBBlock *sBlock;
- set *lSet = setFromSet (theLoop->regBlocks);
-
- /* if this block does not dominate all exits */
- /* make sure this defintion is not used anywhere else */
- if (!domsAllExits)
- {
-
- if (isOperandGlobal (IC_RESULT (ic)))
- continue;
- /* for successors for all exits */
- for (sBlock = setFirstItem (theLoop->exits); sBlock;
- sBlock = setNextItem (theLoop->exits))
- {
-
- for (i = 0; i < count; ebbs[i++]->visited = 0);
- lBlock->visited = 1;
- if (applyToSet (sBlock->succList, isDefAlive, ic))
- break;
- }
-
- /* we have found usage */
- if (sBlock)
- continue;
- }
-
- /* now make sure this is the only definition */
- for (sBlock = setFirstItem (lSet); sBlock;
- sBlock = setNextItem (lSet))
- {
+ /* this definition exists in the out definition of all the */
+ /* blocks, this will ensure that this is not assigned any */
+ /* other value in the loop, and not used in this block */
+ /* prior to this definition which means only this definition */
+ /* is used in this loop */
+ if (lin && rin && IC_RESULT (ic))
+ {
+ eBBlock *sBlock;
+ set *lSet = setFromSet (theLoop->regBlocks);
+
+ /* if this block does not dominate all exits */
+ /* make sure this defintion is not used anywhere else */
+ if (!domsAllExits)
+ {
+
+ if (isOperandGlobal (IC_RESULT (ic)))
+ continue;
+ /* for successors for all exits */
+ for (sBlock = setFirstItem (theLoop->exits); sBlock;
+ sBlock = setNextItem (theLoop->exits))
+ {
+
+ for (i = 0; i < count; ebbs[i++]->visited = 0);
+ lBlock->visited = 1;
+ if (applyToSet (sBlock->succList, isDefAlive, ic))
+ break;
+ }
+
+ /* we have found usage */
+ if (sBlock)
+ continue;
+ }
+
+ /* now make sure this is the only definition */
+ for (sBlock = setFirstItem (lSet); sBlock;
+ sBlock = setNextItem (lSet))
+ {
iCode *ic2;
int used;
int defDominates;
- /* if this is the block make sure the definition */
- /* reaches the end of the block */
- if (sBlock == lBlock)
- {
- if (!ifDiCodeIs (sBlock->outExprs, ic))
- break;
- }
- else if (bitVectBitsInCommon (sBlock->defSet, OP_DEFS (IC_RESULT (ic))))
- break;
+ /* if this is the block make sure the definition */
+ /* reaches the end of the block */
+ if (sBlock == lBlock)
+ {
+ if (!ifDiCodeIs (sBlock->outExprs, ic))
+ break;
+ }
+ else if (bitVectBitsInCommon (sBlock->defSet, OP_DEFS (IC_RESULT (ic))))
+ break;
/* Check that this definition is not assigned */
/* any other value in this block. Also check */
}
if (ic2) /* found another definition or a usage before the definition */
break;
- }
+ }
+
+ if (sBlock)
+ continue; /* another definition present in the block */
- if (sBlock)
- continue; /* another definition present in the block */
-
/* now check if it exists in the in of this block */
- /* if not then it was killed before this instruction */
- if (!bitVectBitValue (lBlock->inDefs, ic->key))
- continue;
+ /* if not then it was killed before this instruction */
+ if (!bitVectBitValue (lBlock->inDefs, ic->key))
+ continue;
- /* now we know it is a true invariant */
- /* remove it from the insts chain & put */
- /* in the invariant set */
+ /* now we know it is a true invariant */
+ /* remove it from the insts chain & put */
+ /* in the invariant set */
OP_SYMBOL (IC_RESULT (ic))->isinvariant = 1;
SPIL_LOC (IC_RESULT (ic)) = NULL;
- remiCodeFromeBBlock (lBlock, ic);
-
- /* maintain the data flow */
- /* this means removing from definition from the */
- /* defset of this block and adding it to the */
- /* inexpressions of all blocks within the loop */
- bitVectUnSetBit (lBlock->defSet, ic->key);
- bitVectUnSetBit (lBlock->ldefs, ic->key);
- ivar = newCseDef (IC_RESULT (ic), ic);
- applyToSet (theLoop->regBlocks, addDefInExprs, ivar, ebbi);
- addSet (&lInvars, ivar);
- }
- }
- } /* for all loop blocks */
+ remiCodeFromeBBlock (lBlock, ic);
+
+ /* maintain the data flow */
+ /* this means removing from definition from the */
+ /* defset of this block and adding it to the */
+ /* inexpressions of all blocks within the loop */
+ bitVectUnSetBit (lBlock->defSet, ic->key);
+ bitVectUnSetBit (lBlock->ldefs, ic->key);
+ ivar = newCseDef (IC_RESULT (ic), ic);
+ applyToSet (theLoop->regBlocks, addDefInExprs, ivar, ebbi);
+ addSet (&lInvars, ivar);
+ }
+ }
+ } /* for all loop blocks */
/* if we have some invariants then */
if (lInvars)
/* create an iCode chain from it */
for (cdp = setFirstItem (lInvars); cdp; cdp = setNextItem (lInvars))
- {
-
- /* maintain data flow .. add it to the */
- /* ldefs defSet & outExprs of the preheader */
- preHdr->defSet = bitVectSetBit (preHdr->defSet, cdp->diCode->key);
- preHdr->ldefs = bitVectSetBit (preHdr->ldefs, cdp->diCode->key);
- cdp->diCode->lineno = preHdr->ech->lineno;
- addSetHead (&preHdr->outExprs, cdp);
-
-
- if (!icFirst)
- icFirst = cdp->diCode;
- if (icLast)
- {
- icLast->next = cdp->diCode;
- cdp->diCode->prev = icLast;
- icLast = cdp->diCode;
- }
- else
- icLast = cdp->diCode;
- change++;
- }
+ {
+
+ /* maintain data flow .. add it to the */
+ /* ldefs defSet & outExprs of the preheader */
+ preHdr->defSet = bitVectSetBit (preHdr->defSet, cdp->diCode->key);
+ preHdr->ldefs = bitVectSetBit (preHdr->ldefs, cdp->diCode->key);
+ cdp->diCode->filename = preHdr->ech->filename;
+ cdp->diCode->lineno = preHdr->ech->lineno;
+ addSetHead (&preHdr->outExprs, cdp);
+
+
+ if (!icFirst)
+ icFirst = cdp->diCode;
+ if (icLast)
+ {
+ icLast->next = cdp->diCode;
+ cdp->diCode->prev = icLast;
+ icLast = cdp->diCode;
+ }
+ else
+ icLast = cdp->diCode;
+ change++;
+ }
/* add the instruction chain to the end of the
preheader for this loop, preheaders will always
ebp = loop->item;
loop2 = ebp->addrOf;
while (loop2)
- {
- if (isOperandEqual ((operand *) loop2->item, sym))
- return 1;
- loop2 = loop2->next;
- }
+ {
+ if (isOperandEqual ((operand *) loop2->item, sym))
+ return 1;
+ loop2 = loop2->next;
+ }
}
return 0;
/* if a definition for this exists */
if (bitVectBitsInCommon (lBlock->defSet, OP_DEFS (defOp)))
- {
- iCode *ic;
-
- /* go thru the instruction chain to find it */
- for (ic = lBlock->sch; ic; ic = ic->next)
- if (bitVectBitValue (OP_DEFS (defOp), ic->key))
- {
- if (owner)
- *owner = lBlock;
- return ic;
- }
- }
+ {
+ iCode *ic;
+
+ /* go thru the instruction chain to find it */
+ for (ic = lBlock->sch; ic; ic = ic->next)
+ if (bitVectBitValue (OP_DEFS (defOp), ic->key))
+ {
+ if (owner)
+ *owner = lBlock;
+ return ic;
+ }
+ }
}
return NULL;
bitVect *loopSuccs;
int i;
- /* if the number of exits is greater than one then
+ /* if the number of exits is greater than one then
we use another trick: we will create an intersection
of succesors of the exits, then take those that are not
part of the loop and have dfNumber greater loop entry (eblock),
/* and add it */
addiCodeToeBBlock (postLoopBlk, newic, NULL);
+ postLoopBlk->sch->filename =
+ postLoopBlk->ech->filename = eblock->sch->filename;
postLoopBlk->sch->lineno =
postLoopBlk->ech->lineno = eblock->sch->lineno;
/* for all instructions in the blocks do */
for (ic = lBlock->sch; ic; ic = ic->next)
- {
-
- operand *aSym;
- long litValue;
- induction *ip;
- iCode *indIc;
- eBBlock *owner = NULL;
- int nexits;
+ {
+
+ operand *aSym;
+ long litValue;
+ induction *ip;
+ iCode *indIc;
+ eBBlock *owner = NULL;
+ int nexits;
sym_link *optype;
- /* To find an induction variable, we need to */
+ /* To find an induction variable, we need to */
/* find within the loop three iCodes in this */
/* general form: */
/* */
/* */
/* (symbolVar may also be an iTemp if it is */
/* register equivalent) */
-
+
/* look for assignments of the form */
- /* symbolVar := iTempNN */
- if (ic->op != '=')
- continue;
+ /* symbolVar := iTempNN */
+ if (ic->op != '=')
+ continue;
- if (!IS_TRUE_SYMOP (IC_RESULT (ic)) &&
- !OP_SYMBOL (IC_RESULT (ic))->isreqv)
- continue;
+ if (!IS_TRUE_SYMOP (IC_RESULT (ic)) &&
+ !OP_SYMBOL (IC_RESULT (ic))->isreqv)
+ continue;
- if (isOperandGlobal (IC_RESULT (ic)))
- continue;
+ if (isOperandGlobal (IC_RESULT (ic)))
+ continue;
- if (!IS_ITEMP (IC_RIGHT (ic)))
- continue;
+ if (!IS_ITEMP (IC_RIGHT (ic)))
+ continue;
- /* if it has multiple assignments within the loop then skip */
- if (assignmentsToSym (loopReg->regBlocks, IC_RESULT (ic)) > 1)
- continue;
+ /* if it has multiple assignments within the loop then skip */
+ if (assignmentsToSym (loopReg->regBlocks, IC_RESULT (ic)) > 1)
+ continue;
- /* if the address of this was taken inside the loop then continue */
- if (addressTaken (loopReg->regBlocks, IC_RESULT (ic)))
- continue;
+ /* if the address of this was taken inside the loop then continue */
+ if (addressTaken (loopReg->regBlocks, IC_RESULT (ic)))
+ continue;
/* Only consider variables with integral type. */
/* (2004/12/06 - EEP - ds390 fails regression tests unless */
if (!IS_INTEGRAL (optype) && !IS_PTR (optype))
continue;
- /* find the definition for the result in the block */
- if (!(dic = findDefInRegion (setFromSet (loopReg->regBlocks),
- IC_RIGHT (ic), &owner)))
- continue;
-
- /* if not +/- continue */
- if (dic->op != '+' && dic->op != '-')
- continue;
-
- /* make sure definition is of the form a +/- c */
- if (!IS_OP_LITERAL (IC_LEFT (dic)) && !IS_OP_LITERAL (IC_RIGHT (dic)))
- continue;
-
+ /* find the definition for the result in the block */
+ if (!(dic = findDefInRegion (setFromSet (loopReg->regBlocks),
+ IC_RIGHT (ic), &owner)))
+ continue;
+
+ /* if not +/- continue */
+ if (dic->op != '+' && dic->op != '-')
+ continue;
+
+ /* make sure definition is of the form a +/- c */
+ if (!IS_OP_LITERAL (IC_LEFT (dic)) && !IS_OP_LITERAL (IC_RIGHT (dic)))
+ continue;
+
/* make sure the definition found is the only one */
if (assignmentsToSym (loopReg->regBlocks, IC_RIGHT (ic)) > 1)
- continue;
+ continue;
- if (IS_OP_LITERAL (IC_RIGHT (dic)))
+ if (IS_OP_LITERAL (IC_RIGHT (dic)))
{
aSym = IC_LEFT (dic);
litValue = (long) operandLitValue (IC_RIGHT (dic));
litValue = (long) operandLitValue (IC_LEFT (dic));
}
- if (!isOperandEqual (IC_RESULT (ic), aSym) &&
- !isOperandEqual (IC_RIGHT (ic), aSym))
- {
- iCode *ddic;
- /* find the definition for this and check */
- if (!(ddic = findDefInRegion (setFromSet (loopReg->regBlocks),
- aSym, &owner)))
- continue;
-
- if (ddic->op != '=')
- continue;
-
- if (!isOperandEqual (IC_RESULT (ddic), aSym) ||
- !isOperandEqual (IC_RIGHT (ddic), IC_RESULT (ic)))
- continue;
- }
-
- /* if the right hand side has more than one usage then
- don't make it an induction (will have to think some more) */
- if (bitVectnBitsOn (OP_USES (IC_RIGHT (ic))) > 1)
- continue;
-
- /* if the definition is volatile then it cannot be
- an induction object */
- if (isOperandVolatile (IC_RIGHT (ic), FALSE) ||
- isOperandVolatile (IC_RESULT (ic), FALSE))
- continue;
-
- /* whew !! that was a lot of work to find the definition */
- /* create an induction object */
- indIc = newiCode ('=', NULL, IC_RESULT (ic));
- indIc->lineno = ic->lineno;
- IC_RESULT (indIc) = operandFromOperand (IC_RIGHT (ic));
- IC_RESULT (indIc)->isaddr = 0;
- OP_SYMBOL (IC_RESULT (indIc))->isind = 1;
- ip = newInduction (IC_RIGHT (ic), dic->op, litValue, indIc, NULL);
-
- /* replace the inducted variable by the iTemp */
- replaceSymBySym (loopReg->regBlocks, IC_RESULT (ic), IC_RIGHT (ic));
+ if (!isOperandEqual (IC_RESULT (ic), aSym) &&
+ !isOperandEqual (IC_RIGHT (ic), aSym))
+ {
+ iCode *ddic;
+ /* find the definition for this and check */
+ if (!(ddic = findDefInRegion (setFromSet (loopReg->regBlocks),
+ aSym, &owner)))
+ continue;
+
+ if (ddic->op != '=')
+ continue;
+
+ if (!isOperandEqual (IC_RESULT (ddic), aSym) ||
+ !isOperandEqual (IC_RIGHT (ddic), IC_RESULT (ic)))
+ continue;
+ }
+
+ /* if the right hand side has more than one usage then
+ don't make it an induction (will have to think some more) */
+ if (bitVectnBitsOn (OP_USES (IC_RIGHT (ic))) > 1)
+ continue;
+
+ /* if the definition is volatile then it cannot be
+ an induction object */
+ if (isOperandVolatile (IC_RIGHT (ic), FALSE) ||
+ isOperandVolatile (IC_RESULT (ic), FALSE))
+ continue;
+
+ /* whew !! that was a lot of work to find the definition */
+ /* create an induction object */
+ indIc = newiCode ('=', NULL, IC_RESULT (ic));
+ indIc->filename = ic->filename;
+ indIc->lineno = ic->lineno;
+ IC_RESULT (indIc) = operandFromOperand (IC_RIGHT (ic));
+ IC_RESULT (indIc)->isaddr = 0;
+ OP_SYMBOL (IC_RESULT (indIc))->isind = 1;
+ ip = newInduction (IC_RIGHT (ic), dic->op, litValue, indIc, NULL);
+
+ /* replace the inducted variable by the iTemp */
+ replaceSymBySym (loopReg->regBlocks, IC_RESULT (ic), IC_RIGHT (ic));
/* ic should now be moved to the exit block(s) */
nexits = elementsInSet (loopReg->exits);
/* last block is the one with the highest block
number */
if (lastBlock->bbnum < lBlock->bbnum)
- lastBlock = lBlock;
+ lastBlock = lBlock;
for (ic = lBlock->sch; ic; ic = ic->next)
- {
- operand *aSym;
- long litVal;
+ {
+ operand *aSym;
+ long litVal;
- /* consider only * & / */
- if (ic->op != '*' && ic->op != '/')
- continue;
+ /* consider only * & / */
+ if (ic->op != '*' && ic->op != '/')
+ continue;
/* only consider variables with integral type */
if (!IS_INTEGRAL (operandType (IC_RESULT (ic))))
continue;
-
+
/* if the result has more definitions then */
- if (assignmentsToSym (loopReg->regBlocks, IC_RESULT (ic)) > 1)
- continue;
+ if (assignmentsToSym (loopReg->regBlocks, IC_RESULT (ic)) > 1)
+ continue;
- /* check if the operands are what we want */
- /* i.e. one of them an symbol the other a literal */
- if (!((IS_SYMOP (IC_LEFT (ic)) && IS_OP_LITERAL (IC_RIGHT (ic))) ||
- (IS_OP_LITERAL (IC_LEFT (ic)) && IS_SYMOP (IC_RIGHT (ic)))))
- continue;
+ /* check if the operands are what we want */
+ /* i.e. one of them an symbol the other a literal */
+ if (!((IS_SYMOP (IC_LEFT (ic)) && IS_OP_LITERAL (IC_RIGHT (ic))) ||
+ (IS_OP_LITERAL (IC_LEFT (ic)) && IS_SYMOP (IC_RIGHT (ic)))))
+ continue;
- if (IS_SYMOP (IC_LEFT (ic)))
+ if (IS_SYMOP (IC_LEFT (ic)))
{
aSym = IC_LEFT (ic);
litVal = (long) operandLitValue (IC_RIGHT (ic));
litVal = (long) operandLitValue (IC_LEFT (ic));
}
- ip = NULL;
- /* check if this is an induction variable */
- if (!applyToSetFTrue (basicInd, findInduction, aSym, &ip))
- continue;
-
- /* ask port for size not worth if native instruction
- exist for multiply & divide */
- if (getSize (operandType (IC_LEFT (ic))) <= (unsigned long) port->support.muldiv ||
- getSize (operandType (IC_RIGHT (ic))) <= (unsigned long) port->support.muldiv)
- continue;
-
- /* if this is a division then the remainder should be zero
- for it to be inducted */
- if (ic->op == '/' && (ip->cval % litVal))
- continue;
-
- /* create the iCode to be placed in the loop header */
- /* and create the induction object */
-
- /* create an instruction */
- /* this will be put on the loop header */
- indIc = newiCode (ic->op,
- operandFromOperand (aSym),
- operandFromLit (litVal));
- indIc->lineno = ic->lineno;
- IC_RESULT (indIc) = operandFromOperand (IC_RESULT (ic));
- OP_SYMBOL (IC_RESULT (indIc))->isind = 1;
-
- /* keep track of the inductions */
- litVal = (ic->op == '*' ? (litVal * ip->cval) :
- (ip->cval / litVal));
-
- addSet (&indVars,
- newInduction (IC_RESULT (ic), ip->op, litVal, indIc, NULL));
-
- /* Replace mul/div with assignment to self; killDeadCode() will */
+ ip = NULL;
+ /* check if this is an induction variable */
+ if (!applyToSetFTrue (basicInd, findInduction, aSym, &ip))
+ continue;
+
+ /* ask port for size not worth if native instruction
+ exist for multiply & divide */
+ if (getSize (operandType (IC_LEFT (ic))) <= (unsigned long) port->support.muldiv ||
+ getSize (operandType (IC_RIGHT (ic))) <= (unsigned long) port->support.muldiv)
+ continue;
+
+ /* if this is a division then the remainder should be zero
+ for it to be inducted */
+ if (ic->op == '/' && (ip->cval % litVal))
+ continue;
+
+ /* create the iCode to be placed in the loop header */
+ /* and create the induction object */
+
+ /* create an instruction */
+ /* this will be put on the loop header */
+ indIc = newiCode (ic->op,
+ operandFromOperand (aSym),
+ operandFromLit (litVal));
+ indIc->filename = ic->filename;
+ indIc->lineno = ic->lineno;
+ IC_RESULT (indIc) = operandFromOperand (IC_RESULT (ic));
+ OP_SYMBOL (IC_RESULT (indIc))->isind = 1;
+
+ /* keep track of the inductions */
+ litVal = (ic->op == '*' ? (litVal * ip->cval) :
+ (ip->cval / litVal));
+
+ addSet (&indVars,
+ newInduction (IC_RESULT (ic), ip->op, litVal, indIc, NULL));
+
+ /* Replace mul/div with assignment to self; killDeadCode() will */
/* clean this up since we can't use remiCodeFromeBBlock() here. */
ic->op = '=';
IC_LEFT (ic) = NULL;
operandFromOperand (IC_RESULT (ic)),
operandFromLit (litVal));
IC_RESULT (indIc) = operandFromOperand (IC_RESULT (ic));
- owner = NULL;
+ owner = NULL;
dic = findDefInRegion (setFromSet (loopReg->regBlocks), aSym, &owner);
assert (dic);
- addiCodeToeBBlock (owner, indIc, dic);
+ addiCodeToeBBlock (owner, indIc, dic);
- }
+ }
}
/* if we have some induction variables then */
/* create an iCode chain from it */
for (ip = setFirstItem (indVars);
- ip;
- ip = setNextItem (indVars))
- {
- indVect = bitVectSetBit (indVect, ip->ic->key);
- ip->ic->lineno = preHdr->ech->lineno;
- if (!icFirst)
- icFirst = ip->ic;
- if (icLast)
- {
- icLast->next = ip->ic;
- ip->ic->prev = icLast;
- icLast = ip->ic;
- }
- else
- icLast = ip->ic;
- change++;
- }
+ ip;
+ ip = setNextItem (indVars))
+ {
+ indVect = bitVectSetBit (indVect, ip->ic->key);
+ ip->ic->filename = preHdr->ech->filename;
+ ip->ic->lineno = preHdr->ech->lineno;
+ if (!icFirst)
+ icFirst = ip->ic;
+ if (icLast)
+ {
+ icLast->next = ip->ic;
+ ip->ic->prev = icLast;
+ icLast = ip->ic;
+ }
+ else
+ icLast = ip->ic;
+ change++;
+ }
/* add the instruction chain to the end of the */
/* preheader for this loop */
{
if (lp == theLoop)
- continue;
+ continue;
if (lp->entry == theLoop->entry)
- {
- theLoop->regBlocks = unionSets (theLoop->regBlocks,
- lp->regBlocks, THROW_DEST);
- lp->merged = 1;
- }
+ {
+ theLoop->regBlocks = unionSets (theLoop->regBlocks,
+ lp->regBlocks, THROW_DEST);
+ lp->merged = 1;
+ }
}
return 1;
{
if (lp == theLoop)
- continue;
+ continue;
if (isinSet (lp->regBlocks, theLoop->entry))
- {
- lp->containsLoops += theLoop->containsLoops + 1;
- if (lp->containsLoops > (*maxDepth))
- *maxDepth = lp->containsLoops;
-
- lp->regBlocks = unionSets (lp->regBlocks,
- theLoop->regBlocks, THROW_DEST);
- }
+ {
+ lp->containsLoops += theLoop->containsLoops + 1;
+ if (lp->containsLoops > (*maxDepth))
+ *maxDepth = lp->containsLoops;
+
+ lp->regBlocks = unionSets (lp->regBlocks,
+ theLoop->regBlocks, THROW_DEST);
+ }
}
return 1;
hTab *
createLoopRegions (ebbIndex * ebbi)
{
- set *allRegion = NULL; /* set of all loops */
+ set *allRegion = NULL; /* set of all loops */
hTab *orderedLoops = NULL;
set *bEdges = NULL;
int maxDepth = 0;
/* get all the back edges in the graph */
if (!applyToSet (graphEdges, backEdges, &bEdges))
- return 0; /* found no loops */
+ return 0; /* found no loops */
/* for each of these back edges get the blocks that */
/* constitute the loops */
for (lp = setFirstItem (allRegion); lp; lp = setNextItem (allRegion))
{
applyToSet (lp->regBlocks, addToExitsMarkDepth,
- lp->regBlocks, &lp->exits,
- (maxDepth - lp->containsLoops), lp);
+ lp->regBlocks, &lp->exits,
+ (maxDepth - lp->containsLoops), lp);
hTabAddItem (&orderedLoops, lp->containsLoops, lp);
{
if (optimize.loopInvariant)
- change += loopInvariants (lp, ebbi);
+ change += loopInvariants (lp, ebbi);
if (optimize.loopInduction)
- change += loopInduction (lp, ebbi);
+ change += loopInduction (lp, ebbi);
}
return change;
operand *left;
operand *right;
symbol *func = NULL;
+ char *filename = ic->filename;
int lineno = ic->lineno;
int bytesPushed=0;
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
if (IS_SYMOP (left))
OP_USES (left) = bitVectSetBit (OP_USES (left), newic->key);
IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type)->next);
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
if (IS_SYMOP (right))
OP_USES (right) = bitVectSetBit (OP_USES (right), newic->key);
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
if (IS_SYMOP (right))
OP_USES (right) = bitVectSetBit (OP_USES (right), newic->key);
bytesPushed += getSize(operandType(left));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
if (IS_SYMOP (left))
OP_USES (left) = bitVectSetBit (OP_USES (left), newic->key);
IC_RESULT (newic) = IC_RESULT (ic);
bitVectUnSetBit (OP_DEFS (IC_RESULT (ic)), ic->key);
OP_USES (IC_RESULT (newic)) = bitVectSetBit (OP_USES (IC_RESULT (newic)), newic->key);
+ newic->filename = filename;
newic->lineno = lineno;
newic->parmBytes += bytesPushed;
ebp->hasFcall = 1;
IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = linenno;
}
bytesPushed += getSize(operandType(IC_RIGHT(ic)));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = linenno;
-
}
/* make the call */
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = linenno;
}
IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = linenno;
}
bytesPushed += getSize(operandType(IC_RIGHT(ic)));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = linenno;
-
}
/* make the call */
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = linenno;
}
iCode *ip, *newic;
symbol *func = NULL;
sym_link *type = operandType (IC_LEFT (ic));
+ char *filename = ic->filename;
int lineno = ic->lineno;
int bwd, su;
int bytesPushed=0;
IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
}
bytesPushed += getSize(operandType(IC_RIGHT(ic)));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
}
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
}
iCode *ip, *newic;
symbol *func = NULL;
sym_link *type = operandType (IC_LEFT (ic));
+ char *filename = ic->filename;
int lineno = ic->lineno;
int bwd, su;
int bytesPushed=0;
IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
-
}
else
{
bytesPushed += getSize(operandType(IC_RIGHT(ic)));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
-
}
/* make the call */
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
}
symbol *func = NULL;
iCode *ip = ic->next;
iCode *newic;
+ char *filename = ic->filename;
int lineno = ic->lineno;
int bwd;
int su;
IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
/* second one */
IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type)->next);
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
}
bytesPushed += getSize(operandType(IC_RIGHT(ic)));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
/* insert push left */
bytesPushed += getSize(operandType(IC_LEFT(ic)));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
}
/* for the result */
newic = newiCode (CALL, operandFromSymbol (func), NULL);
IC_RESULT (newic) = IC_RESULT (ic);
+ newic->filename = filename;
newic->lineno = lineno;
newic->parmBytes+=bytesPushed; // to clear the stack after the call
ebp->hasFcall = 1;
nilist = Safe_alloc (sizeof (initList));
nilist->type = type;
- nilist->lineno = lexLineno;
nilist->filename = lexFilename;
+ nilist->lineno = lexLineno;
switch (type)
{
}
if(ival) {
- setAstLineno(ival, sym->lineDef);
+ setAstFileLine (ival, sym->fileDef, sym->lineDef);
codeOutBuf = &statsg->oBuf;
GcurMemmap = statsg;
eBBlockFromiCode (iCodeFromAst (ival));