From 779c8b2faef435c2bdc63d90aa304ab5a7083bd4 Mon Sep 17 00:00:00 2001 From: tecodev Date: Sat, 14 May 2005 12:11:22 +0000 Subject: [PATCH] * device/lib/pic16/Makefile.common.in: add --optimize-df to OPT_FLAGS * device/lib/pic16/libc/stdlib/itoa.c (new) * device/lib/pic16/libc/stdlib/Makefile: have itoa.c built * device/lib/pic16/libio/Makefile: exclude subdir according to ${subdir}.ignore for certain PICs (lacking e.g. i2c) * device/lib/pic16/libio/i2c.ignore (new): pic18f1220 has no I2C support * src/pic16/gen.c (genFunction): prevent annoying warning * src/pic16/pcode.c: renamed stack_t to dynstack_t to prevent nameclashes on BeOS * support/cpp2/cppmain.c (cpp_output_string): new * support/cpp2/cpplib.c (_cpp_do__Pragma): fixed _Pragma (""), fixes bug 1116802 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3756 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 15 ++++++++++++ device/lib/pic16/Makefile.common.in | 1 + device/lib/pic16/libc/stdlib/Makefile | 1 + device/lib/pic16/libc/stdlib/itoa.c | 34 +++++++++++++++++++++++++++ device/lib/pic16/libio/Makefile | 9 ++++--- device/lib/pic16/libio/i2c.ignore | 1 + src/pic16/gen.c | 3 ++- src/pic16/pcode.c | 24 +++++++++---------- support/cpp2/cpplib.c | 6 ++++- support/cpp2/cppmain.c | 5 ++++ 10 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 device/lib/pic16/libc/stdlib/itoa.c create mode 100644 device/lib/pic16/libio/i2c.ignore diff --git a/ChangeLog b/ChangeLog index 126396f2..bbe29f0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-05-14 Raphael Neider + + * device/lib/pic16/Makefile.common.in: add --optimize-df to OPT_FLAGS + * device/lib/pic16/libc/stdlib/itoa.c (new) + * device/lib/pic16/libc/stdlib/Makefile: have itoa.c built + * device/lib/pic16/libio/Makefile: exclude subdir according to + ${subdir}.ignore for certain PICs (lacking e.g. i2c) + * device/lib/pic16/libio/i2c.ignore (new): pic18f1220 has no I2C support + * src/pic16/gen.c (genFunction): prevent annoying warning + * src/pic16/pcode.c: renamed stack_t to dynstack_t to prevent + nameclashes on BeOS + * support/cpp2/cppmain.c (cpp_output_string): new + * support/cpp2/cpplib.c (_cpp_do__Pragma): fixed _Pragma(""), + fixes bug 1116802 + 2005-05-13 Borut Razem * src/SDCCmain.c (linkEdit): fixed bug 1195202 diff --git a/device/lib/pic16/Makefile.common.in b/device/lib/pic16/Makefile.common.in index c9fef252..b90c0559 100644 --- a/device/lib/pic16/Makefile.common.in +++ b/device/lib/pic16/Makefile.common.in @@ -35,4 +35,5 @@ MODELFLAGS = -mpic16 OPT_FLAGS += --denable-peeps OPT_FLAGS += --obanksel=9 OPT_FLAGS += --optimize-goto +OPT_FLAGS += --optimize-df OPT_FLAGS += --i-code-in-asm diff --git a/device/lib/pic16/libc/stdlib/Makefile b/device/lib/pic16/libc/stdlib/Makefile index bb727da0..07ba9c16 100644 --- a/device/lib/pic16/libc/stdlib/Makefile +++ b/device/lib/pic16/libc/stdlib/Makefile @@ -18,6 +18,7 @@ SRCS = atof \ atol \ calloc \ free \ + itoa \ ltoa \ malloc \ memfree \ diff --git a/device/lib/pic16/libc/stdlib/itoa.c b/device/lib/pic16/libc/stdlib/itoa.c new file mode 100644 index 00000000..f788fa09 --- /dev/null +++ b/device/lib/pic16/libc/stdlib/itoa.c @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------- + itoa.c - convert (unsigned) int to strings + + written by: Raphael Neider + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + $Id$ +-------------------------------------------------------------------*/ + +#include + +void uitoa (unsigned int value, __data char *str, unsigned char radix) +{ + ultoa (value, str, radix); +} + +void itoa (int value, __data char *str, unsigned char radix) +{ + ltoa (value, str, radix); +} + diff --git a/device/lib/pic16/libio/Makefile b/device/lib/pic16/libio/Makefile index 8dc2251c..6e9e72fc 100644 --- a/device/lib/pic16/libio/Makefile +++ b/device/lib/pic16/libio/Makefile @@ -37,11 +37,14 @@ build-libraries: build-processor-library: for dir in $(DIRS) ; do \ $(MAKE) -C $$dir clean ; \ - $(MAKE) -C $$dir build-io-lib MCU=18f$(MMCU); \ + grep $(MMCU) "$${dir}.ignore" > /dev/null 2>&1 || $(MAKE) -C $$dir build-io-lib MCU=18f$(MMCU); \ done; - gplib -c $(LIB) $(LOBJS) + make invoke-gplib mv -v $(LIB) ../bin - + +# needed so that make updates the list of .o files correctly... +invoke-gplib: + gplib -c $(LIB) $(foreach dir,$(DIRS),$(wildcard $(dir)/*.o)) clean-intermediate: @for dir in $(DIRS) ; do \ diff --git a/device/lib/pic16/libio/i2c.ignore b/device/lib/pic16/libio/i2c.ignore new file mode 100644 index 00000000..15186126 --- /dev/null +++ b/device/lib/pic16/libio/i2c.ignore @@ -0,0 +1 @@ +1220 diff --git a/src/pic16/gen.c b/src/pic16/gen.c index b181f94c..5b678647 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -3674,7 +3674,8 @@ static void genFunction (iCode *ic) pic16_addpCode2pBlock(apb, pic16_newpCodeCharP(";-----------------------------------------")); pic16_addpCode2pBlock(apb, pic16_newpCodeFunction(moduleName, asym->name)); //pic16_addpCode2pBlock(apb, pic16_newpCode(POC_GOTO, pic16_popGetWithString( sym->rname ))); - pic16_addpCode2pBlock(apb, pic16_newpCode(POC_GOTO, pic16_newpCodeOpLabel (sym->rname, 0))); + //pic16_addpCode2pBlock(apb, pic16_newpCode(POC_GOTO, pic16_newpCodeOpLabel (sym->rname, 0))); + pic16_addpCode2pBlock(apb, pic16_newpCodeAsmDir ("GOTO", "%s", sym->rname)); /* this suppresses a warning in LinkFlow */ /* mark the end of this tiny function */ pic16_addpCode2pBlock(apb,pic16_newpCodeFunction(NULL,NULL)); diff --git a/src/pic16/pcode.c b/src/pic16/pcode.c index b55056db..c2f6ae2e 100644 --- a/src/pic16/pcode.c +++ b/src/pic16/pcode.c @@ -9911,18 +9911,18 @@ typedef struct stack_s { struct stack_s *next; } stackitem_t; -typedef stackitem_t *stack_t; +typedef stackitem_t *dynstack_t; static stackitem_t *free_stackitems = NULL; /* Create a stack with one item. */ -static stack_t *newStack () { - stack_t *s = (stack_t *) Safe_malloc (sizeof (stack_t)); +static dynstack_t *newStack () { + dynstack_t *s = (dynstack_t *) Safe_malloc (sizeof (dynstack_t)); *s = NULL; return s; } /* Remove a stack -- its items are only marked free. */ -static void deleteStack (stack_t *s) { +static void deleteStack (dynstack_t *s) { stackitem_t *i; while (*s) { @@ -9945,7 +9945,7 @@ static void releaseStack () { } // while } -static void stackPush (stack_t *stack, void *data) { +static void stackPush (dynstack_t *stack, void *data) { stackitem_t *i; if (free_stackitems) { @@ -9959,7 +9959,7 @@ static void stackPush (stack_t *stack, void *data) { *stack = i; } -static void *stackPop (stack_t *stack) { +static void *stackPop (dynstack_t *stack) { void *data; stackitem_t *i; @@ -9976,7 +9976,7 @@ static void *stackPop (stack_t *stack) { } #if 0 -static int stackContains (stack_t *s, void *data) { +static int stackContains (dynstack_t *s, void *data) { stackitem_t *i; if (!s) return 0; i = *s; @@ -9990,7 +9990,7 @@ static int stackContains (stack_t *s, void *data) { } #endif -static int stackIsEmpty (stack_t *s) { +static int stackIsEmpty (dynstack_t *s) { return (*s == NULL); } @@ -10011,7 +10011,7 @@ static void deleteState (state_t *s) { Safe_free (s); } -static int stateIsNew (state_t *state, stack_t *todo, stack_t *done) { +static int stateIsNew (state_t *state, dynstack_t *todo, dynstack_t *done) { stackitem_t *i; /* scan working list for state */ @@ -10098,8 +10098,8 @@ static int defmapFindAll (symbol_t sym, pCode *pc, defmap_t **chain) { pCodeFlow *curr; pCodeFlowLink *succ; state_t *state; - stack_t *todo; /** stack of state_t */ - stack_t *done; /** stack of state_t */ + dynstack_t *todo; /** stack of state_t */ + dynstack_t *done; /** stack of state_t */ int firstState, n_defs; @@ -10453,7 +10453,7 @@ int pic16_isAliveInFlow (symbol_t sym, int mask, pCodeFlow *pcfl, pCode *pc) { static int pic16_isAlive (symbol_t sym, pCode *pc) { int mask, visit; defmap_t *map; - stack_t *todo, *done; + dynstack_t *todo, *done; state_t *state; pCodeFlow *pcfl; pCodeFlowLink *succ; diff --git a/support/cpp2/cpplib.c b/support/cpp2/cpplib.c index 2b3512b8..93621adb 100644 --- a/support/cpp2/cpplib.c +++ b/support/cpp2/cpplib.c @@ -111,6 +111,8 @@ static struct answer ** find_answer PARAMS ((cpp_hashnode *, const struct answer *)); static void handle_assertion PARAMS ((cpp_reader *, const char *, int)); +extern cpp_output_string (const char *s); + /* This is the table of directive handlers. It is ordered by frequency of occurrence; the numbers at the end are directive counts from all the source code I have lying around (egcs and libc @@ -1285,7 +1287,9 @@ _cpp_do__Pragma (pfile) } buffer = destringize (&string.val.str, &len); - run_directive (pfile, T_PRAGMA, BUF_PRAGMA, (char *) buffer, len); + buffer[len] = 0; + cpp_output_string ("\n#pragma "); cpp_output_string (buffer); cpp_output_string ("\n"); + //run_directive (pfile, T_PRAGMA, BUF_PRAGMA, (char *) buffer, len); free ((PTR) buffer); } diff --git a/support/cpp2/cppmain.c b/support/cpp2/cppmain.c index 004aeebc..95fd2955 100644 --- a/support/cpp2/cppmain.c +++ b/support/cpp2/cppmain.c @@ -441,6 +441,11 @@ cb_def_pragma (pfile) print.lineno++; } +void +cpp_output_string (const char *s) { + fputs (s, print.outf); +} + /* Dump out the hash table. */ static int dump_macro (pfile, node, v) -- 2.47.2