From: sandeep Date: Sun, 19 Aug 2001 15:52:51 +0000 (+0000) Subject: Fixed pointer post increment problem X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=a12dad7dfe654ada025ae6752fca404d58edc2fa;p=fw%2Fsdcc Fixed pointer post increment problem git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1152 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCast.h b/src/SDCCast.h index da757258..ff406517 100644 --- a/src/SDCCast.h +++ b/src/SDCCast.h @@ -171,7 +171,7 @@ ast; /* forward declarations for global variables */ extern ast *staticAutos; extern FILE *codeOutFile; -extern memmap *GcurMemmap; +extern struct memmap *GcurMemmap; /* forward definitions for functions */ ast *newAst_VALUE (value * val); diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 456db512..8787bd48 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -866,7 +866,7 @@ updateSpillLocation (iCode * ic) setype = getSpec (operandType (IC_RESULT (ic))); - if (!IC_RIGHT (ic)->noSpilLoc && + if (!OP_SYMBOL(IC_RIGHT (ic))->noSpilLoc && !IS_VOLATILE (setype) && !IN_FARSPACE (SPEC_OCLS (setype)) && /* PENDING */ @@ -885,7 +885,7 @@ updateSpillLocation (iCode * ic) setype = getSpec (operandType (IC_RESULT (ic))); - if (!IC_RIGHT (ic)->noSpilLoc && + if (!OP_SYMBOL(IC_RIGHT (ic))->noSpilLoc && !IS_VOLATILE (setype) && !IN_FARSPACE (SPEC_OCLS (setype)) && /* PENDING */ @@ -1123,7 +1123,7 @@ constFold (iCode * ic, set * cseSet) if (IS_ITEMP (IC_RESULT (ic))) { SPIL_LOC (IC_RESULT (ic)) = NULL; - IC_RESULT (ic)->noSpilLoc = 1; + OP_SYMBOL(IC_RESULT (ic))->noSpilLoc = 1; } diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 4e93c888..e784abc2 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -146,12 +146,12 @@ printOperand (operand * op, FILE * file) case SYMBOL: #define REGA 1 #ifdef REGA - fprintf (file, "%s [k%d lr%d:%d so:%d]{ ia%d re%d rm%d}", /*{ar%d rm%d ru%d p%d a%d u%d i%d au%d k%d ks%d}" , */ + fprintf (file, "%s [k%d lr%d:%d so:%d]{ ia%d re%d rm%d nos%d}", /*{ar%d rm%d ru%d p%d a%d u%d i%d au%d k%d ks%d}" , */ (OP_SYMBOL (op)->rname[0] ? OP_SYMBOL (op)->rname : OP_SYMBOL (op)->name), op->key, OP_LIVEFROM (op), OP_LIVETO (op), OP_SYMBOL (op)->stack, - op->isaddr, OP_SYMBOL (op)->isreqv, OP_SYMBOL (op)->remat + op->isaddr, OP_SYMBOL (op)->isreqv, OP_SYMBOL (op)->remat,OP_SYMBOL(op)->noSpilLoc ); { fprintf (file, "{"); @@ -1089,7 +1089,6 @@ newiTempFromOp (operand * op) nop->isvolatile = op->isvolatile; nop->isGlobal = op->isGlobal; nop->isLiteral = op->isLiteral; - nop->noSpilLoc = op->noSpilLoc; nop->usesDefs = op->usesDefs; nop->isParm = op->isParm; return nop; @@ -1112,7 +1111,6 @@ operandFromOperand (operand * op) nop->isvolatile = op->isvolatile; nop->isGlobal = op->isGlobal; nop->isLiteral = op->isLiteral; - nop->noSpilLoc = op->noSpilLoc; nop->usesDefs = op->usesDefs; nop->isParm = op->isParm; @@ -2021,10 +2019,10 @@ geniCodePostInc (operand * op) } rOp = newiTempOperand (rvtype, 0); - rOp->noSpilLoc = 1; + OP_SYMBOL(rOp)->noSpilLoc = 1; if (IS_ITEMP (rv)) - rv->noSpilLoc = 1; + OP_SYMBOL(rv)->noSpilLoc = 1; geniCodeAssign (rOp, rv, 0); @@ -2101,10 +2099,10 @@ geniCodePostDec (operand * op) } rOp = newiTempOperand (rvtype, 0); - rOp->noSpilLoc = 1; + OP_SYMBOL(rOp)->noSpilLoc = 1; if (IS_ITEMP (rv)) - rv->noSpilLoc = 1; + OP_SYMBOL(rv)->noSpilLoc = 1; geniCodeAssign (rOp, rv, 0); diff --git a/src/SDCCicode.h b/src/SDCCicode.h index d94c8de5..ae5be9a1 100644 --- a/src/SDCCicode.h +++ b/src/SDCCicode.h @@ -84,7 +84,6 @@ typedef struct operand unsigned int isGptr:1; /* is a generic pointer */ unsigned int isParm:1; /* is a parameter */ unsigned int isLiteral:1; /* operand is literal */ - unsigned int noSpilLoc:1; /* cannot be assigned a spil location */ unsigned key; union diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 2b06d0dd..41e4ec78 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -227,6 +227,7 @@ typedef struct symbol unsigned ruonly:1; /* used in return statement only */ unsigned spildir:1; /* spilt in direct space */ unsigned ptrreg:1; /* this symbol assigned to a ptr reg */ + unsigned noSpilLoc:1; /* cannot be assigned a spil location */ unsigned accuse; /* can be left in the accumulator On the Z80 accuse is devided into ACCUSE_A and ACCUSE_HL as the idea diff --git a/src/avr/gen.c b/src/avr/gen.c index 06258e4f..1d7171a3 100644 --- a/src/avr/gen.c +++ b/src/avr/gen.c @@ -475,10 +475,10 @@ aopForSym (iCode * ic, symbol * sym, bool result) _G.nRegsSaved)); } else { - emitcode ("subi", "%s,lo8(%d)", + emitcode ("subi", "%s,(%d & 0xff)", aop->aopu.aop_ptr->name, sym->stack - _G.nRegsSaved); - emitcode ("sbci", "%s,hi8(%d)", + emitcode ("sbci", "%s,((%d >> 8) & 0xff)", aop->aop_ptr2->name, sym->stack - _G.nRegsSaved); } @@ -490,10 +490,10 @@ aopForSym (iCode * ic, symbol * sym, bool result) sym->stack); } else { - emitcode ("subi", "%s,lo8(-%d)", + emitcode ("subi", "%s,((-%d) & 0xff)", aop->aopu.aop_ptr->name, sym->stack); - emitcode ("sbci", "%s,hi8(-%d)", + emitcode ("sbci", "%s,(((-%d) >> 8) & 0xff))", aop->aop_ptr2->name, sym->stack); } @@ -5041,7 +5041,7 @@ genAVRCode (iCode * lic) if (currFunc) { cdbSymbol (currFunc, cdbFile, FALSE, TRUE); _G.debugLine = 1; - emitcode ("", ".type %s,@function", currFunc->name); +/* emitcode ("", ".type %s,@function", currFunc->name); */ _G.debugLine = 0; } /* stack pointer name */ diff --git a/src/avr/main.c b/src/avr/main.c index a9bcd469..84a14681 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -38,7 +38,7 @@ static int regParmFlg = 0; /* determine if we can register a parameter */ static void _avr_init (void) { - asm_addTree (&asm_gas_mapping); + asm_addTree (&asm_asxxxx_mapping); } static void @@ -138,11 +138,11 @@ _avr_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts) MUST be terminated with a NULL. */ static const char *_linkCmd[] = { - "avr-ld", "", "$1", NULL + "linkavr", "", "$1", NULL }; static const char *_asmCmd[] = { - "avr-as", "-mmcu=avr3" , "$1.s", NULL + "asavr", "$l" , "-plosgff", "$1.s", NULL }; /* Globals */ @@ -156,7 +156,7 @@ PORT avr_port = { MODEL_SMALL}, { _asmCmd, - "-plosgffc", /* Options with debug */ + "-plosgff", /* Options with debug */ "-plosgff", /* Options without debug */ 0, ".s"}, diff --git a/src/avr/ralloc.c b/src/avr/ralloc.c index b3d2a81f..8388d84b 100644 --- a/src/avr/ralloc.c +++ b/src/avr/ralloc.c @@ -2073,8 +2073,11 @@ packRegisters (eBBlock * ebp) if (POINTER_SET (ic)) OP_SYMBOL (IC_RESULT (ic))->uptr = 1; - if (POINTER_GET (ic)) + if (POINTER_GET (ic)) { OP_SYMBOL (IC_LEFT (ic))->uptr = 1; + if (OP_SYMBOL (IC_LEFT(ic))->remat) + OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL; + } /* if the condition of an if instruction is defined in the previous instruction then @@ -2218,8 +2221,8 @@ setDefaultRegs (eBBlock ** ebbs, int count) else { regsAVR[R26_IDX].type = (regsAVR[R26_IDX].type & ~REG_MASK) | REG_PTR; regsAVR[R27_IDX].type = (regsAVR[R27_IDX].type & ~REG_MASK) | REG_PTR; - regsAVR[R28_IDX].type = (regsAVR[R28_IDX].type & ~REG_MASK) | REG_PTR; - regsAVR[R29_IDX].type = (regsAVR[R29_IDX].type & ~REG_MASK) | REG_PTR; + regsAVR[R30_IDX].type = (regsAVR[R30_IDX].type & ~REG_MASK) | REG_PTR; + regsAVR[R31_IDX].type = (regsAVR[R31_IDX].type & ~REG_MASK) | REG_PTR; } /* registers 0-1 / 24-25 used as scratch */ diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index b17dcf80..aaa47ce2 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -1432,6 +1432,7 @@ regTypeNum () (ic = hTabItemWithKey (iCodehTab, bitVectFirstBit (sym->defs))) && POINTER_GET (ic) && + !sym->noSpilLoc && !IS_BITVAR (sym->etype)) {