+2004-04-24 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+ * src/SDCCpeeph.c (replaceRule): support empty replacement peephole
+ rules
+ * src/SDCCmain.c,
+ * src/SDCCglobl.h,
+ * src/SDCCpeeph.c (getPeepLine): new option --no-peep-comments omits
+ comments from the peephole optimizer replacement rules
+ * src/SDCCmem.c (printAllocInfoSeg): give actual location of spilled
+ symbols
+ * src/SDCCcse.c (updateSpillLocation),
+ * src/SDCCopt.c (killDeadCode, findReqv): better tracking of register
+ equivalents
+ * src/hc08/ralloc.c (regTypeNum): pseudo symbols must be in DATA only
+ * src/hc08/main.c (_hc08_finaliseOptions): made pointers to stack
+ objects far pointers
+
2004-04-23 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
* src/SDCCsymt.h: a missing part of my last change
if (!OP_SYMBOL(IC_RIGHT (ic))->noSpilLoc &&
!IS_VOLATILE (setype) &&
!IN_FARSPACE (SPEC_OCLS (setype)) &&
- !OTHERS_PARM (OP_SYMBOL (IC_RESULT (ic))))
+ !OTHERS_PARM (OP_SYMBOL (IC_RESULT (ic)))) {
SPIL_LOC (IC_RIGHT (ic)) =
SPIL_LOC (IC_RESULT (ic));
+ OP_SYMBOL (IC_RIGHT (ic))->prereqv =
+ OP_SYMBOL (IC_RESULT (ic))->prereqv;
+ }
}
/* special case for inductions */
if (induction &&
!OP_SYMBOL(IC_RESULT (ic))->noSpilLoc &&
!SPIL_LOC(IC_RESULT(ic))) {
SPIL_LOC (IC_RESULT (ic)) = SPIL_LOC (IC_RIGHT (ic));
+ OP_SYMBOL (IC_RESULT (ic))->prereqv =
+ OP_SYMBOL (IC_RIGHT (ic))->prereqv;
}
}
}
int noXinitOpt; /* don't optimize initialized xdata */
int noCcodeInAsm; /* hide c-code from asm */
int iCodeInAsm; /* show i-code in asm */
+ int noPeepComments; /* hide peephole optimizer comments */
int printSearchDirs; /* display the directories in the compiler's search path */
int vc_err_style; /* errors and warnings are compatible with Micro$oft visual studio */
int use_stdout; /* send errors to stdout instead of stderr */
#define OPTION_USE_STDOUT "--use-stdout"
#define OPTION_STACK_SIZE "--stack-size"
#define OPTION_PACK_IRAM "--pack-iram"
+#define OPTION_NO_PEEP_COMMENTS "--no-peep-comments"
static const OPTION
optionsTable[] = {
{ 0, OPTION_NO_XINIT_OPT, &options.noXinitOpt, "don't memcpy initialized xram from code"},
{ 0, OPTION_NO_CCODE_IN_ASM, &options.noCcodeInAsm, "don't include c-code as comments in the asm file"},
{ 0, OPTION_ICODE_IN_ASM, &options.iCodeInAsm, "include i-code as comments in the asm file"},
+ { 0, OPTION_NO_PEEP_COMMENTS, &options.noPeepComments, "don't include peephole optimizer comments"},
{ 0, OPTION_PRINT_SEARCH_DIRS, &options.printSearchDirs, "display the directories in the compiler's search path"},
{ 0, OPTION_MSVC_ERROR_STYLE, &options.vc_err_style, "messages are compatible with Micro$oft visual studio"},
{ 0, OPTION_USE_STDOUT, &options.use_stdout, "send errors to stdout instead of stderr"},
int i;
sym = OP_SYMBOL (sym->reqv);
- fprintf (of, "to registers ");
- for (i = 0; i < 4 && sym->regs[i]; i++)
- fprintf (of, "%s ", port->getRegName (sym->regs[i]));
- fprintf (of, "\n");
- continue;
+ if (!sym->isspilt || sym->remat)
+ {
+ fprintf (of, "to registers ");
+ for (i = 0; i < 4 && sym->regs[i]; i++)
+ fprintf (of, "%s ", port->getRegName (sym->regs[i]));
+ fprintf (of, "\n");
+ continue;
+ }
+ else
+ {
+ sym = sym->usl.spillLoc;
+ }
}
/* if on stack */
}
}
+/*-----------------------------------------------------------------*/
+/* findReqv - search for a register equivalent */
+/*-----------------------------------------------------------------*/
+operand *
+findReqv (symbol * prereqv, eBBlock ** ebbs, int count)
+{
+ int i;
+ iCode * ic;
+
+ /* for all blocks do */
+ for (i=0; i<count; i++)
+ {
+ /* for all instructions in the block do */
+ for (ic = ebbs[i]->sch; ic; ic = ic->next)
+ {
+ if (ic->op == IFX)
+ {
+ if (IS_ITEMP (IC_COND (ic))
+ && OP_SYMBOL (IC_COND (ic))->prereqv == prereqv)
+ return IC_COND (ic);
+ }
+ else if (ic->op == JUMPTABLE)
+ {
+ if (IS_ITEMP (IC_JTCOND (ic))
+ && OP_SYMBOL (IC_JTCOND (ic))->prereqv == prereqv)
+ return IC_JTCOND (ic);
+ }
+ else
+ {
+ if (IS_ITEMP (IC_LEFT (ic))
+ && OP_SYMBOL (IC_LEFT (ic))->prereqv == prereqv)
+ return IC_LEFT (ic);
+ if (IS_ITEMP (IC_RIGHT (ic))
+ && OP_SYMBOL (IC_RIGHT (ic))->prereqv == prereqv)
+ return IC_RIGHT (ic);
+ if (IS_ITEMP (IC_RESULT (ic))
+ && OP_SYMBOL (IC_RESULT (ic))->prereqv == prereqv)
+ return IC_RESULT (ic);
+ }
+ }
+ }
+
+ return NULL;
+}
+
/*-----------------------------------------------------------------*/
/* killDeadCode - eliminates dead assignments */
/*-----------------------------------------------------------------*/
/* and defset of the block */
bitVectUnSetBit (ebbs[i]->defSet, ic->key);
+ /* If this is the last of a register equivalent, */
+ /* look for a successor register equivalent. */
+ bitVectUnSetBit (OP_DEFS (IC_RESULT (ic)), ic->key);
+ if (IS_ITEMP (IC_RESULT (ic))
+ && OP_SYMBOL (IC_RESULT (ic))->isreqv
+ && bitVectIsZero (OP_DEFS (IC_RESULT (ic))))
+ {
+ symbol * resultsym = OP_SYMBOL (IC_RESULT (ic));
+ symbol * prereqv = resultsym->prereqv;
+
+ if (OP_SYMBOL (prereqv->reqv) == resultsym)
+ {
+ operand * newreqv;
+
+ IC_RESULT (ic) = NULL;
+ newreqv = findReqv (prereqv, ebbs, count);
+ if (newreqv)
+ {
+ prereqv->reqv = newreqv;
+ }
+ }
+ }
+
/* delete the result */
IC_RESULT (ic) = NULL;
{
char lines[MAX_PATTERN_LEN];
char *lp;
+ int isComment;
lineNode *currL = NULL;
char *bp = *bpp;
lp = lines;
while ((*bp != '\n' && *bp != '}') && *bp)
*lp++ = *bp++;
-
*lp = '\0';
- if (!currL)
- *head = currL = newLineNode (lines);
- else
- currL = connectLine (currL, newLineNode (lines));
-
+
lp = lines;
while (*lp && isspace(*lp))
lp++;
- if (*lp==';')
- currL->isComment = 1;
+ isComment = (*lp == ';');
+
+ if (!isComment || (isComment && !options.noPeepComments))
+ {
+ if (!currL)
+ *head = currL = newLineNode (lines);
+ else
+ currL = connectLine (currL, newLineNode (lines));
+ currL->isComment = isComment;
+ }
+
}
*bpp = bp;
lhead = comment;
}
- /* determine which iCodes the replacment lines relate to */
- reassociate_ic(*shead,stail,lhead,cl);
-
- /* now we need to connect / replace the original chain */
- /* if there is a prev then change it */
- if ((*shead)->prev)
+ if (lhead)
{
- (*shead)->prev->next = lhead;
- lhead->prev = (*shead)->prev;
+ /* determine which iCodes the replacment lines relate to */
+ reassociate_ic(*shead,stail,lhead,cl);
+
+ /* now we need to connect / replace the original chain */
+ /* if there is a prev then change it */
+ if ((*shead)->prev)
+ {
+ (*shead)->prev->next = lhead;
+ lhead->prev = (*shead)->prev;
+ }
+ *shead = lhead;
+ /* now for the tail */
+ if (stail && stail->next)
+ {
+ stail->next->prev = cl;
+ if (cl)
+ cl->next = stail->next;
+ }
}
- *shead = lhead;
- /* now for the tail */
- if (stail && stail->next)
+ else
{
- stail->next->prev = cl;
- if (cl)
- cl->next = stail->next;
+ /* the replacement is empty - delete the source lines */
+ if ((*shead)->prev)
+ (*shead)->prev->next = stail->next;
+ if (stail->next)
+ stail->next->prev = (*shead)->prev;
+ *shead = stail->next;
}
}
port->mem.default_globl_map = data;
}
+ istack->ptrType = FPOINTER;
}
static void
(ic = hTabItemWithKey (iCodehTab,
bitVectFirstBit (sym->defs))) &&
POINTER_GET (ic) &&
- !IS_BITVAR (sym->etype))
+ !IS_BITVAR (sym->etype) &&
+ (aggrToPtrDclType (operandType (IC_LEFT (ic)), FALSE) == POINTER))
{
-
if (ptrPseudoSymSafe (sym, ic))
{
ptrPseudoSymConvert (sym, ic, rematStr (OP_SYMBOL (IC_LEFT (ic))));