From 67cab3e626a6eda77d36e7e706951e8088db1b52 Mon Sep 17 00:00:00 2001 From: tecodev Date: Fri, 12 Aug 2005 11:21:04 +0000 Subject: [PATCH] * 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 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3840 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 18 +++++++++++++++++ device/lib/Makefile.in | 2 +- device/lib/pic16/Makefile | 9 +++++++++ device/lib/pic16/Makefile.common.in | 2 +- src/pic16/glue.c | 22 ++++++++++---------- src/pic16/pcode.c | 31 ++++++++++++++++++++++++----- src/pic16/ralloc.c | 2 +- 7 files changed, 68 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb05705e..9bcd73e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2005-08-12 Raphael Neider + + * 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 * device/lib/Makefile.in: fixed copying pic16 libraries (broken by diff --git a/device/lib/Makefile.in b/device/lib/Makefile.in index 3539dc77..f88dbf83 100644 --- a/device/lib/Makefile.in +++ b/device/lib/Makefile.in @@ -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); \ diff --git a/device/lib/pic16/Makefile b/device/lib/pic16/Makefile index ad27fa23..a28c9f7c 100644 --- a/device/lib/pic16/Makefile +++ b/device/lib/pic16/Makefile @@ -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 diff --git a/device/lib/pic16/Makefile.common.in b/device/lib/pic16/Makefile.common.in index 35b7736b..2c787dfd 100644 --- a/device/lib/pic16/Makefile.common.in +++ b/device/lib/pic16/Makefile.common.in @@ -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 diff --git a/src/pic16/glue.c b/src/pic16/glue.c index 5c78ee67..7cea4080 100644 --- a/src/pic16/glue.c +++ b/src/pic16/glue.c @@ -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); diff --git a/src/pic16/pcode.c b/src/pic16/pcode.c index 32a5a32f..11e825c4 100644 --- a/src/pic16/pcode.c +++ b/src/pic16/pcode.c @@ -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_ */ + 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); diff --git a/src/pic16/ralloc.c b/src/pic16/ralloc.c index b6a50842..5b7b0f0f 100644 --- a/src/pic16/ralloc.c +++ b/src/pic16/ralloc.c @@ -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); -- 2.30.2