based on absolute register address, patch by Alex Blond
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4595
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2007-01-25 Raphael Neider <rneider AT web.de>
+
+ * src/pic/pcode.c (sameBank,FixRegisterBanking): optimize banksels
+ based on absolute register address, patch by Alex Blond
+
2007-01-22 Raphael Neider <rneider AT web.de>
* src/pic/glue.c (pic14emitRegularMap): mark initialized symbols as
2007-01-22 Raphael Neider <rneider AT web.de>
* src/pic/glue.c (pic14emitRegularMap): mark initialized symbols as
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
-static int sameBank(regs *reg, const char *new_bank, const char *cur_bank)
+static int sameBank(regs *reg, regs *previous_reg, const char *new_bank, const char *cur_bank, unsigned max_mask)
{
if (!cur_bank) return 0;
{
if (!cur_bank) return 0;
if (cur_bank[0] == '(' && reg && reg->name && !strncmp(reg->name, &cur_bank[1], strlen(reg->name))) return 1;
if (cur_bank[0] == '(' && new_bank && !strncmp(new_bank, &cur_bank[1], strlen(new_bank))) return 1;
if (cur_bank[0] == '(' && reg && reg->name && !strncmp(reg->name, &cur_bank[1], strlen(reg->name))) return 1;
if (cur_bank[0] == '(' && new_bank && !strncmp(new_bank, &cur_bank[1], strlen(new_bank))) return 1;
+ if (previous_reg && reg && previous_reg->isFixed && reg->isFixed && ((previous_reg->address & max_mask) == (reg->address & max_mask))) // only if exists
+ return 1; // if we have address info, we use it for banksel optimization
+
// XXX: identify '(regname + X)' and '(regname + Y)'
return ((reg && reg->name && !strcmp(reg->name, cur_bank)) || (new_bank && !strcmp(new_bank, cur_bank)));
// XXX: identify '(regname + X)' and '(regname + Y)'
return ((reg && reg->name && !strcmp(reg->name, cur_bank)) || (new_bank && !strcmp(new_bank, cur_bank)));
pCode *pc;
pCodeInstruction *pci;
regs *reg;
pCode *pc;
pCodeInstruction *pci;
regs *reg;
+ regs *previous_reg; // contains the previous variable access info
const char *cur_bank, *new_bank;
unsigned cur_mask, new_mask, max_mask;
int allRAMmshared;
const char *cur_bank, *new_bank;
unsigned cur_mask, new_mask, max_mask;
int allRAMmshared;
max_mask = pic14_getPIC()->bankMask;
cur_mask = max_mask;
cur_bank = NULL;
max_mask = pic14_getPIC()->bankMask;
cur_mask = max_mask;
cur_bank = NULL;
allRAMmshared = pic14_allRAMShared();
allRAMmshared = pic14_allRAMShared();
// this one has a label---might check bank at all jumps here...
if (isPCI(pc) && (PCI(pc)->label || PCI(pc)->op == POC_CALL)) {
addpCodeComment(pc->prev, "BANKOPT3 drop assumptions: PCI with label or call found");
// this one has a label---might check bank at all jumps here...
if (isPCI(pc) && (PCI(pc)->label || PCI(pc)->op == POC_CALL)) {
addpCodeComment(pc->prev, "BANKOPT3 drop assumptions: PCI with label or call found");
cur_bank = NULL; // start new flow
cur_mask = max_mask;
}
cur_bank = NULL; // start new flow
cur_mask = max_mask;
}
// this one is/might be a label or BANKSEL---assume nothing
if (isPCL(pc) || isPCASMDIR(pc)) {
addpCodeComment(pc->prev, "BANKOPT4 drop assumptions: label or ASMDIR found");
// this one is/might be a label or BANKSEL---assume nothing
if (isPCL(pc) || isPCASMDIR(pc)) {
addpCodeComment(pc->prev, "BANKOPT4 drop assumptions: label or ASMDIR found");
cur_bank = NULL;
cur_mask = max_mask;
}
cur_bank = NULL;
cur_mask = max_mask;
}
// is in (as well as the previous registers)
cur_mask &= new_mask;
// is in (as well as the previous registers)
cur_mask &= new_mask;
- if (sameBank(reg, 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);
continue;
// no BANKSEL required
addpCodeComment(pc->prev, "BANKOPT2 BANKSEL dropped; %s present in same bank as %s", new_bank, cur_bank);
continue;
cur_mask = new_mask;
cur_bank = new_bank;
cur_mask = new_mask;
cur_bank = new_bank;
insertBankSel(pci, cur_bank);
} // if
} // if
insertBankSel(pci, cur_bank);
} // if
} // if