From df8a872aeeaebc41286411e563d1b1120c5a5308 Mon Sep 17 00:00:00 2001 From: sdattalo Date: Wed, 9 Jan 2002 14:36:40 +0000 Subject: [PATCH] Now the PIC port DOESN'T spew debug info by default. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1786 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/pic/gen.c | 27 ++++--- src/pic/glue.c | 21 ++--- src/pic/main.c | 6 +- src/pic/pcode.c | 49 +++++++----- src/pic/pcode.h | 20 +++++ src/pic/pcodepeep.c | 168 ++++++++++++++++++++-------------------- src/pic/ralloc.c | 16 ++-- src/regression/Makefile | 3 +- src/regression/rt.sh | 4 +- 9 files changed, 172 insertions(+), 142 deletions(-) diff --git a/src/pic/gen.c b/src/pic/gen.c index c8a8fc64..d75b4a8d 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -1124,11 +1124,8 @@ pCodeOp *popGetWithString(char *str) pCodeOp *popRegFromString(char *str) { - pCodeOp *pcop = Safe_calloc(1,sizeof(pCodeOpReg) ); - pcop->type = PO_GPR_REGISTER; - - PCOR(pcop)->rIdx = -1; - PCOR(pcop)->r = NULL; + pCodeOp *pcop = Safe_calloc(1,sizeof(pCodeOp) ); + pcop->type = PO_DIR; DEBUGpic14_emitcode(";","%d",__LINE__); pcop->name = Safe_strdup( ( (str) ? str : "BAD STRING")); @@ -9167,18 +9164,19 @@ void genpic14Code (iCode *lic) addpBlock(pb); /* if debug information required */ -/* if (options.debug && currFunc) { */ - if (currFunc) { + if (options.debug && currFunc) { + if (currFunc) { cdbSymbol(currFunc,cdbFile,FALSE,TRUE); _G.debugLine = 1; if (IS_STATIC(currFunc->etype)) { - pic14_emitcode("",";F%s$%s$0$0 %d",moduleName,currFunc->name,__LINE__); - //addpCode2pBlock(pb,newpCodeLabel(moduleName,currFunc->name)); + pic14_emitcode("",";F%s$%s$0$0 %d",moduleName,currFunc->name,__LINE__); + //addpCode2pBlock(pb,newpCodeLabel(moduleName,currFunc->name)); } else { - pic14_emitcode("",";G$%s$0$0 %d",currFunc->name,__LINE__); - //addpCode2pBlock(pb,newpCodeLabel(NULL,currFunc->name)); + pic14_emitcode("",";G$%s$0$0 %d",currFunc->name,__LINE__); + //addpCode2pBlock(pb,newpCodeLabel(NULL,currFunc->name)); } _G.debugLine = 0; + } } @@ -9395,14 +9393,15 @@ void genpic14Code (iCode *lic) /* now we are ready to call the peep hole optimizer */ if (!options.nopeep) { - printf("peep hole optimizing\n"); - peepHole (&lineHead); + peepHole (&lineHead); } /* now do the actual printing */ printLine (lineHead,codeOutFile); - printf("printing pBlock\n\n"); +#ifdef PCODE_DEBUG + DFPRINTF((stderr,"printing pBlock\n\n")); printpBlock(stdout,pb); +#endif return; } diff --git a/src/pic/glue.c b/src/pic/glue.c index 35d24fa5..1baf9327 100644 --- a/src/pic/glue.c +++ b/src/pic/glue.c @@ -1007,16 +1007,16 @@ picglue () addSet(&s,&b); addSet(&s,&c); - fprintf(stdout,"\n\n\n******************\n\n\n"); + DFPRINTF((stderr,"\n\n\n******************\n\n\n")); for(t=s; t; t=t->next) { if(t->item) - fprintf(stdout,"Set item %d\n",*(char *)t->item); + DFPRINTF((stderr,"Set item %d\n",*(char *)t->item)); } s =reverseSet(s); for(t=s; t; t=t->next) { if(t->item) - fprintf(stdout,"Set item %d\n",*(char *)t->item); + DFPRINTF((stderr,"Set item %d\n",*(char *)t->item)); } addSetHead(&tmpfileSet,ovrFile); @@ -1056,12 +1056,9 @@ picglue () AnalyzepCode('*'); //code->dbName); +#ifdef PCODE_DEBUG printCallTree(stderr); - - //pCodePeepInit(); - - //OptimizepCode(code->dbName); - +#endif /* print the global struct definitions */ if (options.debug) @@ -1140,9 +1137,6 @@ picglue () fprintf (asmFile, "; dpl and dph to emulate the 8051 calling mechanism \n"); fprintf (asmFile, "%s", iComments2); - fprintf (asmFile, "\tdph\n"); - - /* copy the sbit segment */ fprintf (asmFile, "%s", iComments2); @@ -1156,6 +1150,8 @@ picglue () fprintf (asmFile, "%s", iComments2); copyFile (asmFile, data->oFile); + fprintf (asmFile, "\tendc\n"); + /* create the overlay segments */ fprintf (asmFile, "%s", iComments2); @@ -1195,9 +1191,6 @@ picglue () copyFile (asmFile, xdata->oFile); - fprintf (asmFile, "\tendc\n"); - - /* copy the bit segment */ fprintf (asmFile, "%s", iComments2); fprintf (asmFile, "; bit data\n"); diff --git a/src/pic/main.c b/src/pic/main.c index 346ffa98..8669abd9 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -208,9 +208,13 @@ static const char *_linkCmd[] = "aslink", "-nf", "$1", NULL }; +/* Sigh. This really is not good. For now, I recommend: + * sdcc -S -mpic14 file.c + * the -S option does not compile or link + */ static const char *_asmCmd[] = { - "gpasm", NULL, NULL, NULL + "gpasm", "-c -I /usr/local/share/gpasm/header", "$1.asm", NULL }; diff --git a/src/pic/pcode.c b/src/pic/pcode.c index 0f935752..14522f8a 100644 --- a/src/pic/pcode.c +++ b/src/pic/pcode.c @@ -873,7 +873,7 @@ void pic14initMnemonics(void) pci = hTabFirstItem(pic14MnemonicsHash, &key); while(pci) { - fprintf( stderr, "element %d key %d, mnem %s\n",i++,key,pci->mnemonic); + DFPRINTF((stderr, "element %d key %d, mnem %s\n",i++,key,pci->mnemonic)); pci = hTabNextItem(pic14MnemonicsHash, &key); } @@ -977,7 +977,7 @@ void copypCode(FILE *of, char dbName) void pcode_test(void) { - printf("pcode is alive!\n"); + DFPRINTF((stderr,"pcode is alive!\n")); //initMnemonics(); @@ -2079,9 +2079,15 @@ void AnalyzepBlock(pBlock *pb) if(!pb) return; - /* Find all of the registers used in this pBlock */ + /* Find all of the registers used in this pBlock + * by looking at each instruction and examining it's + * operands + */ for(pc = pb->pcHead; pc; pc = pc->next) { + + /* Is this an instruction with operands? */ if(pc->type == PC_OPCODE && PCI(pc)->pcop) { + if(PCI(pc)->pcop->type == PO_GPR_TEMP) { /* Loop through all of the registers declared so far in @@ -2111,7 +2117,7 @@ void AnalyzepBlock(pBlock *pb) if(PCI(pc)->pcop->type == PO_GPR_REGISTER) { if(PCOR(PCI(pc)->pcop)->r) { pic14_allocWithIdx (PCOR(PCI(pc)->pcop)->r->rIdx); - fprintf(stderr,"found register in pblock: reg 0x%x\n",PCOR(PCI(pc)->pcop)->r->rIdx); + DFPRINTF((stderr,"found register in pblock: reg 0x%x\n",PCOR(PCI(pc)->pcop)->r->rIdx)); } else { if(PCI(pc)->pcop->name) fprintf(stderr,"ERROR: %s is a NULL register\n",PCI(pc)->pcop->name ); @@ -2135,11 +2141,11 @@ int OptimizepBlock(pBlock *pb) if(!pb || !peepOptimizing) return 0; - fprintf(stderr," Optimizing pBlock: %c\n",getpBlock_dbName(pb)); + DFPRINTF((stderr," Optimizing pBlock: %c\n",getpBlock_dbName(pb))); for(pc = pb->pcHead; pc; pc = pc->next) matches += pCodePeepMatchRule(pc); if(matches) - fprintf(stderr," Optimizing pBlock: %c - matches=%d\n",getpBlock_dbName(pb),matches); + DFPRINTF((stderr," Optimizing pBlock: %c - matches=%d\n",getpBlock_dbName(pb),matches)); return matches; } @@ -2191,7 +2197,7 @@ void pBlockRemoveUnusedLabels(pBlock *pb) * So, unlink the pCode label from it's pCode chain * and destroy the label */ - fprintf(stderr," !!! REMOVED A LABEL !!! key = %d\n", pcl->key); + DFPRINTF((stderr," !!! REMOVED A LABEL !!! key = %d\n", pcl->key)); if(pc->type == PC_LABEL) { unlinkPC(pc); @@ -2274,7 +2280,7 @@ void OptimizepCode(char dbName) if(!the_pFile) return; - fprintf(stderr," Optimizing pCode\n"); + DFPRINTF((stderr," Optimizing pCode\n")); do { for(pb = the_pFile->pbHead; pb; pb = pb->next) { @@ -2309,13 +2315,13 @@ void AnalyzepCode(char dbName) i = 0; do { - fprintf(stderr," Analyzing pCode: PASS #%d\n",i+1); + DFPRINTF((stderr," Analyzing pCode: PASS #%d\n",i+1)); /* First, merge the labels with the instructions */ for(pb = the_pFile->pbHead; pb; pb = pb->next) { if('*' == dbName || getpBlock_dbName(pb) == dbName) { - fprintf(stderr," analyze and merging block %c\n",dbName); + DFPRINTF((stderr," analyze and merging block %c\n",dbName)); pBlockMergeLabels(pb); AnalyzepBlock(pb); } @@ -2542,8 +2548,9 @@ set *register_usage(pBlock *pb) } - +#ifdef PCODE_DEBUG pBlockStats(stderr,pb); // debug +#endif // Mark the registers in this block as used. @@ -2555,7 +2562,7 @@ set *register_usage(pBlock *pb) regs *r1,*r2, *newreg; - fprintf(stderr,"comparing registers\n"); + DFPRINTF((stderr,"comparing registers\n")); r1 = setFirstItem(registersInCallPath); while(r1) { @@ -2569,12 +2576,12 @@ set *register_usage(pBlock *pb) if(!newreg) { - fprintf(stderr,"Bummer, no more registers.\n"); + DFPRINTF((stderr,"Bummer, no more registers.\n")); exit(1); } - fprintf(stderr,"Cool found register collision nIdx=%d moving to %d\n", - r1->rIdx, newreg->rIdx); + DFPRINTF((stderr,"Cool found register collision nIdx=%d moving to %d\n", + r1->rIdx, newreg->rIdx)); r2->rIdx = newreg->rIdx; //if(r2->name) free(r2->name); if(newreg->name) @@ -2604,15 +2611,15 @@ set *register_usage(pBlock *pb) // MarkUsedRegisters(pb->registers); registers = unionSets(pb->registers, registersInCallPath, THROW_NONE); - +#ifdef PCODE_DEBUG if(registers) - fprintf(stderr,"returning regs\n"); + DFPRINTF((stderr,"returning regs\n")); else - fprintf(stderr,"not returning regs\n"); + DFPRINTF((stderr,"not returning regs\n")); - fprintf(stderr,"pBlock after register optim.\n"); + DFPRINTF((stderr,"pBlock after register optim.\n")); pBlockStats(stderr,pb); // debug - +#endif return registers; } @@ -2757,7 +2764,7 @@ void printCallTree(FILE *of) fprintf(of, "\npBlock statistics\n"); for(pb = the_pFile->pbHead; pb; pb = pb->next ) - pBlockStats(stderr,pb); + pBlockStats(of,pb); diff --git a/src/pic/pcode.h b/src/pic/pcode.h index ed230e74..39a637d0 100644 --- a/src/pic/pcode.h +++ b/src/pic/pcode.h @@ -65,6 +65,26 @@ struct regs; #ifndef __PCODE_H__ #define __PCODE_H__ +/*********************************************************************** + * debug stuff + * + * The DFPRINTF macro will call fprintf if PCODE_DEBUG is defined. + * The macro is used like: + * + * DPRINTF(("%s #%d\n","test", 1)); + * + * The double parenthesis (()) are necessary + * + ***********************************************************************/ +//#define PCODE_DEBUG + +#ifdef PCODE_DEBUG +#define DFPRINTF(args) (fprintf args) +#else +#define DFPRINTF(args) ; +#endif + + /*********************************************************************** * PIC status bits - this will move into device dependent headers ***********************************************************************/ diff --git a/src/pic/pcodepeep.c b/src/pic/pcodepeep.c index 115852a5..b21f7cea 100644 --- a/src/pic/pcodepeep.c +++ b/src/pic/pcodepeep.c @@ -307,7 +307,7 @@ static void * cvt_altpat_label(void *pp) { parsedPattern *p = pp; - fprintf(stderr,"altpat_label with ID = %d\n",p->pct[1].tok.n); + DFPRINTF((stderr,"altpat_label with ID = %d\n",p->pct[1].tok.n)); return newpCodeLabel(-p->pct[1].tok.n); } @@ -324,7 +324,7 @@ static void * cvt_altpat_comment(void *pp) { parsedPattern *p = pp; - fprintf(stderr,"altpat_comment = %s\n",p->pct[0].tok.s); + DFPRINTF((stderr,"altpat_comment = %s\n",p->pct[0].tok.s)); return newpCodeCharP(p->pct[0].tok.s); } @@ -338,7 +338,7 @@ static void * cvt_altpat_mnem0(void *pp) pCodeInstruction *pci=NULL; - fprintf(stderr,"altpat_mnem0 %s\n", p->pct[0].tok.s); + DFPRINTF((stderr,"altpat_mnem0 %s\n", p->pct[0].tok.s)); opcode = getpCode(p->pct[0].tok.s,0); if(opcode < 0) { @@ -366,7 +366,7 @@ static void * cvt_altpat_mnem0a(void *pp) { parsedPattern *p = pp; - fprintf(stderr,"altpat_mnem0a wild mnem # %d\n", p[0].pct[1].tok.n); + DFPRINTF((stderr,"altpat_mnem0a wild mnem # %d\n", p[0].pct[1].tok.n)); /* Save the index of the maximum wildcard mnemonic */ @@ -394,7 +394,7 @@ static void * cvt_altpat_mnem1(void *pp) pCodeInstruction *pci=NULL; pCodeOp *pcosubtype; - fprintf(stderr,"altpat_mnem1 %s var %s\n", p->pct[0].tok.s,p[1].pct[0].tok.s); + DFPRINTF((stderr,"altpat_mnem1 %s var %s\n", p->pct[0].tok.s,p[1].pct[0].tok.s)); opcode = getpCode(p->pct[0].tok.s,0); if(opcode < 0) { @@ -433,7 +433,7 @@ static void * cvt_altpat_mnem1a(void *pp) pCodeInstruction *pci=NULL; pCodeOp *pcosubtype; - fprintf(stderr,"altpat_mnem1a %s var %d\n", p->pct[0].tok.s,p[1].pct[1].tok.n); + DFPRINTF((stderr,"altpat_mnem1a %s var %d\n", p->pct[0].tok.s,p[1].pct[1].tok.n)); opcode = getpCode(p->pct[0].tok.s,0); if(opcode < 0) { @@ -470,7 +470,7 @@ static void * cvt_altpat_mnem1b(void *pp) pCodeInstruction *pci=NULL; - fprintf(stderr,"altpat_mnem1b %s var %d\n", p->pct[0].tok.s,p[1].pct[0].tok.n); + DFPRINTF((stderr,"altpat_mnem1b %s var %d\n", p->pct[0].tok.s,p[1].pct[0].tok.n)); opcode = getpCode(p->pct[0].tok.s,0); if(opcode < 0) { @@ -500,11 +500,11 @@ static void * cvt_altpat_mnem2(void *pp) dest = cvt_extract_destination(&p[3]); - fprintf(stderr,"altpat_mnem2 %s var %s destination %s(%d)\n", + DFPRINTF((stderr,"altpat_mnem2 %s var %s destination %s(%d)\n", p->pct[0].tok.s, p[1].pct[0].tok.s, p[3].pct[0].tok.s, - dest); + dest)); opcode = getpCode(p->pct[0].tok.s,dest); @@ -555,11 +555,11 @@ static void * cvt_altpat_mnem2a(void *pp) dest = cvt_extract_destination(&p[3]); - fprintf(stderr,"altpat_mnem2a %s var %d destination %s(%d)\n", + DFPRINTF((stderr,"altpat_mnem2a %s var %d destination %s(%d)\n", p->pct[0].tok.s, p[1].pct[1].tok.n, p[3].pct[0].tok.s, - dest); + dest)); opcode = getpCode(p->pct[0].tok.s,dest); @@ -688,7 +688,7 @@ static void tokenizeLineNode(char *ln) void dump1Token(pCodeTokens tt) { - +#ifdef PCODE_DEBUG switch(tt) { case PCT_SPACE: fprintf(stderr, " space "); @@ -720,6 +720,7 @@ void dump1Token(pCodeTokens tt) fprintf(stderr, " null "); } +#endif } @@ -733,16 +734,16 @@ int pcComparePattern(pCodeToken *pct, char *pat, int max_tokens) if(!pct || !pat || !*pat) return 0; - //fprintf(stderr,"comparing against:\n"); + //DFPRINTF((stderr,"comparing against:\n")); while(i < max_tokens) { if(*pat == 0){ - //fprintf(stderr,"matched\n"); + //DFPRINTF((stderr,"matched\n")); return (i+1); } - //dump1Token(*pat); fprintf(stderr,"\n"); + //dump1Token(*pat); DFPRINTF((stderr,"\n")); if(pct->tt != *pat) return 0; @@ -770,11 +771,11 @@ int altComparePattern( char *pct, parsedPattern *pat, int max_tokens) while(i < max_tokens) { if(*pct == 0) { - //fprintf(stderr,"matched\n"); + //DFPRINTF((stderr,"matched\n")); return i; } - //dump1Token(*pat); fprintf(stderr,"\n"); + //dump1Token(*pat); DFPRINTF((stderr,"\n")); if( !pat || !pat->pcp ) return 0; @@ -782,7 +783,7 @@ int altComparePattern( char *pct, parsedPattern *pat, int max_tokens) if (pat->pcp->pt != *pct) return 0; - //fprintf(stderr," pct=%d\n",*pct); + //DFPRINTF((stderr," pct=%d\n",*pct)); pct++; pat++; i++; @@ -833,9 +834,9 @@ void parseTokens(void) for(i=0; i<=tokIdx; i++) dump1Token(tokArr[i].tt); - +#ifdef PCODE_DEBUG fputc('\n',stderr); - +#endif { int lparsedPatIdx=0; int lpcpIdx; @@ -880,32 +881,32 @@ void parseTokens(void) switch(pcpArr[lpcpIdx].pt) { case PCP_LABEL: if(state == PS_START){ - fprintf(stderr," label\n"); + DFPRINTF((stderr," label\n")); state = PS_HAVE_LABEL; } else - fprintf(stderr," bad state (%d) for label\n",state); + DFPRINTF((stderr," bad state (%d) for label\n",state)); break; case PCP_STR: - fprintf(stderr," %s is",tokArr[ltokIdx].tok.s); + DFPRINTF((stderr," %s is",tokArr[ltokIdx].tok.s)); switch(state) { case PS_START: case PS_HAVE_LABEL: - fprintf(stderr," mnem\n"); + DFPRINTF((stderr," mnem\n")); cPmnem = tokArr[ltokIdx].tok.s; state = PS_HAVE_MNEM; break; case PS_HAVE_MNEM: - fprintf(stderr," 1st operand\n"); + DFPRINTF((stderr," 1st operand\n")); cP1stop = tokArr[ltokIdx].tok.s; //pco1 = newpCodeOp(NULL,PO_GPR_REGISTER); state = PS_HAVE_1OPERAND; break; case PS_HAVE_1OPERAND: - fprintf(stderr," error expecting comma\n"); + DFPRINTF((stderr," error expecting comma\n")); break; case PS_HAVE_COMMA: - fprintf(stderr," 2 operands\n"); + DFPRINTF((stderr," 2 operands\n")); cP2ndop = tokArr[ltokIdx].tok.s; break; case PS_HAVE_2OPERANDS: @@ -917,18 +918,18 @@ void parseTokens(void) switch(state) { case PS_START: case PS_HAVE_LABEL: - fprintf(stderr," wild mnem\n"); + DFPRINTF((stderr," wild mnem\n")); state = PS_HAVE_MNEM; break; case PS_HAVE_MNEM: - fprintf(stderr," 1st operand is wild\n"); + DFPRINTF((stderr," 1st operand is wild\n")); state = PS_HAVE_1OPERAND; break; case PS_HAVE_1OPERAND: - fprintf(stderr," error expecting comma\n"); + DFPRINTF((stderr," error expecting comma\n")); break; case PS_HAVE_COMMA: - fprintf(stderr," 2nd operand is wild\n"); + DFPRINTF((stderr," 2nd operand is wild\n")); break; case PS_HAVE_2OPERANDS: break; @@ -942,14 +943,14 @@ void parseTokens(void) fprintf(stderr," ERROR number\n"); break; case PS_HAVE_MNEM: - fprintf(stderr," 1st operand is a number\n"); + DFPRINTF((stderr," 1st operand is a number\n")); state = PS_HAVE_1OPERAND; break; case PS_HAVE_1OPERAND: fprintf(stderr," error expecting comma\n"); break; case PS_HAVE_COMMA: - fprintf(stderr," 2nd operand is a number\n"); + DFPRINTF((stderr," 2nd operand is a number\n")); break; case PS_HAVE_2OPERANDS: break; @@ -960,7 +961,7 @@ void parseTokens(void) break; case PCP_COMMA: if(state == PS_HAVE_1OPERAND){ - fprintf(stderr," got a comma\n"); + DFPRINTF((stderr," got a comma\n")); state = PS_HAVE_COMMA; } else fprintf(stderr," unexpected comma\n"); @@ -974,7 +975,7 @@ void parseTokens(void) //dump1Token(tokArr[ltokIdx].tt); if(advTokIdx(<okIdx, strlen(pcpArr[lpcpIdx].tokens) ) ) { - fprintf(stderr," reached end \n"); + DFPRINTF((stderr," reached end \n")); matching = 0; //return; } @@ -1009,18 +1010,18 @@ void parseTokens(void) while(j<=lparsedPatIdx && kf ) parsedPatArr[j].pcp->f(&parsedPatArr[j]); - fprintf(stderr," %d",parsedPatArr[j].pcp->pt); + DFPRINTF((stderr," %d",parsedPatArr[j].pcp->pt)); j++; } while(jnext) { - //fprintf(stderr,"%s\n",ln->line); + //DFPRINTF((stderr,"%s\n",ln->line)); tokenizeLineNode(ln->line); parseTokens(); @@ -1054,12 +1055,12 @@ static void peepRuleCondition(char *cond) if(!cond) return; - //fprintf(stderr,"\nCondition: %s\n",cond); + //DFPRINTF((stderr,"\nCondition: %s\n",cond)); /* brute force compares for now */ if(STRCASECMP(cond, "NZ") == 0) { - //fprintf(stderr,"found NZ\n"); + //DFPRINTF((stderr,"found NZ\n")); curPeep->postFalseCond = PCC_Z; } @@ -1093,7 +1094,7 @@ void peepRules2pCode(peepRule *rules) for (pr = rules; pr; pr = pr->next) { - //fprintf(stderr,"\nRule:\n\n"); + //DFPRINTF((stderr,"\nRule:\n\n")); pcps = Safe_calloc(1,sizeof(pCodePeepSnippets)); curPeep = pcps->peep = Safe_calloc(1,sizeof(pCodePeep)); @@ -1112,14 +1113,16 @@ void peepRules2pCode(peepRule *rules) /* Convert the target block */ peepRuleBlock2pCodeBlock(pr->match); - //fprintf(stderr,"finished target, here it is in pcode form:\n"); + //DFPRINTF((stderr,"finished target, here it is in pcode form:\n")); //printpBlock(stderr, curBlock); - //fprintf(stderr,"target with labels merged:\n"); + //DFPRINTF((stderr,"target with labels merged:\n")); pBlockMergeLabels(curBlock); +#ifdef PCODE_DEBUG printpBlock(stderr, curBlock); +#endif - //fprintf(stderr,"\nReplaced by:\n"); + //DFPRINTF((stderr,"\nReplaced by:\n")); curPeep->replace = curBlock = newpCodeChain(NULL, 'W', NULL); @@ -1127,10 +1130,10 @@ void peepRules2pCode(peepRule *rules) /* Convert the replace block */ peepRuleBlock2pCodeBlock(pr->replace); - //fprintf(stderr,"finished replace block, here it is in pcode form:\n"); + //DFPRINTF((stderr,"finished replace block, here it is in pcode form:\n")); //printpBlock(stderr, curBlock); - //fprintf(stderr,"replace with labels merged:\n"); + //DFPRINTF((stderr,"replace with labels merged:\n")); pBlockMergeLabels(curBlock); //printpBlock(stderr, curBlock); @@ -1269,20 +1272,20 @@ int pCodePeepMatchLabels(pCodePeep *peepBlock, pCode *pcs, pCode *pcd) pcl = pcd->label->pc; labindex = -PCL(pcl)->key; - //fprintf(stderr,"label id = %d (labindex = %d)\n",PCL(pcl)->key,labindex); + //DFPRINTF((stderr,"label id = %d (labindex = %d)\n",PCL(pcl)->key,labindex)); if(peepBlock->vars[labindex] == NULL) { // First time to encounter this label peepBlock->vars[labindex] = PCL(pcs->label->pc)->label; - //fprintf(stderr,"first time for a label: %d %s\n",labindex, peepBlock->vars[labindex]); + //DFPRINTF((stderr,"first time for a label: %d %s\n",labindex, peepBlock->vars[labindex])); } else { if(strcmp(peepBlock->vars[labindex],PCL(pcs->label->pc)->label) != 0) { - // fprintf(stderr,"labels don't match\n"); + // DFPRINTF((stderr,"labels don't match\n")); return 0; } - //fprintf(stderr,"matched a label\n"); + //DFPRINTF((stderr,"matched a label\n")); } } else { - // fprintf(stderr,"destination doesn't have a label\n"); + // DFPRINTF((stderr,"destination doesn't have a label\n")); if(pcs->label) return 0; @@ -1332,7 +1335,7 @@ int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd) return 0; /* - fprintf(stderr,"%s comparing\n",__FUNCTION__); + DFPRINTF((stderr,"%s comparing\n",__FUNCTION__)); pcs->print(stderr,pcs); pcd->print(stderr,pcd); */ @@ -1345,10 +1348,10 @@ int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd) if (PCI(pcd)->pcop->type == PO_WILD) { index = PCOW(PCI(pcd)->pcop)->id; - //fprintf(stderr,"destination is wild\n"); + //DFPRINTF((stderr,"destination is wild\n")); #ifdef DEBUG_PCODEPEEP if (index > peepBlock->nops) { - fprintf(stderr,"%s - variables exceeded\n",__FUNCTION__); + DFPRINTF((stderr,"%s - variables exceeded\n",__FUNCTION__)); exit(1); } #endif @@ -1376,7 +1379,7 @@ int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd) if(peepBlock->vars[index]) return (strcmp(peepBlock->vars[index],n) == 0); else { - // fprintf(stderr,"first time for a variable: %d, %s\n",index,n); + // DFPRINTF((stderr,"first time for a variable: %d, %s\n",index,n)); peepBlock->vars[index] = n; return 1; } @@ -1396,7 +1399,7 @@ int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd) index = PCW(pcd)->id; - // fprintf(stderr,"%s comparing wild cards\n",__FUNCTION__); + // DFPRINTF((stderr,"%s comparing wild cards\n",__FUNCTION__)); //pcs->print(stderr,pcs); //pcd->print(stderr,pcd); @@ -1411,10 +1414,10 @@ int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd) int i = (strcmp(peepBlock->vars[index],PCI(pcs)->pcop->name) == 0); /* if(i) - fprintf(stderr," (matched)\n"); + DFPRINTF((stderr," (matched)\n")); else { - fprintf(stderr," (no match: wild card operand mismatch\n"); - fprintf(stderr," peepblock= %s, pcodeop= %s\n", + DFPRINTF((stderr," (no match: wild card operand mismatch\n")); + DFPRINTF((stderr," peepblock= %s, pcodeop= %s\n"), peepBlock->vars[index], PCI(pcs)->pcop->name); } @@ -1428,7 +1431,7 @@ int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd) pcs = findNextInstruction(pcs->next); if(pcs) { - //fprintf(stderr," (next to match)\n"); + //DFPRINTF((stderr," (next to match)\n")); //pcs->print(stderr,pcs); } else if(pcd->next) { /* oops, we ran out of code, but there's more to the rule */ @@ -1489,7 +1492,7 @@ static pCodeOp *pCodeOpCopy(pCodeOp *pcop) switch(pcop->type) { case PO_CRY: case PO_BIT: - //fprintf(stderr,"pCodeOpCopy bit\n"); + //DFPRINTF((stderr,"pCodeOpCopy bit\n")); pcopnew = Safe_calloc(1,sizeof(pCodeOpBit) ); PCOB(pcopnew)->bit = PCOB(pcop)->bit; PCOB(pcopnew)->inBitSpace = PCOB(pcop)->inBitSpace; @@ -1499,28 +1502,28 @@ static pCodeOp *pCodeOpCopy(pCodeOp *pcop) case PO_WILD: /* Here we expand the wild card into the appropriate type: */ /* By recursively calling pCodeOpCopy */ - //fprintf(stderr,"pCodeOpCopy wild\n"); + //DFPRINTF((stderr,"pCodeOpCopy wild\n")); if(PCOW(pcop)->matched) pcopnew = pCodeOpCopy(PCOW(pcop)->matched); else { // Probably a label pcopnew = pCodeOpCopy(PCOW(pcop)->subtype); pcopnew->name = Safe_strdup(PCOW(pcop)->pcp->vars[PCOW(pcop)->id]); - //fprintf(stderr,"copied a wild op named %s\n",pcopnew->name); + //DFPRINTF((stderr,"copied a wild op named %s\n",pcopnew->name)); } return pcopnew; break; case PO_LABEL: - //fprintf(stderr,"pCodeOpCopy label\n"); + //DFPRINTF((stderr,"pCodeOpCopy label\n")); pcopnew = Safe_calloc(1,sizeof(pCodeOpLabel) ); PCOLAB(pcopnew)->key = PCOLAB(pcop)->key; break; case PO_LITERAL: case PO_IMMEDIATE: - //fprintf(stderr,"pCodeOpCopy lit\n"); + //DFPRINTF((stderr,"pCodeOpCopy lit\n")); pcopnew = Safe_calloc(1,sizeof(pCodeOpLit) ); PCOL(pcopnew)->lit = PCOL(pcop)->lit; break; @@ -1530,15 +1533,15 @@ static pCodeOp *pCodeOpCopy(pCodeOp *pcop) case PO_GPR_BIT: case PO_FSR: case PO_INDF: - //fprintf(stderr,"pCodeOpCopy GPR register\n"); + //DFPRINTF((stderr,"pCodeOpCopy GPR register\n")); pcopnew = Safe_calloc(1,sizeof(pCodeOpReg) ); PCOR(pcopnew)->r = PCOR(pcop)->r; PCOR(pcopnew)->rIdx = PCOR(pcop)->rIdx; - fprintf(stderr," register index %d\n", PCOR(pcop)->r->rIdx); + DFPRINTF((stderr," register index %d\n", PCOR(pcop)->r->rIdx)); break; case PO_DIR: - //fprintf(stderr,"pCodeOpCopy PO_DIR\n"); + //DFPRINTF((stderr,"pCodeOpCopy PO_DIR\n")); case PO_SFR_REGISTER: case PO_STR: case PO_NONE: @@ -1547,7 +1550,7 @@ static pCodeOp *pCodeOpCopy(pCodeOp *pcop) case PO_PCL: case PO_PCLATH: - //fprintf(stderr,"pCodeOpCopy register type %d\n", pcop->type); + //DFPRINTF((stderr,"pCodeOpCopy register type %d\n", pcop->type)); pcopnew = Safe_calloc(1,sizeof(pCodeOp) ); } @@ -1581,7 +1584,7 @@ void pCodeDeleteChain(pCode *f,pCode *t) while(f && f!=t) { - fprintf(stderr,"delete pCode:\n"); + DFPRINTF((stderr,"delete pCode:\n")); pc = f->next; f->print(stderr,f); //f->delete(f); this dumps core... @@ -1620,11 +1623,11 @@ int pCodePeepMatchRule(pCode *pc) pcin = findNextInstruction(pcin->next); pct = pct->next; //debug: - //fprintf(stderr," matched\n"); + //DFPRINTF((stderr," matched\n")); if(!pcin) - fprintf(stderr," end of code\n"); + DFPRINTF((stderr," end of code\n")); if(!pct) - fprintf(stderr," end of rule\n"); + DFPRINTF((stderr," end of rule\n")); } if(matched) { @@ -1637,7 +1640,7 @@ int pCodePeepMatchRule(pCode *pc) * following the point just past where we have matched depend on * the `postFalseCond' as input then we abort the match */ - fprintf(stderr," matched rule so far, now checking conditions\n"); + DFPRINTF((stderr," matched rule so far, now checking conditions\n")); if (pcin && peepBlock->postFalseCond && (pCodeSearchCondition(pcin,peepBlock->postFalseCond) > 0) ) matched = 0; @@ -1651,13 +1654,14 @@ int pCodePeepMatchRule(pCode *pc) /* We matched a rule! Now we have to go through and remove the inefficient code with the optimized version */ - - fprintf(stderr, "Found a pcode peep match:\nRule:\n"); +#ifdef PCODE_DEBUG + DFPRINTF((stderr, "Found a pcode peep match:\nRule:\n")); printpCodeString(stderr,peepBlock->target->pcHead,10); - fprintf(stderr,"first thing matched\n"); + DFPRINTF((stderr,"first thing matched\n")); pc->print(stderr,pc); +#endif if(pcin) { - fprintf(stderr,"last thing matched\n"); + DFPRINTF((stderr,"last thing matched\n")); pcin->print(stderr,pcin); } @@ -1700,15 +1704,15 @@ int pCodePeepMatchRule(pCode *pc) * Is it wild? */ if(PCI(pcr)->pcop->type == PO_WILD) { int index = PCOW(PCI(pcr)->pcop)->id; - //fprintf(stderr,"copying wildopcode\n"); + //DFPRINTF((stderr,"copying wildopcode\n")); if(peepBlock->wildpCodeOps[index]) pcop = pCodeOpCopy(peepBlock->wildpCodeOps[index]); else - fprintf(stderr,"error, wildopcode in replace but not source?\n"); + DFPRINTF((stderr,"error, wildopcode in replace but not source?\n")); } else pcop = pCodeOpCopy(PCI(pcr)->pcop); } - //fprintf(stderr,"inserting pCode\n"); + //DFPRINTF((stderr,"inserting pCode\n")); pCodeInsertAfter(pc, newpCode(PCI(pcr)->op,pcop)); } else if (pcr->type == PC_WILD) { pCodeInsertAfter(pc,peepBlock->wildpCodes[PCW(pcr)->id]); diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index 125bd812..2160bf9b 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -2173,7 +2173,7 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) if (IS_TRUE_SYMOP (IC_RESULT (dic)) && IS_OP_VOLATILE (IC_RESULT (dic))) { - debugLog (" %d - \n", __LINE__); + debugLog (" %d - dic is VOLATILE \n", __LINE__); dic = NULL; break; } @@ -2181,7 +2181,9 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) if (IS_SYMOP (IC_RESULT (dic)) && IC_RESULT (dic)->key == IC_RIGHT (ic)->key) { - debugLog (" %d - dic key == ic key -- pointer set=%c\n", __LINE__, ((POINTER_SET (dic)) ? 'Y' : 'N')); + /* A previous result was assigned to the same register - we'll our definition */ + debugLog (" %d - dic result key == ic right key -- pointer set=%c\n", + __LINE__, ((POINTER_SET (dic)) ? 'Y' : 'N')); if (POINTER_SET (dic)) dic = NULL; @@ -2192,7 +2194,7 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) (IC_RIGHT (dic)->key == IC_RESULT (ic)->key || IC_RIGHT (dic)->key == IC_RIGHT (ic)->key)) { - debugLog (" %d - \n", __LINE__); + debugLog (" %d - dic right key == ic rightor result key\n", __LINE__); dic = NULL; break; } @@ -2201,7 +2203,7 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) (IC_LEFT (dic)->key == IC_RESULT (ic)->key || IC_LEFT (dic)->key == IC_RIGHT (ic)->key)) { - debugLog (" %d - \n", __LINE__); + debugLog (" %d - dic left key == ic rightor result key\n", __LINE__); dic = NULL; break; } @@ -2209,7 +2211,8 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) if (POINTER_SET (dic) && IC_RESULT (dic)->key == IC_RESULT (ic)->key) { - debugLog (" %d - \n", __LINE__); + debugLog (" %d - dic result key == ic result key -- pointer set=Y\n", + __LINE__); dic = NULL; break; } @@ -2238,6 +2241,7 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) } pack: debugLog (" packing. removing %s\n", OP_SYMBOL (IC_RIGHT (ic))->rname); + debugLog (" replacing with %s\n", OP_SYMBOL (IC_RESULT (dic))->rname); /* found the definition */ /* replace the result with the result of */ /* this assignment and remove this assignment */ @@ -3126,7 +3130,7 @@ pic14_assignRegisters (eBBlock ** ebbs, int count) int i; debugLog ("<><><><><><><><><><><><><><><><><>\nstarting\t%s:%s", __FILE__, __FUNCTION__); - debugLog ("ebbs before optimizing:\n"); + debugLog ("\nebbs before optimizing:\n"); dumpEbbsToDebug (ebbs, count); setToNull ((void *) &_G.funcrUsed); diff --git a/src/regression/Makefile b/src/regression/Makefile index d5fe5cae..6561def8 100644 --- a/src/regression/Makefile +++ b/src/regression/Makefile @@ -98,7 +98,7 @@ all: test # The asm files are generated by sdcc .c.asm: - $(CC) -mpic14 -c $*.c + $(CC) -mpic14 -S $*.c # The .cod files are generated by gpasm # these get loaded by gpsim. @@ -108,7 +108,6 @@ all: test # The .stc files are script files for gpsim .cod.stc: ./$(CREATESTC) $*.cod $*.stc - echo "Created $*.stc" ./$(SIMULATE) $*.stc $(LOGFILE) # this will also make .stc files diff --git a/src/regression/rt.sh b/src/regression/rt.sh index 6e7273d9..60692136 100755 --- a/src/regression/rt.sh +++ b/src/regression/rt.sh @@ -8,9 +8,9 @@ if [ $# -lt 1 ] ; then fi # compile -../../bin/sdcc -c -mpic14 $1.c +../../bin/sdcc -S -mpic14 $1.c gpasm -c -I /usr/local/share/gpasm/header $1.asm ./create_stc $1.cod $1.stc ./simulate $1.stc garbage.log cat garbage.log -rm garbage.log \ No newline at end of file +rm garbage.log -- 2.30.2