]> git.gag.com Git - fw/sdcc/commitdiff
* src/pic/device.{c,h}: added pic14_getPIC()
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 20 Nov 2006 23:21:40 +0000 (23:21 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 20 Nov 2006 23:21:40 +0000 (23:21 +0000)
* src/pic/gen.c (continueIfTrue,jumpIfTrue): added PIC code,
  (genAnd): added PIC code for one case, fixes #1597044
* src/pic/pcode.c (BankSelect): Ohoh, added generic optimization for
  SFRs that are present in all banks (e.g., STATUS)

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4474 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/pic/device.c
src/pic/device.h
src/pic/gen.c
src/pic/pcode.c

index c83c79fe0763d3e19dd76d28534badcfd8413229..298764e05dc3bf40d032329eced92f976284431e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-11-21 Raphael Neider <rneider AT web.de>
+
+       * src/pic/device.{c,h}: added pic14_getPIC()
+       * src/pic/gen.c (continueIfTrue,jumpIfTrue): added PIC code,
+         (genAnd): added PIC code for one case, fixes #1597044
+       * src/pic/pcode.c (BankSelect): Ohoh, added generic optimization for
+         SFRs that are present in all banks (e.g., STATUS)
+
 2006-11-20 Raphael Neider <rneider AT web.de>
 
        * src/pic/pcode.c: changed inverted ops for DECFSZ/DECFSZW and
index 5546e1f182b73fac97d9aa5a7984d7c92cae52b2..d6b4939249a28aa85b472daf55f1bcbff7bb88eb 100644 (file)
@@ -1062,3 +1062,7 @@ int pic14_getSharebankAddress(void)
        return sharebankAddress;
 }
 
+PIC_device * pic14_getPIC(void)
+{
+    return pic;
+}
index bea75a49625c661a3770aa2f4395dec283ce0de5..ad8a890d9909c063e8a273ca89e9d2132046b0d9 100644 (file)
@@ -114,5 +114,6 @@ unsigned pic14_getMaxRam(void);
 int pic14_getHasSecondConfigReg(void);
 int pic14_getSharebankSize(void);
 int pic14_getSharebankAddress(void);
+PIC_device * pic14_getPIC(void);
 
 #endif  /* __DEVICE_H__ */
index f76cb10159fc948066db853caf8f09f59b1235d8..fbfd19c99efde622db3111e4d451576f8cc60a40 100644 (file)
@@ -5487,7 +5487,11 @@ static void continueIfTrue (iCode *ic)
        FENTRY;
        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
        if(IC_TRUE(ic))
-               pic14_emitcode("ljmp","%05d_DS_",IC_TRUE(ic)->key+100);
+       {
+               // Why +100?!?
+               emitpcode(POC_GOTO, popGetLabel(IC_TRUE(ic)->key+100));
+               pic14_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
+       }
        ic->generated = 1;
 }
 
@@ -5499,7 +5503,11 @@ static void jumpIfTrue (iCode *ic)
        FENTRY;
        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
        if(!IC_TRUE(ic))
+       {
+               // Why +100?!?
+               emitpcode(POC_GOTO, popGetLabel(IC_TRUE(ic)->key+100));
                pic14_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
+       }
        ic->generated = 1;
 }
 
@@ -5640,7 +5648,7 @@ static void genAnd (iCode *ic, iCode *ifx)
                                                offset++;
                                        }
                                        emitpcode(((rIfx.condition) ? POC_BTFSC : POC_BTFSS),
-                                               newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),posbit,0));
+                                               newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),posbit-1,0));
                                        emitpcode(POC_GOTO,popGetLabel(rIfx.lbl->key));
                                        
                                        ifx->generated = 1;
@@ -5654,16 +5662,29 @@ static void genAnd (iCode *ic, iCode *ifx)
                                pic14_emitcode("setb","c");
                        while(sizel--){
                                if((bytelit = ((lit >> (offset*8)) & 0x0FFL)) != 0x0L){
-                                       MOVA( aopGet(AOP(left),offset,FALSE,FALSE));
+                                       mov2w( AOP(left), offset);
                                        // byte ==  2^n ?
-                                       if((posbit = isLiteralBit(bytelit)) != 0)
+                                       if((posbit = isLiteralBit(bytelit)) != 0) {
+                                               emitpcode(rIfx.condition ? POC_BTFSC : POC_BTFSS, // XXX: or the other way round?
+                                                       newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),posbit - 1, 0));
                                                pic14_emitcode("jb","acc.%d,%05d_DS_",(posbit-1)&0x07,tlbl->key+100);
+                                       }
                                        else{
+                                               emitpcode(POC_ANDLW, newpCodeOpLit(bytelit & 0x0ff));
+                                               if (rIfx.condition) emitSKPZ;
+                                               else emitSKPNZ;
+                                               
                                                if(bytelit != 0x0FFL)
+                                               {
                                                        pic14_emitcode("anl","a,%s",
                                                        aopGet(AOP(right),offset,FALSE,TRUE));
+                                               }
                                                pic14_emitcode("jnz","%05d_DS_",tlbl->key+100);
                                        }
+
+                                       emitpcode(POC_GOTO, popGetLabel(rIfx.lbl->key));
+                                       ifx->generated = 1;
+                                               
                                }
                                offset++;
                        }
index c1dd7d392bf28ba5fc9af81fbe7d28e3a116d3bd..4067610bc8d8ade88c00e1173db246cedf7fc96b 100644 (file)
@@ -4607,9 +4607,13 @@ static int BankSelect(pCodeInstruction *pci, int cur_bank, regs *reg)
 #if 1
        /* Always insert BANKSELs rather than try to be clever:
         * Too many bugs in optimized banksels... */
+       static PIC_device *pic;
+       if (!pic) pic = pic14_getPIC();
 
        // possible optimizations:
        // * do not emit BANKSELs for SFRs that are present in all banks (bankmsk == regmap for this register)
+       if (reg && pic && ((reg->alias & pic->bankMask) == pic->bankMask)) return 'L';
+       
        insertBankSel(pci, reg->name); // Let linker choose the bank selection
        return 'L';
 #else