Cumulative patch for pic16 port
authorvrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 6 Jun 2004 21:25:57 +0000 (21:25 +0000)
committervrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 6 Jun 2004 21:25:57 +0000 (21:25 +0000)
* src/pic16/device.h (typedef PIC16_device) modified fields for
defining microcontrollers,
* src/pic16/device.c: added new info for all devices in Pics16 array,
* src/pic16/gen.c (genPcall): fixed bug that caused the return label
to be optimised out by the pCode optimiser,
* src/pic16/glue.c (pic16emitRegularMap): treat implicit aggragates
specially, bug reported by G.M. Gallant,
* src/pic16/pcode.c (pic16_newpCodeLabelFORCE): NEW, marks a label
as force'd so that cannot be optimised out by pCode optimiser,
* src/pic16/pcode.c,
* src/pic16/pcodepeeph.c,
* src/pic16/pcoderegs.c: many modifications to re-enable peepholes,
they are disabled by default, but can be enabled explicit with
command argument --denable-peeps, for testing,
* device/lib/pic16/startup/Makefile: added --no-peep,--pomit-config-words,
--pomit-ivt in COMPILE_FLAGS

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

ChangeLog
device/lib/pic16/startup/Makefile
src/pic16/device.c
src/pic16/device.h
src/pic16/gen.c
src/pic16/glue.c
src/pic16/main.c
src/pic16/pcode.c
src/pic16/pcode.h
src/pic16/pcodepeep.c
src/pic16/ralloc.c

index 8010e55e709c74cc5a73920b87b3da989e0590d1..8cbd19d65f2db4b1bcc51af59a7085cc3382971e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2004-06-07 Vangelis Rokas <vrokas AT otenet.gr>
+
+       Cumulative patch for pic16 port:
+       * src/pic16/device.h (typedef PIC16_device) modified fields for
+       defining microcontrollers,
+       * src/pic16/device.c: added new info for all devices in Pics16 array,
+       * src/pic16/gen.c (genPcall): fixed bug that caused the return label
+       to be optimised out by the pCode optimiser,
+       * src/pic16/glue.c (pic16emitRegularMap): treat implicit aggragates
+       specially, bug reported by G.M. Gallant,
+       * src/pic16/pcode.c (pic16_newpCodeLabelFORCE): NEW, marks a label
+       as force'd so that cannot be optimised out by pCode optimiser,
+       * src/pic16/pcode.c,
+       * src/pic16/pcodepeeph.c,
+       * src/pic16/pcoderegs.c: many modifications to re-enable peepholes,
+       they are disabled by default, but can be enabled explicit with
+       command argument --denable-peeps, for testing,
+        * device/lib/pic16/startup/Makefile: added --no-peep,--pomit-config-words,
+        --pomit-ivt in COMPILE_FLAGS
 2004-06-06 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * src/pic16/pcode.c (pic16_emitDB): removed double semicolon which fails
index 1c2f2eb8be9c1a10f615ccfbc81a9fdcfd5726dd..ba2b341be320cf33517ae6fd6eb9742f33fba293 100644 (file)
@@ -22,6 +22,7 @@ SRCS  =       crt0    \
 
 
 # add nostdinc and nostdlib for this device libraries
+COMPILE_FLAGS  += --no-peep --pomit-config-words --pomit-ivt
 COMPILE_FLAGS  += $(MODELFLAGS) --nostdinc --nostdlib
 
 CFILES = $(patsubst %,%.c,$(SRCS))
index 2364bd9e7cb67ecaa3f729dd4e3493eded9115a2..f63d5095ebede308303a215e72d6bae59227b497 100644 (file)
 
 
 static PIC16_device Pics16[] = {
+//  {
+//    {"p18f242", "18f242", "pic18f242", "f242"},              // aliases
+//    0,
+//    0x300,                                           // RAMsize
+//    0,
+//    { 0xf80, 0xfff },       /* PIC18F242 range of SFR's */
+//     {
+//             /* PIC18F242 configuration words */
+//             0x300001,
+//             0x30000d,
+//             { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+//             { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+//             { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+//             { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
+//             { 0x40, 0, 0xff } /* d */ } 
+//     }
+//  },
+
   {
-    {"p18f242", "18f242", "pic18f242", "f242"},                // aliases
+    {"p18f242", "18f242", "pic18f242", "f242"},
     0,
-    0x300,                                             // bank mask
-    0x300,                                             // RAMsize
+    0x300,     /* 768 */
+    0x80,
     0,
-       {
-               /* PIC18F242 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    { 0xf80, 0xfff },  /* PIC18F242 range of SFR's */
+    {
+    /* PIC18F242 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f248", "18f248", "pic18f248", "f248"},                // aliases
+    {"p18f248", "18f248", "pic18f248", "f248"},
     0,
-    0x300,                                             // bank mask
-    0x300,                                             // RAMsize
+    0x300,     /* 768 */
+    0x60,
     0,
-       {
-               /* PIC18F248 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { -1, 0, 0xff } /* 5 */  , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    { 0xf00, 0xfff },  /* PIC18F248 range of SFR's */
+    {
+    /* PIC18F248 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { -1, 0, 0xff } /* 5 */  , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f252", "18f252", "pic18f252", "f252"},                // aliases
+    {"p18f252", "18f252", "pic18f252", "f252"},
     0,
-    0x600,                                             // bank mask
-    0x600,                                             // RAMsize
+    0x600,     /* 1536 */
+    0x80,
     0,
-       {
-               /* PIC18F252 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    { 0xf80, 0xfff },  /* PIC18F252 range of SFR's */
+    {
+    /* PIC18F252 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f258", "18f258", "pic18f258", "f258"},                // aliases
+    {"p18f258", "18f258", "pic18f258", "f258"},
     0,
-    0x600,                                             // bank mask
-    0x600,                                             // RAMsize
+    0x600,     /* 1536 */
+    0x60,
     0,
-       {
-               /* PIC18F258 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { -1, 0, 0xff } /* 5 */  , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    { 0xf00, 0xfff },  /* PIC18F258 range of SFR's */
+    {
+    /* PIC18F258 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { -1, 0, 0xff } /* 5 */  , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f442", "18f442", "pic18f442", "f442"},                // aliases
+    {"p18f442", "18f442", "pic18f442", "f442"},
     0,
-    0x300,                                             // bank mask
-    0x300,                                             // RAMsize
+    0x300,     /* 768 */
+    0x80,
     0,
-       {
-               /* PIC18F442 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    { 0xf80, 0xfff },  /* PIC18F442 range of SFR's */
+    {
+    /* PIC18F442 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f448", "18f448", "pic18f448", "f448"},                // aliases
+    {"p18f448", "18f448", "pic18f448", "f448"},
     0,
-    0x300,                                             // bank mask
-    0x300,                                             // RAMsize
+    0x300,     /* 768 */
+    0x60,
     0,
-       {
-               /* PIC18F448 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { -1, 0, 0xff } /* 5 */  , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    { 0xf00, 0xfff },  /* PIC18F448 range of SFR's */
+    {
+    /* PIC18F448 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { -1, 0, 0xff } /* 5 */  , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-  
   {
-    {"p18f452", "18f452", "pic18f452", "f452"},                // aliases
+    {"p18f452", "18f452", "pic18f452", "f452"},
     0,
-    0x600,                                             // bank mask
-    0x600,                                             // RAMsize
+    0x600,     /* 1536 */
+    0x80,
     0,
-       {
-               /* PIC18F452 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    { 0xf80, 0xfff },  /* PIC18F452 range of SFR's */
+    {
+    /* PIC18F452 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f458", "18f458", "pic18f458", "f458"},                // aliases
+    {"p18f458", "18f458", "pic18f458", "f458"},
     0,
-    0x600,                                             // bank mask
-    0x600,                                             // RAMsize
+    0x600,     /* 1536 */
+    0x60,
     0,
-       {
-               /* PIC18F458 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { -1, 0, 0xff } /* 5 */  , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    { 0xf00, 0xfff },  /* PIC18F458 range of SFR's */
+    {
+    /* PIC18F458 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { -1, 0, 0xff } /* 5 */  , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f1220", "18f1220", "pic18f1220", "f1220"},    // aliases
+    {"p18f1220", "18f1220", "pic18f1220", "f1220"},
     0,
-    0x200,
-    0x200,
+    0x100,     /* 256 */
+    0x80,
     0,
-       {
-               /* PIC18F1220 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0xcf, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { 0x80, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    { 0xf80, 0xfff },  /* PIC18F1220 range of SFR's */
+    {
+    /* PIC18F1220 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0xcf, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { 0x80, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
-
   {
-    {"p18f6520", "18f6520", "pic18f6520", "f6520"},    // aliases
+    {"p18f6520", "18f6520", "pic18f6520", "f6520"},
     0,
-    0x800,                                             // bank mask
-    0x800,                                             // RAMsize
-    1,
-       {
-               /* PIC18F6520 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { 0x80, 0, 0xff } /* 4 */ , { 0x88, 0, 0xff } /* 5 */ , { -1, 0, 0xff } /* 6 */  , 
-               { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    0x800,     /* 2048 */
+    0x60,
+    0,
+    { 0xf6b, 0xfff },  /* PIC18F6520 range of SFR's */
+    {
+    /* PIC18F6520 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { 0x80, 0, 0xff } /* 4 */ , { 0x88, 0, 0xff } /* 5 */ , { -1, 0, 0xff } /* 6 */  , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f6620", "18f6620", "pic18f6620", "f6620"},    // aliases
+    {"p18f6620", "18f6620", "pic18f6620", "f6620"},
     0,
-    0xf00,                                             // bank mask
-    0xf00,                                             // RAMsize
-    1,
-       {
-               /* PIC18F6620 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    0xf00,     /* 3840 */
+    0x60,
+    0,
+    { 0xf6b, 0xfff },  /* PIC18F6620 range of SFR's */
+    {
+    /* PIC18F6620 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f6680", "18f6680", "pic18f6680", "f6680"},    // aliases
+    {"p18f6680", "18f6680", "pic18f6680", "f6680"},
     0,
-    0xc00,                                             // bank mask
-    0xc00,                                             // RAMsize
-    1,
-       {
-               /* PIC18F6680 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x2f, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { 0x83, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    0xf00,     /* 3840 */
+    0x60,
+    0,
+    { 0xf00, 0xfff },  /* PIC18F6680 range of SFR's */
+    {
+    /* PIC18F6680 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x2f, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { 0x83, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f6720", "18f6720", "pic18f6720", "f6720"},    // aliases
+    {"p18f6720", "18f6720", "pic18f6720", "f6720"},
     0,
-    0xf00,                                             // bank mask
-    0xf00,                                             // RAMsize
-    1,
-       {
-               /* PIC18F6720 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    0xf00,     /* 3840 */
+    0x60,
+    0,
+    { 0xf6b, 0xfff },  /* PIC18F6720 range of SFR's */
+    {
+    /* PIC18F6720 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f8520", "18f8520", "pic18f8520", "f8520"},    // aliases
+    {"p18f8520", "18f8520", "pic18f8520", "f8520"},
     0,
-    0x800,                                             // bank mask
-    0x800,                                             // RAMsize
+    0x800,     /* 2048 */
+    0x60,
     1,
-       {
-               /* PIC18F8520 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { 0x83, 0, 0xff } /* 4 */ , { 0x88, 0, 0xff } /* 5 */ , { -1, 0, 0xff } /* 6 */  , 
-               { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ } 
-       }
+    { 0xf6b, 0xfff },  /* PIC18F8520 range of SFR's */
+    {
+    /* PIC18F8520 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x88, 0, 0xff } /* 5 */ , { -1, 0, 0xff } /* 6 */  , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f8620", "18f8620", "pic18f8620", "f8620"},    // aliases
+    {"p18f8620", "18f8620", "pic18f8620", "f8620"},
     0,
-    0xf00,                                             // bank mask
-    0xf00,                                             // RAMsize
+    0xf00,     /* 3840 */
+    0x60,
     1,
-       {
-               /* PIC18F8620 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { 0x83, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ }
-       }
+    { 0xf6b, 0xfff },  /* PIC18F8620 range of SFR's */
+    {
+    /* PIC18F8620 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
   {
-    {"p18f8680", "18f8680", "pic18f8680", "f8680"},    // aliases
+    {"p18f8680", "18f8680", "pic18f8680", "f8680"},
     0,
-    0xc00,                                             // bank mask
-    0x800,                                             // RAMsize
-    1,
-       {
-               /* PIC18F8680 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x2f, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ , 
-               { 0x83, 0, 0xff } /* 4 */ , { 0x83, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ }
-       }
+    0xf00,     /* 3840 */
+    0x60,
+    0,
+    { 0xf00, 0xfff },  /* PIC18F8680 range of SFR's */
+    {
+    /* PIC18F8680 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x2f, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x83, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
   },
-
   {
-    {"p18f8720", "18f8720", "pic18f8720", "f8720"},    // aliases
+    {"p18f8720", "18f8720", "pic18f8720", "f8720"},
     0,
-    0xf00,                                             // bank mask
-    0xf00,                                             // RAMsize
+    0xf00,     /* 3840 */
+    0x60,
     1,
-       {
-               /* PIC18F8720 configuration words */
-               0x300001,
-               0x30000d,
-               { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-               { 0x83, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-               { -1, 0, 0xff } /* 7 */  , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-               { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ , 
-               { 0x40, 0, 0xff } /* d */ }
-       }
-  }
+    { 0xf6b, 0xfff },  /* PIC18F8720 range of SFR's */
+    {
+    /* PIC18F8720 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    }
+  },
 
 };
 
@@ -1084,7 +1103,6 @@ void pic16_assignConfigWordValue(int address, int value)
 {
   int i;
 
-
         for(i=0;i<pic16->cwInfo.confAddrEnd-pic16->cwInfo.confAddrStart+1;i++) {
                 if((address == pic16->cwInfo.confAddrStart+i)
                   && (pic16->cwInfo.crInfo[i].mask != -1)) {
index f9bef22108e03f765c2659817b9e0b61449ced94..88a90ab5358b27da3c17fabe89c8eda859e17ed2 100644 (file)
 
 #define CONFIGURATION_WORDS    20
 
+typedef struct {
+       int sfrLoAddr;
+       int sfrHiAddr;
+} sfrRangeInfo_t;
+       
+
 typedef struct {
        int mask;
        int emit;
        int value;
-} configRegInfo;
+} configRegInfo_t;
 
 typedef struct {
        int confAddrStart;      /* starting address */
        int confAddrEnd;        /* ending address */
-       configRegInfo crInfo[ CONFIGURATION_WORDS ];
-} configWordsInfo;
-
+       configRegInfo_t crInfo[ CONFIGURATION_WORDS ];
+} configWordsInfo_t;
 
 
 #define PROCESSOR_NAMES    4
@@ -57,11 +62,12 @@ typedef struct {
 typedef struct PIC16_device {
   char *name[PROCESSOR_NAMES];/* aliases for the processor name */
 
-  int maxRAMaddress;          /* maximum value for a data address */
-  int bankMask;               /* Bitmask that is ANDed with address to extract banking bits */
-  int RAMsize;               /* size of Data RAM - VR 031120 */
-  int extMIface;               /* device has external memory interface */
-  configWordsInfo cwInfo;      /* configuration words info */
+  int maxRAMaddress;           /* maximum value for a data address */
+  int RAMsize;                 /* size of Data RAM - VR 031120 */
+  int acsSplitOfs;             /* access bank split offset */
+  int extMIface;               /* device has external memory interface */
+  sfrRangeInfo_t sfrRange;     /* SFR range */
+  configWordsInfo_t cwInfo;    /* configuration words info */
 } PIC16_device;
 
 /* Given a pointer to a register, this macro returns the bank that it is in */
index c84e20e5e5349c4133a59ef01d04ec335147156b..395abc91fddb170cfebc59b8477c15f398379b3c 100644 (file)
@@ -273,6 +273,11 @@ void pic16_emitpLabel(int key)
   pic16_addpCode2pBlock(pb,pic16_newpCodeLabel(NULL,key+100+labelOffset));
 }
 
+void pic16_emitpLabelFORCE(int key)
+{
+  pic16_addpCode2pBlock(pb,pic16_newpCodeLabelFORCE(NULL,key+100+labelOffset));
+}
+
 void pic16_emitpcode(PIC_OPCODE poc, pCodeOp *pcop)
 {
 
@@ -2963,9 +2968,7 @@ static void genPcall (iCode *ic)
        // push return address
        // push $ on return stack, then replace with retlbl
 
-       // Note: retlbl is supplied as dummy operand to PUSH
-       // This has the nice side effect of keeping the label from being optimized out :o)
-       pic16_emitpcode(POC_PUSH, pic16_popGetLabel(retlbl->key));      
+       pic16_emitpcodeNULLop(POC_PUSH);
 
        pic16_emitpcode(POC_MOVLW, pic16_popGetImmd(pcop_lbl->name, 0, 0));
        pic16_emitpcode(POC_MOVWF, pic16_popCopyReg(&pic16_pc_tosl));
@@ -2975,22 +2978,22 @@ static void genPcall (iCode *ic)
        pic16_emitpcode(POC_MOVWF, pic16_popCopyReg(&pic16_pc_tosu));
 
        /* make the call by writing the pointer into pc */
-       // FIXME Disabled writes to PCLATU because of gpsim problems
-#if 1
        pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(IC_LEFT(ic)),2), pic16_popCopyReg(&pic16_pc_pclatu)));
-#else
-       fprintf(stderr,
-"WARNING: (%s:%d) PCLATU is not written because of gpsim problems\n\
-Correct this as soon as gpsim bug is fixed\n", __FILE__, __LINE__);
-#endif
        pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(IC_LEFT(ic)),1), pic16_popCopyReg(&pic16_pc_pclath)));
+
        // note: MOVFF to PCL not allowed
        pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(IC_LEFT(ic)),0));
        pic16_emitpcode(POC_MOVWF, pic16_popCopyReg(&pic16_pc_pcl));
 
+
+//     pic16_emitpcode(POC_GOTO, pic16_popGetLabel(retlbl->key));
+//     pic16_emitpcodeNULLop(POC_NOP);
+//     pic16_emitpcodeNULLop(POC_NOP);
+
        /* return address is here: (X) */
-       pic16_emitpLabel(retlbl->key);
+       pic16_emitpLabelFORCE(retlbl->key);
+
+//     pic16_emitpcodeNULLop(POC_NOP);
 
        pic16_freeAsmop (IC_LEFT(ic),NULL,ic,TRUE);
 
index 211c3822e5bcead403ced7bc2da7a84427ca9485..52e6d7799db94702a7e2e3f4fc2c7fafb0db6342 100644 (file)
@@ -132,8 +132,9 @@ pic16emitRegularMap (memmap * map, bool addPublics, bool arFlag)
        for (sym = setFirstItem (map->syms); sym; sym = setNextItem (map->syms)) {
 
 #if 0
-               fprintf(stderr, "\t%s: sym: %s\tused: %d\textern: %d\tstatic: %d\n",
-                       map->sname, sym->name, sym->used, IS_EXTERN(sym->etype), IS_STATIC(sym->etype));
+               fprintf(stderr, "\t%s: sym: %s\tused: %d\textern: %d\tstatic: %d\taggregate: %d\n",
+                       map->sname, sym->name, sym->used, IS_EXTERN(sym->etype), IS_STATIC(sym->etype),
+                       IS_AGGREGATE(sym->type));
                printTypeChain( sym->type, stderr );
                fprintf(stderr, "\n");
 #endif
@@ -168,7 +169,6 @@ pic16emitRegularMap (memmap * map, bool addPublics, bool arFlag)
                        !IS_STATIC (sym->etype) && !IS_FUNC(sym->type)) {
                  
                        checkAddSym(&publics, sym);
-//                     addSetHead(&publics, sym);
                } else
                        if(IS_STATIC(sym->etype)
                                && !(sym->ival && !sym->level)
@@ -272,7 +272,11 @@ pic16emitRegularMap (memmap * map, bool addPublics, bool arFlag)
                                        sym->implicit = 1;              // mark as implicit
 #endif
                                if(!sym->ival) {
-                                       reg = pic16_allocDirReg( operandFromSymbol( sym ) );
+                                       if(IS_AGGREGATE(sym->type)) {
+                                               reg=pic16_allocRegByName(sym->rname, getSize( sym->type ), NULL);
+                                       } else {
+                                               reg = pic16_allocDirReg( operandFromSymbol( sym ) );
+                                       }
                                        if(checkAddReg(&pic16_rel_udata, reg)) {
                                                addSetHead(&publics, sym);
                                        }
@@ -619,11 +623,10 @@ pic16emitStaticSeg (memmap * map)
        fprintf(stderr, "\n");
 #endif
 
-        if(SPEC_ABSA(sym->etype)
-             && (SPEC_ABSA(sym->etype) && PIC16_IS_CONFIG_ADDRESS(SPEC_ADDR(sym->etype)))) {
+        if(SPEC_ABSA(sym->etype) && PIC16_IS_CONFIG_ADDRESS(SPEC_ADDR(sym->etype))) {
              
-               pic16_assignConfigWordValue(SPEC_ADDR (sym->etype),
-                       (int) floatFromVal(list2val( sym->ival )));
+               pic16_assignConfigWordValue(SPEC_ADDR(sym->etype),
+                       (int) floatFromVal(list2val(sym->ival)));
 
                continue;
         }
index 3e4f9c7df8fd2f454fefd138059dc9eee5bc51e4..e26f3da70c17ab3ba38361dd0e6b754a185e13b7 100644 (file)
@@ -208,6 +208,8 @@ extern int pic16_debug_verbose;
 extern int pic16_ralloc_debug;
 extern int pic16_pcode_verbose;
 
+int pic16_enable_peeps=0;
+
 OPTION pic16_optionsTable[]= {
        { 0,    "--pno-banksel",        &pic16_options.no_banksel,      "do not generate BANKSEL assembler directives"},
        { 0,    OPT_BANKSEL,            NULL,                           "set banksel optimization level (default=0 no)"},
@@ -225,6 +227,8 @@ OPTION pic16_optionsTable[]= {
        { 0,    ALT_ASM,        NULL,   "Use alternative assembler"},
        { 0,    ALT_LINK,       NULL,   "Use alternative linker"},
 
+       { 0,    "--denable-peeps",      &pic16_enable_peeps,    "explicit enable of peepholes"},
+
        { 0,    NULL,           NULL,   NULL}
        };
 
@@ -333,6 +337,10 @@ _pic16_finaliseOptions (void)
        /* peepholes are disabled for the time being */
        options.nopeep = 1;
 
+       /* explicit enable peepholes for testing */
+       if(pic16_enable_peeps)
+               options.nopeep = 0;
+
        options.all_callee_saves = 1;           // always callee saves
 //     options.float_rent = 1;
 //     options.intlong_rent = 1;
index 9aa84272b0dc736641682009c6e5f9f0ccd47145..206add78693c7b705aedf0bbce2e2a88ca85140f 100644 (file)
@@ -3646,7 +3646,8 @@ pCode *pic16_newpCodeLabel(char *name, int key)
   pcl->pc.print = pCodePrintLabel;
 
   pcl->key = key;
-
+  pcl->force = 0;
+  
   pcl->label = NULL;
   if(key>0) {
     sprintf(s,"_%05d_DS_",key);
@@ -3664,6 +3665,15 @@ pCode *pic16_newpCodeLabel(char *name, int key)
 
 }
 
+pCode *pic16_newpCodeLabelFORCE(char *name, int key)
+{
+  pCodeLabel *pcl = (pCodeLabel *)pic16_newpCodeLabel(name, key);
+  
+       pcl->force = 1;
+  
+  return ( (pCode *)pcl );
+}
+
 
 /*-----------------------------------------------------------------*/
 /* newpBlock - create and return a pointer to a new pBlock         */
@@ -3843,6 +3853,8 @@ pCodeOp *pic16_newpCodeOpWild(int id, pCodeWildBlock *pcwb, pCodeOp *subtype)
   PCOW(pcop)->subtype = subtype;
   PCOW(pcop)->matched = NULL;
 
+  PCOW(pcop)->pcop2 = NULL;
+  
   return pcop;
 }
 
@@ -3854,23 +3866,41 @@ pCodeOp *pic16_newpCodeOpWild2(int id, int id2, pCodeWildBlock *pcwb, pCodeOp *s
   pCodeOp *pcop;
 
 
-  if(!pcwb || !subtype || !subtype2) {
-    fprintf(stderr, "Wild opcode declaration error: %s-%d\n",__FILE__,__LINE__);
-    exit(1);
-  }
+       if(!pcwb || !subtype || !subtype2) {
+               fprintf(stderr, "Wild opcode declaration error: %s-%d\n",__FILE__,__LINE__);
+               exit(1);
+       }
 
-  pcop = Safe_calloc(1,sizeof(pCodeOpWild));
-  pcop->type = PO_WILD;
-  sprintf(s,"%%%d",id);
-  pcop->name = Safe_strdup(s);
+       pcop = Safe_calloc(1,sizeof(pCodeOpWild));
+       pcop->type = PO_WILD;
+       sprintf(s,"%%%d",id);
+       pcop->name = Safe_strdup(s);
 
-  PCOW(pcop)->id = id;
-  PCOW(pcop)->pcwb = pcwb;
-  PCOW(pcop)->subtype = subtype;
-  PCOW(pcop)->matched = NULL;
+       PCOW(pcop)->id = id;
+       PCOW(pcop)->pcwb = pcwb;
+       PCOW(pcop)->subtype = subtype;
+       PCOW(pcop)->matched = NULL;
+
+       PCOW(pcop)->pcop2 = Safe_calloc(1, sizeof(pCodeOpWild));
+
+       if(!subtype2->name) {
+               PCOW(pcop)->pcop2 = Safe_calloc(1, sizeof(pCodeOpWild));
+               PCOW2(pcop)->pcop.type = PO_WILD;
+               sprintf(s, "%%%d", id2);
+               PCOW2(pcop)->pcop.name = Safe_strdup(s);
+               PCOW2(pcop)->id = id2;
+               PCOW2(pcop)->subtype = subtype2;
+
+//             fprintf(stderr, "%s:%d %s [wild,wild] for name: %s (%d)\tname2: %s (%d)\n", __FILE__, __LINE__, __FUNCTION__,
+//                             pcop->name, id, PCOW2(pcop)->pcop.name, id2);
+       } else {
+               PCOW2(pcop)->pcop2 = pic16_pCodeOpCopy( subtype2 );
+
+//             fprintf(stderr, "%s:%d %s [wild,str] for name: %s (%d)\tname2: %s (%d)\n", __FILE__, __LINE__, __FUNCTION__,
+//                             pcop->name, id, PCOW2(pcop)->pcop.name, id2);
+       }
+  
 
-  PCOW(pcop)->id2 = id2;
-  PCOW(pcop)->subtype2 = subtype2;
 
   return pcop;
 }
@@ -6175,7 +6205,8 @@ static void pBlockRemoveUnusedLabels(pBlock *pb)
     /* This pCode is a label, so search the pBlock to see if anyone
      * refers to it */
 
-    if( (pcl->key>0) && (!findInstructionUsingLabel(pcl, pb->pcHead))) {
+    if( (pcl->key>0) && (!findInstructionUsingLabel(pcl, pb->pcHead))
+       && (!pcl->force)) {
     //if( !findInstructionUsingLabel(pcl, pb->pcHead)) {
       /* Couldn't find an instruction that refers to this label
        * So, unlink the pCode label from it's pCode chain
index 3f8a1da3f910647a919d61eb3ac3ce70e1396306..7c1bd2d503d09e5e460238c833fe1ebbf390748a 100644 (file)
@@ -439,9 +439,8 @@ typedef struct pCodeOpWild
                           * card will be expanded */
   pCodeOp *matched;       /* When a wild matches, we'll store a pointer to the
                           * opcode we matched */
-  int id2;               /* same as id but for second wild operand */
-  pCodeOp *subtype2;     /* Poiter to the second Operand type */
-  pCodeOp *matched2;     /* same as matched but for second wil operand */
+
+  pCodeOp *pcop2;        /* second operand if exists */
 
 } pCodeOpWild;
 
@@ -648,6 +647,7 @@ typedef struct pCodeLabel
 
   char *label;
   int key;
+  int force;           /* label cannot be optimized out */
 
 } pCodeLabel;
 
@@ -861,7 +861,7 @@ typedef struct peepCommand {
 #define PCOR2(x)  ((pCodeOpReg2 *)(x))
 #define PCORB(x)  ((pCodeOpRegBit *)(x))
 #define PCOW(x)   ((pCodeOpWild *)(x))
-
+#define PCOW2(x)  (PCOW(PCOW(x)->pcop2))
 #define PBR(x)    ((pBranch *)(x))
 
 #define PCWB(x)   ((pCodeWildBlock *)(x))
@@ -900,6 +900,7 @@ pCode *pic16_newpCodeCharP(char *cP);              // Create a new pCode given a
 pCode *pic16_newpCodeInlineP(char *cP);            // Create a new pCode given a char *
 pCode *pic16_newpCodeFunction(char *g, char *f);   // Create a new function
 pCode *pic16_newpCodeLabel(char *name,int key);    // Create a new label given a key
+pCode *pic16_newpCodeLabelFORCE(char *name, int key); // Same as newpCodeLabel but label cannot be optimized out
 pCode *pic16_newpCodeCSource(int ln, char *f, char *l); // Create a new symbol line 
 pBlock *pic16_newpCodeChain(memmap *cm,char c, pCode *pc); // Create a new pBlock
 void pic16_printpBlock(FILE *of, pBlock *pb);      // Write a pBlock to a file
index 7a2409cfcc570bf090bf4b81cef341eed579ce88..b905e0221a34eec5197419c9e52a217b2aa2258c 100644 (file)
@@ -652,6 +652,14 @@ static void * cvt_altpat_mnem2a(void *pp,pCodeWildBlock *pcwb)
          p[3].pct[0].tok.s,
          dest));
 
+#if 0
+  fprintf(stderr,"altpat_mnem2a %s var %d destination %s(%d)\n",
+         p->pct[0].tok.s,
+         p[1].pct[1].tok.n,
+         p[3].pct[0].tok.s,
+         dest);
+#endif
+
 
   opcode = pic16_getpCode(p->pct[0].tok.s,dest);
   if(opcode < 0) {
@@ -662,13 +670,14 @@ static void * cvt_altpat_mnem2a(void *pp,pCodeWildBlock *pcwb)
   if(pic16Mnemonics[opcode]->isBitInst) {
     pcosubtype = pic16_newpCodeOp(NULL,PO_BIT);
     pcosubtype2 = NULL;
-  } else
+  } else {
+#if 0
   if(pic16Mnemonics[opcode]->is2MemOp) {
-       return NULL;
        /* support for movff instruction */
        pcosubtype = pic16_newpCodeOp(NULL, PO_GPR_REGISTER);
-       pcosubtype2 = pic16_newpCodeOp(p[3].pct[0].tok.s, PO_GPR_REGISTER);
+       pcosubtype2 = pic16_newpCodeOp(p[3].pct[0].tok.s, PO_STR);
   } else {
+#endif
     pcosubtype = pic16_newpCodeOp(NULL,PO_GPR_REGISTER); pcosubtype2 = NULL; }
 
 
@@ -693,7 +702,6 @@ static void * cvt_altpat_mnem2a(void *pp,pCodeWildBlock *pcwb)
 
 }
 
-#if 1
 /*-----------------------------------------------------------------*/
 /* cvt_altpat_mem2b - convert assembly line type to a pCode        */
 /*                    instruction with 2 wild operands             */
@@ -761,7 +769,6 @@ static void * cvt_altpat_mnem2b(void *pp,pCodeWildBlock *pcwb)
   return pci;
 
 }
-#endif
 
 
 /*-----------------------------------------------------------------*/
@@ -1738,7 +1745,7 @@ static int pCodeOpCompare(pCodeOp *pcops, pCodeOp *pcopd)
     return 0;
 
 #if 0
-  fprintf(stderr," Comparing operands %s",
+  fprintf(stderr,"%s:%d Comparing operands %s", __FILE__, __LINE__, 
          pic16_get_op( pcops,NULL,0));
 
   fprintf(stderr," to %s\n",
@@ -1764,14 +1771,14 @@ static int pCodeOpCompare(pCodeOp *pcops, pCodeOp *pcopd)
   n2 = pic16_get_op(pcopd,NULL,0);
 
   if( !n2 || strcmp(b,n2)) {
-    //fprintf(stderr,"  - fail - diff names: %s, len=%d,  %s, len=%d\n",b,strlen(b), n2, strlen(n2) );
+//     fprintf(stderr,"  - fail - diff names: %s, len=%d,  %s, len=%d\n",b,strlen(b), n2, strlen(n2) );
     return 0;  // different names
   }
 
   switch(pcops->type) {
   case PO_DIR:
     if( PCOR(pcops)->instance != PCOR(pcopd)->instance) {
-      //fprintf(stderr, "  - fail different instances\n");
+//     fprintf(stderr, "  - fail different instances\n");
       return 0;
     }
     break;
@@ -1911,6 +1918,7 @@ static int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd)
 #endif
 
          PCOW(PCI(pcd)->pcop)->matched = PCI(pcs)->pcop;
+         havematch = -1;
          if(!peepBlock->target.wildpCodeOps[index]) {
            peepBlock->target.wildpCodeOps[index] = PCI(pcs)->pcop;
 
@@ -1930,7 +1938,7 @@ static int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd)
 //         return pCodeOpCompare(PCI(pcs)->pcop, peepBlock->target.wildpCodeOps[index]);
          }
 
-         if(!havematch && PCI(pcs)->pcop) {
+         if((havematch==-1) && PCI(pcs)->pcop) {
            char *n;
 
            switch(PCI(pcs)->pcop->type) {
@@ -1953,13 +1961,13 @@ static int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd)
 //           return 1;
            }
          }
-
+  
          /* now check whether the second operand matches */
-         if(PCI(pcd)->is2MemOp && (PCOR2(PCI(pcd)->pcop)->pcop2->type == PO_WILD)) {
+         if(PCOW2(PCI(pcd)->pcop) && (PCOR2(PCI(pcd)->pcop)->pcop2->type == PO_WILD)) {
        
                fprintf(stderr, "%s:%d %s second operand is wild\n", __FILE__, __LINE__, __FUNCTION__);
        
-                 index = PCOW(PCI(pcd)->pcop)->id2;
+                 index = PCOW2(PCI(pcd)->pcop)->id;
                //DFPRINTF((stderr,"destination is wild\n"));
 #ifdef DEBUG_PCODEPEEP
                if (index > peepBlock->nops) {
@@ -1968,7 +1976,7 @@ static int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd)
                }
 #endif
 
-               PCOW(PCI(pcd)->pcop)->matched2 = PCOR2(PCI(pcs)->pcop)->pcop2;
+               PCOW2(PCI(pcd)->pcop)->matched = PCOR2(PCI(pcs)->pcop)->pcop2;
                if(!peepBlock->target.wildpCodeOps[index]) {
                        peepBlock->target.wildpCodeOps[index] = PCOR2(PCI(pcs)->pcop)->pcop2;
 
@@ -1984,7 +1992,7 @@ static int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd)
                                );
                        */
 
-                 return (havematch && pCodeOpCompare(PCOR2(PCI(pcs)->pcop)->pcop2,
+                 return ((havematch==1) && pCodeOpCompare(PCOR2(PCI(pcs)->pcop)->pcop2,
                                peepBlock->target.wildpCodeOps[index]));
                }
 
@@ -2006,7 +2014,7 @@ static int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd)
                        else {
                                DFPRINTF((stderr,"first time for a variable: %d, %s\n",index,n));
                                peepBlock->target.vars[index] = n;
-                               return (havematch);             //&& 1;
+                               return (havematch==1);          //&& 1;
                        }
                }
          
@@ -2322,6 +2330,7 @@ int pic16_pCodePeepMatchRule(pCode *pc)
   pCodeCSource *pc_cline=NULL;
   _DLL *peeprules;
   int matched;
+  pCode *pcr;
 
   peeprules = (_DLL *)peepSnippets;
 
@@ -2386,7 +2395,7 @@ int pic16_pCodePeepMatchRule(pCode *pc)
          (pic16_pCodeSearchCondition(pcin,peepBlock->postFalseCond) > 0) )
        matched = 0;
 
-      //fprintf(stderr," condition results = %d\n",pic16_pCodeSearchCondition(pcin,peepBlock->postFalseCond));
+//     fprintf(stderr," condition results = %d\n",pic16_pCodeSearchCondition(pcin,peepBlock->postFalseCond));
 
 
       //if(!matched) fprintf(stderr,"failed on conditions\n");
@@ -2395,7 +2404,7 @@ int pic16_pCodePeepMatchRule(pCode *pc)
     if(matched) {
 
       pCode *pcprev;
-      pCode *pcr;
+//      pCode *pcr;
 
 
       /* We matched a rule! Now we have to go through and remove the
@@ -2456,7 +2465,7 @@ int pic16_pCodePeepMatchRule(pCode *pc)
       if(pcin)
        pCodeDeleteChain(pc,pcin);
 
-       fprintf(stderr, "%s:%d rule matched\n", __FILE__, __LINE__);
+//     fprintf(stderr, "%s:%d rule matched\n", __FILE__, __LINE__);
 
       /* Generate the replacement code */
       pc = pcprev;
@@ -2472,7 +2481,7 @@ int pic16_pCodePeepMatchRule(pCode *pc)
             * Is it wild? */
            if(PCI(pcr)->pcop->type == PO_WILD) {
              int index = PCOW(PCI(pcr)->pcop)->id;
-               fprintf(stderr, "%s:%d replacing index= %d\n", __FUNCTION__, __LINE__, index);
+//             fprintf(stderr, "%s:%d replacing index= %d\n", __FUNCTION__, __LINE__, index);
              //DFPRINTF((stderr,"copying wildopcode\n"));
              if(peepBlock->target.wildpCodeOps[index])
                pcop = pic16_pCodeOpCopy(peepBlock->target.wildpCodeOps[index]);
@@ -2485,10 +2494,10 @@ int pic16_pCodePeepMatchRule(pCode *pc)
          if(PCI(pcr)->is2MemOp && PCOR2(PCI(pcr)->pcop)->pcop2) {
            /* The replacing instruction has also a second operand.
             * Is it wild? */
-               fprintf(stderr, "%s:%d pcop2= %p\n", __FILE__, __LINE__, PCOR2(PCI(pcr)->pcop)->pcop2);
+//             fprintf(stderr, "%s:%d pcop2= %p\n", __FILE__, __LINE__, PCOR2(PCI(pcr)->pcop)->pcop2);
            if(PCOR2(PCI(pcr)->pcop)->pcop2->type == PO_WILD) {
-             int index = PCOW(PCI(pcr)->pcop)->id2;
-               fprintf(stderr, "%s:%d replacing index= %d\n", __FUNCTION__, __LINE__, index);
+             int index = PCOW2(PCI(pcr)->pcop)->id;
+//             fprintf(stderr, "%s:%d replacing index= %d\n", __FUNCTION__, __LINE__, index);
              //DFPRINTF((stderr,"copying wildopcode\n"));
              if(peepBlock->target.wildpCodeOps[index])
                pcop = pic16_popCombine2(pic16_pCodeOpCopy(pcop),
@@ -2497,7 +2506,7 @@ int pic16_pCodePeepMatchRule(pCode *pc)
                DFPRINTF((stderr,"error, wildopcode in replace but not source?\n"));
            } else
              pcop = pic16_popCombine2(pic16_pCodeOpCopy(pcop),
-               pic16_pCodeOpCopy(PCI(pcr)->pcop), 0);
+               pic16_pCodeOpCopy(PCOR2(PCI(pcr)->pcop)->pcop2), 0);
              
          }
          
index b283377805b123adaf9a30e055f873b1bc971b66..93cab98daa5fe1301d79092c2a845a0d526c19ea 100644 (file)
@@ -750,7 +750,9 @@ pic16_allocRegByName (char *name, int size, operand *op)
     /* Register wasn't found in hash, so let's create
      * a new one and put it in the hash table AND in the 
      * dynDirectRegNames set */
-       fprintf (stderr,"%s:%d symbol name %s\tregop= %p\n", __FUNCTION__, __LINE__, name, op);
+
+//     fprintf (stderr,"%s:%d symbol name %s\tregop= %p\n", __FUNCTION__, __LINE__, name, op);
+
     reg = newReg(REG_GPR, PO_DIR, rDirectIdx++, name,size,0, op);
 
     debugLog ("%d  -- added %s to hash, size = %d\n", __LINE__, name,reg->size);