operand *left;
operand *right;
symbol *func = NULL;
+ char *filename = ic->filename;
int lineno = ic->lineno;
int bytesPushed=0;
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
- if(IS_FLOAT(operandType( IC_RIGHT( ic ) ))) {
+ if (IS_SYMOP (left))
+ bitVectUnSetBit (OP_USES (left), ic->key);
+ if (IS_SYMOP (right))
+ bitVectUnSetBit (OP_USES (right), ic->key);
+
+ if (IS_FLOAT (operandType (right))) {
switch (ic->op)
{
case '+':
break;
}
} else
- if(IS_FIXED16X16 (operandType (IC_RIGHT(ic)))) {
+ if (IS_FIXED16X16 (operandType (right))) {
switch (ic->op)
{
case '+':
break;
}
}
-
+
/* if float support routines NOT compiled as reentrant */
if (!options.float_rent)
/* first one */
if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
{
- newic = newiCode (SEND, IC_LEFT (ic), NULL);
+ newic = newiCode (SEND, left, NULL);
newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
}
else
{
- newic = newiCode ('=', NULL, IC_LEFT (ic));
+ newic = newiCode ('=', NULL, left);
IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
+ if (IS_SYMOP (left))
+ OP_USES (left) = bitVectSetBit (OP_USES (left), newic->key);
/* second one */
if (IS_REGPARM (FUNC_ARGS(func->type)->next->etype))
{
- newic = newiCode (SEND, IC_RIGHT (ic), NULL);
+ newic = newiCode (SEND, right, NULL);
newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->next->etype);
}
else
{
- newic = newiCode ('=', NULL, IC_RIGHT (ic));
+ newic = newiCode ('=', NULL, right);
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);
}
else
{
newic = newiCode (IPUSH, right, NULL);
newic->parmPush = 1;
- //bytesPushed+=4;
bytesPushed += getSize(operandType(right));
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
+ if (IS_SYMOP (right))
+ OP_USES (right) = bitVectSetBit (OP_USES (right), newic->key);
/* insert push left */
if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
{
newic = newiCode (IPUSH, left, NULL);
newic->parmPush = 1;
- //bytesPushed+=4;
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);
+
}
/* insert the call */
newic = newiCode (CALL, operandFromSymbol (func), NULL);
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;
+ newic->parmBytes += bytesPushed;
ebp->hasFcall = 1;
if (currFunc)
FUNC_HASFCALL (currFunc->type) = 1;
- if(TARGET_IS_PIC16) {
+ if(TARGET_IS_PIC16 || TARGET_IS_PIC) {
/* normally these functions aren't marked external, so we can use their
* _extern field to marked as already added to symbol table */
if(!SPEC_EXTR(func->etype)) {
memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
- SPEC_EXTR(func->etype) = 1;
- seg = SPEC_OCLS( func->etype );
- addSet(&seg->syms, func);
+ SPEC_EXTR(func->etype) = 1;
+ seg = SPEC_OCLS( func->etype );
+ addSet(&seg->syms, func);
}
}
if (!options.float_rent)
{
/* first one */
- if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
{
newic = newiCode (SEND, IC_RIGHT (ic), NULL);
newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
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 */
if (currFunc)
FUNC_HASFCALL (currFunc->type) = 1;
- if(TARGET_IS_PIC16) {
- /* normally these functions aren't marked external, so we can use their
- * _extern field to marked as already added to symbol table */
-
- if(!SPEC_EXTR(func->etype)) {
- memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
-
- SPEC_EXTR(func->etype) = 1;
- seg = SPEC_OCLS( func->etype );
- addSet(&seg->syms, func);
- }
+ if(TARGET_IS_PIC16 || TARGET_IS_PIC) {
+ /* normally these functions aren't marked external, so we can use their
+ * _extern field to marked as already added to symbol table */
+
+ if(!SPEC_EXTR(func->etype)) {
+ memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
+
+ SPEC_EXTR(func->etype) = 1;
+ seg = SPEC_OCLS( func->etype );
+ addSet(&seg->syms, func);
+ }
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = linenno;
}
/*----------------------------------------------------------------------*/
/* cnvToFixed16x16Cast - converts casts to fixed16x16 to function calls */
/*----------------------------------------------------------------------*/
-static void
+static void
cnvToFixed16x16Cast (iCode * ic, eBBlock * ebp)
{
iCode *ip, *newic;
for (bwd = 0; bwd < 3; bwd++)
{
for (su = 0; su < 2; su++)
- {
- if (compareType (type, __multypes[bwd][su]) == 1)
- {
- func = __fp16x16conv[0][bwd][su];
- goto found;
- }
- }
+ {
+ if (compareType (type, __multypes[bwd][su]) == 1)
+ {
+ func = __fp16x16conv[0][bwd][su];
+ goto found;
+ }
+ }
}
assert (0);
found:
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 */
if (currFunc)
FUNC_HASFCALL (currFunc->type) = 1;
- if(TARGET_IS_PIC16) {
+ if(TARGET_IS_PIC16 || TARGET_IS_PIC) {
/* normally these functions aren't marked external, so we can use their
* _extern field to marked as already added to symbol table */
}
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;
}
if (currFunc)
FUNC_HASFCALL (currFunc->type) = 1;
- if(TARGET_IS_PIC16) {
+ if(TARGET_IS_PIC16 || TARGET_IS_PIC) {
/* normally these functions aren't marked external, so we can use their
* _extern field to marked as already added to symbol table */
}
addiCodeToeBBlock (ebp, newic, ip);
+ newic->filename = filename;
newic->lineno = lineno;
}
/*--------------------------------------------------------------------------*/
/* cnvFromFixed16x16Cast - converts casts from fixed16x16 to function calls */
/*--------------------------------------------------------------------------*/
-static void
+static void
cnvFromFixed16x16Cast (iCode * ic, eBBlock * ebp)
{
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;
}
}
}
-
+
if (compareType (type, floatType) == 1)
{
func = __fp16x16conv[1][3][0];
goto found;
}
-
+
assert (0);
found:
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 */
if (currFunc)
FUNC_HASFCALL (currFunc->type) = 1;
- if(TARGET_IS_PIC16) {
- /* normally these functions aren't marked external, so we can use their
- * _extern field to marked as already added to symbol table */
-
- if(!SPEC_EXTR(func->etype)) {
- memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
-
- SPEC_EXTR(func->etype) = 1;
- seg = SPEC_OCLS( func->etype );
- addSet(&seg->syms, func);
- }
+ if(TARGET_IS_PIC16 || TARGET_IS_PIC) {
+ /* normally these functions aren't marked external, so we can use their
+ * _extern field to marked as already added to symbol table */
+
+ if(!SPEC_EXTR(func->etype)) {
+ memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
+
+ SPEC_EXTR(func->etype) = 1;
+ seg = SPEC_OCLS( func->etype );
+ addSet(&seg->syms, func);
+ }
}
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;
if (currFunc)
FUNC_HASFCALL (currFunc->type) = 1;
- if(TARGET_IS_PIC16) {
+ if(TARGET_IS_PIC || TARGET_IS_PIC16) {
/* normally these functions aren't marked external, so we can use their
* _extern field to marked as already added to symbol table */
converted to function calls */
if ((IS_CONDITIONAL (ic) ||
IS_ARITHMETIC_OP (ic)) &&
- (IS_FLOAT (operandType (IC_RIGHT (ic)))
- || IS_FIXED( operandType (IC_RIGHT (ic)))))
+ (IS_FLOAT (operandType (IC_RIGHT (ic))) ||
+ IS_FIXED( operandType (IC_RIGHT (ic)))))
{
-
cnvToFcall (ic, ebbs[i]);
}
cnvFromFloatCast (ic, ebbs[i]);
else if (IS_FLOAT (operandType (IC_LEFT (ic))))
cnvToFloatCast (ic, ebbs[i]);
- if (IS_FIXED16X16 (operandType (IC_RIGHT (ic))))
- cnvFromFixed16x16Cast (ic, ebbs[i]);
- else if (IS_FIXED16X16 (operandType (IC_LEFT (ic))))
- cnvToFixed16x16Cast (ic, ebbs[i]);
+ if (IS_FIXED16X16 (operandType (IC_RIGHT (ic))))
+ cnvFromFixed16x16Cast (ic, ebbs[i]);
+ else if (IS_FIXED16X16 (operandType (IC_LEFT (ic))))
+ cnvToFixed16x16Cast (ic, ebbs[i]);
}
// Easy special case which avoids function call: modulo by a literal power
if (ic->op == '%' && isOperandLiteral(IC_RIGHT(ic)) &&
IS_UNSIGNED(operandType(IC_LEFT(ic))))
{
- unsigned litVal = fabs(operandLitValue(IC_RIGHT(ic)));
+ unsigned litVal = abs((unsigned) double2ul (operandLitValue(IC_RIGHT(ic))));
/* modulo by 1: no remainder */
if (litVal == 1)
symbol * resultsym = OP_SYMBOL (IC_RESULT (ic));
symbol * prereqv = resultsym->prereqv;
- if (prereqv && prereqv->reqv && (OP_SYMBOL (prereqv->reqv) == resultsym))
+ if (prereqv && prereqv->reqv && (OP_SYMBOL (prereqv->reqv) == resultsym))
{
operand * newreqv;
} /* end of all instructions */
if (!ebbs[i]->sch && !ebbs[i]->noPath)
- disconBBlock (ebbs[i], ebbi);
+ disconBBlock (ebbs[i], ebbi);
} /* end of for all blocks */
/* replace the local variables with their
register equivalents : the liveRange computation
- along with the register allocation will determine
+ along with the register allocation will determine
if it finally stays in the registers */
replaceRegEqv (ebbi);
{
change += cseAllBlocks (ebbi, FALSE);
if (options.dump_gcse)
- dumpEbbsToFileExt (DUMP_GCSE, ebbi);
+ dumpEbbsToFileExt (DUMP_GCSE, ebbi);
}
else
{
computeDataFlow (ebbi);
change += cseAllBlocks (ebbi, FALSE);
if (options.dump_loop)
- dumpEbbsToFileExt (DUMP_LOOPG, ebbi);
+ dumpEbbsToFileExt (DUMP_LOOPG, ebbi);
/* if loop optimizations caused a change then do
dead code elimination once more : this will
killDeadCode (ebbi);
if (options.dump_loop)
- dumpEbbsToFileExt (DUMP_LOOPD, ebbi);
+ dumpEbbsToFileExt (DUMP_LOOPD, ebbi);
}
&& !FUNC_ISNAKED(currFunc->type)) {
eBBlock *bp;
// make sure all predecessors of the last block end in a return
- for (bp=setFirstItem(ebbi->bbOrder[ebbi->count-1]->predList);
+ for (bp=setFirstItem(ebbi->bbOrder[ebbi->count-1]->predList);
bp;
- bp=setNextItem(ebbi->bbOrder[ebbi->count-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);
/* convert operations with support routines
written in C to function calls : I am doing
this at this point since I want all the
- operations to be as they are for optimzations */
+ operations to be as they are for optimizations */
convertToFcall (ebbi->bbOrder, ebbi->count);
/* compute the live ranges */
- computeLiveRanges (ebbi->bbOrder, ebbi->count);
+ computeLiveRanges (ebbi->bbOrder, ebbi->count, TRUE);
if (options.dump_range)
dumpEbbsToFileExt (DUMP_RANGE, ebbi);