From: vrokas Date: Tue, 9 May 2006 21:48:44 +0000 (+0000) Subject: * src/pic16/gen.c (pic16_freeAsmop): release any temp registers X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=33a22bd9eb00ed7326b06ef484e37537cabae64d;p=fw%2Fsdcc * src/pic16/gen.c (pic16_freeAsmop): release any temp registers allocated by aopForSym thus fixing bug #1478657 about failed testfwk.c * src/pic16/main.c (_pic16_keywords): added 'sfr16' keyword, * src/pic16/ralloc.c (pic16_allocWithIdx): also a fix for bug exposed by bug report #1478657 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4160 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/pic16/gen.c b/src/pic16/gen.c index aa811c3e..735f113c 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -6,7 +6,7 @@ Bug Fixes - Wojciech Stryjewski wstryj1@tiger.lsu.edu (1999 v2.1.9a) PIC port - Scott Dattalo scott@dattalo.com (2000) PIC16 port - Martin Dubuc m.dubuc@rogers.com (2002) - - Vangelis Rokas vrokas@otenet.gr (2003,2004,2005) + - Vangelis Rokas (2003-2006) Bug Fixes - Raphael Neider (2004,2005) This program is free software; you can redistribute it and/or modify it @@ -707,6 +707,7 @@ static asmop *aopForSym (iCode *ic, operand *op, bool result) /* if SEND do the send here */ _G.resDirect = 1; } else { +// debugf3("symbol `%s' level = %d / %d\n", sym->name, ic->level, ic->seq); for(i=0;isize;i++) { aop->aopu.stk.pop[i] = pcop[i] = pic16_popGetTempRegCond(_G.fregsUsed, _G.sregsAlloc, 0 ); _G.sregsAlloc = bitVectSetBit(_G.sregsAlloc, PCOR(pcop[i])->r->rIdx); @@ -1411,10 +1412,21 @@ void pic16_freeAsmop (operand *op, asmop *aaop, iCode *ic, bool pop) for(i=0;isize;i++) { PCOR(aop->aopu.stk.pop[i] )->r->isFree = 1; - if(bitVectBitValue(_G.sregsAlloc, PCOR(aop->aopu.stk.pop[i])->r->rIdx)) + if(bitVectBitValue(_G.sregsAlloc, PCOR(aop->aopu.stk.pop[i])->r->rIdx)) { bitVectUnSetBit(_G.sregsAlloc, PCOR(aop->aopu.stk.pop[i])->r->rIdx); +// pic16_popReleaseTempReg(aop->aopu.stk.pop[i], 0); + } } + + { + regs *sr; + _G.sregsAllocSet = reverseSet( _G.sregsAllocSet ); + for(sr=setFirstItem(_G.sregsAllocSet) ; sr; sr=setFirstItem(_G.sregsAllocSet)) { + pic16_poppCodeOp( pic16_popRegFromIdx( sr->rIdx ) ); + deleteSetItem( &_G.sregsAllocSet, sr ); + } + } } _G.resDirect = 0; } diff --git a/src/pic16/main.c b/src/pic16/main.c index c9515fbb..5547e34e 100644 --- a/src/pic16/main.c +++ b/src/pic16/main.c @@ -53,6 +53,7 @@ static char *_pic16_keywords[] = "pdata", "reentrant", "sfr", + "sfr16", "using", "_data", "_code", diff --git a/src/pic16/pcode.h b/src/pic16/pcode.h index 597abf53..cf3d1911 100644 --- a/src/pic16/pcode.h +++ b/src/pic16/pcode.h @@ -299,6 +299,8 @@ typedef enum POC_XORFW, POC_BANKSEL + + /* pseudo-instructions */ } PIC_OPCODE; diff --git a/src/pic16/ralloc.c b/src/pic16/ralloc.c index 21555884..611142db 100644 --- a/src/pic16/ralloc.c +++ b/src/pic16/ralloc.c @@ -1086,7 +1086,7 @@ regs * pic16_allocWithIdx (int idx) { - regs *dReg; + regs *dReg=NULL; debugLog ("%s - allocating with index = 0x%x\n", __FUNCTION__,idx); // fprintf(stderr, "%s - allocating with index = 0x%x\n", __FUNCTION__,idx); @@ -1105,12 +1105,19 @@ pic16_allocWithIdx (int idx) debugLog ("Dynamic Register not found\n"); -// return (NULL); - //fprintf(stderr,"%s %d - requested register: 0x%x\n",__FUNCTION__,__LINE__,idx); - werror (E_INTERNAL_ERROR, __FILE__, __LINE__, - "allocWithIdx not found"); - exit (1); +#if 1 + dReg = newReg(REG_GPR, PO_GPR_TEMP, idx, NULL, 1, 0, NULL); + addSet(&pic16_dynAllocRegs, dReg); + hTabAddItem(&dynAllocRegNames, regname2key(dReg->name), dReg); +#endif + if(!dReg) { +// return (NULL); + //fprintf(stderr,"%s %d - requested register: 0x%x\n",__FUNCTION__,__LINE__,idx); + werror (E_INTERNAL_ERROR, __FILE__, __LINE__, + "allocWithIdx not found"); + exit (1); + } } dReg->wasUsed = 1;