]> git.gag.com Git - fw/sdcc/commitdiff
Some new peephole optimizations, primarily for 24 bit flat mode; also use dpx for...
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 10 Feb 2000 21:44:58 +0000 (21:44 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 10 Feb 2000 21:44:58 +0000 (21:44 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@98 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCpeeph.c
src/mcs51/Makefile
src/mcs51/gen.c
src/mcs51/peeph.def

index aa923fbbe1ef100bed2c1270c71e3df5527851e5..d64619ab9210a101e3a508395f62ca70d6410f43 100644 (file)
@@ -64,6 +64,14 @@ int pcDistance (lineNode *cpos, char *lbl, bool back)
     return 0;
 }
 
+/*-----------------------------------------------------------------*/
+/* flat24bitMode - will check to see if we are in flat24 mode     */
+/*-----------------------------------------------------------------*/
+FBYNAME(flat24bitMode)
+{
+    return (options.model == MODEL_FLAT24);
+}
+
 /*-----------------------------------------------------------------*/
 /* labelInRange - will check to see if label %5 is within range    */
 /*-----------------------------------------------------------------*/
@@ -125,7 +133,8 @@ int callFuncByName ( char *fname,
        int (*func)(hTab *,lineNode *,lineNode *) ; 
     }  ftab[] = { 
        {"labelInRange",   labelInRange },
-       {"operandsNotSame", operandsNotSame }
+       {"operandsNotSame", operandsNotSame },
+       {"24bitMode", flat24bitMode },
     };
     int i;
 
index a248555c8f80fa13bd9f8d17ba25d2f9d7327e46..0b6875143cd144b2bb067683ed1055715d793825 100644 (file)
@@ -10,6 +10,8 @@ CFLAGS += -I.. -I. -I../..
 
 all: $(LIB)
 
+main.o: main.c peeph.rul
+
 $(LIB): peeph.rul $(OBJ)
        rm -f $(LIB)
        ar r $(LIB) $(OBJ)
index 6277354244c91b9a3db301c850da1362b33a3eff..57fe38fc63f4dbe2653107f4acec9ca0447de9d5 100644 (file)
@@ -60,7 +60,11 @@ char *aopLiteral (value *val, int offset);
 static char *zero = "#0x00";
 static char *one  = "#0x01";
 static char *spname ;
-static char *fReturn[] = {"dpl","dph","b","a" };
+
+static char *fReturn8051[] = {"dpl","dph","b","a" };
+static char *fReturn390[] = {"dpl","dph","dpx", "b","a" };
+static unsigned fReturnSize = 4;
+static char **fReturn = fReturn8051;
 static char *accUse[] = {"a","b"};
 
 static short rbank = -1;
@@ -551,7 +555,7 @@ static void aopOp (operand *op, iCode *ic, bool result)
             int i;
             aop = op->aop = sym->aop = newAsmop(AOP_STR);
             aop->size = getSize(sym->type);
-            for ( i = 0 ; i < 4 ; i++ )
+            for ( i = 0 ; i < fReturnSize ; i++ )
                 aop->aopu.aop_str[i] = fReturn[i];
             return;
         }
@@ -7170,10 +7174,10 @@ static void genReceive (iCode *ic)
          IS_TRUE_SYMOP(IC_RESULT(ic))) ) {
 
        int size = getSize(operandType(IC_RESULT(ic)));
-       int offset =  4 - size;
+       int offset =  fReturnSize - size;
        while (size--) {
-           emitcode ("push","%s", (strcmp(fReturn[3 - offset],"a") ?
-                                   fReturn[3 - offset] : "acc"));
+           emitcode ("push","%s", (strcmp(fReturn[fReturnSize - offset - 1],"a") ?
+                                   fReturn[fReturnSize - offset - 1] : "acc"));
            offset++;
        }
        aopOp(IC_RESULT(ic),ic,FALSE);  
@@ -7202,6 +7206,13 @@ void gen51Code (iCode *lic)
     iCode *ic;
     int cln = 0;
 
+    /* Hack-o-matic: change fReturn based on model. */
+    if (options.model == MODEL_FLAT24)
+    {
+        fReturn = fReturn390;
+        fReturnSize = 5;
+    }
+
     lineHead = lineCurr = NULL;
 
     /* if debug information required */
index 9ae5acff0c8f95a42bb041e278f0aecef6d737cc..240182043f1a9024429ae7f5093c2cbf7c08fe40 100644 (file)
@@ -536,6 +536,20 @@ replace {
         orl  a,r%2
 }
 
+replace {
+        mov  %1,a
+        mov  dpl,%2
+        mov  dph,%3
+       mov  dpx,%4
+        mov  a,%1
+} by {
+        ; Peephole 136a   removed redundant moves
+        mov  %1,a
+        mov  dpl,%2
+        mov  dph,%3
+       mov  dpx,%4
+} if 24bitMode
+
 replace {
         mov  %1,a
         mov  dpl,%2
@@ -1019,6 +1033,15 @@ replace {
         clr  a
 }
 
+replace {
+        mov  dpl,#0x00
+        mov  dph,#0x00
+       mov  dpx,#0x00
+} by {
+        ; Peephole 181a   used 24 bit load of dptr
+        mov  dptr,#0x0000
+} if 24bitMode
+
 // saving 3 byte, 2 cycles, return(NULL) profits here
 replace {
         mov  dpl,#0x00
@@ -1028,6 +1051,16 @@ replace {
         mov  dptr,#0x0000
 }
 
+// saves 2 bytes, ?? cycles.
+replace {
+        mov  dpl,#%1
+        mov  dph,#(%1 >> 8)
+       mov  dpx,#(%1 >> 16)
+} by {
+        ; Peephole 182a   used 24 bit load of dptr
+        mov  dptr,#%1
+} if 24bitMode
+
 // saving 3 byte, 2 cycles, return(float_constant) profits here
 replace {
         mov  dpl,#%1
@@ -1507,6 +1540,13 @@ replace {
         inc  %1
 }
 
+replace {
+        mov  dptr,#((((%1 >> 16)) <<16) + (((%1 >> 8)) <<8) + %1)
+} by {
+        ; Peephole 210a   simplified expression
+        mov  dptr,#%1
+} if 24bitMode
+
 replace {
         mov  dptr,#((((%1 >> 8)) <<8) + %1)
 } by {
@@ -1626,4 +1666,36 @@ replace {
        mov   @r%1,a
        inc   r%1
        mov   @r%1,a
+}
+
+replace {
+       clr   a
+       movx  @dptr,a
+       mov   dptr,%1
+       clr   a
+       movx  @dptr,a
+} by {
+       ; Peephole 219 removed redundant clear
+       clr   a
+       movx  @dptr,a
+       mov   dptr,%1
+       movx  @dptr,a
+}
+
+replace {
+       clr   a
+       movx  @dptr,a
+       mov   dptr,%1
+       movx  @dptr,a
+       mov   dptr,%2
+       clr   a
+       movx  @dptr,a
+} by {
+       ; Peephole 219a removed redundant clear
+       clr   a
+       movx  @dptr,a
+       mov   dptr,%1
+       movx  @dptr,a
+       mov   dptr,%2
+       movx  @dptr,a
 }
\ No newline at end of file