* src/pic16/glue.c (pic16_print(G)PointerType): do not flush
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 12 Aug 2005 11:21:04 +0000 (11:21 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 12 Aug 2005 11:21:04 +0000 (11:21 +0000)
  db-statements in order to allow for arrays of pointers in code
  sections to be placed without interspersed 0-padding, fixes
  bug #1256215
* (emitStatistics): fixed division by zero for pic18f1220
* src/pic16/pcode.c: buffer (up to) 12 DB directives to allow for
  unpadded writing of 8-bit, 16-bit, 24-bit and 32-bit values
* (pic16_emitDS): respect DB_ITEMS_PER_LINE
* (pic16_pCodeConstString): keep track of already emitted string
  literals to prevent "duplicate definitions of symbol _str_NR"
* src/pic16/ralloc.c (pic16_allocRegByName): removed not so helpful
  debug message
* device/lib/Makefile.in: ignore failing PIC16 library builds
* device/lib/pic16/Makefile: do not build if gputils are missing
* device/lib/pic16/Makefile.common.in: do not enforce MAKEFLAGS=-s

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

ChangeLog
device/lib/Makefile.in
device/lib/pic16/Makefile
device/lib/pic16/Makefile.common.in
src/pic16/glue.c
src/pic16/pcode.c
src/pic16/ralloc.c

index bb05705e6484a395b661201b4078a91c4ac2fde9..9bcd73e28cd2c1f7faf0b44a07043663abbfefd4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2005-08-12 Raphael Neider <rneider AT web.de>
+
+       * src/pic16/glue.c (pic16_print(G)PointerType): do not flush
+         db-statements in order to allow for arrays of pointers in code
+         sections to be placed without interspersed 0-padding, fixes
+         bug #1256215
+       * (emitStatistics): fixed division by zero for pic18f1220
+       * src/pic16/pcode.c: buffer (up to) 12 DB directives to allow for
+         unpadded writing of 8-bit, 16-bit, 24-bit and 32-bit values
+       * (pic16_emitDS): respect DB_ITEMS_PER_LINE
+       * (pic16_pCodeConstString): keep track of already emitted string
+         literals to prevent "duplicate definitions of symbol _str_NR"
+       * src/pic16/ralloc.c (pic16_allocRegByName): removed not so helpful
+         debug message
+       * device/lib/Makefile.in: ignore failing PIC16 library builds
+       * device/lib/pic16/Makefile: do not build if gputils are missing
+       * device/lib/pic16/Makefile.common.in: do not enforce MAKEFLAGS=-s
+
 2005-08-10 Raphael Neider <rneider AT web.de>
 
        * device/lib/Makefile.in: fixed copying pic16 libraries (broken by
index 3539dc77ef59d2b33e859390c5f00160e2124ab0..f88dbf831732456c06855b637ae14ded86cc35db 100644 (file)
@@ -255,7 +255,7 @@ port-specific-objects:
        fi
 
 port-specific-objects-pic16:
-       if [ -d $(PORT) ]; then \
+       -if [ -d $(PORT) ]; then \
          mkdir -p $(PORT)/bin; \
          $(MAKE) -C $(PORT); \
          cp -f $(PORT)/bin/*.o $(PORT)/bin/*.lib $(PORTDIR); \
index ad27fa232dad638d18b110910b6a59650faa8bf6..a28c9f7c17b6a11ac1b1d8b074beeeed0d912b3b 100644 (file)
@@ -20,6 +20,13 @@ topsrcdir = .
 
 include $(topsrcdir)/Makefile.common
 
+ifeq (:,$(findstring :,$(LD) $(AS) $(LIB)))
+
+all % : 
+       @echo "gputils not found -- PIC16 library not built!"
+
+else
+
 SUBDIRS           = debug libc libdev libio libm libsdcc startup
 builddir   = build
 installdir = bin
@@ -41,3 +48,5 @@ clean : recurse
 clean-intermediate : recurse
 
 include $(topsrcdir)/Makefile.rules
+
+endif
index 35b7736b9813cdab4885b7ef5574756b784f4fff..2c787dfd70d087b357461e159a700ee0e63be43e 100644 (file)
@@ -21,7 +21,7 @@
 #Q     ?=              # be verbose
 Q      ?= @            # be quiet
 # be really quiet (suppress "Entering/Leaving directory...")
-MAKEFLAGS := $(filter-out -s,$(MAKEFLAGS)) -s
+#MAKEFLAGS := $(filter-out -s,$(MAKEFLAGS)) -s
 
 #################################################
 ### compiler switches
index 5c78ee677ef11ff56e2b99e5db6c39d42df71e1f..7cea40809bc040bb77c2714004e510434cec1257 100644 (file)
@@ -544,7 +544,7 @@ void _pic16_printPointerType (const char *name, char ptype, void *p)
 void pic16_printPointerType (const char *name, char ptype, void *p)
 {
   _pic16_printPointerType (name, ptype, p);
-  pic16_flushDB(ptype, p);
+  //pic16_flushDB(ptype, p); /* breaks char* const arr[] = {&c, &c, &c}; */
 }
 
 /*-----------------------------------------------------------------*/
@@ -576,7 +576,7 @@ void pic16_printGPointerType (const char *iname, const unsigned int itype,
         assert( 0 );
     }
 
-    pic16_flushDB(ptype, p);
+    //pic16_flushDB(ptype, p); /* might break char* const arr[] = {...}; */
 }
 
 
@@ -1300,7 +1300,7 @@ CODESPACE: %d\tCONST: %d\tPTRCONST: %d\tSPEC_CONST: %d\n", __FUNCTION__,
              
              pic16_addpCode2pBlock(pb,pcf);
              pic16_addpCode2pBlock(pb,pic16_newpCodeLabel(sym->rname,-1));
-//           fprintf(stderr, "%s:%d [1] generating init for label: %s\n", __FILE__, __LINE__, sym->rname);
+             //fprintf(stderr, "%s:%d [1] generating init for label: %s\n", __FILE__, __LINE__, sym->rname);
              pic16_printIval(sym, sym->type, sym->ival, 'p', (void *)pb);
               pic16_flushDB('p', (void *)pb);
 
@@ -1350,10 +1350,9 @@ CODESPACE: %d\tCONST: %d\tPTRCONST: %d\tSPEC_CONST: %d\n", __FUNCTION__,
                
                didcode++;
              }
-                            
-//           fprintf(stderr, "%s:%d [2] generating init for label: %s\n", __FILE__, __LINE__, sym->rname);
 
              pic16_addpCode2pBlock(pb,pic16_newpCodeLabel(sym->rname,-1));
+             //fprintf(stderr, "%s:%d [2] generating init for label: %s\n", __FILE__, __LINE__, sym->rname);
              pic16_printIval(sym, sym->type, sym->ival, 'p', (void *)pb);
               pic16_flushDB('p', (void *)pb);
              noAlloc--;
@@ -1599,17 +1598,20 @@ pic16emitOverlay (FILE * afile)
 
 void emitStatistics(FILE *asmFile)
 {
-  unsigned long isize, udsize;
+  unsigned long isize, udsize, ramsize;
   statistics.isize = pic16_countInstructions();
   isize = (statistics.isize >= 0) ? statistics.isize : 0;
   udsize = (statistics.udsize >= 0) ? statistics.udsize : 0;
+  ramsize = pic16 ? pic16->RAMsize : 0x200;
+  ramsize -= 256; /* ignore access bank and SFRs */
+  if (ramsize == 0) ramsize = 64; /* prevent division by zero (below) */
        
   fprintf (asmFile, "\n\n; Statistics:\n");
-  fprintf (asmFile, "; code size:\t%5ld (0x%04lx) bytes (%3.2f%%)\n;           \t%5ld (0x%04lx) words\n",
-    isize, isize, (isize*100.0)/(128 << 10),
+  fprintf (asmFile, "; code size:\t%5ld (0x%04lx) bytes (%5.2f%%)\n;           \t%5ld (0x%04lx) words\n",
+    isize, isize, (isize*100.0)/(128UL << 10),
     isize>>1, isize>>1);
-  fprintf (asmFile, "; udata size:\t%5ld (0x%04lx) bytes (%3.2f%%)\n",
-    udsize, udsize, (udsize*100.0) / ((pic16 ? pic16->RAMsize : 0x200) -256));
+  fprintf (asmFile, "; udata size:\t%5ld (0x%04lx) bytes (%5.2f%%)\n",
+    udsize, udsize, (udsize*100.0) / (1.0 * ramsize));
   fprintf (asmFile, "; access size:\t%5ld (0x%04lx) bytes\n",
     statistics.intsize, statistics.intsize);
 
index 32a5a32f4132236d2f3e33228756441536bdaa2a..11e825c4791fd301dab97f2beea0e2c269e79836 100644 (file)
@@ -4385,12 +4385,18 @@ pCodeOp *pic16_newpCodeOp(char *name, PIC_OPTYPE type)
   return pcop;
 }
 
-#define DB_ITEMS_PER_LINE      8
+/* This is a multiple of two as gpasm pads DB directives to even length,
+ * thus the data would be interleaved with \0 bytes...
+ * This is a multiple of three in order to have arrays of 3-byte pointers
+ * continuously in memory (without 0-padding at the lines' end).
+ * This is rather 12 than 6 in order not to split up 4-byte data types
+ * in arrays right in the middle of a 4-byte word. */
+#define DB_ITEMS_PER_LINE      12
 
 typedef struct DBdata
   {
     int count;
-    char buffer[256];
+    char buffer[512];
   } DBdata;
 
 struct DBdata DBd;
@@ -4470,7 +4476,7 @@ void pic16_emitDS(char *s, char ptype, void *p)
 //     fprintf(stderr, "%s:%d DBbuffer: '%s'\n", __FILE__, __LINE__, DBd.buffer);
 
        DBd.count++;    //=strlen(s);
-       if (DBd.count>=16)
+       if (DBd.count>=DB_ITEMS_PER_LINE)
                pic16_flushDB(ptype, p);
 }
 
@@ -4480,12 +4486,27 @@ void pic16_emitDS(char *s, char ptype, void *p)
 void pic16_pCodeConstString(char *name, char *value)
 {
   pBlock *pb;
-
-  //  fprintf(stderr, " %s  %s  %s\n",__FUNCTION__,name,value);
+  char *item;
+  static set *emittedSymbols = NULL;
 
   if(!name || !value)
     return;
 
+  /* keep track of emitted symbols to avoid multiple definition of str_<nr> */
+  if (emittedSymbols) {
+    /* scan set for name */
+    for (item = setFirstItem (emittedSymbols); item; item = setNextItem (emittedSymbols))
+    {
+      if (!strcmp (item,name)) {
+        //fprintf (stderr, "%s already emitted\n", name);
+        return;
+      } // if
+    } // for
+  } // if
+  addSet (&emittedSymbols, Safe_strdup (name));
+
+  //fprintf(stderr, " %s  %s  %s\n",__FUNCTION__,name,value);
+
   pb = pic16_newpCodeChain(NULL, 'P',pic16_newpCodeCharP("; Starting pCode block"));
 
   pic16_addpBlock(pb);
index b6a50842db49cea97161620c920cb391be79ac6a..5b7b0f0f7459e155a1dfa4cb9c315011d3819bfd 100644 (file)
@@ -960,7 +960,7 @@ pic16_allocRegByName (char *name, int size, operand *op)
      * 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);