+2004-02-09 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+ * src/SDCCsymt.h,
+ * src/SDCCicode.c (operandFromSymbol),
+ * src/mcs51/ralloc.c (verifyRegsAssigned, serialRegAssign),
+ * src/ds390/ralloc.c (verifyRegsAssigned, serialRegAssign),
+ * src/z80/ralloc.c (verifyRegsAssigned, serialRegAssign),
+ * src/hc08/ralloc.c (verifyRegsAssigned, serialRegAssign),
+ * src/pic/ralloc.c (verifyRegsAssigned, serialRegAssign),
+ * src/pic16/ralloc.c (verifyRegsAssigned, serialRegAssign): fixed
+ bug #892038
+ * src/SDCCast.c (createIvalStruct, createIvalArray, gatherAutoInit),
+ * src/SDCCglue.c (emitRegularMap, printIvalStruct, printIvalArray,
+ printIvalCharPtr, printIvalPtr, printIval, emitStaticSeg, emitOverlay)
+ * src/SDCCsymt.c (newSymbol),
+ * src/SDCC.y (struct_or_union_specifier, enum_specifier,
+ enumerator_list),
+ * src/SDCCval.h,
+ * src/SDCCval.c (newiList): fixed bug #885705
+
2004-02-08 Jesus Calvino-Fraga <jesusc AT ece.ubc.ca>
* doc/sdccman.lyx: added section 3.1.4: sdcclib.
// check for errors in structure members
for (sym=$5; sym; sym=sym->next) {
if (IS_ABSOLUTE(sym->etype)) {
- werrorfl(filename, sym->lineDef, E_NOT_ALLOWED, "'at'");
+ werrorfl(sym->fileDef, sym->lineDef, E_NOT_ALLOWED, "'at'");
SPEC_ABSA(sym->etype) = 0;
}
if (IS_SPEC(sym->etype) && SPEC_SCLS(sym->etype)) {
- werrorfl(filename, sym->lineDef, E_NOT_ALLOWED, "storage class");
+ werrorfl(sym->fileDef, sym->lineDef, E_NOT_ALLOWED, "storage class");
printTypeChainRaw (sym->type,NULL);
SPEC_SCLS(sym->etype) = 0;
}
for (dsym=sym->next; dsym; dsym=dsym->next) {
if (strcmp(sym->name, dsym->name)==0) {
- werrorfl(filename, sym->lineDef, E_DUPLICATE_MEMBER,
+ werrorfl(sym->fileDef, sym->lineDef, E_DUPLICATE_MEMBER,
$1==STRUCT ? "struct" : "union", sym->name);
}
}
csym=findSym(enumTab,$2,$2->name);
if ((csym && csym->level == $2->level))
- werrorfl(filename, $2->lineDef, E_DUPLICATE_TYPEDEF,csym->name);
+ werrorfl($2->fileDef, $2->lineDef, E_DUPLICATE_TYPEDEF,csym->name);
enumtype = newEnumType ($4); //copyLinkChain(cenum->type);
SPEC_SCLS(getSpec(enumtype)) = 0;
for (dsym=$1; dsym; dsym=dsym->next)
{
if (strcmp($3->name, dsym->name)==0)
- werrorfl(filename, $3->lineDef, E_DUPLICATE_MEMBER, "enum", $3->name);
+ werrorfl($3->fileDef, $3->lineDef, E_DUPLICATE_MEMBER, "enum", $3->name);
}
$3->next = $1 ;
}
if (iloop) {
- werrorfl (filename, sym->opval.val->sym->lineDef,
+ werrorfl (sym->opval.val->sym->fileDef, sym->opval.val->sym->lineDef,
W_EXCESS_INITIALIZERS, "struct",
sym->opval.val->sym->name);
}
// Array size was specified, and we have more initializers than needed.
char *name=sym->opval.val->sym->name;
int lineno=sym->opval.val->sym->lineDef;
+ char *filename=sym->opval.val->sym->fileDef;
werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name);
}
// there has to be a better way
char *name=sym->opval.val->sym->name;
int lineno=sym->opval.val->sym->lineDef;
+ char *filename=sym->opval.val->sym->fileDef;
werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name);
break;
work = initAggregates (sym, sym->ival, NULL);
} else {
if (getNelements(sym->type, sym->ival)>1) {
- werrorfl (filename, sym->lineDef,
+ werrorfl (sym->fileDef, sym->lineDef,
W_EXCESS_INITIALIZERS, "scalar",
sym->name);
}
work = initAggregates (sym, sym->ival, NULL);
} else {
if (getNelements(sym->type, sym->ival)>1) {
- werrorfl (filename, sym->lineDef,
+ werrorfl (sym->fileDef, sym->lineDef,
W_EXCESS_INITIALIZERS, "scalar",
sym->name);
}
ival = initAggregates (sym, sym->ival, NULL);
} else {
if (getNelements(sym->type, sym->ival)>1) {
- werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar",
+ werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar",
sym->name);
}
ival = newNode ('=', newAst_VALUE (symbolVal (sym)),
else {
int size = getSize (sym->type);
if (size==0) {
- werrorfl (filename, sym->lineDef, E_UNKNOWN_SIZE, sym->name);
+ werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE, sym->name);
}
/* allocate space */
if (options.debug) {
sflds = SPEC_STRUCT (type)->fields;
if (ilist->type != INIT_DEEP) {
- werrorfl (filename, sym->lineDef, E_INIT_STRUCT, sym->name);
+ werrorfl (sym->fileDef, sym->lineDef, E_INIT_STRUCT, sym->name);
return;
}
}
}
if (iloop) {
- werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "struct", sym->name);
+ werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "struct", sym->name);
}
return;
}
/* by a string */
if (IS_CHAR (type->next)) {
if (!IS_LITERAL(list2val(ilist)->etype)) {
- werrorfl (filename, ilist->lineno, E_CONST_EXPECTED);
+ werrorfl (ilist->filename, ilist->lineno, E_CONST_EXPECTED);
return;
}
if (printIvalChar (type,
/* not the special case */
if (ilist->type != INIT_DEEP)
{
- werrorfl (filename, ilist->lineno, E_INIT_STRUCT, sym->name);
+ werrorfl (ilist->filename, ilist->lineno, E_INIT_STRUCT, sym->name);
return;
}
printIval (sym, type->next, iloop, oFile);
if (++size > DCL_ELEM(type)) {
- werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "array", sym->name);
+ werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "array", sym->name);
break;
}
}
if (IS_LITERAL(val->etype)) {
if (compareType(type,val->etype)==0) {
- werrorfl (filename, ilist->lineno, E_INCOMPAT_TYPES);
+ werrorfl (ilist->filename, ilist->lineno, E_INCOMPAT_TYPES);
printFromToType (val->type, type);
}
printIvalCharPtr (NULL, type, val, oFile);
case 3:
if (IS_GENPTR(type) && floatFromVal(val)!=0) {
// non-zero mcs51 generic pointer
- werrorfl (filename, sym->lineDef, E_LITERAL_GENERIC);
+ werrorfl (sym->fileDef, sym->lineDef, E_LITERAL_GENERIC);
}
if (port->little_endian) {
fprintf (oFile, "\t.byte %s,%s,%s\n",
case 4:
if (IS_GENPTR(type) && floatFromVal(val)!=0) {
// non-zero ds390 generic pointer
- werrorfl (filename, sym->lineDef, E_LITERAL_GENERIC);
+ werrorfl (sym->fileDef, sym->lineDef, E_LITERAL_GENERIC);
}
if (port->little_endian) {
fprintf (oFile, "\t.byte %s,%s,%s,%s\n",
/* check the type */
if (compareType (type, val->type) == 0) {
- werrorfl (filename, ilist->lineno, W_INIT_WRONG);
+ werrorfl (ilist->filename, ilist->lineno, W_INIT_WRONG);
printFromToType (val->type, type);
}
if (ilist->type!=INIT_NODE) {
// or a 1-element list
if (ilist->init.deep->next) {
- werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar",
+ werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar",
sym->name);
} else {
ilist=ilist->init.deep;
IS_PTR(type) && DCL_TYPE(type)==CPOINTER) {
// no sweat
} else {
- werrorfl (filename, ilist->lineno, E_TYPE_MISMATCH, "assignment", " ");
+ werrorfl (ilist->filename, ilist->lineno, E_TYPE_MISMATCH, "assignment", " ");
printFromToType(itype, type);
}
}
int size = getSize (sym->type);
if (size==0) {
- werrorfl (filename, sym->lineDef, E_UNKNOWN_SIZE,sym->name);
+ werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE,sym->name);
}
fprintf (out, "%s:\n", sym->rname);
/* special case for character strings */
int size = getSize(sym->type);
if (size==0) {
- werrorfl (filename, sym->lineDef, E_UNKNOWN_SIZE);
+ werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE);
}
if (options.debug)
fprintf (afile, "==.\n");
and before liveRange calculation */
sym->reqv = newiTempOperand (sym->type, 0);
sym->reqv->key = sym->key;
+ OP_SYMBOL (sym->reqv)->prereqv = sym;
OP_SYMBOL (sym->reqv)->key = sym->key;
OP_SYMBOL (sym->reqv)->isreqv = 1;
OP_SYMBOL (sym->reqv)->islocal = 1;
sym->level = scope; /* set the level */
sym->block = currBlockno;
sym->lineDef = mylineno; /* set the line number */
+ sym->fileDef = currFname;
return sym;
}
struct iCode *fuse; /* furthest use */
struct iCode *rematiCode; /* rematerialse with which instruction */
struct operand *reqv; /* register equivalent of a local variable */
+ struct symbol *prereqv; /* symbol before register equiv. substituion */
union
{
struct symbol *spillLoc; /* register spil location */
unsigned offset; /* offset from top if struct */
int lineDef; /* defined line number */
+ char *fileDef; /* defined filename */
int lastLine; /* for functions the last line */
struct sym_link *type; /* 1st link to declator chain */
struct sym_link *etype; /* last link to declarator chn */
nilist->type = type;
nilist->lineno = mylineno;
+ nilist->filename = currFname;
switch (type)
{
{
int type;
int lineno;
+ char *filename;
union
{
struct ast *node;
}
}
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get */
+/* the operand in a valid state. */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+ symbol * sym;
+
+ if (!op) return;
+ if (!IS_ITEMP (op)) return;
+
+ sym = OP_SYMBOL (op);
+ if (sym->isspilt) return;
+ if (!sym->nRegs) return;
+ if (sym->regs[0]) return;
+
+ werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
+ sym->prereqv ? sym->prereqv->name : sym->name);
+ spillThis (sym);
+}
+
+
/*-----------------------------------------------------------------*/
/* serialRegAssign - serially allocate registers to the variables */
/*-----------------------------------------------------------------*/
}
reassignUnusedLRs(unusedLRs);
}
+
+ /* Check for and fix any problems with uninitialized operands */
+ for (i = 0; i < count; i++)
+ {
+ iCode *ic;
+
+ if (ebbs[i]->noPath &&
+ (ebbs[i]->entryLabel != entryLabel &&
+ ebbs[i]->entryLabel != returnLabel))
+ continue;
+
+ for (ic = ebbs[i]->sch; ic; ic = ic->next)
+ {
+ if (SKIP_IC2 (ic))
+ continue;
+
+ if (ic->op == IFX)
+ {
+ verifyRegsAssigned (IC_COND (ic), ic);
+ continue;
+ }
+
+ if (ic->op == JUMPTABLE)
+ {
+ verifyRegsAssigned (IC_JTCOND (ic), ic);
+ continue;
+ }
+
+ verifyRegsAssigned (IC_RESULT (ic), ic);
+ verifyRegsAssigned (IC_LEFT (ic), ic);
+ verifyRegsAssigned (IC_RIGHT (ic), ic);
+ }
+ }
+
}
/*-----------------------------------------------------------------*/
return change;
}
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get */
+/* the operand in a valid state. */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+ symbol * sym;
+
+ if (!op) return;
+ if (!IS_ITEMP (op)) return;
+
+ sym = OP_SYMBOL (op);
+ if (sym->isspilt) return;
+ if (!sym->nRegs) return;
+ if (sym->regs[0]) return;
+
+ werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
+ sym->prereqv ? sym->prereqv->name : sym->name);
+ spillThis (sym);
+}
+
+
+
/*-----------------------------------------------------------------*/
/* serialRegAssign - serially allocate registers to the variables */
/*-----------------------------------------------------------------*/
}
}
}
+
+ /* Check for and fix any problems with uninitialized operands */
+ for (i = 0; i < count; i++)
+ {
+ iCode *ic;
+
+ if (ebbs[i]->noPath &&
+ (ebbs[i]->entryLabel != entryLabel &&
+ ebbs[i]->entryLabel != returnLabel))
+ continue;
+
+ for (ic = ebbs[i]->sch; ic; ic = ic->next)
+ {
+ if (SKIP_IC2 (ic))
+ continue;
+
+ if (ic->op == IFX)
+ {
+ verifyRegsAssigned (IC_COND (ic), ic);
+ continue;
+ }
+
+ if (ic->op == JUMPTABLE)
+ {
+ verifyRegsAssigned (IC_JTCOND (ic), ic);
+ continue;
+ }
+
+ verifyRegsAssigned (IC_RESULT (ic), ic);
+ verifyRegsAssigned (IC_LEFT (ic), ic);
+ verifyRegsAssigned (IC_RIGHT (ic), ic);
+ }
+ }
+
}
/*-----------------------------------------------------------------*/
return change;
}
+
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get */
+/* the operand in a valid state. */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+ symbol * sym;
+
+ if (!op) return;
+ if (!IS_ITEMP (op)) return;
+
+ sym = OP_SYMBOL (op);
+ if (sym->isspilt) return;
+ if (!sym->nRegs) return;
+ if (sym->regs[0]) return;
+
+ werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
+ sym->prereqv ? sym->prereqv->name : sym->name);
+ spillThis (sym);
+}
+
+
+
/*-----------------------------------------------------------------*/
/* serialRegAssign - serially allocate registers to the variables */
/*-----------------------------------------------------------------*/
}
}
}
+
+ /* Check for and fix any problems with uninitialized operands */
+ for (i = 0; i < count; i++)
+ {
+ iCode *ic;
+
+ if (ebbs[i]->noPath &&
+ (ebbs[i]->entryLabel != entryLabel &&
+ ebbs[i]->entryLabel != returnLabel))
+ continue;
+
+ for (ic = ebbs[i]->sch; ic; ic = ic->next)
+ {
+ if (SKIP_IC2 (ic))
+ continue;
+
+ if (ic->op == IFX)
+ {
+ verifyRegsAssigned (IC_COND (ic), ic);
+ continue;
+ }
+
+ if (ic->op == JUMPTABLE)
+ {
+ verifyRegsAssigned (IC_JTCOND (ic), ic);
+ continue;
+ }
+
+ verifyRegsAssigned (IC_RESULT (ic), ic);
+ verifyRegsAssigned (IC_LEFT (ic), ic);
+ verifyRegsAssigned (IC_RIGHT (ic), ic);
+ }
+ }
}
/*-----------------------------------------------------------------*/
for (j = 0; j < sym->nRegs; j++)
{
+ if (sym->regs[j]) /* EEP - debug */
rumask = bitVectSetBit (rumask,
sym->regs[j]->rIdx);
}
}
}
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get */
+/* the operand in a valid state. */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+ symbol * sym;
+
+ if (!op) return;
+ if (!IS_ITEMP (op)) return;
+
+ sym = OP_SYMBOL (op);
+ if (sym->isspilt) return;
+ if (!sym->nRegs) return;
+ if (sym->regs[0]) return;
+
+ werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
+ sym->prereqv ? sym->prereqv->name : sym->name);
+ spillThis (sym);
+}
+
+
/*-----------------------------------------------------------------*/
/* serialRegAssign - serially allocate registers to the variables */
/*-----------------------------------------------------------------*/
}
}
}
+
+ /* Check for and fix any problems with uninitialized operands */
+ for (i = 0; i < count; i++)
+ {
+ iCode *ic;
+
+ if (ebbs[i]->noPath &&
+ (ebbs[i]->entryLabel != entryLabel &&
+ ebbs[i]->entryLabel != returnLabel))
+ continue;
+
+ for (ic = ebbs[i]->sch; ic; ic = ic->next)
+ {
+ if (SKIP_IC2 (ic))
+ continue;
+
+ if (ic->op == IFX)
+ {
+ verifyRegsAssigned (IC_COND (ic), ic);
+ continue;
+ }
+
+ if (ic->op == JUMPTABLE)
+ {
+ verifyRegsAssigned (IC_JTCOND (ic), ic);
+ continue;
+ }
+
+ verifyRegsAssigned (IC_RESULT (ic), ic);
+ verifyRegsAssigned (IC_LEFT (ic), ic);
+ verifyRegsAssigned (IC_RIGHT (ic), ic);
+ }
+ }
+
}
/*-----------------------------------------------------------------*/
}
}
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get */
+/* the operand in a valid state. */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+ symbol * sym;
+
+ if (!op) return;
+ if (!IS_ITEMP (op)) return;
+
+ sym = OP_SYMBOL (op);
+ if (sym->isspilt) return;
+ if (!sym->nRegs) return;
+ if (sym->regs[0]) return;
+
+ werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
+ sym->prereqv ? sym->prereqv->name : sym->name);
+ spillThis (sym);
+}
+
+
/*-----------------------------------------------------------------*/
/* serialRegAssign - serially allocate registers to the variables */
/*-----------------------------------------------------------------*/
}
}
}
+
+ /* Check for and fix any problems with uninitialized operands */
+ for (i = 0; i < count; i++)
+ {
+ iCode *ic;
+
+ if (ebbs[i]->noPath &&
+ (ebbs[i]->entryLabel != entryLabel &&
+ ebbs[i]->entryLabel != returnLabel))
+ continue;
+
+ for (ic = ebbs[i]->sch; ic; ic = ic->next)
+ {
+ if (SKIP_IC2 (ic))
+ continue;
+
+ if (ic->op == IFX)
+ {
+ verifyRegsAssigned (IC_COND (ic), ic);
+ continue;
+ }
+
+ if (ic->op == JUMPTABLE)
+ {
+ verifyRegsAssigned (IC_JTCOND (ic), ic);
+ continue;
+ }
+
+ verifyRegsAssigned (IC_RESULT (ic), ic);
+ verifyRegsAssigned (IC_LEFT (ic), ic);
+ verifyRegsAssigned (IC_RIGHT (ic), ic);
+ }
+ }
+
}
/*-----------------------------------------------------------------*/
return FALSE;
}
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get */
+/* the operand in a valid state. */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+ symbol * sym;
+
+ if (!op) return;
+ if (!IS_ITEMP (op)) return;
+
+ sym = OP_SYMBOL (op);
+ if (sym->isspilt) return;
+ if (!sym->nRegs) return;
+ if (sym->regs[0]) return;
+
+ werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
+ sym->prereqv ? sym->prereqv->name : sym->name);
+ spillThis (sym);
+}
+
+
/** Serially allocate registers to the variables.
This is the main register allocation function. It is called after
packing.
}
}
}
+
+ /* Check for and fix any problems with uninitialized operands */
+ for (i = 0; i < count; i++)
+ {
+ iCode *ic;
+
+ if (ebbs[i]->noPath &&
+ (ebbs[i]->entryLabel != entryLabel &&
+ ebbs[i]->entryLabel != returnLabel))
+ continue;
+
+ for (ic = ebbs[i]->sch; ic; ic = ic->next)
+ {
+ if (SKIP_IC2 (ic))
+ continue;
+
+ if (ic->op == IFX)
+ {
+ verifyRegsAssigned (IC_COND (ic), ic);
+ continue;
+ }
+
+ if (ic->op == JUMPTABLE)
+ {
+ verifyRegsAssigned (IC_JTCOND (ic), ic);
+ continue;
+ }
+
+ verifyRegsAssigned (IC_RESULT (ic), ic);
+ verifyRegsAssigned (IC_LEFT (ic), ic);
+ verifyRegsAssigned (IC_RIGHT (ic), ic);
+ }
+ }
+
}
/*-----------------------------------------------------------------*/