* device/lib/libsdcc.lib: added module rand
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 30 Sep 2006 17:03:45 +0000 (17:03 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 30 Sep 2006 17:03:45 +0000 (17:03 +0000)
* src/ds390/ralloc.c (rematStr),
* src/hc08/ralloc.c (rematStr),
* src/mcs51/ralloc.c (rematStr),
* src/z80/ralloc.c (rematStr): made output more consistent
* src/mcs51/gen.c: cosmetic changes

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

ChangeLog
device/lib/libsdcc.lib
src/ds390/ralloc.c
src/hc08/ralloc.c
src/mcs51/gen.c
src/mcs51/ralloc.c
src/z80/ralloc.c

index 4f9106166148fbdae0916aa7568c01a5c58a366b..89225abc8e45cf607ac1001a73dbb65b9d54c2d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-09-30 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * device/lib/libsdcc.lib: added module rand
+       * src/ds390/ralloc.c (rematStr),
+       * src/hc08/ralloc.c (rematStr),
+       * src/mcs51/ralloc.c (rematStr),
+       * src/z80/ralloc.c (rematStr): made output more consistent
+       * src/mcs51/gen.c: cosmetic changes
+
 2006-09-30 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * src/port.h: added mem.cabs_name to PORT
index 89ee78caaef64828275397c047c58715d91332cf..eaad6ac5276107a6e23dab5bbcb6926e2e49c280 100644 (file)
@@ -36,6 +36,7 @@ _bp
 _spx
 abs
 labs
+rand
 _atoi
 _atol
 calloc
index a6dfae4c4ab18df4d6ab1c1341f7cd85e39389c3..3db3a8483279d9b17e34550f993e015ce7c4dc09 100644 (file)
@@ -1934,21 +1934,23 @@ createRegMask (eBBlock ** ebbs, int count)
 static char *
 rematStr (symbol * sym)
 {
-  char *s = buffer;
   iCode *ic = sym->rematiCode;
-
-  *s = 0;
+  int offset = 0;
 
   while (1)
     {
+      /* if plus adjust offset to right hand side */
+      if (ic->op == '+')
+        {
+          offset += (int) operandLitValue (IC_RIGHT (ic));
+          ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
+          continue;
+        }
 
-      /* if plus or minus print the right hand side */
-      if (ic->op == '+' || ic->op == '-')
+      /* if minus adjust offset to right hand side */
+      if (ic->op == '-')
         {
-          SNPRINTF (s, sizeof(buffer) - strlen(buffer),
-                    "0x%04x %c ", (int) operandLitValue (IC_RIGHT (ic)),
-                    ic->op);
-          s += strlen (s);
+          offset -= (int) operandLitValue (IC_RIGHT (ic));
           ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
           continue;
         }
@@ -1959,11 +1961,21 @@ rematStr (symbol * sym)
           continue;
       }
       /* we reached the end */
-      SNPRINTF (s, sizeof(buffer) - strlen(buffer),
-                "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
       break;
     }
 
+  if (offset)
+    {
+      SNPRINTF (buffer, sizeof(buffer),
+                "(%s %c 0x%04x)",
+                OP_SYMBOL (IC_LEFT (ic))->rname,
+                offset >= 0 ? '+' : '-',
+                abs (offset) & 0xffff);
+    }
+  else
+    {
+      strncpyz (buffer, OP_SYMBOL (IC_LEFT (ic))->rname, sizeof(buffer));
+    }
   return buffer;
 }
 
index 995b78763b3f8a0353d4d2b566ee7da231868015..116804335972d319f21ff542f0d2217db85349ef 100644 (file)
@@ -1671,49 +1671,58 @@ createRegMask (eBBlock ** ebbs, int count)
 static char *
 rematStr (symbol * sym)
 {
-  char *s = buffer;
   iCode *ic = sym->rematiCode;
-//  int offset = 0;
+  int offset = 0;
 
   while (1)
     {
-      /* if plus or minus print the right hand side */
-      if (ic->op == '+' || ic->op == '-')
-       {
-         sprintf (s, "0x%04x %c ", (int) operandLitValue (IC_RIGHT (ic)),
-                  ic->op);
-         s += strlen (s);
-         ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
-         continue;
-       }
-
-/*
+      /* if plus adjust offset to right hand side */
       if (ic->op == '+')
         {
-          offset += operandLitValue (IC_RIGHT (ic));
+          offset += (int) operandLitValue (IC_RIGHT (ic));
          ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
           continue;
         }
+
+      /* if minus adjust offset to right hand side */
       if (ic->op == '-')
         {
-          offset -= operandLitValue (IC_RIGHT (ic));
+          offset -= (int) operandLitValue (IC_RIGHT (ic));
          ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
           continue;
         }
-*/
+
       /* cast then continue */
       if (IS_CAST_ICODE(ic)) {
          ic = OP_SYMBOL (IC_RIGHT (ic))->rematiCode;
          continue;
       }
       /* we reached the end */
-      if (ic->op == ADDRESS_OF)
-        sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
-      else if (ic->op == '=')
-        sprintf (s, "0x%04x", (int) operandLitValue (IC_RIGHT (ic)) );
       break;
     }
 
+  if (ic->op == ADDRESS_OF)
+    {
+      if (offset)
+        {
+          SNPRINTF (buffer, sizeof(buffer),
+                    "(%s %c 0x%04x)",
+                    OP_SYMBOL (IC_LEFT (ic))->rname,
+                    offset >= 0 ? '+' : '-',
+                    abs (offset) & 0xffff);
+        }
+      else
+        {
+          strncpyz (buffer, OP_SYMBOL (IC_LEFT (ic))->rname, sizeof(buffer));
+        }
+    }
+  else if (ic->op == '=')
+    {
+      offset += (int) operandLitValue (IC_RIGHT (ic));
+      SNPRINTF (buffer, sizeof(buffer),
+                "0x%04x",
+                offset & 0xffff);
+    }
   return buffer;
 }
 
index 7f091daed7d43da26dd2210af8abca3a11e8b75a..1f0107050d4ae11ea862a81249af04999c8e2c1f 100644 (file)
@@ -967,8 +967,7 @@ aopOp (operand * op, iCode * ic, bool result)
       /* rematerialize it NOW */
       if (sym->remat)
         {
-          sym->aop = op->aop = aop =
-            aopForRemat (sym);
+          sym->aop = op->aop = aop = aopForRemat (sym);
           aop->size = getSize (sym->type);
           return;
         }
@@ -4082,7 +4081,7 @@ genPlusIncr (iCode * ic)
 
   icount = (unsigned int) floatFromVal (AOP (IC_RIGHT (ic))->aopu.aop_lit);
 
-  D(emitcode (";     genPlusIncr",""));
+  D(emitcode (";","genPlusIncr"));
 
   /* if increment >=16 bits in register or direct space */
   if (( AOP_TYPE(IC_LEFT(ic)) == AOP_REG || 
@@ -9738,18 +9737,17 @@ genDataPointerGet (operand * left,
 
   /* get the string representation of the name */
   l = aopGet (left, 0, FALSE, TRUE);
+  l++; // remove #
   size = AOP_SIZE (result);
   while (size--)
     {
       if (offset)
         {
-          SNPRINTF (buffer, sizeof(buffer),
-                    "(%s + %d)", l + 1, offset);
+          SNPRINTF (buffer, sizeof(buffer), "(%s + %d)", l, offset);
         }
       else
         {
-          SNPRINTF (buffer, sizeof(buffer),
-                    "%s", l + 1);
+          SNPRINTF (buffer, sizeof(buffer), "%s", l);
         }
       aopPut (result, buffer, offset++);
     }
@@ -10434,13 +10432,14 @@ genDataPointerSet (operand * right,
   aopOp (right, ic, FALSE);
 
   l = aopGet (result, 0, FALSE, TRUE);
+  l++; //remove #
   size = AOP_SIZE (right);
   while (size--)
     {
       if (offset)
-        SNPRINTF (buffer, sizeof(buffer), "(%s + %d)", l + 1, offset);
+        SNPRINTF (buffer, sizeof(buffer), "(%s + %d)", l, offset);
       else
-        SNPRINTF (buffer, sizeof(buffer), "%s", l + 1);
+        SNPRINTF (buffer, sizeof(buffer), "%s", l);
       emitcode ("mov", "%s,%s", buffer,
                 aopGet (right, offset++, FALSE, FALSE));
     }
index 972925da7ebed58b927451155fb6b34eb4dea675..832a203cbdc9205fd41f6756a84d2e4e43964832 100644 (file)
@@ -1831,21 +1831,23 @@ createRegMask (eBBlock ** ebbs, int count)
 static char *
 rematStr (symbol * sym)
 {
-  char *s = buffer;
   iCode *ic = sym->rematiCode;
-
-  *s = 0;
+  int offset = 0;
 
   while (1)
     {
+      /* if plus adjust offset to right hand side */
+      if (ic->op == '+')
+        {
+          offset += (int) operandLitValue (IC_RIGHT (ic));
+          ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
+          continue;
+        }
 
-      /* if plus or minus print the right hand side */
-      if (ic->op == '+' || ic->op == '-')
+      /* if minus adjust offset to right hand side */
+      if (ic->op == '-')
         {
-          SNPRINTF (s, sizeof(buffer) - strlen(buffer),
-                    "0x%04x %c ", (int) operandLitValue (IC_RIGHT (ic)),
-                    ic->op);
-          s += strlen (s);
+          offset -= (int) operandLitValue (IC_RIGHT (ic));
           ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
           continue;
         }
@@ -1856,11 +1858,21 @@ rematStr (symbol * sym)
           continue;
       }
       /* we reached the end */
-      SNPRINTF (s, sizeof(buffer) - strlen(buffer),
-                "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
       break;
     }
 
+  if (offset)
+    {
+      SNPRINTF (buffer, sizeof(buffer),
+                "(%s %c 0x%04x)",
+                OP_SYMBOL (IC_LEFT (ic))->rname,
+                offset >= 0 ? '+' : '-',
+                abs (offset) & 0xffff);
+    }
+  else
+    {
+      strncpyz (buffer, OP_SYMBOL (IC_LEFT (ic))->rname, sizeof(buffer));
+    }
   return buffer;
 }
 
index 28a18be19bc4d466cba29e2b3ef5ad42bd9599e5..18e3d77e5b6c33faf977b7b604f4fc8b549c2853 100644 (file)
@@ -1540,29 +1540,51 @@ createRegMask (eBBlock ** ebbs, int count)
 
 /** Returns the rematerialized string for a remat var.
  */
-char *
+static char *
 rematStr (symbol * sym)
 {
-  char *s = buffer;
   iCode *ic = sym->rematiCode;
+  int offset = 0;
 
   while (1)
     {
+      /* if plus adjust offset to right hand side */
+      if (ic->op == '+')
+        {
+          offset += (int) operandLitValue (IC_RIGHT (ic));
+          ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
+          continue;
+        }
 
-      /* if plus or minus print the right hand side */
-      if (ic->op == '+' || ic->op == '-')
+      /* if minus adjust offset to right hand side */
+      if (ic->op == '-')
        {
-         sprintf (s, "0x%04x %c ", (int) operandLitValue (IC_RIGHT (ic)),
-                  ic->op);
-         s += strlen (s);
+          offset -= (int) operandLitValue (IC_RIGHT (ic));
          ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
          continue;
        }
+
+      /* cast then continue */
+      if (IS_CAST_ICODE(ic)) {
+          ic = OP_SYMBOL (IC_RIGHT (ic))->rematiCode;
+          continue;
+      }
       /* we reached the end */
-      sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
       break;
     }
 
+  if (offset)
+    {
+      SNPRINTF (buffer, sizeof(buffer),
+                "(%s %c 0x%04x)",
+                OP_SYMBOL (IC_LEFT (ic))->rname,
+                offset >= 0 ? '+' : '-',
+                abs (offset) & 0xffff);
+    }
+  else
+    {
+      strncpyz (buffer, OP_SYMBOL (IC_LEFT (ic))->rname, sizeof(buffer));
+    }
   return buffer;
 }