From: sdattalo Date: Wed, 20 Mar 2002 06:10:31 +0000 (+0000) Subject: Added -p command line option to allow selection of port dependent processor. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=e33c24b4e792f1136531ed4108dcfc7e67871d65;p=fw%2Fsdcc Added -p command line option to allow selection of port dependent processor. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2001 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 6bf1381f..fa2883d3 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -138,6 +138,7 @@ typedef struct { static const OPTION optionsTable[] = { { 'm', NULL, NULL, "Set the port to use e.g. -mz80." }, + { 'p', NULL, NULL, "Select port specific processor e.g. -mpic14 -p16f84" }, { 'd', NULL, NULL, NULL }, { 'D', NULL, NULL, "Define macro as in -Dmacro" }, { 'I', NULL, NULL, "Add to the include (*.h) path, as in -Ipath" }, @@ -235,8 +236,6 @@ unsupportedOptTable[] = { { 'g', NULL, "use --generic instead" }, { 'X', NULL, "use --xstack-loc instead" }, { 'x', NULL, "use --xstack instead" }, - { 'p', NULL, "use --stack-loc instead" }, - { 'P', NULL, "use --stack-loc instead" }, { 'i', NULL, "use --idata-loc instead" }, { 'r', NULL, "use --xdata-loc instead" }, { 's', NULL, "use --code-loc instead" }, @@ -293,10 +292,9 @@ static PORT *_ports[] = #define NUM_PORTS (sizeof(_ports)/sizeof(_ports[0])) -/** - remove me - TSD a hack to force sdcc to generate gpasm format .asm files. - */ +#if !OPT_DISABLE_PIC extern void picglue (); +#endif /** Sets the port to the one given by the command line option. @param The name minus the option (eg 'mcs51') @@ -327,11 +325,16 @@ _validatePorts (void) { if (_ports[i]->magic != PORT_MAGIC) { + /* Uncomment this line to debug which port is causing the problem + * (the target name is close to the beginning of the port struct + * and probably can be accessed just fine). */ + fprintf(stderr,"%s :",_ports[i]->target); wassertl (0, "Port definition structure is incomplete"); } } } +/* search through the command line options for the port */ static void _findPort (int argc, char **argv) { @@ -599,6 +602,13 @@ _setModel (int model, const char *sz) werror (W_UNSUPPORTED_MODEL, sz, port->target); } +static void +_setProcessor (char *_processor) +{ + port->processor = _processor; + fprintf(stderr,"Processor: %s\n",_processor); +} + /** Gets the string argument to this option. If the option is '--opt' then for input of '--optxyz' or '--opt xyz' returns xyz. */ @@ -947,6 +957,11 @@ parseCmdLine (int argc, char **argv) _setPort (argv[i] + 2); break; + case 'p': + /* Used to select the processor in port */ + _setProcessor (getStringArg("-p", argv, &i, argc)); + break; + case 'c': verifyShortOption(argv[i]); @@ -1167,11 +1182,13 @@ linkEdit (char **envp) } #endif -#if !OPT_DISABLE_XA51 +#if !OPT_DISABLE_XA51 +#ifdef STD_XA51_LIB if (options.model == MODEL_PAGE0) { fprintf (lnkfile, "-l %s\n", STD_XA51_LIB); } +#endif #endif fprintf (lnkfile, "-l %s\n", STD_LIB); fprintf (lnkfile, "-l %s\n", STD_INT_LIB); diff --git a/src/avr/main.c b/src/avr/main.c index d073f507..05b77984 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -151,6 +151,7 @@ PORT avr_port = { TARGET_ID_AVR, "avr", "ATMEL AVR", /* Target name */ + NULL, /* processor */ { TRUE, /* Emit glue around main */ MODEL_LARGE | MODEL_SMALL, diff --git a/src/ds390/main.c b/src/ds390/main.c index 4e112d6b..57444c80 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -324,6 +324,7 @@ PORT ds390_port = TARGET_ID_DS390, "ds390", "DS80C390", /* Target name */ + NULL, { TRUE, /* Emit glue around main */ MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24, @@ -607,6 +608,7 @@ PORT tininative_port = TARGET_ID_DS390, "TININative", "DS80C390", /* Target name */ + NULL, /* processor */ { FALSE, /* Emit glue around main */ MODEL_FLAT24, diff --git a/src/izt/i186.c b/src/izt/i186.c index e01ebe4d..60048a43 100644 --- a/src/izt/i186.c +++ b/src/izt/i186.c @@ -136,6 +136,7 @@ PORT i186_port = { TARGET_ID_I186, "i186", "Intel 80186", /* Target name */ + NULL, { FALSE, /* Emit glue around main */ MODEL_SMALL, diff --git a/src/izt/tlcs900h.c b/src/izt/tlcs900h.c index 48a854f1..2f5a9d22 100644 --- a/src/izt/tlcs900h.c +++ b/src/izt/tlcs900h.c @@ -135,6 +135,7 @@ PORT tlcs900h_port = TARGET_ID_TLCS900H, "tlcs900h", "Toshiba TLCS-900H", /* Target name */ + NULL, { TRUE, /* Emit glue around main */ MODEL_SMALL, diff --git a/src/mcs51/main.c b/src/mcs51/main.c index bad1b313..b3097374 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -227,6 +227,7 @@ PORT mcs51_port = TARGET_ID_MCS51, "mcs51", "MCU 8051", /* Target name */ + NULL, /* Processor name */ { TRUE, /* Emit glue around main */ MODEL_SMALL | MODEL_LARGE, diff --git a/src/pic/device.c b/src/pic/device.c index 87004950..a7d546f4 100644 --- a/src/pic/device.c +++ b/src/pic/device.c @@ -48,6 +48,7 @@ memRange p16f627_sfr[] = { {0x02, 0x04, 0x180, 0}, {0x05, 0x05, 0x000, 0}, {0x06, 0x06, 0x100, 0}, + {0x81, 0x81, 0x100, 1}, {0x85, 0x85, 0x000, 1}, {0x86, 0x86, 0x100, 1}, {0x0a, 0x0b, 0x180, 0}, @@ -72,7 +73,8 @@ memRange p16f84_sfr[] = { {0x01, 0x01, 0x00, 0}, {0x02, 0x04, 0x80, 0}, {0x05, 0x06, 0x00, 0}, - {0x85, 0x86, 0x80, 1}, + {0x81, 0x81, 0x00, 1}, + {0x85, 0x86, 0x00, 1}, {0x08, 0x09, 0x00, 0}, {0x88, 0x89, 0x00, 1}, {0x0a, 0x0b, 0x80, 0}, @@ -94,6 +96,7 @@ memRange p16f877_sfr[] = { {0x02, 0x04, 0x180, 0}, {0x05, 0x05, 0x000, 0}, {0x85, 0x85, 0x000, 1}, + {0x81, 0x81, 0x100, 1}, {0x06, 0x06, 0x100, 0}, {0x86, 0x86, 0x100, 1}, {0x07, 0x09, 0x000, 0}, @@ -144,7 +147,7 @@ static PIC_device Pics[] = { static int num_of_supported_PICS = sizeof(Pics)/sizeof(PIC_device); static int default_pic = 0; -#define DEFAULT_PIC "f84" +#define DEFAULT_PIC "f877" static PIC_device *pic=NULL; @@ -463,7 +466,7 @@ void mapRegister(regs *reg) do { - fprintf(stdout,"mapping %s to address 0x%02x\n",reg->name, (reg->address+alias+i)); + //fprintf(stdout,"mapping %s to address 0x%02x\n",reg->name, (reg->address+alias+i)); finalMapping[reg->address + alias + i].reg = reg; finalMapping[reg->address + alias + i].instance = i; @@ -535,7 +538,7 @@ void assignFixedRegisters(set *regset) } -void assignRelocatableRegisters(set *regset) +void assignRelocatableRegisters(set *regset, int used) { regs *reg; @@ -546,7 +549,7 @@ void assignRelocatableRegisters(set *regset) //fprintf(stdout,"assigning %s\n",reg->name); - if(!reg->isFixed) + if((!reg->isFixed) && ( (used==0) || reg->wasUsed)) address = assignRegister(reg,address); } diff --git a/src/pic/gen.c b/src/pic/gen.c index 0bf3c7b1..08537ea7 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -1678,10 +1678,14 @@ static void genNot (iCode *ic) DEBUGpic14_AopType(__LINE__,IC_LEFT(ic),NULL,IC_RESULT(ic)); /* if in bit space then a special case */ if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY) { - pic14_emitcode("movlw","1<aop->aopu.aop_dir); - //pic14_emitcode("cpl","c"); - //pic14_outBitC(IC_RESULT(ic)); + if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) { + emitpcode(POC_MOVLW,popGet(AOP(IC_LEFT(ic)),0)); + emitpcode(POC_XORWF,popGet(AOP(IC_RESULT(ic)),0)); + } else { + emitpcode(POC_CLRF,popGet(AOP(IC_RESULT(ic)),0)); + emitpcode(POC_BTFSS,popGet(AOP(IC_LEFT(ic)),0)); + emitpcode(POC_INCF,popGet(AOP(IC_RESULT(ic)),0)); + } goto release; } @@ -4458,6 +4462,19 @@ static void genCmpEq (iCode *ic, iCode *ifx) pic14_emitcode("ljmp","%05d_DS_",IC_FALSE(ifx)->key+100); } pic14_emitcode("","%05d_DS_:",tlbl->key+100+labelOffset); + + { + /* left and right are both bit variables, result is carry */ + resolvedIfx rIfx; + + resolveIfx(&rIfx,ifx); + + emitpcode(POC_MOVLW,popGet(AOP(left),0)); + emitpcode(POC_ANDFW,popGet(AOP(left),0)); + emitpcode(POC_BTFSC,popGet(AOP(right),0)); + emitpcode(POC_ANDLW,popGet(AOP(left),0)); + genSkipz2(&rIfx); + } } else { /* They're not both bit variables. Is the right a literal? */ diff --git a/src/pic/glue.c b/src/pic/glue.c index c48be267..d467d816 100644 --- a/src/pic/glue.c +++ b/src/pic/glue.c @@ -860,7 +860,7 @@ picglue () AnalyzepCode('*'); //code->dbName); //#ifdef PCODE_DEBUG - printCallTree(stderr); + // printCallTree(stderr); //#endif pcode_test(); diff --git a/src/pic/main.c b/src/pic/main.c index 96ae3b39..d2693844 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -234,6 +234,7 @@ PORT pic_port = TARGET_ID_PIC, "pic14", "MCU pic", /* Target name */ + NULL, /* Processor */ { TRUE, /* Emit glue around main */ MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24, diff --git a/src/pic/pcode.c b/src/pic/pcode.c index f2177942..98113546 100644 --- a/src/pic/pcode.c +++ b/src/pic/pcode.c @@ -45,8 +45,8 @@ pCodeOpReg pc_pcl = {{PO_PCL, "PCL"}, -1, NULL,0,NULL}; pCodeOpReg pc_pclath = {{PO_PCLATH, "PCLATH"}, -1, NULL,0,NULL}; pCodeOpReg pc_kzero = {{PO_GPR_REGISTER, "KZ"}, -1, NULL,0,NULL}; -pCodeOpReg pc_wsave = {{PO_GPR_REGISTER, "W_SAVE"}, -1, NULL,0,NULL}; -pCodeOpReg pc_ssave = {{PO_GPR_REGISTER, "STATUS_SAVE"}, -1, NULL,0,NULL}; +pCodeOpReg pc_wsave = {{PO_GPR_REGISTER, "WSAVE"}, -1, NULL,0,NULL}; +pCodeOpReg pc_ssave = {{PO_GPR_REGISTER, "SSAVE"}, -1, NULL,0,NULL}; static int mnemonics_initialized = 0; @@ -56,7 +56,7 @@ static hTab *pic14MnemonicsHash = NULL; static pFile *the_pFile = NULL; -static int peepOptimizing = 0; +static int peepOptimizing = 1; static int GpCodeSequenceNumber = 1; static int GpcFlowSeq = 1; diff --git a/src/pic/pcode.h b/src/pic/pcode.h index c0a8bee3..8a8df94f 100644 --- a/src/pic/pcode.h +++ b/src/pic/pcode.h @@ -76,7 +76,7 @@ struct regs; * The double parenthesis (()) are necessary * ***********************************************************************/ -//#define PCODE_DEBUG +#define PCODE_DEBUG #ifdef PCODE_DEBUG #define DFPRINTF(args) (fprintf args) diff --git a/src/pic/pcodepeep.c b/src/pic/pcodepeep.c index fe125973..8e7dcdb4 100644 --- a/src/pic/pcodepeep.c +++ b/src/pic/pcodepeep.c @@ -1529,9 +1529,17 @@ static pCodeOp *pCodeOpCopy(pCodeOp *pcop) PCOL(pcopnew)->lit = PCOL(pcop)->lit; break; + case PO_GPR_BIT: + + pcopnew = newpCodeOpBit(pcop->name, PCORB(pcop)->bit,PCORB(pcop)->inBitSpace); + PCOR(pcopnew)->r = PCOR(pcop)->r; + PCOR(pcopnew)->rIdx = PCOR(pcop)->rIdx; + DFPRINTF((stderr," pCodeOpCopy Bit -register index\n")); + return pcopnew; + break; + case PO_GPR_REGISTER: case PO_GPR_TEMP: - case PO_GPR_BIT: case PO_FSR: case PO_INDF: //DFPRINTF((stderr,"pCodeOpCopy GPR register\n")); @@ -1541,6 +1549,8 @@ static pCodeOp *pCodeOpCopy(pCodeOp *pcop) DFPRINTF((stderr," register index %d\n", PCOR(pcop)->r->rIdx)); break; + case PO_STATUS: + DFPRINTF((stderr,"pCodeOpCopy PO_STATUS\n")); case PO_DIR: //DFPRINTF((stderr,"pCodeOpCopy PO_DIR\n")); case PO_SFR_REGISTER: @@ -1548,7 +1558,6 @@ static pCodeOp *pCodeOpCopy(pCodeOp *pcop) case PO_NONE: case PO_W: case PO_INTCON: - case PO_STATUS: case PO_PCL: case PO_PCLATH: diff --git a/src/pic/peeph.def b/src/pic/peeph.def index d6a80a0e..bb586cc7 100644 --- a/src/pic/peeph.def +++ b/src/pic/peeph.def @@ -36,9 +36,9 @@ // clrw //lab1 // -// However, the Rule has wild cards four wild cards. -// The first allows the btfss instruction operate -// on anything, not just the Z bit in status register. +// However, the Rule has four wild cards. +// The first allows the btfss instruction operator +// be anything, not just the Z bit in status register. // The second wild card applies to a label. // The third wild card is for an instruction - any // single instruction can be substituted. diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index 7b7f125b..19faff94 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -760,6 +760,8 @@ pic14_allocWithIdx (int idx) debugLog ("Found a Stack Register!\n"); } else if( (dReg = regWithIdx ( dynProcessorRegs, idx,0)) != NULL ) { debugLog ("Found a Processor Register!\n"); + } else if( (dReg = regWithIdx ( dynInternalRegs, idx,0)) != NULL ) { + debugLog ("Found an Internal Register!\n"); } else { debugLog ("Dynamic Register not found\n"); @@ -871,7 +873,7 @@ void writeSetUsedRegs(FILE *of, set *dRegs) } extern void assignFixedRegisters(set *regset); -extern void assignRelocatableRegisters(set *regset); +extern void assignRelocatableRegisters(set *regset,int used); extern void dump_map(void); extern void dump_cblock(FILE *of); @@ -993,9 +995,10 @@ void writeUsedRegs(FILE *of) assignFixedRegisters(dynStackRegs); assignFixedRegisters(dynDirectRegs); - assignRelocatableRegisters(dynAllocRegs); - assignRelocatableRegisters(dynStackRegs); - assignRelocatableRegisters(dynDirectRegs); + assignRelocatableRegisters(dynInternalRegs,1); + assignRelocatableRegisters(dynAllocRegs,0); + assignRelocatableRegisters(dynStackRegs,0); + assignRelocatableRegisters(dynDirectRegs,0); //dump_map(); diff --git a/src/port.h b/src/port.h index 672a701b..04b02102 100644 --- a/src/port.h +++ b/src/port.h @@ -51,6 +51,9 @@ typedef struct /** Target name string, used for --help */ const char *target_name; +/** Specific processor for the given target family. specified by -p */ + char *processor; + struct { /** TRUE if all types of glue functions should be inserted into diff --git a/src/xa51/main.c b/src/xa51/main.c index eb2c944f..077af218 100755 --- a/src/xa51/main.c +++ b/src/xa51/main.c @@ -209,6 +209,7 @@ PORT xa51_port = TARGET_ID_XA51, "xa51", "MCU 80C51XA", /* Target name */ + NULL, /* Processor name */ { FALSE, /* Emit glue around main */ MODEL_PAGE0, diff --git a/src/z80/main.c b/src/z80/main.c index 06cc6c1f..81c9a80b 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -455,6 +455,7 @@ PORT z80_port = TARGET_ID_Z80, "z80", "Zilog Z80", /* Target name */ + NULL, /* Processor name */ { FALSE, MODEL_MEDIUM | MODEL_SMALL, @@ -546,6 +547,7 @@ PORT gbz80_port = TARGET_ID_GBZ80, "gbz80", "Gameboy Z80-like", /* Target name */ + NULL, { FALSE, MODEL_MEDIUM | MODEL_SMALL,