]> git.gag.com Git - fw/sdcc/commitdiff
* src/pic16/gen.c (pic16_freeAsmop): release any temp registers
authorvrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 9 May 2006 21:48:44 +0000 (21:48 +0000)
committervrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 9 May 2006 21:48:44 +0000 (21:48 +0000)
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

src/pic16/gen.c
src/pic16/main.c
src/pic16/pcode.h
src/pic16/ralloc.c

index aa811c3e1cc039aa21da410bf4178ab86e0f4ddc..735f113ccfc8e3ce4515644761cde442b807b04d 100644 (file)
@@ -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 <vrokas AT users.sourceforge.net> (2003-2006)
   Bug Fixes  -  Raphael Neider <rneider AT web.de> (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;i<aop->size;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;i<aop->size;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;
           }
index c9515fbb23c18e202c063425956da6d63ccb6ccc..5547e34edfb66044e8e6880448c1cdce98d00eca 100644 (file)
@@ -53,6 +53,7 @@ static char *_pic16_keywords[] =
   "pdata",
   "reentrant",
   "sfr",
+  "sfr16",
   "using",
   "_data",
   "_code",
index 597abf53fe20901e59999bee5fa3ee7a49c923c5..cf3d19113f359f1e9848a413fe2b8186abb5ccd3 100644 (file)
@@ -299,6 +299,8 @@ typedef enum
   POC_XORFW,
 
   POC_BANKSEL
+
+  /* pseudo-instructions */
 } PIC_OPCODE;
 
 
index 21555884de10ce24e20449ae68247e4bc3375c29..611142db48593b9f1a8f813824fae562902ce9b5 100644 (file)
@@ -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;