* src/pic/pcode.c (insertBankSel, FixRegisterBanking): emit
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 29 Dec 2008 20:08:55 +0000 (20:08 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 29 Dec 2008 20:08:55 +0000 (20:08 +0000)
    incorrectly discarded BANKSELs

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

ChangeLog
src/pic/pcode.c

index 24ee04a0f4976b5761fa4cd10414bcc46f914c0a..7aba32e9e40fba457531e05cfd5df8dff5c662d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-12-29 Raphael Neider <rneider AT web.de>
+
+       * src/pic/pcode.c (insertBankSel, FixRegisterBanking): emit
+         incorrectly discarded BANKSELs
+
 2008-12-29 Philipp Klaus Krause <pkk AT spth.de>
 
        * support/regression/tests/memory.c:
index 8bf1f0b979c8325810e7be9a72f512caa77e4abd..43a97d7a9c6aa4ed3dbdd59dd226ef22f1da3e89 100644 (file)
@@ -4013,14 +4013,14 @@ static void insertPCodeInstruction(pCodeInstruction *pci, pCodeInstruction *new_
 
 /*-----------------------------------------------------------------*/
 /*-----------------------------------------------------------------*/
-static void insertBankSel(pCodeInstruction  *pci, const char *name)
+static int insertBankSel(pCodeInstruction  *pci, const char *name)
 {
        pCode *new_pc;
        
        pCodeOp *pcop;
 
        // Never BANKSEL STATUS, this breaks all kinds of code (e.g., interrupt handlers).
-       if (!strcmp("STATUS", name) || !strcmp("_STATUS", name)) return;
+       if (!strcmp("STATUS", name) || !strcmp("_STATUS", name)) return 0;
        
        pcop = popCopyReg(PCOR(pci->pcop));
        pcop->type = PO_GPR_REGISTER; // Sometimes the type is set to legacy 8051 - so override it
@@ -4029,6 +4029,7 @@ static void insertBankSel(pCodeInstruction  *pci, const char *name)
        new_pc = newpCode(POC_BANKSEL, pcop);
        
        insertPCodeInstruction(pci, PCI(new_pc));
+       return 1;
 }
 
 /*
@@ -4193,14 +4194,10 @@ static void FixRegisterBanking(pBlock *pb)
                    // XXX: We can do better with fixed registers.
                    if (allRAMmshared && reg && (reg->type != REG_SFR) && (!reg->isFixed)) {
                        // no BANKSEL required
-                       addpCodeComment(pc->prev, "BANKOPT1b BANKSEL dropped; %s present in all of %s's banks", new_bank, cur_bank);
+                       addpCodeComment(pc->prev, "BANKOPT1b BANKSEL dropped; %s present in all (of %s's) banks", new_bank, cur_bank);
                        continue;
                    }
 
-                   // restrict cur_mask to cover only the banks this register
-                   // is in (as well as the previous registers)
-                   cur_mask &= new_mask;
-
                    if (sameBank(reg, previous_reg, new_bank, cur_bank, max_mask)) {
                        // no BANKSEL required
                        addpCodeComment(pc->prev, "BANKOPT2 BANKSEL dropped; %s present in same bank as %s", new_bank, cur_bank);
@@ -4208,10 +4205,11 @@ static void FixRegisterBanking(pBlock *pb)
                    }
                } // if
 
-               cur_mask = new_mask;
-               cur_bank = new_bank;
-               previous_reg = reg;
-               insertBankSel(pci, cur_bank);
+               if (insertBankSel(pci, new_bank)) {
+                   cur_mask = new_mask;
+                   cur_bank = new_bank;
+                   previous_reg = reg;
+               } // if
            } // if
        } // if
     } // for