From: michaelh Date: Sun, 23 Jan 2000 18:26:04 +0000 (+0000) Subject: More shifting. Remove SDCCralloc.h, made all in mcs51 static, X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=9cfb06226bf95c1b0d76c2c99c263809f3bfc19d;p=fw%2Fsdcc More shifting. Remove SDCCralloc.h, made all in mcs51 static, prepended mcs51_ for shared functions, made 'regs' an incomplete type. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@23 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCglue.c b/src/SDCCglue.c index eb574a35..3dfe3748 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -63,6 +63,39 @@ void copyFile (FILE * dest, FILE * src) fputc (ch, dest); } +/*-----------------------------------------------------------------*/ +/* aopLiteral - string from a literal value */ +/*-----------------------------------------------------------------*/ +char *aopLiteral (value *val, int offset) +{ + char *rs; + union { + float f; + unsigned char c[4]; + } fl; + + /* if it is a float then it gets tricky */ + /* otherwise it is fairly simple */ + if (!IS_FLOAT(val->type)) { + unsigned long v = floatFromVal(val); + + v >>= (offset * 8); + sprintf(buffer,"#0x%02x",((char) v) & 0xff); + ALLOC_ATOMIC(rs,strlen(buffer)+1); + return strcpy (rs,buffer); + } + + /* it is type float */ + fl.f = (float) floatFromVal(val); +#ifdef _BIG_ENDIAN + sprintf(buffer,"#0x%02x",fl.c[3-offset]); +#else + sprintf(buffer,"#0x%02x",fl.c[offset]); +#endif + ALLOC_ATOMIC(rs,strlen(buffer)+1); + return strcpy (rs,buffer); +} + /*-----------------------------------------------------------------*/ /* emitRegularMap - emit code for maps with no special cases */ /*-----------------------------------------------------------------*/ diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 733aaa53..adfc7307 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -184,9 +184,7 @@ int printOperand (operand *op, FILE *file) int i; fprintf(file,"["); for(i=0;inRegs;i++) - fprintf(file,"%s ",(OP_SYMBOL(op)->regs[i] ? - OP_SYMBOL(op)->regs[i]->name : - "err")); + fprintf(file,"%s ", port->getRegName(OP_SYMBOL(op))); fprintf(file,"]"); } } diff --git a/src/SDCCralloc.h b/src/SDCCralloc.h deleted file mode 100644 index 4db755fb..00000000 --- a/src/SDCCralloc.h +++ /dev/null @@ -1,58 +0,0 @@ -/*------------------------------------------------------------------------- - - SDCCralloc.h - header file register allocation - - Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - In other words, you are welcome to use, share and improve this program. - You are forbidden to forbid anyone else to use, share and improve - what you give them. Help stamp out software-hoarding! --------------------------------------------------------------------------*/ -#include "SDCCicode.h" -#include "SDCCBBlock.h" -#ifndef SDCCRALLOC_H -#define SDCCRALLOC_H 1 - -enum { R2_IDX = 0, R3_IDX , R4_IDX , - R5_IDX ,R6_IDX , R7_IDX , - R0_IDX ,R1_IDX , X8_IDX , - X9_IDX ,X10_IDX , X11_IDX , - X12_IDX ,CND_IDX }; - - -#define REG_PTR 0x01 -#define REG_GPR 0x02 -#define REG_CND 0x04 -/* definition for the registers */ -typedef struct regs -{ - short type; /* can have value - REG_GPR, REG_PTR or REG_CND */ - short rIdx ; /* index into register table */ - short otype; - char *name ; /* name */ - char *dname; /* name when direct access needed */ - char *base ; /* base address */ - short offset; /* offset from the base */ - unsigned isFree :1; /* is currently unassigned */ -} regs; -extern regs regs8051[]; - -void assignRegisters (eBBlock **, int ); -regs *regWithIdx (int); - -#endif diff --git a/src/common.h b/src/common.h index 2e6f0319..30872eae 100644 --- a/src/common.h +++ b/src/common.h @@ -18,9 +18,12 @@ #include "SDCCcflow.h" #include "SDCCdflow.h" #include "SDCClrange.h" -#include "SDCCralloc.h" #include "SDCCptropt.h" #include "SDCCopt.h" #include "port.h" #include "config.h" + +/* +#include "SDCCralloc.h" +*/ diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index b4dccfd0..6fb9f88d 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -5,24 +5,27 @@ and - Jean-Louis VERN.jlvern@writeme.com (1999) Bug Fixes - Wojciech Stryjewski wstryj1@tiger.lsu.edu (1999 v2.1.9a) - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - In other words, you are welcome to use, share and improve this program. - You are forbidden to forbid anyone else to use, share and improve - what you give them. Help stamp out software-hoarding! - + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! + + Notes: + 000123 mlh Moved aopLiteral to SDCCglue.c to help the split + Made everything static -------------------------------------------------------------------------*/ #include @@ -44,8 +47,11 @@ #include "common.h" #include "SDCCpeeph.h" +#include "ralloc.h" #include "gen.h" +char *aopLiteral (value *val, int offset); + /* this is the down and dirty file with all kinds of kludgy & hacky stuff. This is what it is all about CODE GENERATION for a specific MCU . some of the @@ -96,7 +102,7 @@ unsigned char SRMask[] = {0xFF, 0x7F, 0x3F, 0x1F, 0x0F, /*-----------------------------------------------------------------*/ /* emitcode - writes the code into a file : for now it is simple */ /*-----------------------------------------------------------------*/ -void emitcode (char *inst,char *fmt, ...) +static void emitcode (char *inst,char *fmt, ...) { va_list ap; char lb[MAX_INLINEASM]; @@ -149,14 +155,14 @@ static regs *getFreePtr (iCode *ic, asmop **aopp, bool result) if (!r0iu && !r0ou) { ic->rUsed = bitVectSetBit(ic->rUsed,R0_IDX); (*aopp)->type = AOP_R0; - return (*aopp)->aopu.aop_ptr = regWithIdx(R0_IDX); + return (*aopp)->aopu.aop_ptr = mcs51_regWithIdx(R0_IDX); } /* if no usage of r1 then return it */ if (!r1iu && !r1ou) { ic->rUsed = bitVectSetBit(ic->rUsed,R1_IDX); (*aopp)->type = AOP_R1; - return (*aopp)->aopu.aop_ptr = regWithIdx(R1_IDX); + return (*aopp)->aopu.aop_ptr = mcs51_regWithIdx(R1_IDX); } /* now we know they both have usage */ @@ -165,14 +171,14 @@ static regs *getFreePtr (iCode *ic, asmop **aopp, bool result) /* push it if not already pushed */ if (!_G.r0Pushed) { emitcode ("push","%s", - regWithIdx(R0_IDX)->dname); + mcs51_regWithIdx(R0_IDX)->dname); _G.r0Pushed++ ; } ic->rUsed = bitVectSetBit(ic->rUsed,R0_IDX); (*aopp)->type = AOP_R0; - return (*aopp)->aopu.aop_ptr = regWithIdx(R0_IDX); + return (*aopp)->aopu.aop_ptr = mcs51_regWithIdx(R0_IDX); } /* if r1 not used then */ @@ -181,13 +187,13 @@ static regs *getFreePtr (iCode *ic, asmop **aopp, bool result) /* push it if not already pushed */ if (!_G.r1Pushed) { emitcode ("push","%s", - regWithIdx(R1_IDX)->dname); + mcs51_regWithIdx(R1_IDX)->dname); _G.r1Pushed++ ; } ic->rUsed = bitVectSetBit(ic->rUsed,R1_IDX); (*aopp)->type = AOP_R1; - return regWithIdx(R1_IDX); + return mcs51_regWithIdx(R1_IDX); } @@ -361,7 +367,7 @@ static asmop *aopForRemat (symbol *sym) /*-----------------------------------------------------------------*/ /* regsInCommon - two operands have some registers in common */ /*-----------------------------------------------------------------*/ -bool regsInCommon (operand *op1, operand *op2) +static bool regsInCommon (operand *op1, operand *op2) { symbol *sym1, *sym2; int i; @@ -396,7 +402,7 @@ bool regsInCommon (operand *op1, operand *op2) /*-----------------------------------------------------------------*/ /* operandsEqu - equivalent */ /*-----------------------------------------------------------------*/ -bool operandsEqu ( operand *op1, operand *op2) +static bool operandsEqu ( operand *op1, operand *op2) { symbol *sym1, *sym2; @@ -441,7 +447,7 @@ bool operandsEqu ( operand *op1, operand *op2) /*-----------------------------------------------------------------*/ /* sameRegs - two asmops have the same registers */ /*-----------------------------------------------------------------*/ -bool sameRegs (asmop *aop1, asmop *aop2 ) +static bool sameRegs (asmop *aop1, asmop *aop2 ) { int i; @@ -653,39 +659,6 @@ dealloc: } } -/*-----------------------------------------------------------------*/ -/* aopLiteral - string from a literal value */ -/*-----------------------------------------------------------------*/ -char *aopLiteral (value *val, int offset) -{ - char *rs; - union { - float f; - unsigned char c[4]; - } fl; - - /* if it is a float then it gets tricky */ - /* otherwise it is fairly simple */ - if (!IS_FLOAT(val->type)) { - unsigned long v = floatFromVal(val); - - v >>= (offset * 8); - sprintf(buffer,"#0x%02x",((char) v) & 0xff); - ALLOC_ATOMIC(rs,strlen(buffer)+1); - return strcpy (rs,buffer); - } - - /* it is type float */ - fl.f = (float) floatFromVal(val); -#ifdef _BIG_ENDIAN - sprintf(buffer,"#0x%02x",fl.c[3-offset]); -#else - sprintf(buffer,"#0x%02x",fl.c[offset]); -#endif - ALLOC_ATOMIC(rs,strlen(buffer)+1); - return strcpy (rs,buffer); -} - /*-----------------------------------------------------------------*/ /* aopGet - for fetching value of the aop */ /*-----------------------------------------------------------------*/ @@ -1041,8 +1014,8 @@ static void reAdjustPreg (asmop *aop) AOP_TYPE(x) == AOP_DPTR || AOP(x)->paged)) #define AOP_INPREG(x) (x && (x->type == AOP_REG && \ - (x->aopu.aop_reg[0] == regWithIdx(R0_IDX) || \ - x->aopu.aop_reg[0] == regWithIdx(R1_IDX) ))) + (x->aopu.aop_reg[0] == mcs51_regWithIdx(R0_IDX) || \ + x->aopu.aop_reg[0] == mcs51_regWithIdx(R1_IDX) ))) /*-----------------------------------------------------------------*/ /* genNotFloat - generates not for float operations */ @@ -1085,7 +1058,7 @@ static void genNotFloat (operand *op, operand *res) /*-----------------------------------------------------------------*/ /* getDataSize - get the operand data size */ /*-----------------------------------------------------------------*/ -int getDataSize(operand *op) +static int getDataSize(operand *op) { int size; size = AOP_SIZE(op); @@ -1098,7 +1071,7 @@ int getDataSize(operand *op) /*-----------------------------------------------------------------*/ /* outAcc - output Acc */ /*-----------------------------------------------------------------*/ -void outAcc(operand *result) +static void outAcc(operand *result) { int size, offset; size = getDataSize(result); @@ -1116,7 +1089,7 @@ void outAcc(operand *result) /*-----------------------------------------------------------------*/ /* outBitC - output a bit C */ /*-----------------------------------------------------------------*/ -void outBitC(operand *result) +static void outBitC(operand *result) { /* if the result is bit */ if (AOP_TYPE(result) == AOP_CRY) @@ -1131,7 +1104,7 @@ void outBitC(operand *result) /*-----------------------------------------------------------------*/ /* toBoolean - emit code for orl a,operator(sizeop) */ /*-----------------------------------------------------------------*/ -void toBoolean(operand *oper) +static void toBoolean(operand *oper) { int size = AOP_SIZE(oper) - 1; int offset = 1; @@ -1349,7 +1322,7 @@ static void saveRegisters(iCode *lic) if (i == R0_IDX) emitcode("mov","a,b"); else - emitcode("mov","a,%s",regWithIdx(i)->name); + emitcode("mov","a,%s",mcs51_regWithIdx(i)->name); emitcode("movx","@r0,a"); emitcode("inc","r0"); } @@ -1360,7 +1333,7 @@ static void saveRegisters(iCode *lic) } else for (i = 0 ; i < mcs51_nRegs ; i++) { if (bitVectBitValue(rsave,i)) - emitcode("push","%s",regWithIdx(i)->dname); + emitcode("push","%s",mcs51_regWithIdx(i)->dname); } detype = getSpec(operandType(IC_LEFT(ic))); @@ -1393,7 +1366,7 @@ static void unsaveRegisters (iCode *ic) if (i == R0_IDX) emitcode("mov","b,a"); else - emitcode("mov","%s,a",regWithIdx(i)->name); + emitcode("mov","%s,a",mcs51_regWithIdx(i)->name); } } @@ -1403,7 +1376,7 @@ static void unsaveRegisters (iCode *ic) } else for (i = mcs51_nRegs ; i >= 0 ; i--) { if (bitVectBitValue(rsave,i)) - emitcode("pop","%s",regWithIdx(i)->dname); + emitcode("pop","%s",mcs51_regWithIdx(i)->dname); } } @@ -1412,7 +1385,7 @@ static void unsaveRegisters (iCode *ic) /*-----------------------------------------------------------------*/ /* pushSide - */ /*-----------------------------------------------------------------*/ -void pushSide(operand * oper, int size) +static void pushSide(operand * oper, int size) { int offset = 0; while (size--) { @@ -1430,7 +1403,7 @@ void pushSide(operand * oper, int size) /*-----------------------------------------------------------------*/ /* assignResultValue - */ /*-----------------------------------------------------------------*/ -void assignResultValue(operand * oper) +static void assignResultValue(operand * oper) { int offset = 0; int size = AOP_SIZE(oper); @@ -1949,7 +1922,7 @@ static void genFunction (iCode *ic) for ( i = 0 ; i < sym->regsUsed->size ; i++) { if (bitVectBitValue(sym->regsUsed,i) || (mcs51_ptrRegReq && (i == R0_IDX || i == R1_IDX)) ) - emitcode("push","%s",regWithIdx(i)->dname); + emitcode("push","%s",mcs51_regWithIdx(i)->dname); } } @@ -1972,7 +1945,7 @@ static void genFunction (iCode *ic) for ( i = 0 ; i < sym->regsUsed->size ; i++) { if (bitVectBitValue(sym->regsUsed,i) || (mcs51_ptrRegReq && (i == R0_IDX || i == R1_IDX)) ) { - emitcode("push","%s",regWithIdx(i)->dname); + emitcode("push","%s",mcs51_regWithIdx(i)->dname); _G.nRegsSaved++; } } @@ -2083,7 +2056,7 @@ static void genEndFunction (iCode *ic) for ( i = sym->regsUsed->size ; i >= 0 ; i--) { if (bitVectBitValue(sym->regsUsed,i) || (mcs51_ptrRegReq && (i == R0_IDX || i == R1_IDX)) ) - emitcode("pop","%s",regWithIdx(i)->dname); + emitcode("pop","%s",mcs51_regWithIdx(i)->dname); } } @@ -2136,7 +2109,7 @@ static void genEndFunction (iCode *ic) for ( i = sym->regsUsed->size ; i >= 0 ; i--) { if (bitVectBitValue(sym->regsUsed,i) || (mcs51_ptrRegReq && (i == R0_IDX || i == R1_IDX)) ) - emitcode("pop","%s",regWithIdx(i)->dname); + emitcode("pop","%s",mcs51_regWithIdx(i)->dname); } } @@ -2329,7 +2302,7 @@ static bool genPlusIncr (iCode *ic) /*-----------------------------------------------------------------*/ /* outBitAcc - output a bit in acc */ /*-----------------------------------------------------------------*/ -void outBitAcc(operand *result) +static void outBitAcc(operand *result) { symbol *tlbl = newiTempLabel(NULL); /* if the result is a bit */ @@ -3574,7 +3547,7 @@ static void genOrOp (iCode *ic) /*-----------------------------------------------------------------*/ /* isLiteralBit - test if lit == 2^n */ /*-----------------------------------------------------------------*/ -int isLiteralBit(unsigned long lit) +static int isLiteralBit(unsigned long lit) { unsigned long pw[32] = {1L,2L,4L,8L,16L,32L,64L,128L, 0x100L,0x200L,0x400L,0x800L, diff --git a/src/mcs51/main.c b/src/mcs51/main.c index 6dd76d92..0d34e392 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -1,5 +1,6 @@ #include "common.h" #include "main.h" +#include "ralloc.h" void mcs51_assignRegisters (eBBlock **ebbs, int count); @@ -16,6 +17,13 @@ static void _mcs51_setDefaultOptions(void) { } +static const char *_mcs51_getRegName(struct regs *reg) +{ + if (reg) + return reg->name; + return "err"; +} + /* Globals */ PORT mcs51_port = { "mcs51", @@ -43,6 +51,7 @@ PORT mcs51_port = { _mcs51_parseOptions, _mcs51_finaliseOptions, _mcs51_setDefaultOptions, - mcs51_assignRegisters + mcs51_assignRegisters, + _mcs51_getRegName }; diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index 1154d534..9e0ccc9d 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -92,7 +92,7 @@ void spillThis (symbol *); /*-----------------------------------------------------------------*/ /* allocReg - allocates register of given type */ /*-----------------------------------------------------------------*/ -regs *allocReg (short type) +static regs *allocReg (short type) { int i; @@ -123,9 +123,9 @@ regs *allocReg (short type) } /*-----------------------------------------------------------------*/ -/* regWithIdx - returns pointer to register wit index number */ +/* mcs51_regWithIdx - returns pointer to register wit index number */ /*-----------------------------------------------------------------*/ -regs *regWithIdx (int idx) +regs *mcs51_regWithIdx (int idx) { int i ; @@ -141,7 +141,7 @@ regs *regWithIdx (int idx) /*-----------------------------------------------------------------*/ /* freeReg - frees a register */ /*-----------------------------------------------------------------*/ -void freeReg (regs *reg) +static void freeReg (regs *reg) { reg->isFree = 1; } @@ -150,7 +150,7 @@ void freeReg (regs *reg) /*-----------------------------------------------------------------*/ /* nFreeRegs - returns number of free registers */ /*-----------------------------------------------------------------*/ -int nFreeRegs (int type) +static int nFreeRegs (int type) { int i; int nfr=0; @@ -164,7 +164,7 @@ int nFreeRegs (int type) /*-----------------------------------------------------------------*/ /* nfreeRegsType - free registers with type */ /*-----------------------------------------------------------------*/ -int nfreeRegsType (int type) +static int nfreeRegsType (int type) { int nfr ; if (type == REG_PTR) { @@ -179,7 +179,7 @@ int nfreeRegsType (int type) /*-----------------------------------------------------------------*/ /* allDefsOutOfRange - all definitions are out of a range */ /*-----------------------------------------------------------------*/ -bool allDefsOutOfRange (bitVect *defs,int fseq, int toseq) +static bool allDefsOutOfRange (bitVect *defs,int fseq, int toseq) { int i ; @@ -203,7 +203,7 @@ bool allDefsOutOfRange (bitVect *defs,int fseq, int toseq) /*-----------------------------------------------------------------*/ /* computeSpillable - given a point find the spillable live ranges */ /*-----------------------------------------------------------------*/ -bitVect *computeSpillable (iCode *ic) +static bitVect *computeSpillable (iCode *ic) { bitVect *spillable ; @@ -228,7 +228,7 @@ bitVect *computeSpillable (iCode *ic) /*-----------------------------------------------------------------*/ /* noSpilLoc - return true if a variable has no spil location */ /*-----------------------------------------------------------------*/ -int noSpilLoc (symbol *sym, eBBlock *ebp,iCode *ic) +static int noSpilLoc (symbol *sym, eBBlock *ebp,iCode *ic) { return (sym->usl.spillLoc ? 0 : 1); } @@ -236,7 +236,7 @@ int noSpilLoc (symbol *sym, eBBlock *ebp,iCode *ic) /*-----------------------------------------------------------------*/ /* hasSpilLoc - will return 1 if the symbol has spil location */ /*-----------------------------------------------------------------*/ -int hasSpilLoc (symbol *sym, eBBlock *ebp, iCode *ic) +static int hasSpilLoc (symbol *sym, eBBlock *ebp, iCode *ic) { return (sym->usl.spillLoc ? 1 : 0); } @@ -244,7 +244,7 @@ int hasSpilLoc (symbol *sym, eBBlock *ebp, iCode *ic) /*-----------------------------------------------------------------*/ /* directSpilLoc - will return 1 if the splilocation is in direct */ /*-----------------------------------------------------------------*/ -int directSpilLoc (symbol *sym, eBBlock *ebp, iCode *ic) +static int directSpilLoc (symbol *sym, eBBlock *ebp, iCode *ic) { if ( sym->usl.spillLoc && (IN_DIRSPACE(SPEC_OCLS(sym->usl.spillLoc->etype)))) @@ -257,7 +257,7 @@ int directSpilLoc (symbol *sym, eBBlock *ebp, iCode *ic) /* hasSpilLocnoUptr - will return 1 if the symbol has spil location*/ /* but is not used as a pointer */ /*-----------------------------------------------------------------*/ -int hasSpilLocnoUptr (symbol *sym, eBBlock *ebp, iCode *ic) +static int hasSpilLocnoUptr (symbol *sym, eBBlock *ebp, iCode *ic) { return ((sym->usl.spillLoc && !sym->uptr) ? 1 : 0); } @@ -265,7 +265,7 @@ int hasSpilLocnoUptr (symbol *sym, eBBlock *ebp, iCode *ic) /*-----------------------------------------------------------------*/ /* rematable - will return 1 if the remat flag is set */ /*-----------------------------------------------------------------*/ -int rematable (symbol *sym, eBBlock *ebp, iCode *ic) +static int rematable (symbol *sym, eBBlock *ebp, iCode *ic) { return sym->remat; } @@ -273,7 +273,7 @@ int rematable (symbol *sym, eBBlock *ebp, iCode *ic) /*-----------------------------------------------------------------*/ /* notUsedInBlock - not used in this block */ /*-----------------------------------------------------------------*/ -int notUsedInBlock (symbol *sym, eBBlock *ebp, iCode *ic) +static int notUsedInBlock (symbol *sym, eBBlock *ebp, iCode *ic) { return (!bitVectBitsInCommon(sym->defs,ebp->usesDefs) && allDefsOutOfRange (sym->defs,ebp->fSeq,ebp->lSeq)); @@ -419,8 +419,8 @@ void spillLRWithPtrReg (symbol *forSym) bitVectIsZero(_G.regAssigned)) return; - r0 = regWithIdx(R0_IDX); - r1 = regWithIdx(R1_IDX); + r0 = mcs51_regWithIdx(R0_IDX); + r1 = mcs51_regWithIdx(R1_IDX); /* for all live ranges */ for (lrsym = hTabFirstItem(liveRanges,&k) ; lrsym ; diff --git a/src/mcs51/ralloc.h b/src/mcs51/ralloc.h index 4db755fb..0e1ecbe0 100644 --- a/src/mcs51/ralloc.h +++ b/src/mcs51/ralloc.h @@ -52,7 +52,6 @@ typedef struct regs } regs; extern regs regs8051[]; -void assignRegisters (eBBlock **, int ); -regs *regWithIdx (int); +regs *mcs51_regWithIdx (int); #endif diff --git a/src/port.h b/src/port.h index 2d390891..756efb38 100644 --- a/src/port.h +++ b/src/port.h @@ -64,6 +64,9 @@ typedef struct { void (*setDefaultOptions)(void); /** Does the dirty work. */ void (*assignRegisters)(eBBlock **, int); + /** Returns the register name of a symbol. + Used so that 'regs' can be an incomplete type. */ + const char *(*getRegName)(struct regs *reg); } PORT; extern PORT *port;