Fixed pointer post increment problem
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 19 Aug 2001 15:52:51 +0000 (15:52 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 19 Aug 2001 15:52:51 +0000 (15:52 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1152 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.h
src/SDCCcse.c
src/SDCCicode.c
src/SDCCicode.h
src/SDCCsymt.h
src/avr/gen.c
src/avr/main.c
src/avr/ralloc.c
src/mcs51/ralloc.c

index da7572583f0f4e2097d6cf6325a17056da3b602c..ff406517c288568853f466307400bf7df593176a 100644 (file)
@@ -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);
index 456db5121be50cd3eef6a068f2285b2999c3e201..8787bd48405ab9bb5dbf51b80f67e492eb200714 100644 (file)
@@ -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;
     }
 
 
index 4e93c888ce17805e5b38e4ade37243139f6c8165..e784abc298adb4ea28981dc17e8e19bf0fde6803 100644 (file)
@@ -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);
 
index d94c8de517b0dec8e9076df91f7078e26b75dd91..ae5be9a1abf024c4c9f620bd3176dde5939e80ec 100644 (file)
@@ -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
index 2b06d0dd653dc98e8c2d79c4edebc3246cb295e9..41e4ec78b31d1ccec5b7bb04572f567b8daca319 100644 (file)
@@ -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
index 06258e4f018db076bbaa5f8819728dd17782b3f0..1d7171a3158cf78f6b8d230bd6c98335be0401f1 100644 (file)
@@ -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 */
index a9bcd4696ce99e285b9adc059323d2c13cf772db..84a1468139b62cfbf759f66d65d2c8b727f8544a 100644 (file)
@@ -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"},
index b3d2a81f7e5296e2a382333759fd79c1016a9447..8388d84b58d95ee195c9ae7b853811bea386d81b 100644 (file)
@@ -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 */
index b17dcf80b0db9088a71160bbd8ee4e118436bdf4..aaa47ce21bdd617cc95e56ee02f1f7645ca2c96c 100644 (file)
@@ -1432,6 +1432,7 @@ regTypeNum ()
              (ic = hTabItemWithKey (iCodehTab,
                                     bitVectFirstBit (sym->defs))) &&
              POINTER_GET (ic) &&
+             !sym->noSpilLoc &&
              !IS_BITVAR (sym->etype))
            {