git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2025
4a8a32a2-be11-0410-ad9d-
d568d2c75423
else {
PIC_OPCODE poc = POC_ADDFW;
else {
PIC_OPCODE poc = POC_ADDFW;
- if ((AOP_TYPE(IC_LEFT(ic)) == AOP_PCODE) && AOP(IC_LEFT(ic))->aopu.pcop->type == PO_LITERAL)
+ if ((AOP_TYPE(IC_LEFT(ic)) == AOP_PCODE) && (
+ (AOP(IC_LEFT(ic))->aopu.pcop->type == PO_LITERAL) ||
+ (AOP(IC_LEFT(ic))->aopu.pcop->type == PO_IMMEDIATE)))
poc = POC_ADDLW;
emitpcode(poc, popGet(AOP(IC_LEFT(ic)),0));
if ( AOP_TYPE(IC_RESULT(ic)) != AOP_ACC)
poc = POC_ADDLW;
emitpcode(poc, popGet(AOP(IC_LEFT(ic)),0));
if ( AOP_TYPE(IC_RESULT(ic)) != AOP_ACC)
static void pCodePrintFunction(FILE *of, pCode *pc);
static void pCodeOpPrint(FILE *of, pCodeOp *pcop);
static char *get_op_from_instruction( pCodeInstruction *pcc);
static void pCodePrintFunction(FILE *of, pCode *pc);
static void pCodeOpPrint(FILE *of, pCodeOp *pcop);
static char *get_op_from_instruction( pCodeInstruction *pcc);
-char *get_op( pCodeOp *pcop);
+char *get_op( pCodeOp *pcop,char *buff,int buf_size);
int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd);
int pCodePeepMatchRule(pCode *pc);
void pBlockStats(FILE *of, pBlock *pb);
int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd);
int pCodePeepMatchRule(pCode *pc);
void pBlockStats(FILE *of, pBlock *pb);
len = strlen(*str);
if(len > *size) {
fprintf(stderr,"WARNING, it looks like %s has overflowed\n",__FUNCTION__);
len = strlen(*str);
if(len > *size) {
fprintf(stderr,"WARNING, it looks like %s has overflowed\n",__FUNCTION__);
+ fprintf(stderr,"len = %d is > str size %d\n",len,*size);
len = strlen(buffer);
if(len > *size) {
fprintf(stderr,"WARNING, it looks like %s has overflowed\n",__FUNCTION__);
len = strlen(buffer);
if(len > *size) {
fprintf(stderr,"WARNING, it looks like %s has overflowed\n",__FUNCTION__);
+ fprintf(stderr,"len = %d is > str size %d\n",len,*size);
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
-char *get_op(pCodeOp *pcop)
+char *get_op(pCodeOp *pcop,char *buffer, int size)
- static char buffer[50];
+ if(!buffer) {
+ buffer = b;
+ size = sizeof(b);
+ }
if(pcop) {
switch(pcop->type) {
if(pcop) {
switch(pcop->type) {
// return PCOR(pcc->pcop)->r)->name;
case PO_IMMEDIATE:
s = buffer;
// return PCOR(pcc->pcop)->r)->name;
case PO_IMMEDIATE:
s = buffer;
+ //size = sizeof(buffer);
//fprintf(stderr,"PO_IMMEDIATE name = %s offset = %d\n",pcc->pcop->name,PCOI(pcc->pcop)->offset);
if(PCOI(pcop)->_const) {
//fprintf(stderr,"PO_IMMEDIATE name = %s offset = %d\n",pcc->pcop->name,PCOI(pcc->pcop)->offset);
if(PCOI(pcop)->_const) {
+ //size = sizeof(buffer);
if( PCOR(pcop)->instance) {
SAFE_snprintf(&s,&size,"(%s + %d)",
pcop->name,
if( PCOR(pcop)->instance) {
SAFE_snprintf(&s,&size,"(%s + %d)",
pcop->name,
- return get_op(pcc->pcop);
+ return get_op(pcc->pcop,NULL,0);
return ("ERROR Null: "__FUNCTION__);
return ("ERROR Null: "__FUNCTION__);
int getpCodePeepCommand(char *cmd);
void pBlockMergeLabels(pBlock *pb);
char *pCode2str(char *str, int size, pCode *pc);
int getpCodePeepCommand(char *cmd);
void pBlockMergeLabels(pBlock *pb);
char *pCode2str(char *str, int size, pCode *pc);
-char *get_op( pCodeOp *pcop);
+char *get_op( pCodeOp *pcop,char *buf,int buf_size);
extern pCodeInstruction *pic14Mnemonics[];
extern pCodeInstruction *pic14Mnemonics[];
return 0;
if(pc->type == PC_OPCODE) {
return 0;
if(pc->type == PC_OPCODE) {
+ //fprintf(stderr," checking conditions of: ");
+ //pc->print(stderr,pc);
if(PCI(pc)->inCond & cond)
return 1;
if(PCI(pc)->outCond & cond)
if(PCI(pc)->inCond & cond)
return 1;
if(PCI(pc)->outCond & cond)
*-----------------------------------------------------------------*/
int pCodeOpCompare(pCodeOp *pcops, pCodeOp *pcopd)
{
*-----------------------------------------------------------------*/
int pCodeOpCompare(pCodeOp *pcops, pCodeOp *pcopd)
{
if(!pcops || !pcopd)
return 0;
if(!pcops || !pcopd)
return 0;
fprintf(stderr," Comparing operands %s",
fprintf(stderr," Comparing operands %s",
+ get_op( pcops,NULL,0));
fprintf(stderr," to %s\n",
fprintf(stderr," to %s\n",
+ get_op( pcopd,NULL,0));
+*/
if(pcops->type != pcopd->type) {
//fprintf(stderr," - fail - diff types\n");
return 0; // different types
}
if(pcops->type != pcopd->type) {
//fprintf(stderr," - fail - diff types\n");
return 0; // different types
}
- if(!pcops->name || !pcopd->name || strcmp(pcops->name,pcopd->name)) {
- //fprintf(stderr," - fail - diff names\n");
+ b[0]=0;
+ get_op(pcops,b,sizeof(b));
+ n2 = get_op(pcopd,NULL,0);
+
+ if( !n2 || strcmp(b,n2)) {
+ //fprintf(stderr," - fail - diff names: %s, len=%d, %s, len=%d\n",b,strlen(b), n2, strlen(n2) );
return 0; // different names
}
return 0; // different names
}
- //fprintf(stderr," - pass\n");
+ // fprintf(stderr," - pass\n");
pct = pct->next;
//debug:
//DFPRINTF((stderr," matched\n"));
pct = pct->next;
//debug:
//DFPRINTF((stderr," matched\n"));
if(!pcin && pct) {
DFPRINTF((stderr," partial match... no more code\n"));
if(!pcin && pct) {
DFPRINTF((stderr," partial match... no more code\n"));
+ fprintf(stderr," partial match... no more code\n");
matched = 0;
}
if(!pct) {
matched = 0;
}
if(!pct) {
+ //pCode *pcr = peepBlock->replace.pb->pcHead;
+ //if(pcr) pcr->print(stderr,pcr);
+
/* So far we matched the rule up to the point of the conditions .
* In other words, all of the opcodes match. Now we need to see
* if the post conditions are satisfied.
/* So far we matched the rule up to the point of the conditions .
* In other words, all of the opcodes match. Now we need to see
* if the post conditions are satisfied.
if (pcin && peepBlock->postFalseCond &&
(pCodeSearchCondition(pcin,peepBlock->postFalseCond) > 0) )
matched = 0;
if (pcin && peepBlock->postFalseCond &&
(pCodeSearchCondition(pcin,peepBlock->postFalseCond) > 0) )
matched = 0;
+
+ if(!matched) fprintf(stderr,"failed on conditions\n");
{
/* DEBUG */
/* Converted the deleted pCodes into comments */
{
/* DEBUG */
/* Converted the deleted pCodes into comments */
if(pc_cline2)
pc_cline2->pc.next = NULL;
}
if(pc_cline2)
pc_cline2->pc.next = NULL;
}
if(pcin)
pCodeDeleteChain(pc,pcin);
if(pcin)
pCodeDeleteChain(pc,pcin);
-//replace restart {
-// btfss %1
-// goto %2
-// %3
-//%2: %4
-//} by {
-// ;peep 1 - test/jump to test/skip
-// btfsc %1
-// %3
-//%2: %4
-//}
-//
-//replace restart {
-// btfsc %1
-// goto %2
-// %3
-//%2: %4
-//} by {
-// ;peep 1a - test/jump to test/skip
-// btfss %1
-// %3
-//%2: %4
-//}
-//
-//replace restart {
-// btfss %1
-// goto %4
-//%2: %3
-//%4: %5
-//} by {
-// ;peep 1b - test/jump to test/skip
-// btfsc %1
-//%2: %3
-//%4: %5
-//}
-//
-//replace restart {
-// btfsc %1
-// goto %4
-//%2: %3
-//%4: %5
-//} by {
-// ;peep 1c - test/jump to test/skip
-// btfss %1
-//%2: %3
-//%4: %5
-//}
-
//bogus test for pcode
//replace restart {
//bogus test for pcode
//replace restart {