From 8a668d49eaf102d758f547af148096d2f00faeff Mon Sep 17 00:00:00 2001 From: tecodev Date: Mon, 29 Dec 2008 20:08:55 +0000 Subject: [PATCH] * src/pic/pcode.c (insertBankSel, FixRegisterBanking): emit incorrectly discarded BANKSELs git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5308 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 5 +++++ src/pic/pcode.c | 20 +++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24ee04a0..7aba32e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-12-29 Raphael Neider + + * src/pic/pcode.c (insertBankSel, FixRegisterBanking): emit + incorrectly discarded BANKSELs + 2008-12-29 Philipp Klaus Krause * support/regression/tests/memory.c: diff --git a/src/pic/pcode.c b/src/pic/pcode.c index 8bf1f0b9..43a97d7a 100644 --- a/src/pic/pcode.c +++ b/src/pic/pcode.c @@ -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 -- 2.30.2