incorrectly discarded BANKSELs
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5308
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+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:
2008-12-29 Philipp Klaus Krause <pkk AT spth.de>
* support/regression/tests/memory.c:
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
-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).
{
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
pcop = popCopyReg(PCOR(pci->pcop));
pcop->type = PO_GPR_REGISTER; // Sometimes the type is set to legacy 8051 - so override it
new_pc = newpCode(POC_BANKSEL, pcop);
insertPCodeInstruction(pci, PCI(new_pc));
new_pc = newpCode(POC_BANKSEL, pcop);
insertPCodeInstruction(pci, PCI(new_pc));
// XXX: We can do better with fixed registers.
if (allRAMmshared && reg && (reg->type != REG_SFR) && (!reg->isFixed)) {
// no BANKSEL required
// 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);
- // 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);
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);
- 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