* src/hc08/main.c,
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 16 Sep 2004 07:10:57 +0000 (07:10 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 16 Sep 2004 07:10:57 +0000 (07:10 +0000)
* src/hc08/gen.c (genJumpTable): more efficient jump table, supports
preservation of HX
* src/hc08/gen.c (pullRegs): fixed order of HX & XA pairs
* src/mcs51/ralloc.c (packRegisters): removed the patch applied
on 2004-09-12; it was buggy

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3498 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/hc08/gen.c
src/hc08/main.c
src/mcs51/ralloc.c

index ec46032ec7f1a00cd0ca880e63ca833e80159451..ac6a83358ce481e1fb26dd88e172d2e2bdac315f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-09-16 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * src/hc08/main.c,
+       * src/hc08/gen.c (genJumpTable): more efficient jump table, supports
+       preservation of HX
+       * src/hc08/gen.c (pullRegs): fixed order of HX & XA pairs
+       * src/mcs51/ralloc.c (packRegisters): removed the patch applied
+       on 2004-09-12; it was buggy
+
 2004-09-15 Bernhard Held <bernhard AT bernhardheld.de>
 
        * src/SDCCsymt.h: removed RESULT_CHECK
index 2938ece657accb5c4290d2ededf6a9332d1394ac..75a1f85ceb8e02f32405d2cd7884c3a9b141397e 100644 (file)
@@ -411,18 +411,18 @@ pullReg (regs *reg)
        updateCFA();
         break;
       case HX_IDX:
-        emitcode ("pulx", "");
+        emitcode ("pulh", "");
         _G.stackPushes--;
        updateCFA();
-        emitcode ("pulh", "");
+        emitcode ("pulx", "");
         _G.stackPushes--;
        updateCFA();
         break;
       case XA_IDX:
-        emitcode ("pula", "");
+        emitcode ("pulx", "");
         _G.stackPushes--;
        updateCFA();
-        emitcode ("pulx", "");
+        emitcode ("pula", "");
         _G.stackPushes--;
        updateCFA();
         break;
@@ -7665,32 +7665,59 @@ static void
 genJumpTab (iCode * ic)
 {
   symbol *jtab;
-//  char *l;
-
+  symbol *jtablo = newiTempLabel (NULL);
+  symbol *jtabhi = newiTempLabel (NULL);
+  
   D(emitcode (";     genJumpTab",""));
 
   aopOp (IC_JTCOND (ic), ic, FALSE);
-  /* get the condition into accumulator */
-  loadRegFromAop (hc08_reg_a, AOP (IC_JTCOND (ic)), 0);
-  freeAsmop (IC_JTCOND (ic), NULL, ic, TRUE);
-  /* multiply by three */
-  pushReg (hc08_reg_a, FALSE);
-  emitcode ("lsla", "");
-  emitcode ("add","1,s");
-  transferRegReg (hc08_reg_a, hc08_reg_x, TRUE);
-  loadRegFromConst (hc08_reg_h, zero);
-  pullReg (hc08_reg_a);
+  
+  if (hc08_reg_x->isFree && hc08_reg_x->isFree)
+    {
+      /* get the condition into x */
+      loadRegFromAop (hc08_reg_x, AOP (IC_JTCOND (ic)), 0);
+      freeAsmop (IC_JTCOND (ic), NULL, ic, TRUE);
+      loadRegFromConst (hc08_reg_h, zero);
+
+      emitcode ("lda", "%05d$,x", jtabhi->key + 100);
+      emitcode ("ldx", "%05d$,x", jtablo->key + 100);
+      transferRegReg (hc08_reg_a, hc08_reg_h, TRUE);
+      emitcode ("jmp", ",x");
+
+      hc08_dirtyReg (hc08_reg_a, TRUE);
+      hc08_dirtyReg (hc08_reg_hx, TRUE);
+    }
+  else
+    {
+      adjustStack(-2);
+      pushReg(hc08_reg_hx, TRUE);
+      
+      /* get the condition into x */
+      loadRegFromAop (hc08_reg_x, AOP (IC_JTCOND (ic)), 0);
+      freeAsmop (IC_JTCOND (ic), NULL, ic, TRUE);
+      loadRegFromConst (hc08_reg_h, zero);
+
+      emitcode ("lda", "%05d$,x", jtabhi->key + 100);
+      emitcode ("sta", "3,s");
+      emitcode ("lda", "%05d$,x", jtablo->key + 100);
+      emitcode ("sta", "4,s");
+      
+      pullReg(hc08_reg_hx);
+      emitcode ("rts", "");
+      _G.stackPushes += 2;
+      updateCFA();
+    }
 
-  jtab = newiTempLabel (NULL);
-  emitcode ("jmp", "%05d$,x", jtab->key + 100);
-  emitcode ("", "%05d$:", jtab->key + 100);
   /* now generate the jump labels */
+  emitLabel (jtablo);
+  for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab;
+       jtab = setNextItem (IC_JTLABELS (ic)))
+    emitcode (".db", "%05d$", jtab->key + 100);
+  emitLabel (jtabhi);
   for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab;
        jtab = setNextItem (IC_JTLABELS (ic)))
-    emitcode ("jmp", "%05d$", jtab->key + 100);
+    emitcode (".db", ">%05d$", jtab->key + 100);
 
-  hc08_dirtyReg (hc08_reg_a, TRUE);
-  hc08_dirtyReg (hc08_reg_hx, TRUE);
 }
 
 /*-----------------------------------------------------------------*/
index f586fc639ca2e7aae927da66c3662fd481cba60b..f5efd8603fb2ee21956902fb88bbaada9ab1d038 100644 (file)
@@ -464,12 +464,12 @@ PORT hc08_port =
     },
   },
   {
-    255/3,      /* maxCount */
-    3,          /* sizeofElement */
+    256,        /* maxCount */
+    2,          /* sizeofElement */
     {8,16,32},  /* sizeofMatchJump[] */
     {8,16,32},  /* sizeofRangeCompare[] */
     5,          /* sizeofSubtract */
-    11,         /* sizeofDispatch */
+    10,         /* sizeofDispatch */
   },
   "_",
   _hc08_init,
index 0c9ada1d238547496f3c59022caf22fe7614e6e1..0d4181a290ab9b7d1c8af1ff56d42a8d0e747c36 100644 (file)
@@ -2808,46 +2808,6 @@ packRegisters (eBBlock ** ebpp, int blockno)
 
   for (ic = ebp->sch; ic; ic = ic->next)
     {
-      /* Fix for bug #979599:   */
-      /* P0 &= ~1;              */
-
-      /* Look for two subsequent iCodes with */
-      /*   iTemp := _c;         */
-      /*   _c = iTemp & op;     */
-      /* and replace them by    */
-      /*   _c = _c & op;        */
-      if ((ic->op == BITWISEAND || ic->op == '|' || ic->op == '^') &&
-          /* avoid trouble with unary '&' */
-          IC_RIGHT (ic) &&
-          ic->prev &&
-          ic->prev->op == '=' &&
-          IS_ITEMP (IC_LEFT (ic)) &&
-          IC_LEFT (ic) == IC_RESULT (ic->prev) &&
-          isOperandEqual (IC_RESULT(ic), IC_RIGHT(ic->prev)))
-        {
-          int key = ic->prev->key;
-
-          bitVectUnSetBit (OP_SYMBOL (IC_RESULT (ic->prev))->defs, key);
-          ReplaceOpWithCheaperOp (&IC_LEFT (ic), IC_RESULT (ic));
-          if (/*IS_ITEMP (IC_RESULT (ic->prev)) && */
-              OP_SYMBOL (IC_RESULT (ic->prev))->liveFrom > ic->seq)
-            {
-              OP_SYMBOL (IC_RESULT (ic->prev))->liveFrom = ic->seq;
-            }
-          // TODO: and the other way round?
-
-          /* delete from liverange table also
-             delete from all the points in between and the new one */
-          bitVectUnSetBit (ic->prev->rlive, IC_RESULT (ic->prev)->key);
-          bitVectSetBit   (ic->prev->rlive, IC_RESULT (ic)->key);
-          bitVectUnSetBit (ic->rlive, IC_RESULT (ic->prev)->key);
-          bitVectSetBit   (ic->rlive, IC_RESULT (ic)->key);
-
-          remiCodeFromeBBlock (ebp, ic->prev);
-          // bitVectUnSetBit (OP_SYMBOL (IC_RESULT (ic))->defs, ic->key);
-          hTabDeleteItem (&iCodehTab, key, ic->prev, DELETE_ITEM, NULL);
-          // OP_DEFS (IC_RESULT (ic->prev)) = bitVectSetBit (OP_DEFS (IC_RESULT (ic->prev)), ic->prev->key);
-        }
 
       /* if this is an itemp & result of an address of a true sym
          then mark this as rematerialisable   */