pc = findNextInstruction(pcfl->pc.next);
- while(isPCinFlow(pc,PCODE(pcfl))) {
-
-
+ while(pc && !isPCFL(pc)) {
+ while (pc && !isPCI(pc) && !isPCFL(pc))
+ {
+ pc = pc->next;
+ } // while
+ if (!pc || isPCFL(pc)) continue;
+ assert( isPCI(pc) );
+
reg = getRegFromInstruction(pc);
-
+ #if 0
+ pc->print(stderr, pc);
+ fprintf( stderr, "--> reg %p (%s,%u), inCond/outCond: %x/%x\n",
+ reg, reg ? reg->name : "(null)", reg ? reg->rIdx : -1,
+ PCI(pc)->inCond, PCI(pc)->outCond );
+ #endif
if(reg) {
/*
fprintf(stderr, "flow seq %d, inst seq %d %s ",PCODE(pcfl)->seq,pc->seq,reg->name);
}
- pc = findNextInstruction(pc->next);
+ //pc = findNextInstruction(pc->next);
+ pc = pc->next;
}
-
+
}
/*-----------------------------------------------------------------*
}
}
+
+void RegsUnMapLiveRanges(void);
+extern pFile *the_pFile;
+void pic14_ReMapLiveRanges(void)
+{
+ pBlock *pb;
+ if (!the_pFile) return;
+ RegsUnMapLiveRanges();
+ for (pb = the_pFile->pbHead; pb; pb = pb->next)
+ {
+ #if 0
+ pCode *pc = findNextpCode(pb->pcHead, PC_FLOW);
+ if (pc) {
+ pc->print( stderr, pc );
+ } else {
+ fprintf( stderr, "unnamed pBlock\n");
+ }
+ pc = findNextInstruction(pb->pcHead);
+ while (pc) {
+ pc->print( stderr, pc );
+ pc = findNextInstruction(pc->next);;
+ }
+ #endif
+ pCodeRegMapLiveRanges(pb);
+ } // for
+}
+
/*-----------------------------------------------------------------*
* void RemoveUnusedRegisters(void)
*
void RemoveUnusedRegisters(void)
{
/* First, get rid of registers that are used only one time */
+ pic14_ReMapLiveRanges();
//RemoveRegsFromSet(dynInternalRegs);
RemoveRegsFromSet(dynAllocRegs);
if (reg && reg->type == REG_SFR && reg->pc_type != PO_STATUS) return result;
}
- /* MUST SUCEED FROM NOW ON (or ervert the changes done since NOW ;-)) */
+ /* MUST SUCEED FROM NOW ON (or revert the changes done since NOW ;-)) */
/* fix flow */
if (PCI(pc)->pcflow && PCI(pc)->pcflow->end == pc)
pCodeInsertAfter (&pc->pc, &newpc->pc);
/* FIXME: replacing pc will break the liverange maps (usedpCodes, ...) */
+ pCodeRegMapLiveRanges( pc->pBlock ); /*FIXME:UNTESTED*/
if (comment)
{