* device/include/asm/pic16/features.h: added _CODE, _DATA, _AUTOMEM,
authorvrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 18 Jan 2005 10:09:24 +0000 (10:09 +0000)
committervrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 18 Jan 2005 10:09:24 +0000 (10:09 +0000)
_STATMEM macros,
* device/include/pic16/adc.h: added GPL info,
* src/pic16/gen.c (genIfxpCOpJump): perform an genIfxJump but using
a pCodeOp as tested operand,
* (genNearPointerGet): optimized bit testing, does not use
intermediate register for bit value, test directly instead with
BTFSS, BTFSC, works only for single bits,
* (genpic16Code): dump the name of the iCode in the asm,
* src/pic16/ralloc.c (decodeOp): removed static declaration and
renamed to pic16_decodeOp,
* (serialRegAssign): do not allocate a temporary register for iCode
sequences that test a single bit for 1/0

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

ChangeLog
device/include/asm/pic16/features.h
device/include/pic16/adc.h
device/include/pic16/malloc.h
device/include/pic16/stdio.h
device/include/pic16/string.h
src/pic16/device.h
src/pic16/gen.c
src/pic16/ralloc.c
src/pic16/ralloc.h

index f1be8d9f8b25bb2f59120ececa295d97bbf6f5d5..17ebe8cc616f4b3103bfd3d0f23ef87fa50beee9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2005-01-18 Vangelis Rokas <vrokas AT otenet.gr>
+
+       * device/include/asm/pic16/features.h: added _CODE, _DATA, _AUTOMEM,
+       _STATMEM macros,
+       * device/include/pic16/adc.h: added GPL info,
+       * src/pic16/gen.c (genIfxpCOpJump): perform an genIfxJump but using
+       a pCodeOp as tested operand,
+       * (genNearPointerGet): optimized bit testing, does not use
+       intermediate register for bit value, test directly instead with
+       BTFSS, BTFSC, works only for single bits,
+       * (genpic16Code): dump the name of the iCode in the asm,
+       * src/pic16/ralloc.c (decodeOp): removed static declaration and
+       renamed to pic16_decodeOp,
+       * (serialRegAssign): do not allocate a temporary register for iCode
+       sequences that test a single bit for 1/0
+
 2005-01-12 Vangelis Rokas <vrokas AT otenet.gr>
 
        * src/pic16/pcode.[ch]: introduced pic16_stackpnt_*,
index d0ef2bbd5210c2d63f7cbe659b5b6f4a56aa8fbe..c6e861a5bca988d91c2a94514f98067beb485669 100644 (file)
@@ -19,5 +19,9 @@
 #define _FS_REENTRANT
 #define _MATH_REENTRANT
 
+#define _CODE  code
+#define _DATA  data
+#define _AUTOMEM
+#define _STATMEM
 
 #endif /* __PIC16_ASM_FEATURES_H */
index 66a3cdf2a4f5e411ad8af44067d31ffeea955dfa..68f3f09571af8e9bc5c61b47f4762b92aeddeb34 100644 (file)
@@ -2,9 +2,25 @@
 /*
  * A/D conversion module library header
  *
+ * written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+ *
  * Devices implemented:
  *     PIC18F[24][45][28]
  *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
 /*
index 0fc3636e29175d14fc5118c06f60baadfe4d9997..cc5f2462e9505e627ae35746eccbb8ae0989af73 100644 (file)
@@ -5,10 +5,6 @@
  *
  */
 
-/*
-** $Id$
- */
 
 /*
  * Structure of memory block header:
@@ -21,6 +17,8 @@
 #ifndef __MALLOC_H__
 #define __MALLOC_H__
 
+#include <../asm/pic16/features.h>
+
 #define EMULATION      0
 
 #if EMULATION
 #define free   pic16_free
 #define realloc        pic16_realloc
 #define calloc pic16_calloc
+#define _MALLOC_SPEC
 #endif
 
+#define _MALLOC_SPEC   data
 
 #define MAX_BLOCK_SIZE 0x7f            /* 126 bytes */
 #define        MAX_HEAP_SIZE   0x200           /* 512 bytes */
@@ -48,10 +48,10 @@ typedef union {
 } _malloc_rec;
 
 
-unsigned char *malloc(unsigned char);
-void free(unsigned char *);
-unsigned char *calloc(unsigned char num);              //, unsigned char len);
-unsigned char *realloc(unsigned char *mblock, unsigned char len);
+unsigned char _MALLOC_SPEC *malloc(unsigned char);
+void free(unsigned char _MALLOC_SPEC *);
+unsigned char _MALLOC_SPEC *calloc(unsigned char num);         //, unsigned char len);
+unsigned char _MALLOC_SPEC *realloc(unsigned char _MALLOC_SPEC *mblock, unsigned char len);
 
 
 #endif /* __MALLOC_H__ */
index 1444bca49ff4a9eb5ae0930649b81c39179aed53..e0d52d14e105f6dec9c8df6536cabd1cd14a01ed 100644 (file)
@@ -50,7 +50,9 @@ extern int _print_format (pfn_outputchar pfn, void* pvoid, const char *format, v
 
 /*-----------------------------------------------------------------------*/
 
-extern void printf_small (char *,...) _REENTRANT;
+extern void printfl(char *, ...);
+
+//extern void printf_small (char *,...) _REENTRANT;
 extern int printf (const char *,...);
 extern int vprintf (const char *, va_list);
 extern int sprintf (char *, const char *, ...);
@@ -58,6 +60,8 @@ extern int vsprintf (char *, const char *, va_list);
 extern int puts(const char *);
 extern char *gets(char *);
 extern char getchar(void);
+
+#pragma wparam putchar
 extern void putchar(char);
 
 
index 5f9189cc259c9a152e5587605ee46ec45db90d75..fe5e355fc718d6b66f694525b4560fd504be3b95 100644 (file)
@@ -30,6 +30,8 @@
 #ifndef __STRING_H     /* { */
 #define __STRING_H 1
 
+#define _STRING_SPEC   data
+
 #ifndef NULL
 # define NULL (void *)0
 #endif
@@ -62,6 +64,6 @@ extern int   memcmp (void *, void *, size_t);
 extern void *memcpy (void *, void *, size_t);
 extern void *memmove (void *, void *, size_t);
 extern void *memrchr(void *, char, size_t);
-extern void *memset (void *, unsigned char, size_t );
+extern void *memset (_STRING_SPEC void *, unsigned char, size_t );
 
 #endif /* } */
index 0251116ffbefe25ee61c120d2379f8b19413b862..1bcafdd4df995107941a0387c9936d488212b000 100644 (file)
@@ -89,7 +89,6 @@ typedef struct PIC16_device {
 #define OF_LR_SUPPORT          0x00000001
 #define OF_OPTIMIZE_GOTO       0x00000002
 
-
 typedef struct {
   int no_banksel;
   int opt_banksel;
index bc7aed3efeed171bc697901fffdcaa6df83cbcd1..fc6eb6f85420df6f758d1433c2dc0b9f7b51fe4d 100644 (file)
@@ -1998,16 +1998,12 @@ pCodeOp *pic16_popGet (asmop *aop, int offset) //, bool bit16, bool dname)
                          __LINE__, 
                          ((aop->aopu.pcop->name)? (aop->aopu.pcop->name) : "no name"), offset);
       pcop = pic16_pCodeOpCopy(aop->aopu.pcop);
-#if 1
-       switch( aop->aopu.pcop->type ) {
-               case PO_DIR: PCOR(pcop)->instance += offset; break; // patch 8
-               case PO_IMMEDIATE: PCOI(pcop)->offset = offset; break;
-               default:
-                       assert( 0 );    /* should never reach here */;
-       }
-#else
-      PCOI(pcop)->offset = offset;
-#endif
+      switch( aop->aopu.pcop->type ) {
+        case PO_DIR: PCOR(pcop)->instance += offset; break;
+        case PO_IMMEDIATE: PCOI(pcop)->offset = offset; break;
+        default:
+          assert( 0 ); /* should never reach here */;
+      }
       return pcop;
     }
 
@@ -4573,6 +4569,33 @@ static void genIfxJump (iCode *ic, char *jval)
     ic->generated = 1;
 }
 
+static void genIfxpCOpJump (iCode *ic, pCodeOp *jop)
+{
+  FENTRY;
+  
+    /* if true label then we jump if condition
+    supplied is true */
+    if ( IC_TRUE(ic) ) {
+      DEBUGpic16_emitcode ("; ***","%d - assuming is in bit space",__LINE__);    
+      pic16_emitpcode(POC_BTFSC, jop);
+
+      pic16_emitpcode(POC_GOTO,pic16_popGetLabel(IC_TRUE(ic)->key));
+      pic16_emitcode(" goto","_%05d_DS_",IC_TRUE(ic)->key+100 + pic16_labelOffset);
+
+    } else {
+      /* false label is present */
+      DEBUGpic16_emitcode ("; ***","%d - assuming is in bit space",__LINE__);
+      pic16_emitpcode(POC_BTFSS, jop);
+         
+      pic16_emitpcode(POC_GOTO,pic16_popGetLabel(IC_FALSE(ic)->key));
+      pic16_emitcode(" goto","_%05d_DS_",IC_FALSE(ic)->key+100 + pic16_labelOffset);
+    }
+
+
+    /* mark the icode as generated */
+    ic->generated = 1;
+}
+
 #if 0
 // not needed ATM
 
@@ -10989,6 +11012,50 @@ static void genNearPointerGet (operand *left,
     }
     
     DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    pic16_aopOp (result,ic,FALSE);
+    
+    DEBUGpic16_pic16_AopType(__LINE__, left, NULL, result);
+
+#if 1
+    if(IS_BITFIELD( retype )
+      && (SPEC_BLEN(operandType(result))==1)
+    ) {
+      iCode *nextic;
+      pCodeOp *jop;
+      int bitstrt, bytestrt;
+
+        /* if this is bitfield of size 1, see if we are checking the value
+         * of a single bit in an if-statement,
+         * if yes, then don't generate usual code, but execute the
+         * genIfx directly -- VR */
+
+        nextic = ic->next;
+
+        /* CHECK: if next iCode is IFX
+         * and current result operand is nextic's conditional operand
+         * and current result operand live ranges ends at nextic's key number
+         */
+        if((nextic->op == IFX)
+          && (result == IC_COND(nextic))
+          && (OP_LIVETO(result) == nextic->seq)
+          ) {
+            /* everything is ok then */
+            /* find a way to optimize the genIfx iCode */
+
+            bytestrt = SPEC_BSTR(operandType(result))/8;
+            bitstrt = SPEC_BSTR(operandType(result))%8;
+            
+            jop = pic16_popCopyGPR2Bit(pic16_popGet(AOP(left), 0), bitstrt);
+
+            genIfxpCOpJump(nextic, jop);
+            
+            pic16_freeAsmop(left, NULL, ic, TRUE);
+            pic16_freeAsmop(result, NULL, ic, TRUE);
+            return;
+        }
+    }
+#endif
+
 
     /* if the value is already in a pointer register
      * then don't need anything more */
@@ -11009,12 +11076,6 @@ static void genNearPointerGet (operand *left,
         }
       }
     }
-//    else
-//    rname = pic16_aopGet(AOP(left),0,FALSE,FALSE);
-    
-    pic16_aopOp (result,ic,FALSE);
-    
-    DEBUGpic16_pic16_AopType(__LINE__, left, NULL, result);
 
     /* if bitfield then unpack the bits */
     if (IS_BITFIELD(retype)) 
@@ -11220,6 +11281,7 @@ static void genFarPointerGet (operand *left,
 
     pic16_freeAsmop(result,NULL,ic,TRUE);
 }
+
 #if 0
 /*-----------------------------------------------------------------*/
 /* genCodePointerGet - get value from code space                  */
@@ -11272,6 +11334,7 @@ static void genCodePointerGet (operand *left,
     pic16_freeAsmop(result,NULL,ic,TRUE);
 }
 #endif
+
 #if 0
 /*-----------------------------------------------------------------*/
 /* genGenPointerGet - gget value from generic pointer space        */
@@ -11440,29 +11503,11 @@ static void genConstPointerGet (operand *left,
   DEBUGpic16_pic16_AopType(__LINE__,left,NULL,result);
 
   DEBUGpic16_emitcode ("; "," %d getting const pointer",__LINE__);
-#if 0                                                                  // patch 15
-  pic16_emitpcode(POC_CALL,pic16_popGetLabel(albl->key));
-  pic16_emitpcode(POC_GOTO,pic16_popGetLabel(blbl->key));
-  pic16_emitpLabel(albl->key);
-
-  poc = ( (AOP_TYPE(left) == AOP_PCODE) ? POC_MOVLW : POC_MOVFW);
-  
-  /* this performs a goto to the specified address -- Why not to use pointer? -- VR */
-  pic16_emitpcode(poc,pic16_popGet(AOP(left),1));
-  pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_pclath));
-  pic16_emitpcode(poc,pic16_popGet(AOP(left),0));
-  pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_pcl));
-
-  pic16_emitpLabel(blbl->key);
-
-  pic16_emitpcode(POC_MOVWF,pic16_popGet(AOP(result),0));
-#endif                                                                 // patch 15
-
 
   // set up table pointer
   if( (AOP_TYPE(left) == AOP_PCODE) 
       && ((AOP(left)->aopu.pcop->type == PO_IMMEDIATE)
-          || (AOP(left)->aopu.pcop->type == PO_DIR)))                  // patch 15 ......
+          || (AOP(left)->aopu.pcop->type == PO_DIR)))
     {
       pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(left),0));
       pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_tblptrl));
@@ -11470,25 +11515,20 @@ static void genConstPointerGet (operand *left,
       pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_tblptrh));
       pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(left),2));
       pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_tblptru));
-    }
-  else
-    {
-      pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),0), pic16_popCopyReg(&pic16_pc_tblptrl)));
-      pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),1), pic16_popCopyReg(&pic16_pc_tblptrh)));
-      pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),2), pic16_popCopyReg(&pic16_pc_tblptru)));
-    }
-
+  } else {
+    pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),0), pic16_popCopyReg(&pic16_pc_tblptrl)));
+    pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),1), pic16_popCopyReg(&pic16_pc_tblptrh)));
+    pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),2), pic16_popCopyReg(&pic16_pc_tblptru)));
+  }
 
-  while(size--)
-    {
-      pic16_emitpcodeNULLop(POC_TBLRD_POSTINC);
-      pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popCopyReg(&pic16_pc_tablat), pic16_popGet(AOP(result),offset)));
-      offset++;
-    }
+  while(size--) {
+    pic16_emitpcodeNULLop(POC_TBLRD_POSTINC);
+    pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popCopyReg(&pic16_pc_tablat), pic16_popGet(AOP(result),offset)));
+    offset++;
+  }
     
   pic16_freeAsmop(left,NULL,ic,TRUE);
   pic16_freeAsmop(result,NULL,ic,TRUE);
-
 }
 
 
@@ -11497,9 +11537,9 @@ static void genConstPointerGet (operand *left,
 /*-----------------------------------------------------------------*/
 static void genPointerGet (iCode *ic)
 {
-    operand *left, *result ;
-    sym_link *type, *etype;
-    int p_type;
+  operand *left, *result ;
+  sym_link *type, *etype;
+  int p_type;
 
     FENTRY;
     
@@ -11520,57 +11560,56 @@ static void genPointerGet (iCode *ic)
 
     /* if left is of type of pointer then it is simple */
     if (IS_PTR(type) && !IS_FUNC(type->next)) 
-        p_type = DCL_TYPE(type);
+      p_type = DCL_TYPE(type);
     else {
-       /* we have to go by the storage class */
-       p_type = PTR_TYPE(SPEC_OCLS(etype));
+      /* we have to go by the storage class */
+      p_type = PTR_TYPE(SPEC_OCLS(etype));
 
-       DEBUGpic16_emitcode ("; ***","%d - resolve pointer by storage class",__LINE__);
+      DEBUGpic16_emitcode ("; ***","%d - resolve pointer by storage class",__LINE__);
 
-       if (SPEC_OCLS(etype)->codesp ) {
-         DEBUGpic16_emitcode ("; ***","%d - cpointer",__LINE__);
-         //p_type = CPOINTER ; 
-       }
-       else
-           if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged)
-             DEBUGpic16_emitcode ("; ***","%d - fpointer",__LINE__);
-              /*p_type = FPOINTER ;*/ 
-           else
-               if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged)
-                 DEBUGpic16_emitcode ("; ***","%d - ppointer",__LINE__);
-/*                 p_type = PPOINTER; */
-               else
-                   if (SPEC_OCLS(etype) == idata )
-                     DEBUGpic16_emitcode ("; ***","%d - ipointer",__LINE__);
-/*                     p_type = IPOINTER; */
-                   else
-                     DEBUGpic16_emitcode ("; ***","%d - pointer",__LINE__);
-/*                     p_type = POINTER ; */
+      if (SPEC_OCLS(etype)->codesp ) {
+        DEBUGpic16_emitcode ("; ***","%d - cpointer",__LINE__);
+        //p_type = CPOINTER ;  
+      } else
+      if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) {
+        DEBUGpic16_emitcode ("; ***","%d - fpointer",__LINE__);
+        /*p_type = FPOINTER ;*/ 
+      } else
+      if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) {
+        DEBUGpic16_emitcode ("; ***","%d - ppointer",__LINE__);
+        /* p_type = PPOINTER; */
+      } else
+      if (SPEC_OCLS(etype) == idata ) {
+        DEBUGpic16_emitcode ("; ***","%d - ipointer",__LINE__);
+        /* p_type = IPOINTER; */
+      } else {
+        DEBUGpic16_emitcode ("; ***","%d - pointer",__LINE__);
+        /* p_type = POINTER ; */
+      }
     }
 
     /* now that we have the pointer type we assign
     the pointer values */
     switch (p_type) {
-
-    case POINTER:      
-    case IPOINTER:
+      case POINTER:    
+      case IPOINTER:
        genNearPointerGet (left,result,ic);
        break;
 
-    case PPOINTER:
+      case PPOINTER:
        genPagedPointerGet(left,result,ic);
        break;
 
-    case FPOINTER:
+      case FPOINTER:
        genFarPointerGet (left,result,ic);
        break;
 
-    case CPOINTER:
+      case CPOINTER:
        genConstPointerGet (left,result,ic);
        //pic16_emitcodePointerGet (left,result,ic);
        break;
 
-    case GPOINTER:
+      case GPOINTER:
 #if 0
       if (IS_PTR_CONST(type))
        genConstPointerGet (left,result,ic);
@@ -11584,7 +11623,6 @@ static void genPointerGet (iCode *ic)
              "genPointerGet: illegal pointer type");
     
     }
-
 }
 
 /*-----------------------------------------------------------------*/
@@ -11952,24 +11990,24 @@ static void genNearPointerSet (operand *right,
                                pic16_emitcode("movf","indf0,w ;1");
                        } else {
 
-                               if (AOP_TYPE(right) == AOP_LIT) {                                                       // patch 10
-                                       pic16_emitpcode(POC_MOVLW, pic16_popGet(AOP(right),offset));                    // 
-                                       if (size) {                                                                     // 
-                                               pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_postinc0));        // 
-                                       } else {                                                                        // 
-                                               pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_indf0));           // 
-                                       }                                                                               // 
-                               } else { // no literal                                                                  // 
-                                       if(size) {                                                                      // 
-                                               pic16_emitpcode(POC_MOVFF,                                              // 
-                                                               pic16_popGet2p(pic16_popGet(AOP(right),offset),         // 
-                                                                       pic16_popCopyReg(&pic16_pc_postinc0)));         // 
-                                       } else {                                                                        // 
-                                               pic16_emitpcode(POC_MOVFF,                                              // 
-                                                               pic16_popGet2p(pic16_popGet(AOP(right),offset),         // 
-                                                                       pic16_popCopyReg(&pic16_pc_indf0)));            //
-                                       }                                                                               //
-                               }                                                                                       // patch 10
+                               if (AOP_TYPE(right) == AOP_LIT) {
+                                       pic16_emitpcode(POC_MOVLW, pic16_popGet(AOP(right),offset));
+                                       if (size) {
+                                               pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_postinc0));
+                                       } else {
+                                               pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_indf0));
+                                       }
+                               } else { // no literal
+                                       if(size) {
+                                               pic16_emitpcode(POC_MOVFF,
+                                                               pic16_popGet2p(pic16_popGet(AOP(right),offset),
+                                                                       pic16_popCopyReg(&pic16_pc_postinc0)));
+                                       } else {
+                                               pic16_emitpcode(POC_MOVFF,
+                                                               pic16_popGet2p(pic16_popGet(AOP(right),offset),
+                                                                       pic16_popCopyReg(&pic16_pc_indf0)));
+                                       }
+                               }
                        }
                        offset++;
                }
@@ -12385,27 +12423,26 @@ static void genPointerSet (iCode *ic)
     /* now that we have the pointer type we assign
     the pointer values */
     switch (p_type) {
+      case POINTER:
+      case IPOINTER:
+        genNearPointerSet (right,result,ic);
+        break;
 
-    case POINTER:
-    case IPOINTER:
-       genNearPointerSet (right,result,ic);
+      case PPOINTER:
+        genPagedPointerSet (right,result,ic);
        break;
 
-    case PPOINTER:
-       genPagedPointerSet (right,result,ic);
-       break;
-
-    case FPOINTER:
-       genFarPointerSet (right,result,ic);
-       break;
-
-    case GPOINTER:
-       genGenPointerSet (right,result,ic);
-       break;
+      case FPOINTER:
+        genFarPointerSet (right,result,ic);
+        break;
+        
+      case GPOINTER:
+        genGenPointerSet (right,result,ic);
+        break;
 
-    default:
-      werror (E_INTERNAL_ERROR, __FILE__, __LINE__, 
-             "genPointerSet: illegal pointer type");
+      default:
+        werror (E_INTERNAL_ERROR, __FILE__, __LINE__, 
+          "genPointerSet: illegal pointer type");
     }
 }
 
@@ -12500,10 +12537,6 @@ static void genAddrOf (iCode *ic)
     pic16_aopOp((left=IC_LEFT(ic)), ic, FALSE);
     size = AOP_SIZE(IC_RESULT(ic));
 
-
-    /* Assume that what we want the address of is in data space
-     * since there is no stack on the PIC, yet! -- VR */
-  
     pcop0 = PCOP(pic16_newpCodeOpImmd(sym->rname, 0, 0, IN_CODESPACE( SPEC_OCLS(sym->etype))));
     pcop1 = PCOP(pic16_newpCodeOpImmd(sym->rname, 1, 0, IN_CODESPACE( SPEC_OCLS(sym->etype))));
     pcop2 = PCOP(pic16_newpCodeOpImmd(sym->rname, 2, 0, IN_CODESPACE( SPEC_OCLS(sym->etype))));
@@ -13476,7 +13509,7 @@ void genpic16Code (iCode *lic)
 
     for (ic = lic ; ic ; ic = ic->next ) {
 
-      DEBUGpic16_emitcode(";ic ", "\t%c 0x%x",ic->op, ic->op);
+      DEBUGpic16_emitcode(";ic ", "\t%c 0x%x\t(%s)",ic->op, ic->op, pic16_decodeOp(ic->op));
       if ( cln != ic->lineno ) {
         if ( options.debug ) {
           debugFile->writeCLine (ic);
index 9ed5a88c497da96ea02419103621a0411af3d8a5..b12a47d128be3cf3bab4743a1d41c8347c752771 100644 (file)
@@ -42,7 +42,7 @@
 #endif
 void _debugf(char *f, int l, char *frm, ...);
 
-
+#define NEWREG_DEBUG   0
 //#define USE_ONSTACK
 
 
@@ -203,8 +203,8 @@ debugAopGet (char *str, operand * op)
   return NULL;
 }
 
-static char *
-decodeOp (unsigned int op)
+char *
+pic16_decodeOp (unsigned int op)
 {
        if (op < 128 && op > ' ') {
                buffer[0] = (op & 0xff);
@@ -390,8 +390,9 @@ regs* newReg(short type, short pc_type, int rIdx, char *name, int size, int alia
                dReg->accessBank = 0;
        }
 
-//     fprintf(stderr,"newReg: %s, rIdx = 0x%02x\taccess= %d\tregop= %p\n",dReg->name,rIdx, dReg->accessBank, refop);
-
+#if NEWREG_DEBUG
+       fprintf(stderr,"newReg: %s, rIdx = 0x%02x\taccess= %d\tregop= %p\n",dReg->name,rIdx, dReg->accessBank, refop);
+#endif
        dReg->size = size;
        dReg->alias = alias;
        dReg->reg_alias = NULL;
@@ -540,9 +541,10 @@ allocReg (short type)
 
        debugLog ("%s of type %s for register rIdx: %d (0x%x)\n", __FUNCTION__, debugLogRegType (type), dynrIdx-1, dynrIdx-1);
 
-//     fprintf(stderr,"%s:%d: %s\t%s addr= 0x%x\trIdx= 0x%02x isFree: %d\n",
-//             __FILE__, __LINE__, __FUNCTION__, reg->name, reg->address, reg->rIdx, reg->isFree);
-
+#if 0
+       fprintf(stderr,"%s:%d: %s\t%s addr= 0x%x\trIdx= 0x%02x isFree: %d\n",
+               __FILE__, __LINE__, __FUNCTION__, reg->name, reg->address, reg->rIdx, reg->isFree);
+#endif
        if(reg) {
                reg->accessBank = 1;    /* this is a temporary register alloc in accessBank */
                reg->isLocal = 1;       /* this is a local frame register */
@@ -2210,14 +2212,12 @@ static void
 serialRegAssign (eBBlock ** ebbs, int count)
 {
   int i;
-
+  iCode *ic;
+  
   debugLog ("%s\n", __FUNCTION__);
   /* for all blocks */
   for (i = 0; i < count; i++)
     {
-
-      iCode *ic;
-
       if (ebbs[i]->noPath &&
          (ebbs[i]->entryLabel != entryLabel &&
           ebbs[i]->entryLabel != returnLabel))
@@ -2227,7 +2227,7 @@ serialRegAssign (eBBlock ** ebbs, int count)
       for (ic = ebbs[i]->sch; ic; ic = ic->next)
        {
 
-         debugLog ("  op: %s\n", decodeOp (ic->op));
+         debugLog ("  op: %s\n", pic16_decodeOp (ic->op));
 
                if(IC_RESULT(ic) && !IS_ITEMP( IC_RESULT(ic)))
                        pic16_allocDirReg(IC_RESULT(ic));
@@ -2340,6 +2340,19 @@ serialRegAssign (eBBlock ** ebbs, int count)
              if (ic->op == RECEIVE)
                debugLog ("When I get clever, I'll optimize the receive logic\n");
 
+              if(POINTER_GET(ic) && IS_BITFIELD(getSpec(operandType(IC_RESULT(ic))))
+                && (SPEC_BLEN(getSpec(operandType(IC_RESULT(ic))))==1)
+                && (ic->next->op == IFX)
+                && (OP_LIVETO(IC_RESULT(ic)) == ic->next->seq)) {
+
+                /* skip register allocation since none will be used */
+                for(j=0;j<sym->nRegs;j++)
+                  sym->regs[j] = newReg(REG_TMP, PO_GPR_TEMP, 0, "bad", 1, 0, NULL);
+//                OP_SYMBOL(IC_RESULT(ic))->nRegs = 0;
+                
+                continue;
+              }
+
              /* if we need ptr regs for the right side
                 then mark it */
              if (POINTER_GET (ic) && IS_SYMOP( IC_LEFT(ic) ) && getSize (OP_SYMBOL (IC_LEFT (ic))->type)
@@ -2913,7 +2926,7 @@ packRegsForAssign (iCode * ic, eBBlock * ebp)
   iCode *dic, *sic;
 
   debugLog ("%d\t%s\n", __LINE__, __FUNCTION__);
-  debugLog ("ic->op = %s\n", decodeOp( ic->op ) );
+  debugLog ("ic->op = %s\n", pic16_decodeOp( ic->op ) );
   debugAopGet ("  result:", IC_RESULT (ic));
   debugAopGet ("  left:", IC_LEFT (ic));
   debugAopGet ("  right:", IC_RIGHT (ic));
@@ -3625,20 +3638,16 @@ packForReceive (iCode * ic, eBBlock * ebp)
 
   for (dic = ic->next; dic; dic = dic->next)
     {
-
-
-
       if (IC_LEFT (dic) && (IC_RESULT (ic)->key == IC_LEFT (dic)->key))
-       debugLog ("    used on left\n");
+        debugLog ("    used on left\n");
       if (IC_RIGHT (dic) && IC_RESULT (ic)->key == IC_RIGHT (dic)->key)
-       debugLog ("    used on right\n");
+        debugLog ("    used on right\n");
       if (IC_RESULT (dic) && IC_RESULT (ic)->key == IC_RESULT (dic)->key)
-       debugLog ("    used on result\n");
+        debugLog ("    used on result\n");
 
       if ((IC_LEFT (dic) && (IC_RESULT (ic)->key == IC_LEFT (dic)->key)) ||
-         (IC_RESULT (dic) && IC_RESULT (ic)->key == IC_RESULT (dic)->key))
+        (IC_RESULT (dic) && IC_RESULT (ic)->key == IC_RESULT (dic)->key))
        return;
-
     }
 
   debugLog ("  hey we can remove this unnecessary assign\n");
index c1d5bc7340c62ae19c421606965ce79ad3267b35..1c9d126b98c94620bbdbc7d58605b06036226288 100644 (file)
@@ -122,6 +122,7 @@ regs *pic16_allocWithIdx (int idx);
 
 regs *pic16_allocDirReg (operand *op );
 regs *pic16_allocRegByName (char *name, int size, operand *op);
+extern char *pic16_decodeOp(unsigned int op);
 
 regs* newReg(short type, short pc_type, int rIdx, char *name, int size, int alias, operand *refop);