* src/SDCCicode.c (isiCodeInFunctionCall),
* src/avr/ralloc.c (selectSpil),
* src/pic/ralloc.c (selectSpil),
* src/pic16/ralloc.c (selectSpil),
* src/ds390/ralloc.c (selectSpil),
* src/hc08/ralloc.c (selectSpil),
* src/xa51/ralloc.c (selectSpil),
* src/mcs51/ralloc.c (selectSpil): Don't use remainSpil to spill to the
stack in the middle of a function call sequence (fixes bug #
1020268)
* src/SDCCicode.c (geniCodeJumpTable): fixed error in computing the
costs associated with the minimum switch case.
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3505
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2004-09-23 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+ * src/SDCCicode.h,
+ * src/SDCCicode.c (isiCodeInFunctionCall),
+ * src/avr/ralloc.c (selectSpil),
+ * src/pic/ralloc.c (selectSpil),
+ * src/pic16/ralloc.c (selectSpil),
+ * src/ds390/ralloc.c (selectSpil),
+ * src/hc08/ralloc.c (selectSpil),
+ * src/xa51/ralloc.c (selectSpil),
+ * src/mcs51/ralloc.c (selectSpil): Don't use remainSpil to spill to the
+ stack in the middle of a function call sequence (fixes bug #1020268)
+ * src/SDCCicode.c (geniCodeJumpTable): fixed error in computing the
+ costs associated with the minimum switch case.
+
2004-09-19 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
* src/SDCC.lex: fixed bug #1030549
if (ic->op == SEND || ic->op == RECEIVE) {
fprintf(of,"{argreg = %d}",ic->argreg);
}
+ if (ic->op == IPUSH) {
+ fprintf(of,"{parmPush = %d}",ic->parmPush);
+ }
fprintf (of, "\n");
}
return IN_FARSPACE (oclass);
}
+/*-----------------------------------------------------------------*/
+/* isiCodeInFunctionCall - return TRUE if an iCode is between a */
+/* CALL/PCALL and the first IPUSH/SEND associated with the call */
+/*-----------------------------------------------------------------*/
+int
+isiCodeInFunctionCall (iCode * ic)
+{
+ iCode * lic = ic;
+
+ /* Find the next CALL/PCALL */
+ while (lic)
+ {
+ if (lic->op == CALL || lic->op == PCALL)
+ break;
+ lic = lic->next;
+ }
+
+ if (!lic)
+ return FALSE;
+
+ /* A function call was found. Scan backwards and see if an */
+ /* IPUSH or SEND is encountered */
+ while (ic)
+ {
+ if (lic != ic && (ic->op == CALL || ic->op == PCALL))
+ return FALSE;
+ if (ic->op == SEND || (ic->op == IPUSH && ic->parmPush))
+ return TRUE;
+ ic = ic->prev;
+ }
+
+ return FALSE;
+}
+
/*-----------------------------------------------------------------*/
/* operandLitValue - literal value of an operand */
/*-----------------------------------------------------------------*/
int needRangeCheck = !optimize.noJTabBoundary
|| tree->values.switchVals.swDefault;
sym_link *cetype = getSpec (operandType (cond));
- int sizeofMinCost, sizeofMaxCost;
+ int sizeofMinCost, sizeofZeroMinCost, sizeofMaxCost;
int sizeofMatchJump, sizeofJumpTable;
int sizeIndex;
/* Compute the size cost of the range check and subtraction. */
sizeofMinCost = 0;
+ sizeofZeroMinCost = 0;
sizeofMaxCost = 0;
if (needRangeCheck)
{
if (!(min==0 && IS_UNSIGNED (cetype)))
sizeofMinCost = port->jumptableCost.sizeofRangeCompare[sizeIndex];
+ if (!IS_UNSIGNED (cetype))
+ sizeofZeroMinCost = port->jumptableCost.sizeofRangeCompare[sizeIndex];
sizeofMaxCost = port->jumptableCost.sizeofRangeCompare[sizeIndex];
}
if (min)
/* If the size cost of handling a non-zero minimum exceeds the */
/* cost of extending the range down to zero, then it might be */
/* better to extend the range to zero. */
- if (min > 0 && sizeofMinCost >= (min * port->jumptableCost.sizeofElement))
+ if (min > 0 && (sizeofMinCost-sizeofZeroMinCost)
+ >= (min * port->jumptableCost.sizeofElement))
{
/* Only extend the jump table if it would still be manageable. */
if (1 + max <= port->jumptableCost.maxCount)
- min = 0;
+ {
+ min = 0;
+ if (IS_UNSIGNED (cetype))
+ sizeofMinCost = 0;
+ else
+ sizeofMinCost = port->jumptableCost.sizeofRangeCompare[sizeIndex];
+ }
}
/* Compute the total size cost of a jump table. */
/* Compute the total size cost of a match & jump sequence */
sizeofMatchJump = cnt * port->jumptableCost.sizeofMatchJump[sizeIndex];
-
+
/* If the size cost of the jump table is uneconomical then exit */
if (sizeofMatchJump < sizeofJumpTable)
return 0;
iCode *copyiCode (iCode *);
operand *newiTempFromOp (operand *);
iCode *getBuiltinParms (iCode *,int *, operand **);
+int isiCodeInFunctionCall (iCode *);
/*-----------------------------------------------------------------*/
/* declaration of exported variables */
/*-----------------------------------------------------------------*/
/* check if there are any live ranges that not
used in the remainder of the block */
if (!_G.blockSpil &&
- (selectS =
+ !isiCodeInFunctionCall (ic) &&
+ (selectS =
liveRangesWith (lrcs, notUsedInRemaining, ebp, ic))) {
sym = leastUsedLR (selectS);
if (sym != forSym) {
/* check if there are any live ranges that not
used in the remainder of the block */
- if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+ if (!_G.blockSpil &&
+ !isiCodeInFunctionCall (ic) &&
+ (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
{
sym = leastUsedLR (selectS);
if (sym != forSym)
/* check if there are any live ranges that not
used in the remainder of the block */
- if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+ if (!_G.blockSpil &&
+ !isiCodeInFunctionCall (ic) &&
+ (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
{
sym = leastUsedLR (selectS);
if (sym != forSym)
return;
}
+
+
/*-----------------------------------------------------------------*/
/* selectSpil - select a iTemp to spil : rather a simple procedure */
/*-----------------------------------------------------------------*/
/* check if there are any live ranges that not
used in the remainder of the block */
- if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+ if (!_G.blockSpil &&
+ !isiCodeInFunctionCall (ic) &&
+ (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
{
sym = leastUsedLR (selectS);
if (sym != forSym)
/* check if there are any live ranges that not
used in the remainder of the block */
- if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+ if (!_G.blockSpil &&
+ !isiCodeInFunctionCall (ic) &&
+ (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
{
sym = leastUsedLR (selectS);
if (!sym->remat)
/* check if there are any live ranges that not
used in the remainder of the block */
- if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+ if (!_G.blockSpil &&
+ !isiCodeInFunctionCall (ic) &&
+ (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
{
sym = leastUsedLR (selectS);
if (!sym->remat)
/* check if there are any live ranges that not
used in the remainder of the block */
- if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+ if (!_G.blockSpil &&
+ !isiCodeInFunctionCall (ic) &&
+ (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
{
sym = leastUsedLR (selectS);
if (sym != forSym)