From 077f4999890c8bf8597265d6913e8b458ff4a59a Mon Sep 17 00:00:00 2001 From: tecodev Date: Sun, 23 Jan 2005 17:54:15 +0000 Subject: [PATCH] * src/pic16/{device.c,pcode.c}: s/free/Safe_free/g for Safe_[mc]?alloc()'ed variables * src/pic16/gen.c (pic16_aopOp,pic16_popGet): added handling of (byte sized) temporaries (assign them to WREG for now) * src/pic16/main.c (_process_pragma): fixed nasty malloc bug (used sizeof(set *sectSyms) instead of sizeof(struct sectSym)), this might fix SIGSEGVs on MinGW... git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3651 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 10 ++++++++++ src/pic16/device.c | 12 ++++++------ src/pic16/gen.c | 15 ++++++++++++--- src/pic16/main.c | 2 +- src/pic16/pcode.c | 22 +++++++++++----------- 5 files changed, 40 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8cd4d22e..df79fc72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-01-23 Raphael Neider + + * src/pic16/{device.c,pcode.c}: s/free/Safe_free/g for + Safe_[mc]?alloc()'ed variables + * src/pic16/gen.c (pic16_aopOp,pic16_popGet): added handling + of (byte sized) temporaries (assign them to WREG for now) + * src/pic16/main.c (_process_pragma): fixed nasty malloc bug + (used sizeof(set *sectSyms) instead of sizeof(struct sectSym)), + this might fix SIGSEGVs on MinGW... + 2005-01-23 Vangelis Rokas * src/pic16/gen.c: fixed bug #1106975, diff --git a/src/pic16/device.c b/src/pic16/device.c index ae3abf2b..fdf37ec6 100644 --- a/src/pic16/device.c +++ b/src/pic16/device.c @@ -578,7 +578,7 @@ void pic16_dump_usection(FILE *of, set *section, int fix) } if(!i) { - if(rlist)free(rlist); + if(rlist)Safe_free(rlist); return; } @@ -633,7 +633,7 @@ void pic16_dump_usection(FILE *of, set *section, int fix) rprev = r; } } - free(rlist); + Safe_free(rlist); } void pic16_dump_gsection(FILE *of, set *sections) @@ -676,7 +676,7 @@ void pic16_dump_isection(FILE *of, set *section, int fix) } if(!i) { - if(slist)free(slist); + if(slist)Safe_free(slist); return; } @@ -742,7 +742,7 @@ void pic16_dump_isection(FILE *of, set *section, int fix) sprev = s; } } - free(slist); + Safe_free(slist); } @@ -763,7 +763,7 @@ void pic16_dump_int_registers(FILE *of, set *section) qsort(rlist, elementsInSet(section), sizeof(regs *), regCompare); if(!i) { - if(rlist)free(rlist); + if(rlist)Safe_free(rlist); return; } @@ -775,7 +775,7 @@ void pic16_dump_int_registers(FILE *of, set *section) statistics.intsize += r->size; } - free(rlist); + Safe_free(rlist); } diff --git a/src/pic16/gen.c b/src/pic16/gen.c index b61a5820..2604eeac 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -1254,9 +1254,16 @@ void pic16_aopOp (operand *op, iCode *ic, bool result) sym->aop = op->aop = aop = newAsmop(AOP_PCODE); //aop->aopu.pcop = pic16_popGetImmd(sym->usl.spillLoc->rname,0,sym->usl.spillLoc->offset); - aop->aopu.pcop = pic16_popRegFromString(sym->usl.spillLoc->rname, - getSize(sym->type), - sym->usl.spillLoc->offset, op); + if (sym->usl.spillLoc && sym->usl.spillLoc->rname) { + aop->aopu.pcop = pic16_popRegFromString(sym->usl.spillLoc->rname, + getSize(sym->type), + sym->usl.spillLoc->offset, op); + } else { + fprintf (stderr, "%s:%d called for a spillLocation -- assigning WREG instead --- CHECK!\n", __FUNCTION__, __LINE__); + DEBUGpic16_emitcode (";","%s:%d called for a spillLocation -- assigning WREG instead --- CHECK", __FUNCTION__, __LINE__); + assert (getSize(sym->type) <= 1); + aop->aopu.pcop = pic16_popCopyReg (&pic16_pc_wreg);//pic16_popRegFromString("_WREG", getSize(sym->type), 0, op); + } aop->size = getSize(sym->type); return; @@ -2046,7 +2053,9 @@ pCodeOp *pic16_popGet (asmop *aop, int offset) //, bool bit16, bool dname) switch( aop->aopu.pcop->type ) { case PO_DIR: PCOR(pcop)->instance += offset; break; case PO_IMMEDIATE: PCOI(pcop)->offset = offset; break; + case PO_WREG: assert (offset==0); break; default: + fprintf (stderr, "%s: unhandled aop->aopu.pcop->type %d\n", __FUNCTION__, aop->aopu.pcop->type); assert( 0 ); /* should never reach here */; } return pcop; diff --git a/src/pic16/main.c b/src/pic16/main.c index 7e51fb27..9d72e646 100644 --- a/src/pic16/main.c +++ b/src/pic16/main.c @@ -256,7 +256,7 @@ _process_pragma(const char *sz) int found=0; while(symname) { - ssym = Safe_calloc(1, sizeof(sectSyms)); + ssym = Safe_calloc(1, sizeof(sectSym)); ssym->name = Safe_calloc(1, strlen(symname)+2); sprintf(ssym->name, "_%s", symname); ssym->reg = NULL; diff --git a/src/pic16/pcode.c b/src/pic16/pcode.c index 802545e6..7de4bcf8 100644 --- a/src/pic16/pcode.c +++ b/src/pic16/pcode.c @@ -3730,7 +3730,7 @@ static void destructpCodeFlow(pCode *pc) pc->type = PC_BAD; pic16_addpCode2pBlock(pb_dead_pcodes, pc); -// free(pc); +// Safe_free(pc); } @@ -3871,7 +3871,7 @@ static void pCodeLabelDestruct(pCode *pc) return; // if((pc->type == PC_LABEL) && PCL(pc)->label) -// free(PCL(pc)->label); +// Safe_free(PCL(pc)->label); /* Instead of deleting the memory used by this pCode, mark * the object as bad so that if there's a pointer to this pCode @@ -3882,7 +3882,7 @@ static void pCodeLabelDestruct(pCode *pc) pc->type = PC_BAD; pic16_addpCode2pBlock(pb_dead_pcodes, pc); -// free(pc); +// Safe_free(pc); } @@ -4671,7 +4671,7 @@ static void genericDestruct(pCode *pc) pc->type = PC_BAD; pic16_addpCode2pBlock(pb_dead_pcodes, pc); - //free(pc); + //Safe_free(pc); } @@ -5263,11 +5263,11 @@ static void unlinkpCodeFromBranch(pCode *pcl , pCode *pc) /* Found a label */ if(bprev) { bprev->next = b->next; /* Not first pCode in chain */ -// free(b); +// Safe_free(b); } else { pc->destruct(pc); PCI(pcl)->label = b->next; /* First pCode in chain */ -// free(b); +// Safe_free(b); } return; /* A label can't occur more than once */ } @@ -6001,7 +6001,7 @@ static void unBuildFlow(pBlock *pb) pc->seq = 0; if(PCI(pc)->pcflow) { - //free(PCI(pc)->pcflow); + //Safe_free(PCI(pc)->pcflow); PCI(pc)->pcflow = NULL; } @@ -6562,7 +6562,7 @@ static void exchangeLabels(pCodeLabel *pcl, pCode *pc) // fprintf(stderr,"changing label key from %d to %d\n",pcol->key, pcl->key); // if(pcol->pcop.name) -// free(pcol->pcop.name); +// Safe_free(pcol->pcop.name); /* If the key is negative, then we (probably) have a label to * a function and the name is already defined */ @@ -6649,7 +6649,7 @@ static void pBlockRemoveUnusedLabels(pBlock *pb) } else { unlinkpCodeFromBranch(pc, PCODE(pcl)); /*if(pc->label->next == NULL && pc->label->pc == NULL) { - free(pc->label); + Safe_free(pc->label); }*/ } @@ -7442,7 +7442,7 @@ static void pBlockDestruct(pBlock *pb) return; -// free(pb); +// Safe_free(pb); } @@ -8196,7 +8196,7 @@ static set *register_usage(pBlock *pb) DFPRINTF((stderr,"Cool found register collision nIdx=%d moving to %d\n", r1->rIdx, newreg->rIdx)); r2->rIdx = newreg->rIdx; - //if(r2->name) free(r2->name); + //if(r2->name) Safe_free(r2->name); if(newreg->name) r2->name = Safe_strdup(newreg->name); else -- 2.47.2