static char *get_op( pCodeInstruction *pcc);
int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd);
int pCodePeepMatchRule(pCode *pc);
+void pBlockStats(FILE *of, pBlock *pb);
pCodeInstruction pciADDWF = {
return;
for(pb = the_pFile->pbHead; pb; pb = pb->next) {
- if(getpBlock_dbName(pb) == dbName)
+ if(getpBlock_dbName(pb) == dbName) {
+ pBlockStats(of,pb);
printpBlock(of,pb);
+ }
}
}
}
}
}
+/*-----------------------------------------------------------------*/
+/* int RegCond(pCodeOp *pcop) - if pcop points to the STATUS reg- */
+/* ister, RegCond will return the bit being referenced. */
+/* */
+/* fixme - why not just OR in the pcop bit field */
+/*-----------------------------------------------------------------*/
+
static int RegCond(pCodeOp *pcop)
{
}
+/*-----------------------------------------------------------------*/
+/* pCodeLabelDestruct - free memory used by a label. */
+/*-----------------------------------------------------------------*/
static void pCodeLabelDestruct(pCode *pc)
{
}
/*-----------------------------------------------------------------*/
-/* newpCodeChai0n - create a new chain of pCodes */
+/* newpCodeChain - create a new chain of pCodes */
/*-----------------------------------------------------------------*
*
* This function will create a new pBlock and the pointer to the
return pcop;
}
+/*-----------------------------------------------------------------*/
+/*-----------------------------------------------------------------*/
pCodeOp *newpCodeOpLit(int lit)
{
char *s = buffer;
return pcop;
}
+/*-----------------------------------------------------------------*/
+/*-----------------------------------------------------------------*/
pCodeOp *newpCodeOpWild(int id, pCodePeep *pcp, pCodeOp *subtype)
{
char *s = buffer;
return pcop;
}
+/*-----------------------------------------------------------------*/
+/*-----------------------------------------------------------------*/
pCodeOp *newpCodeOpBit(char *s, int bit, int inBitSpace)
{
pCodeOp *pcop;
}
+/*-----------------------------------------------------------------*/
+/*-----------------------------------------------------------------*/
void pBlockRegs(FILE *of, pBlock *pb)
{
}
+/*-----------------------------------------------------------------*/
+/*-----------------------------------------------------------------*/
static pBranch * pBranchAppend(pBranch *h, pBranch *n)
{
pBranch *b;
} else
npc = npc->next;
}
+ /* reached the end of the pcode chain without finding
+ * an instruction we could link to. */
}
}
}
}
+/*-----------------------------------------------------------------*/
+/*-----------------------------------------------------------------*/
void AnalyzepBlock(pBlock *pb)
{
if(PCI(pc)->pcop && PCI(pc)->pcop->type == PO_GPR_TEMP) {
/* Loop through all of the registers declared so far in
- this block and see if we find this new there */
+ this block and see if we find this one there */
regs *r = setFirstItem(pb->registers);
}
}
+/*-----------------------------------------------------------------*/
+/*-----------------------------------------------------------------*/
int OptimizepBlock(pBlock *pb)
{
pCode *pc;
pCode *pc;
regs *r;
- fprintf(of,"***\n pBlock Stats\n***\n");
+ fprintf(of,";***\n; pBlock Stats\n;***\n");
// for now just print the first element of each set
pc = setFirstItem(pb->function_entries);
if(pc) {
- fprintf(of,"entry\n");
+ fprintf(of,";entry: ");
pc->print(of,pc);
}
pc = setFirstItem(pb->function_exits);
if(pc) {
- fprintf(of,"has an exit\n");
- pc->print(of,pc);
+ fprintf(of,";has an exit\n");
+ //pc->print(of,pc);
}
pc = setFirstItem(pb->function_calls);
if(pc) {
- fprintf(of,"functions called\n");
+ fprintf(of,";functions called:\n");
while(pc) {
+ fprintf(of,"; ");
pc->print(of,pc);
pc = setNextItem(pb->function_calls);
}
if(r) {
int n = elementsInSet(pb->registers);
- fprintf(of,"%d compiler assigned register%c:\n",n, ( (n!=1) ? 's' : ' '));
+ fprintf(of,";%d compiler assigned register%c:\n",n, ( (n!=1) ? 's' : ' '));
while (r) {
- fprintf(of," %s\n",r->name);
+ fprintf(of,"; %s\n",r->name);
r = setNextItem(pb->registers);
}
}
r2 = setFirstItem(pb->registers);
- while(r2) {
+ while(r2 && (r1->type != REG_STK)) {
if(r2->rIdx == r1->rIdx) {
- newreg = pic14_findFreeReg();
+ newreg = pic14_findFreeReg(REG_GPR);
if(!newreg) {
/* Collisions have been resolved. Now free the registers in the call path */
r1 = setFirstItem(registersInCallPath);
while(r1) {
- newreg = pic14_regWithIdx(r1->rIdx);
- newreg->isFree = 1;
+ if(r1->type != REG_STK) {
+ newreg = pic14_regWithIdx(r1->rIdx);
+ newreg->isFree = 1;
+ }
r1 = setNextItem(registersInCallPath);
}