addSetHead(&binPathSet, Safe_strdup(buf));
}
+#if 0
if (options.printSearchDirs) {
printf("programs:\n");
fputStrSet(stdout, binPathSet);
}
+#endif
}
/* Set system include path */
if ((p = getenv(SDCC_INCLUDE_NAME)) != NULL)
addSetHead(&includeDirsSet, p);
+#if 0
if (options.printSearchDirs) {
printf("includedir:\n");
fputStrSet(stdout, includeDirsSet);
}
+#endif
}
/* Set system lib path */
if ((p = getenv(SDCC_LIB_NAME)) != NULL)
addSetHead(&libDirsSet, p);
+#if 0
if (options.printSearchDirs) {
printf("libdir:\n");
fputStrSet(stdout, libDirsSet);
}
+#endif
}
/* Set data path */
addSet(&dataDirsSet, Safe_strdup(DATADIR));
#endif
+#if 0
if (options.printSearchDirs) {
printf("datadir:\n");
fputStrSet(stdout, dataDirsSet);
}
+#endif
setIncludePath();
setLibPath();
}
+static void doPrintSearchDirs(void)
+{
+ printf("programs:\n");
+ fputStrSet(stdout, binPathSet);
+
+ printf("datadir:\n");
+ fputStrSet(stdout, dataDirsSet);
+
+ printf("includedir:\n");
+ fputStrSet(stdout, includeDirsSet);
+
+ printf("libdir:\n");
+ fputStrSet(stdout, libDirsSet);
+}
+
+
static void
sig_handler (int signal)
{
setBinPaths(argv[0]);
setDataPaths(argv[0]);
+ if(port->initPaths)
+ port->initPaths();
+
+ if(options.printSearchDirs)
+ doPrintSearchDirs();
+
/* if no input then printUsage & exit */
if (!options.c1mode && !fullSrcFileName && peekSet(relFilesSet) == NULL) {
if (!options.printSearchDirs)
_avr_init,
_avr_parseOptions,
NULL,
+ NULL,
_avr_finaliseOptions,
_avr_setDefaultOptions,
avr_assignRegisters,
_ds390_init,
_ds390_parseOptions,
NULL,
+ NULL,
_ds390_finaliseOptions,
_ds390_setDefaultOptions,
ds390_assignRegisters,
_tininative_init,
_ds390_parseOptions,
NULL,
+ NULL,
_tininative_finaliseOptions,
_tininative_setDefaultOptions,
ds390_assignRegisters,
_ds390_init,
_ds390_parseOptions,
NULL,
+ NULL,
_ds400_finaliseOptions,
_ds390_setDefaultOptions,
ds390_assignRegisters,
_hc08_init,
_hc08_parseOptions,
_hc08_options,
+ NULL,
_hc08_finaliseOptions,
_hc08_setDefaultOptions,
hc08_assignRegisters,
"_",
_i186_init,
_i186_parseOptions,
+ NULL,
_i186_finaliseOptions,
_i186_setDefaultOptions,
izt_assignRegisters,
"_",
_tlcs900h_init,
_tlcs900h_parseOptions,
+ NULL,
_tlcs900h_finaliseOptions,
_tlcs900h_setDefaultOptions,
tlcs900h_assignRegisters,
_mcs51_init,
_mcs51_parseOptions,
NULL,
+ NULL,
_mcs51_finaliseOptions,
_mcs51_setDefaultOptions,
mcs51_assignRegisters,
_pic14_init,
_pic14_parseOptions,
NULL,
+ NULL,
_pic14_finaliseOptions,
_pic14_setDefaultOptions,
pic14_assignRegisters,
======================================================================
======================================================================
+2004-May-23 Vangelis Rokas
+
+1. The improvement of the port has been stalled a bit. But, struct/union
+SFR headers are ready for the PIC18F[45][45][28] chips along with their
+respective sources.
+
+2. The genCmp function should be rewritten from scratch.
+
+3. The internal helper functions for char/int/long/float arithmetic
+now compile and will be placed in the appropriate directory under device/
+
+
+
2004-Feb-20 Vangelis Rokas
Major update with many bugfixes.
/* and secondarily by size */
if( (*i)->size > (*j)->size)return 1;
if( (*i)->size < (*j)->size)return -1;
-
+
+ /* register size sorting may have strange results use with care */
+
+ /* finally if in same address and same size sort by name */
+ return (strcmp( (*i)->name, (*j)->name));
return 0;
}
}
} else {
int j=0;
-
+ regs *r1;
+
rprev = NULL;
init_addr = rlist[j]->address;
fprintf(of, "\n\nstatic_%s_%02d\tudata\t0X%04X\n", moduleName, abs_section_no++, init_addr);
for(j=0;j<i;j++) {
r = rlist[j];
+ if(j < i-1)r1 = rlist[j+1]; else r1 = NULL;
+
init_addr = r->address;
- if(rprev && (init_addr != (rprev->address + rprev->size))) {
+
+ if(rprev && (init_addr != (rprev->address + rprev->size))
+ && !(r1 && (init_addr != r1->address))) {
fprintf(of, "\nstatic_%s_%02d\tudata\t0X%04X\n", moduleName, abs_section_no++, init_addr);
}
- fprintf(of, "%s\tres\t%d\n", r->name, r->size);
+
+ if(r1 && (init_addr == r1->address)) {
+ fprintf(of, "%s\tres\t0\n\n", r->name);
+ } else {
+ fprintf(of, "%s\tres\t%d\n", r->name, r->size);
+ }
+
rprev = r;
}
}
typedef struct {
- int gen_banksel;
+ int no_banksel;
int opt_banksel;
int omit_configw;
int omit_ivt;
void pic16_pushpCodeOp(pCodeOp *pcop);
void pic16_poppCodeOp(pCodeOp *pcop);
+static bool is_LitOp(operand *op);
#define BYTEofLONG(l,b) ( (l>> (b<<3)) & 0xff)
}
#endif
+
/*-----------------------------------------------------------------*/
/* pic16_emitDebuggerSymbol - associate the current code location */
/* with a debugger symbol */
_G.debugLine = 0;
}
+
/*-----------------------------------------------------------------*/
/* getFreePtr - returns r0 or r1 whichever is free or can be pushed*/
/*-----------------------------------------------------------------*/
resIfx->lbl = IC_FALSE(ifx);
resIfx->condition = 0;
}
-/*
+
+#if 1
if(IC_TRUE(ifx))
DEBUGpic16_emitcode("; ***","ifx true is non-null");
if(IC_FALSE(ifx))
DEBUGpic16_emitcode("; ***","ifx false is non-null");
-*/
+#endif
}
DEBUGpic16_emitcode("; ***","%s lbl->key=%d, (lab offset=%d)",__FUNCTION__,resIfx->lbl->key,labelOffset);
if(IN_CODESPACE( SPEC_OCLS( OP_SYM_ETYPE(op)))
|| viaimmd) {
- pic16_emitpcomment("%s:%d immediate", __FILE__, __LINE__);
+ DEBUGpic16_emitcode("%s:%d immediate", __FILE__, __LINE__);
aop->aopu.pcop = pic16_popGetImmd(OP_SYMBOL(IC_LEFT(ic))->rname, 0, val);
PCOI(aop->aopu.pcop)->index = val;
} else {
- pic16_emitpcomment("%s:%d dir", __FILE__, __LINE__);
+ DEBUGpic16_emitcode("%s:%d dir", __FILE__, __LINE__);
aop->aopu.pcop = pic16_popRegFromString(OP_SYMBOL(IC_LEFT(ic))->rname, getSize( OP_SYMBOL( IC_LEFT(ic))->type), val);
// aop->size = AOP_SIZE( IC_LEFT(ic) );
PCOR(pcop)->instance = offset;
pcop->type = PCOR(pcop)->r->pc_type;
rs = aop->aopu.aop_reg[offset]->name;
- DEBUGpic16_emitcode(";","%d regiser idx = %d name =%s",__LINE__,rIdx,rs);
+ DEBUGpic16_emitcode(";","%d regiser idx = %d name = %s",__LINE__,rIdx,rs);
return pcop;
}
}
/*-----------------------------------------------------------------*/
-/* pic16_outBitC - output a bit C */
+/* pic16_outBitC - output a bit C */
+/* Move to result the value of Carry flag -- VR */
/*-----------------------------------------------------------------*/
void pic16_outBitC(operand *result)
{
+ int i;
DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
/* if the result is bit */
- if (AOP_TYPE(result) == AOP_CRY)
+ if (AOP_TYPE(result) == AOP_CRY) {
+ fprintf(stderr, "%s:%d: pic16 port warning: unsupported case\n", __FILE__, __LINE__);
pic16_aopPut(AOP(result),"c",0);
- else {
+ } else {
+
+ i = AOP_SIZE(result);
+ while(i--) {
+ pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result), i));
+ }
+ pic16_emitpcode(POC_RLCF, pic16_popGet(AOP(result), 0));
+
+/*
pic16_emitcode("clr","a ; %d", __LINE__);
pic16_emitcode("rlc","a");
pic16_outAcc(result);
+*/
}
}
int size, i;
sym_link *optype, *rtype;
+ DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+
+ /* assign asmops */
+ pic16_aopOp(IC_LEFT(ic),ic,FALSE);
+ pic16_aopOp(IC_RESULT(ic),ic,TRUE);
- DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- /* assign asmops */
- pic16_aopOp(IC_LEFT(ic),ic,FALSE);
- pic16_aopOp(IC_RESULT(ic),ic,TRUE);
-
- /* if both in bit space then special
- case */
- if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY &&
- AOP_TYPE(IC_LEFT(ic)) == AOP_CRY ) {
-
- pic16_emitpcode(POC_BCF, pic16_popGet(AOP(IC_RESULT(ic)),0));
- pic16_emitpcode(POC_BTFSS, pic16_popGet(AOP(IC_LEFT(ic)),0));
- pic16_emitpcode(POC_BSF, pic16_popGet(AOP(IC_RESULT(ic)),0));
+ /* if both in bit space then special case */
+ if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY
+ && AOP_TYPE(IC_LEFT(ic)) == AOP_CRY ) {
- goto release;
- }
+ pic16_emitpcode(POC_BCF, pic16_popGet(AOP(IC_RESULT(ic)),0));
+ pic16_emitpcode(POC_BTFSS, pic16_popGet(AOP(IC_LEFT(ic)),0));
+ pic16_emitpcode(POC_BSF, pic16_popGet(AOP(IC_RESULT(ic)),0));
+
+ goto release;
+ }
- optype = operandType(IC_LEFT(ic));
- rtype = operandType(IC_RESULT(ic));
+ optype = operandType(IC_LEFT(ic));
+ rtype = operandType(IC_RESULT(ic));
- /* if float then do float stuff */
- if (IS_FLOAT(optype)) {
- genUminusFloat(IC_LEFT(ic),IC_RESULT(ic));
- goto release;
- }
+ /* if float then do float stuff */
+ if (IS_FLOAT(optype)) {
+ genUminusFloat(IC_LEFT(ic),IC_RESULT(ic));
+ goto release;
+ }
- /* otherwise subtract from zero by taking the 2's complement */
- size = AOP_SIZE(IC_LEFT(ic));
+ /* otherwise subtract from zero by taking the 2's complement */
+ size = AOP_SIZE(IC_LEFT(ic));
- for(i=0; i<size; i++) {
- if (pic16_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) )
- pic16_emitpcode(POC_COMF, pic16_popGet(AOP(IC_LEFT(ic)),i));
- else {
- pic16_emitpcode(POC_COMFW, pic16_popGet(AOP(IC_LEFT(ic)),i));
- pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(IC_RESULT(ic)),i));
- }
- }
+ for(i=0; i<size; i++) {
+ if (pic16_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) )
+ pic16_emitpcode(POC_COMF, pic16_popGet(AOP(IC_LEFT(ic)),i));
+ else {
+ pic16_emitpcode(POC_COMFW, pic16_popGet(AOP(IC_LEFT(ic)),i));
+ pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(IC_RESULT(ic)),i));
+ }
+ }
- pic16_emitpcode(POC_INCF, pic16_popGet(AOP(IC_RESULT(ic)),0));
- for(i=1; i<size; i++) {
- emitSKPNZ;
- pic16_emitpcode(POC_INCF, pic16_popGet(AOP(IC_RESULT(ic)),i));
- }
+ pic16_emitpcode(POC_INCF, pic16_popGet(AOP(IC_RESULT(ic)),0));
+ for(i=1; i<size; i++) {
+ emitSKPNZ;
+ pic16_emitpcode(POC_INCF, pic16_popGet(AOP(IC_RESULT(ic)),i));
+ }
- release:
- /* release the aops */
- pic16_freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1));
- pic16_freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
+release:
+ /* release the aops */
+ pic16_freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1));
+ pic16_freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
}
/*-----------------------------------------------------------------*/
void pic16_storeForReturn(operand *op, int offset, pCodeOp *dest)
{
-// (AOP(left)->aopu.pcop->type == PO_DIR)?
- if(AOP(op)->aopu.pcop->type == PO_IMMEDIATE) {
+ if(is_LitOp(op))
+// if((AOP(op)->aopu.pcop->type == PO_IMMEDIATE)
+// || (AOP(op)->aopu.pcop->type == PO_LITERAL))
+ {
pic16_emitpcode(POC_MOVLW, pic16_popGet(AOP(op), offset)); // patch 12
- pic16_emitpcode(POC_MOVWF, dest);
+
+ if(dest->type != PO_WREG)
+ pic16_emitpcode(POC_MOVWF, dest);
} else {
pic16_emitpcode(POC_MOVFF, pic16_popGet2p(
pic16_popGet(AOP(op), offset), dest));
}
pic16_genMult8X8_8 (left, right,result);
-
-
-#if 0
- pic16_emitcode("multiply (size>1) ","variable :%s by variable %s and store in %s",
- pic16_aopGet(AOP(right),0,FALSE,FALSE),
- pic16_aopGet(AOP(left),0,FALSE,FALSE),
- pic16_aopGet(AOP(result),0,FALSE,FALSE));
-
- if (SPEC_USIGN(opetype)){
- pic16_emitcode("multiply ","unsigned result. size = %d",AOP_SIZE(result));
- pic16_genUMult8X8_16 (left, right, result, NULL);
-
- if (size > 2) {
- /* for filling the MSBs */
- pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result),2));
- pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result),3));
- }
- }
- else{
- pic16_emitcode("multiply ","signed result. size = %d",AOP_SIZE(result));
-
- pic16_emitcode("mov","a,b");
-
- /* adjust the MSB if left or right neg */
-
- /* if one literal */
- if (AOP_TYPE(right) == AOP_LIT){
- pic16_emitcode("multiply ","right is a lit");
- /* AND literal negative */
- if((int) floatFromVal (AOP(right)->aopu.aop_lit) < 0){
- /* adjust MSB (c==0 after mul) */
- pic16_emitcode("subb","a,%s", pic16_aopGet(AOP(left),0,FALSE,FALSE));
- }
- }
- else{
- pic16_genSMult8X8_16 (left, right, result, NULL);
- }
-
- if(size > 2){
- pic16_emitcode("multiply ","size is greater than 2, so propogate sign");
- /* get the sign */
- pic16_emitcode("rlc","a");
- pic16_emitcode("subb","a,acc");
- }
- }
-
- size -= 2;
- offset = 2;
- if (size > 0)
- while (size--)
- pic16_emitcode("multiply ","size is way greater than 2, so propogate sign");
- //pic16_aopPut(AOP(result),"a",offset++);
- }
-#endif
-
-
}
/*-----------------------------------------------------------------*/
symbol *lbl ;
int size,offset;
+ /* result = divident / divisor
+ * - divident may be a register or a literal,
+ * - divisor may be a register or a literal,
+ * so there are 3 cases (literal / literal is optimized
+ * by the front-end) to handle.
+ * In addition we must handle signed and unsigned, which
+ * result in 6 final different cases -- VR */
+
DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
size = AOP_SIZE(result) - 1;
offset = 1;
/* signed or unsigned */
if (SPEC_USIGN(opetype)) {
+ pCodeOp *pct1, /* count */
+ *pct2, /* reste */
+ *pct3; /* temp */
+ symbol *label1, *label2, *label3;;
+
+
/* unsigned is easy */
- pic16_emitcode("mov","b,%s", pic16_aopGet(AOP(right),0,FALSE,FALSE));
- l = pic16_aopGet(AOP(left),0,FALSE,FALSE);
- MOVA(l);
- pic16_emitcode("div","ab");
- pic16_aopPut(AOP(result),"a",0);
- while (size--)
- pic16_aopPut(AOP(result),zero,offset++);
+
+ pct1 = pic16_popGetTempReg();
+ pct2 = pic16_popGetTempReg();
+ pct3 = pic16_popGetTempReg();
+
+ label1 = newiTempLabel(NULL);
+ label2 = newiTempLabel(NULL);
+ label3 = newiTempLabel(NULL);
+
+ /* the following algorithm is extracted from divuint.c */
+
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit( 8 ));
+ pic16_emitpcode(POC_MOVWF, pic16_pCodeOpCopy( pct1 ));
+
+ pic16_emitpcode(POC_CLRF, pic16_pCodeOpCopy( pct2 ));
+
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(left), 0));
+
+ pic16_emitpLabel(label1->key);
+
+ emitCLRC;
+ pic16_emitpcode(POC_RLCF, pic16_pCodeOpCopy( pct2 ));
+
+
+ emitCLRC;
+ pic16_emitpcode(POC_RLCF, pic16_popCopyReg( &pic16_pc_wreg ));
+
+
+ emitSKPNC;
+ pic16_emitpcode(POC_INCF, pic16_pCodeOpCopy( pct2 ));
+
+ pic16_emitpcode(POC_MOVWF, pic16_pCodeOpCopy( pct3 ));
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right), 0));
+
+ pic16_emitpcode(POC_CPFSLT, pic16_pCodeOpCopy(pct2));
+ pic16_emitpcode(POC_BRA, pic16_popGetLabel(label3->key));
+ pic16_emitpcode(POC_BRA, pic16_popGetLabel(label2->key));
+
+ pic16_emitpLabel( label3->key );
+ pic16_emitpcode(POC_SUBWF, pic16_pCodeOpCopy(pct2));
+ pic16_emitpcode(POC_INCF, pic16_pCodeOpCopy(pct3));
+
+
+
+ pic16_emitpLabel(label2->key);
+ pic16_emitpcode(POC_MOVFW, pic16_pCodeOpCopy(pct3));
+ pic16_emitpcode(POC_DECFSZ, pic16_pCodeOpCopy(pct1));
+ pic16_emitpcode(POC_BRA, pic16_popGetLabel( label1->key ));
+
+ /* result is in wreg */
+ if(AOP_TYPE(result) != AOP_ACC)
+ pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(result), 0));
+
+ pic16_popReleaseTempReg( pct3 );
+ pic16_popReleaseTempReg( pct2 );
+ pic16_popReleaseTempReg( pct1 );
+
return ;
}
operand *right = IC_RIGHT(ic);
operand *result= IC_RESULT(ic);
+
+ /* Division is a very lengthy algorithm, so it is better
+ * to call support routines than inlining algorithm.
+ * Division functions written here just in case someone
+ * wants to inline and not use the support libraries -- VR */
+
DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
/* assign the amsops */
pic16_aopOp (left,ic,FALSE);
//lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
- DEBUGpic16_emitcode(";right lit","lit = 0x%x,sign=%d",lit,sign);
+ DEBUGpic16_emitcode(";right lit","%d lit = 0x%x,sign=%d",__LINE__, lit,sign);
/* special cases */
}
if(ifx) ifx->generated = 1;
- //goto check_carry;
- return;
+ goto check_carry;
+// return;
} else {
}
- // check_carry:
- if (AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)) {
+check_carry:
+ if ((AOP_TYPE(result) != AOP_CRY)
+ && AOP_SIZE(result)) {
DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+// pic16_emitpLabel( rFalseIfx.lbl->key );
+
pic16_outBitC(result);
} else {
DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
/* if this has register type condition and
the next instruction is ifx with the same operand
and live to of the operand is upto the ifx only then */
- if (ic->next &&
- ic->next->op == IFX &&
- IC_COND(ic->next)->key == op->key &&
- OP_SYMBOL(op)->liveTo <= ic->next->seq )
- return ic->next;
+ if (ic->next
+ && ic->next->op == IFX
+ && IC_COND(ic->next)->key == op->key
+ && OP_SYMBOL(op)->liveTo <= ic->next->seq
+ ) {
+ DEBUGpic16_emitcode(";", "%d %s", __LINE__, __FUNCTION__);
+ return ic->next;
+ }
if (ic->next &&
ic->next->op == IFX &&
// return ic->next->next; /* this just might work */ /* FIXME FIXME */
#endif
+
return NULL;
}
/*-----------------------------------------------------------------*/
pic16_emitpcode(POC_GOTO,pic16_popGetLabel(IC_FALSE(ic)->key));
}
*/
+ DEBUGpic16_emitcode("***", "%d %s", __LINE__, __FUNCTION__);
+ size = AOP_SIZE(left);
+
+ {
+ int bp = posbit, ofs=0;
+
+ while(bp > 7) {
+ bp -= 8;
+ ofs++;
+ }
+
+ pic16_emitpcode(((rIfx.condition) ? POC_BTFSC : POC_BTFSS),
+ pic16_newpCodeOpBit(pic16_aopGet(AOP(left),ofs,FALSE,FALSE),bp,0));
+
+ }
+/*
pic16_emitpcode(((rIfx.condition) ? POC_BTFSC : POC_BTFSS),
pic16_newpCodeOpBit(pic16_aopGet(AOP(left),0,FALSE,FALSE),posbit,0));
+*/
pic16_emitpcode(POC_GOTO,pic16_popGetLabel(rIfx.lbl->key));
ifx->generated = 1;
bstr = SPEC_BSTR(etype);
if(AOP_TYPE(right) == AOP_LIT) {
+ if((blen == 1) && (bstr < 8)) {
+ unsigned long lit;
+ /* it is a single bit, so use the appropriate bit instructions */
+
+ DEBUGpic16_emitcode (";","%s %d optimize bit assignment",__FUNCTION__,__LINE__);
+
+ lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
+// pic16_emitpcode(POC_MOVFW, pic16_popCopyReg(&pic16_pc_indf0));
+ if(lit) {
+ pic16_emitpcode(POC_BSF,
+ pic16_popCopyGPR2Bit(pic16_popCopyReg(&pic16_pc_indf0), bstr));
+ } else {
+ pic16_emitpcode(POC_BCF,
+ pic16_popCopyGPR2Bit(pic16_popCopyReg(&pic16_pc_indf0), bstr));
+ }
+
+ return;
+ }
+
pic16_emitpcode(POC_MOVLW, pic16_popGet(AOP(right), 0));
offset++;
} else
pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right), offset++));
-/* l = pic16_aopGet(AOP(right),offset++,FALSE,FALSE);
- MOVA(l);
-*/
/* if the bit lenth is less than or */
/* it exactly fits a byte then */
if((shCnt=SPEC_BSTR(etype))
pic16_emitpcode(POC_MOVWF, pic16_popCopyReg(&pic16_pc_indf0));
#endif
-#if 0
- pic16_emitcode ("anl","a,#0x%02x",(unsigned char)
- ((unsigned char)(0xFF << (blen+bstr)) |
- (unsigned char)(0xFF >> (8-bstr)) ) );
- pic16_emitcode ("orl","a,b");
- if (p_type == GPOINTER)
- pic16_emitcode("pop","b");
-
-
- switch (p_type) {
- case POINTER:
- pic16_emitcode("mov","@%s,a",rname);
- break;
- case FPOINTER:
- pic16_emitcode("movx","@dptr,a");
- break;
- case GPOINTER:
- DEBUGpic16_emitcode(";lcall","__gptrput");
- break;
- }
-#endif
-
return;
}
size = AOP_SIZE(IC_RESULT(ic));
- if(pic16_debug_verbose) {
- fprintf(stderr, "%s:%d %s symbol %s , codespace=%d\n",
- __FILE__, __LINE__, __FUNCTION__, sym->name, IN_CODESPACE( SPEC_OCLS(sym->etype)));
- }
+// if(pic16_debug_verbose) {
+// fprintf(stderr, "%s:%d %s symbol %s , codespace=%d\n",
+// __FILE__, __LINE__, __FUNCTION__, sym->name, IN_CODESPACE( SPEC_OCLS(sym->etype)));
+// }
/* Assume that what we want the address of is in data space
* since there is no stack on the PIC, yet! -- VR */
/* general case */
size = AOP_SIZE(result);
offset = 0 ;
- if(AOP_TYPE(right) == AOP_LIT)
- lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
+
+ if(AOP_TYPE(right) == AOP_LIT) {
+ if(!IS_FLOAT(operandType( right )))
+ lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
+ else {
+ union {
+ unsigned long lit_int;
+ float lit_float;
+ } info;
+
+ /* take care if literal is a float */
+ info.lit_float = floatFromVal(AOP(right)->aopu.aop_lit);
+ lit = info.lit_int;
+ }
+ }
+
+// fprintf(stderr, "%s:%d: assigning value 0x%04lx (%d:%d)\n", __FUNCTION__, __LINE__, lit,
+// sizeof(unsigned long int), sizeof(float));
/* VR - What is this?! */
if( AOP_TYPE(right) == AOP_DIR && (AOP_TYPE(result) == AOP_REG) && size==1) {
DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
size = min( AOP_SIZE(result), AOP_SIZE(right) );
+ size = min( size, AOP_SIZE(left) );
offset = 0;
- if(pic16_debug_verbose)
- fprintf(stderr, "%s:%d size of operands: %d\n", __FILE__, __LINE__, size);
+ if(pic16_debug_verbose) {
+// fprintf(stderr, "%s:%d result: %d\tleft: %d\tright: %d\n", __FILE__, __LINE__,
+// AOP_SIZE(result), AOP_SIZE(left), AOP_SIZE(right));
+// fprintf(stderr, "%s:%d size of operands: %d\n", __FILE__, __LINE__, size);
+ }
+
+
if ((AOP_TYPE(left) == AOP_PCODE) && (
(AOP(left)->aopu.pcop->type == PO_LITERAL) ||
} else {
// right is signed
for(i=size; i< AOP_SIZE(result); i++) {
- pic16_emitpcode(POC_CLRF, pic16_popCopyReg(&pic16_pc_wreg));
- pic16_emitpcode(POC_BTFSC, pic16_newpCodeOpBit(pic16_aopGet(AOP(right),size-1,FALSE,FALSE),7,0));
- pic16_emitpcode(POC_COMFW, pic16_popCopyReg(&pic16_pc_wreg));
- if (pic16_sameRegs(AOP(left), AOP(result)))
- {
- pic16_emitpcode(POC_ADDWFC, pic16_popGet(AOP(left),i));
- } else { // not same
- pic16_emitpcode(POC_ADDFWC, pic16_popGet(AOP(left),i));
- pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(result),i));
+ if(size < AOP_SIZE(left)) {
+ pic16_emitpcode(POC_CLRF, pic16_popCopyReg(&pic16_pc_wreg));
+ pic16_emitpcode(POC_BTFSC, pic16_newpCodeOpBit(pic16_aopGet(AOP(right),size-1,FALSE,FALSE),7,0));
+ pic16_emitpcode(POC_COMFW, pic16_popCopyReg(&pic16_pc_wreg));
+ if (pic16_sameRegs(AOP(left), AOP(result)))
+ {
+ pic16_emitpcode(POC_ADDWFC, pic16_popGet(AOP(left),i));
+ } else { // not same
+ pic16_emitpcode(POC_ADDFWC, pic16_popGet(AOP(left),i));
+ pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(result),i));
+ }
+ } else {
+ pic16_emitpcode(POC_CLRF, pic16_popCopyReg(&pic16_pc_wreg));
+ pic16_emitpcode(POC_ADDWFC, pic16_popGet(AOP(result), i));
}
}
}
if(AOP_TYPE(result) != AOP_ACC) {
pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popCopyReg(&pic16_pc_prodl),
pic16_popGet(AOP(result), 0)));
+
+
+ if(AOP_SIZE(result)>1) {
+ int i;
+
+ pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popCopyReg(&pic16_pc_prodh),
+ pic16_popGet(AOP(result), 1)));
+
+ for(i=2;i<AOP_SIZE(result);i++)
+ pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result), i));
+ }
} else {
pic16_emitpcode(POC_MOVFW, pic16_popCopyReg(&pic16_pc_prodl));
}
#include "main.h"
#include <string.h>
+#include <string.h>
+
#ifdef WORDS_BIGENDIAN
#define _ENDIAN(x) (3-x)
}
+iCode *tic;
+symbol *nsym;
+char tbuffer[512], *tbuf=tbuffer;;
+
+
/*-----------------------------------------------------------------*/
/* emitRegularMap - emit code for maps with no special cases */
/*-----------------------------------------------------------------*/
if (IS_AGGREGATE (sym->type))
ival = initAggregates (sym, sym->ival, NULL);
else {
- addSet(&idataSymSet, copySymbol(sym));
- ival = newNode ('=', newAst_VALUE(symbolVal (sym)),
- decorateType (resolveSymbols (list2expr (sym->ival)), RESULT_CHECK));
+#if 0
+ tic = iCodeFromAst(decorateType (resolveSymbols (list2expr (sym->ival)), RESULT_CHECK));
+
+ if(IS_PTR(sym->type)
+ && !IS_CODEPTR(sym->type)
+ && IS_AGGREGATE(OP_SYMBOL(IC_LEFT(tic))->type)) {
+
+ fprintf(stderr, "symbol %s is a non-code pointer with aggregate initialiser\n", sym->name);
+
+ nsym = copySymbol( sym );
+ sprintf(tbuffer, "_tempbuf_%s", sym->name);
+ strcpy(nsym->name, tbuffer);
+
+// nsym->name = Safe_strdup( tbuf );
+
+ codeOutFile = statsg->oFile;
+ GcurMemmap = statsg;
+ /* assignment of temporary buffer initialiser */
+ ival = initAggregates(nsym, nsym->ival, NULL);
+
+/*
+ ival = newNode ('=', newAst_VALUE(symbolVal (nsym)),
+ decorateType (resolveSymbols (list2expr (nsym->ival)), RESULT_CHECK));
+*/
+
+ fprintf(stderr, "%s:%d: iCode: %s\n", __FILE__, __LINE__,
+ strdup( printILine(iCodeFromAst(ival) )));
+
+ eBBlockFromiCode(iCodeFromAst(ival));
+
+ /* assignment of symbol to temporary buffer */
+ ival = newNode ('=', newAst_VALUE(symbolVal (sym)),
+ newAst_VALUE(symbolVal(nsym)));
+
+ fprintf(stderr, "%s:%d: iCode: %s\n", __FILE__, __LINE__,
+ strdup( printILine(iCodeFromAst(ival) )));
+
+
+ eBBlockFromiCode(iCodeFromAst(ival));
+
+ sym->ival = NULL;
+ ival = NULL;
+ } else {
+#endif
+ addSet(&idataSymSet, copySymbol(sym));
+ ival = newNode ('=', newAst_VALUE(symbolVal (sym)),
+ decorateType (resolveSymbols (list2expr (sym->ival)), RESULT_CHECK));
+// }
+ }
+
+ if(ival) {
+ codeOutFile = statsg->oFile;
+ GcurMemmap = statsg;
+ eBBlockFromiCode (iCodeFromAst (ival));
+ sym->ival = NULL;
}
- codeOutFile = statsg->oFile;
- GcurMemmap = statsg;
- eBBlockFromiCode (iCodeFromAst (ival));
- sym->ival = NULL;
}
#endif
}
if(mainf && IFFUNC_HASBODY(mainf->type)) {
- fprintf (asmFile,"__sdcc_gsinit_startup:\t\t;VRokas\n");
+ fprintf(asmFile, "\tcode\n");
+ fprintf(asmFile,"__sdcc_gsinit_startup:\n");
#if 0
/* FIXME 8051 legacy (?!) - VR 20-Jun-2003 */
pic16_options_t pic16_options;
+extern set *includeDirsSet;
+extern set *dataDirsSet;
+extern set *libFilesSet;
+
/* Also defined in gen.h, but the #include is commented out */
/* for an unknowned reason. - EEP */
void pic16_emitDebuggerSymbol (char *);
+
static void
_pic16_init (void)
{
+#if 0
+ char pic16incDir[512];
+ char pic16libDir[512];
+ set *pic16incDirsSet;
+ set *pic16libDirsSet;
+ char devlib[512];
+#endif
+
asm_addTree (&asm_asxxxx_mapping);
pic16_pCodeInitRegisters();
maxInterrupts = 2;
/* set pic16 port options to defaults */
- pic16_options.gen_banksel = 0;
+ pic16_options.no_banksel = 0;
pic16_options.opt_banksel = 0;
pic16_options.omit_configw = 0;
pic16_options.omit_ivt = 0;
pic16_options.leave_reset = 0;
pic16_options.stack_model = 0; /* 0 for 'small', 1 for 'large' */
+
+
+#if 0
+ setMainValue("mcu", pic16->name[2] );
+ addSet(&preArgvSet, Safe_strdup("-D{mcu}"));
+
+ sprintf(pic16incDir, "%s/pic16", INCLUDE_DIR_SUFFIX);
+ sprintf(pic16libDir, "%s/pic16", LIB_DIR_SUFFIX);
+
+ if(!options.nostdinc) {
+ /* setup pic16 include directory */
+ pic16incDirsSet = appendStrSet(dataDirsSet, NULL, pic16incDir);
+ mergeSets(&includeDirsSet, pic16incDirsSet);
+ }
+
+ if(!options.nostdlib) {
+ /* setup pic16 library directory */
+ pic16libDirsSet = appendStrSet(dataDirsSet, NULL, pic16libDir);
+ mergeSets(&libDirsSet, pic16libDirsSet);
+
+ /* now add the library for the device */
+ sprintf(devlib, "%s.lib", pic16->name[2]);
+ addSet(&libFilesSet, Safe_strdup(devlib));
+ }
+#endif
}
static void
}
#define REP_UDATA "--preplace-udata-with="
-#define REP_UDATAACS "--preplace-udata-acs-with="
-#define REP_UDATAOVR "--preplace-udata-ovr-with="
-#define REP_UDATASHR "--preplace-udata-sht-with="
-
-#define NAME_CODE "--psection-code-name="
-#define NAME_IDATA "--psection-idata-name="
-#define NAME_UDATA "--psection-udata-name="
-#define NAME_UDATAACS "--psection-udata-acs-name="
-#define NAME_UDATAOVR "--psection-udata-ovr-name="
-#define NAME_UDATASHR "--psection-udata-shr-name="
-
-#define ADDR_CODE "--psection-code-addr="
-#define ADDR_IDATA "--psection-idata-addr="
-#define ADDR_UDATA "--psection-udata-addr="
-#define ADDR_UDATAACS "--psection-udata-acs-addr="
-#define ADDR_UDATAOVR "--psection-udata-ovr-addr="
-#define ADDR_UDATASHR "--psection-udata-shr-addr="
#define STACK_MODEL "--pstack-model="
#define OPT_BANKSEL "--obanksel="
extern int pic16_pcode_verbose;
OPTION pic16_optionsTable[]= {
- { 0, "--pgen-banksel", &pic16_options.gen_banksel, "generate BANKSEL assembler directives"},
+ { 0, "--pno-banksel", &pic16_options.no_banksel, "do not generate BANKSEL assembler directives"},
{ 0, OPT_BANKSEL, NULL, "set banksel optimization level (default=0 no)"},
{ 0, "--pomit-config-words", &pic16_options.omit_configw, "omit the generation of configuration words"},
{ 0, "--pomit-ivt", &pic16_options.omit_ivt, "omit the generation of the Interrupt Vector Table"},
{ 0, REP_UDATA, NULL, "Place udata variables at another section: udata_acs, udata_ovr, udata_shr"},
-#if 0
- /* these may not be in any use -- VR */
- { 0, AT_UDATAACS, NULL, "Emit udata_acs variables at another section"},
- { 0, AT_UDATAOVR, NULL, "Emit udata_ovr variables at another section"},
- { 0, AT_UDATASHR, NULL, "Emit udata_shr variables at another section"},
-#endif
-
-#if 0
- /* commented out for the time being -- VR */
- { 0, NAME_CODE, NULL, "Set code section name[,address]"},
- { 0, NAME_IDATA, NULL, "Set idata section name[,address]"},
- { 0, NAME_UDATA, NULL, "Set udata section name[,address]"},
- { 0, NAME_UDATAACS, NULL, "Set udata_acs section name[,address]"},
- { 0, NAME_UDATAOVR, NULL, "Set udata_ovr section name[,address]"},
- { 0, NAME_UDATASHR, NULL, "Set udata_shr section name[,address]"},
-
- { 0, ADDR_CODE, NULL, "Set code section address"},
- { 0, ADDR_IDATA, NULL, "Set idata section address"},
- { 0, ADDR_UDATA, NULL, "Set udata section address"},
- { 0, ADDR_UDATAACS, NULL, "Set udata_acs section address"},
- { 0, ADDR_UDATAOVR, NULL, "Set udata_ovr section address"},
- { 0, ADDR_UDATASHR, NULL, "Set udata_shr section address"},
-#endif
-
{ 0, NULL, NULL, NULL}
};
_pic16_parseOptions (int *pargc, char **argv, int *i)
{
int j=0;
-// set *tset;
char *stkmodel;
/* TODO: allow port-specific command line options to specify
return TRUE;
}
-/*
- if(ISOPT(AT_UDATAACS)) {
- pic16_sectioninfo.at_udataacs = Safe_strdup( getStringArg(AT_UDATAACS, argv, i, *pargc));
- return TRUE;
- }
-
- if(ISOPT(AT_UDATAOVR)) {
- pic16_sectioninfo.at_udataovr = Safe_strdup( getStringArg(AT_UDATAOVR, argv, i, *pargc));
- return TRUE;
- }
-
- if(ISOPT(AT_UDATASHR)) {
- pic16_sectioninfo.at_udatashr = Safe_strdup( getStringArg(AT_UDATASHR, argv, i, *pargc));
- return TRUE;
- }
-*/
-
-#if 0
- if(ISOPT(ADDR_CODE)) {
- pic16_sectioninfo.addr_code = getIntArg(ADDR_CODE, argv, i, *pargc);
- return TRUE;
- }
-
- if(ISOPT(ADDR_IDATA)) {
- pic16_sectioninfo.addr_idata = getIntArg(ADDR_IDATA, argv, i, *pargc);
- return TRUE;
- }
-
- if(ISOPT(ADDR_UDATA)) {
- pic16_sectioninfo.addr_udata = getIntArg(ADDR_UDATA, argv, i, *pargc);
- return TRUE;
- }
-
- if(ISOPT(ADDR_UDATAACS)) {
- pic16_sectioninfo.addr_udataacs = getIntArg(ADDR_UDATAACS, argv, i, *pargc);
- return TRUE;
- }
-
- if(ISOPT(ADDR_UDATAOVR)) {
- pic16_sectioninfo.addr_udataovr = getIntArg(ADDR_UDATAOVR, argv, i, *pargc);
- return TRUE;
- }
-
- if(ISOPT(ADDR_UDATASHR)) {
- pic16_sectioninfo.addr_udatashr = getIntArg(ADDR_UDATASHR, argv, i, *pargc);
- return TRUE;
- }
-
- tset = newSet();
-
- if(ISOPT(NAME_CODE)) {
- setParseWithComma(&tset, getStringArg(NAME_CODE, argv, i, *pargc));
- if(elementsInSet(tset) > 0)
- pic16_sectioninfo.name_code = Safe_strdup( (char *)indexSet(tset, 0));
- if(elementsInSet(tset) > 1)
- pic16_sectioninfo.addr_code = atoi( (char *)indexSet(tset, 1));
- return TRUE;
- }
+ return FALSE;
+}
- if(ISOPT(NAME_IDATA)) {
- setParseWithComma(&tset, getStringArg(NAME_IDATA, argv, i, *pargc));
- if(elementsInSet(tset) > 0)
- pic16_sectioninfo.name_idata = Safe_strdup( (char *)indexSet(tset, 0));
- if(elementsInSet(tset) > 1)
- pic16_sectioninfo.addr_idata = atoi( (char *)indexSet(tset, 1));
- return TRUE;
- }
+static void _pic16_initPaths(void)
+{
+#if 1
+ char pic16incDir[512];
+ char pic16libDir[512];
+ set *pic16incDirsSet;
+ set *pic16libDirsSet;
+ char devlib[512];
+#endif
- if(ISOPT(NAME_UDATA)) {
- setParseWithComma(&tset, getStringArg(NAME_UDATA, argv, i, *pargc));
- if(elementsInSet(tset) > 0)
- pic16_sectioninfo.name_udata = Safe_strdup( (char *)indexSet(tset, 0));
- if(elementsInSet(tset) > 1)
- pic16_sectioninfo.addr_udata = atoi( (char *)indexSet(tset, 1));
- return TRUE;
- }
+#if 1
+ setMainValue("mcu", pic16->name[2] );
+ addSet(&preArgvSet, Safe_strdup("-D{mcu}"));
- if(ISOPT(NAME_UDATAACS)) {
- setParseWithComma(&tset, getStringArg(NAME_UDATAACS, argv, i, *pargc));
- if(elementsInSet(tset) > 0)
- pic16_sectioninfo.name_udataacs = Safe_strdup( (char *)indexSet(tset, 0));
- if(elementsInSet(tset) > 1)
- pic16_sectioninfo.addr_udataacs = atoi( (char *)indexSet(tset, 1));
- return TRUE;
- }
+ sprintf(pic16incDir, "%s/pic16", INCLUDE_DIR_SUFFIX);
+ sprintf(pic16libDir, "%s/pic16", LIB_DIR_SUFFIX);
- if(ISOPT(NAME_UDATAOVR)) {
- setParseWithComma(&tset, getStringArg(NAME_UDATAOVR, argv, i, *pargc));
- if(elementsInSet(tset) > 0)
- pic16_sectioninfo.name_udataovr = Safe_strdup( (char *)indexSet(tset, 0));
- if(elementsInSet(tset) > 1)
- pic16_sectioninfo.addr_udataovr = atoi( (char *)indexSet(tset, 1));
- return TRUE;
+ if(!options.nostdinc) {
+ /* setup pic16 include directory */
+ pic16incDirsSet = appendStrSet(dataDirsSet, NULL, pic16incDir);
+ mergeSets(&includeDirsSet, pic16incDirsSet);
}
-
- if(ISOPT(NAME_UDATASHR)) {
- setParseWithComma(&tset, getStringArg(NAME_UDATASHR, argv, i, *pargc));
- if(elementsInSet(tset) > 0)
- pic16_sectioninfo.name_udatashr = Safe_strdup( (char *)indexSet(tset, 0));
- if(elementsInSet(tset) > 1)
- pic16_sectioninfo.addr_udatashr = atoi( (char *)indexSet(tset, 1));
- return TRUE;
+
+ if(!options.nostdlib) {
+ /* setup pic16 library directory */
+ pic16libDirsSet = appendStrSet(dataDirsSet, NULL, pic16libDir);
+ mergeSets(&libDirsSet, pic16libDirsSet);
+
+ /* now add the library for the device */
+ sprintf(devlib, "%s.lib", pic16->name[2]);
+ addSet(&libFilesSet, Safe_strdup(devlib));
}
-
- deleteSet( &tset );
#endif
-
- return FALSE;
}
-extern set *includeDirsSet;
-extern set *dataDirsSet;
-extern set *libFilesSet;
static void
_pic16_finaliseOptions (void)
{
+#if 0
char pic16incDir[512];
char pic16libDir[512];
set *pic16incDirsSet;
set *pic16libDirsSet;
char devlib[512];
-
+#endif
port->mem.default_local_map = data;
port->mem.default_globl_map = data;
options.all_callee_saves = 1; // always callee saves
- options.float_rent = 1;
- options.intlong_rent = 1;
+// options.float_rent = 1;
+// options.intlong_rent = 1;
- setMainValue("mcu", pic16->name[2] );
+#if 0
+ setMainValue("mcu", pic16->name[2] );
addSet(&preArgvSet, Safe_strdup("-D{mcu}"));
sprintf(pic16incDir, "%s/pic16", INCLUDE_DIR_SUFFIX);
sprintf(devlib, "%s.lib", pic16->name[2]);
addSet(&libFilesSet, Safe_strdup(devlib));
}
+#endif
}
pic16_sectioninfo.addr_udataacs =
pic16_sectioninfo.addr_udataovr =
pic16_sectioninfo.addr_udatashr = -1;
+
+
+
+ /* set pic16 port options to defaults */
+ pic16_options.no_banksel = 0;
+ pic16_options.opt_banksel = 0;
+ pic16_options.omit_configw = 0;
+ pic16_options.omit_ivt = 0;
+ pic16_options.leave_reset = 0;
+ pic16_options.stack_model = 0; /* 0 for 'small', 1 for 'large' */
}
static const char *
static int
_pic16_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
{
+#if 1
/* PIC18F family has only two interrupts, the high and the low
* priority interrupts, which reside at 0x0008 and 0x0018 respectively - VR */
fprintf(of, "\tretfie\n");
}
}
-
+#endif
return TRUE;
}
* False to convert it to function call */
static bool _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right)
{
- // sym_link *test = NULL;
- // value *val;
+// fprintf(stderr,"checking for native mult for %c (size: %d)\n", ic->op, getSize(OP_SYMBOL(IC_RESULT(ic))->type));
-// fprintf(stderr,"checking for native mult\n");
-
- /* support mul for char/int */
- if((getSize(OP_SYMBOL(IC_RESULT(ic))->type ) <= 2)
+ /* support mul for char/int {/long} */
+ if((getSize(OP_SYMBOL(IC_LEFT(ic))->type ) < 2)
&& (ic->op == '*'))return TRUE;
- /* support div for char */
- if((getSize(OP_SYMBOL(IC_RESULT(ic))->type ) < 2)
+ /* support div for char/int/long */
+ if((getSize(OP_SYMBOL(IC_LEFT(ic))->type ) < 0)
&& (ic->op == '/'))return TRUE;
return FALSE;
+}
+
#if 0
- if ( ic->op != '*')
- {
- return FALSE;
- }
+/* Do CSE estimation */
+static bool cseCostEstimation (iCode *ic, iCode *pdic)
+{
+// operand *result = IC_RESULT(ic);
+// sym_link *result_type = operandType(result);
- return TRUE;
-/*
- if ( IS_LITERAL (left))
- {
- fprintf(stderr,"left is lit\n");
- test = left;
- val = OP_VALUE (IC_LEFT (ic));
- }
- else if ( IS_LITERAL (right))
- {
- fprintf(stderr,"right is lit\n");
- test = left;
- val = OP_VALUE (IC_RIGHT (ic));
- }
- else
- {
- fprintf(stderr,"oops, neither is lit so no\n");
- return FALSE;
- }
- if ( getSize (test) <= 2)
- {
- fprintf(stderr,"yep\n");
- return TRUE;
- }
- fprintf(stderr,"nope\n");
+ /* VR -- this is an adhoc. Put here after conversation
+ * with Erik Epetrich */
- return FALSE;
-*/
+ if(ic->op == '<'
+ || ic->op == '>'
+ || ic->op == EQ_OP) {
+
+ fprintf(stderr, "%d %s\n", __LINE__, __FUNCTION__);
+ return 0;
+ }
+
+#if 0
+ /* if it is a pointer then return ok for now */
+ if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
+
+ /* if bitwise | add & subtract then no since mcs51 is pretty good at it
+ so we will cse only if they are local (i.e. both ic & pdic belong to
+ the same basic block */
+ if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
+ /* then if they are the same Basic block then ok */
+ if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
+ else return 0;
+ }
#endif
+ /* for others it is cheaper to do the cse */
+ return 1;
}
+#endif
+
/* Indicate which extended bit operations this port supports */
static bool
},
/* pic16 has an 8 bit mul */
{
- 1, -1
+ 0, -1
},
{
pic16_emitDebuggerSymbol
_pic16_init,
_pic16_parseOptions,
pic16_optionsTable,
+ _pic16_initPaths,
_pic16_finaliseOptions,
_pic16_setDefaultOptions,
pic16_assignRegisters,
1, /* transform != to !(a == b) */
0, /* leave == */
FALSE, /* No array initializer support. */
- 0, /* no CSE cost estimation yet */
+ 0, //cseCostEstimation, /* !!!no CSE cost estimation yet */
NULL, /* no builtin functions */
GPOINTER, /* treat unqualified pointers as "generic" pointers */
1, /* reset labelKey to 1 */
* bank at linking time
*/
- if(!pic16_options.gen_banksel || bsr != -1) {
+ if(pic16_options.no_banksel || bsr != -1) {
// new_pc = pic16_newpCode(POC_MOVLB, pic16_newpCodeOpLit(bsr));
return;
} else {
* before SKIP, but we have to check if the SKIP uses BANKSEL, etc... */
if(!pcprev || (pcprev && !isPCI_SKIP(pcprev))) {
prevreg = reg;
- insertBankSwitch(0, pc, (pic16_options.gen_banksel)?-1:0);
+ insertBankSwitch(0, pc, (pic16_options.no_banksel)?0:-1);
}
}
}
}
+
+#if 0
+ /* This is not needed because currently all register used
+ * by a function are stored in stack -- VR */
+
/* Re-allocate the registers so that there are no collisions
* between local variables when one function call another */
if(!pb->visited)
register_usage(pb);
}
+#endif
}
}
-// From: Vangelis Rokas (vrokas@otenet.gr)
+// From: Vangelis Rokas (vrokas AT otenet dot gr)
// movff peeps are disabled for the moment
// until support is added in the pcodepeeph.c
dReg->isFree = 0;
dReg->wasUsed = 1;
-
-// dReg->isMapped = 0;
dReg->isEmitted = 0;
if(type == REG_SFR) {
// fprintf(stderr,"%s:%d: %s %s addr =0x%x\n",__FILE__, __LINE__, __FUNCTION__, name, rIdx);
- if(reg) {
- reg->wasUsed = 0;
- return addSet(&pic16_dynInternalRegs,reg);
- }
+ if(reg) {
+ reg->wasUsed = 0;
+ return addSet(&pic16_dynInternalRegs,reg);
+ }
return NULL;
}
/* try to reuse some unused registers */
reg = regFindFree( pic16_dynAllocRegs );
+ if(reg) {
+// fprintf(stderr, "%s: found FREE register %s\n", __FILE__, reg->name);
+ }
+
if(!reg) {
reg = newReg(REG_GPR, PO_GPR_TEMP, dynrIdx++, NULL, 1, 0, NULL);
- addSet(&pic16_dynAllocRegs, reg);
+// addSet(&pic16_dynAllocRegs, reg);
}
+
+ addSet(&pic16_dynAllocRegs, reg);
+
reg->isFree=0;
// debugLog ("%s of type %s\n", __FUNCTION__, debugLogRegType (type));
* dynDirectRegNames set */
if(IN_CODESPACE( SPEC_OCLS( OP_SYM_ETYPE(op)))) {
if(pic16_debug_verbose)
- fprintf(stderr, "%s:%d symbol %s in codespace\n", __FILE__, __LINE__,
- OP_SYMBOL(op)->name);
+// fprintf(stderr, "%s:%d symbol %s in codespace\n", __FILE__, __LINE__,
+// OP_SYMBOL(op)->name);
debugLog("%s:%d sym: %s in codespace\n", __FUNCTION__, __LINE__, OP_SYMBOL(op)->name);
return NULL;
}
reg = newReg(REG_GPR, PO_DIR, rDirectIdx++, name,size,0, NULL);
debugLog ("%d -- added %s to hash, size = %d\n", __LINE__, name,reg->size);
- //fprintf(stderr, " -- added %s to hash, size = %d\n", name,reg->size);
+ //fprintf(stderr, " -- added %s to hash, size = %d\n", name,reg->size);
//hTabAddItem(&dynDirectRegNames, regname2key(name), reg); /* initially commented out */
addSet(&pic16_dynDirectRegs, reg);
/** Optional list of automatically parsed options. Should be
implemented to at least show the help text correctly. */
OPTION *poptions;
+/** Initialise port spectific paths */
+ void (*initPaths)(void);
/** Called after all the options have been parsed. */
void (*finaliseOptions) (void);
/** Called after the port has been selected but before any