From 38a121fe1ef6d45686ebe7a07e71eadcba5145b9 Mon Sep 17 00:00:00 2001 From: tecodev Date: Fri, 21 Jan 2005 10:45:54 +0000 Subject: [PATCH] * device/lib/Makefile.in: fixed test for pic16 install dir * device/lib/pic16/*/Makefile*: modified compile flags to enable optimizations * doc/sdccman.lyx: updated banksel optimization, removed --flr-support and added --optimize-goto compiler switch and pragma wparam documentation * src/pic16/pcode.c (pic16_OptimizeBanksel): removed statistics dump * src/pic16/pcodepeep.c (pic16_pCodeOpCopy): fixed copying of WREG, PRODL and PRODH closing bug #1071770 (peephole optimizer) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3642 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 11 +++++++ device/lib/Makefile.in | 3 +- device/lib/pic16/Makefile | 1 + device/lib/pic16/debug/Makefile.rules | 2 +- device/lib/pic16/libc/Makefile.rules | 2 +- device/lib/pic16/libc/ctype/Makefile | 2 +- device/lib/pic16/libc/stdlib/Makefile | 2 +- device/lib/pic16/libc/string/Makefile | 2 +- device/lib/pic16/libc/utils/Makefile | 2 +- device/lib/pic16/libdev/Makefile | 2 +- device/lib/pic16/libio/Makefile.rules | 2 +- device/lib/pic16/libio/adc/Makefile | 2 +- device/lib/pic16/libsdcc/Makefile.rules | 2 +- device/lib/pic16/libsdcc/float/Makefile | 2 +- device/lib/pic16/startup/Makefile | 2 +- doc/sdccman.lyx | 40 +++++++++++++++++++++++-- src/pic16/pcode.c | 4 +-- src/pic16/pcodepeep.c | 9 ++++-- 18 files changed, 71 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 72426368..823e3be0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-01-21 Raphael Neider + + * device/lib/Makefile.in: fixed test for pic16 install dir + * device/lib/pic16/*/Makefile*: modified compile flags to enable + optimizations + * doc/sdccman.lyx: updated banksel optimization, removed --flr-support and + added --optimize-goto compiler switch and pragma wparam documentation + * src/pic16/pcode.c (pic16_OptimizeBanksel): removed statistics dump + * src/pic16/pcodepeep.c (pic16_pCodeOpCopy): fixed copying of WREG, PRODL + and PRODH closing bug #1071770 (peephole optimizer) + 2005-01-19 Raphael Neider * src/SDCCglobl.h: ensure that PATH_MAX >= 2048 to guarantee diff --git a/device/lib/Makefile.in b/device/lib/Makefile.in index 9a662a9f..0c89b270 100644 --- a/device/lib/Makefile.in +++ b/device/lib/Makefile.in @@ -166,6 +166,7 @@ include incl.mk all: checkconf models model-ds390 model-ds400 model-z80 model-gbz80 model-hc08 # model-pic16 +# (needs gputils curently not available of sourceforge's compile farm) objects: build-dir $(OBJECTS) port-specific-objects lib-files clean_intermediate @@ -297,7 +298,7 @@ installdirs: [ -d $(sdcc_libdir)/ds390 ] || mkdir -p $(sdcc_libdir)/ds390 [ -d $(sdcc_libdir)/ds400 ] || mkdir -p $(sdcc_libdir)/ds400 [ -d $(sdcc_libdir)/hc08 ] || mkdir -p $(sdcc_libdir)/hc08 - [ -f $(sdcc_libdir)/pic16 ] || mkdir -p $(sdcc_libdir)/pic16 + [ -d $(sdcc_libdir)/pic16 ] || mkdir -p $(sdcc_libdir)/pic16 mkdir -p $(sdcc_libdir)/src # Creating dependencies diff --git a/device/lib/pic16/Makefile b/device/lib/pic16/Makefile index 1592f580..fee486ad 100644 --- a/device/lib/pic16/Makefile +++ b/device/lib/pic16/Makefile @@ -17,6 +17,7 @@ include ./Makefile.common DIRS = libdev \ libsdcc \ + libc \ startup \ debug diff --git a/device/lib/pic16/debug/Makefile.rules b/device/lib/pic16/debug/Makefile.rules index 3faf7275..82548825 100644 --- a/device/lib/pic16/debug/Makefile.rules +++ b/device/lib/pic16/debug/Makefile.rules @@ -19,7 +19,7 @@ PRJDIR = ../../../../.. LIBC_INC_DIR = $(PRJDIR)/device/include/pic16 -COMPILE_FLAGS += $(MODELFLAGS) --pomit-config-words --pomit-ivt --no-peep --i-code-in-asm +COMPILE_FLAGS += $(MODELFLAGS) --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2 --i-code-in-asm CFLAGS = --nostdinc -I$(LIBC_INC_DIR) CFILES = $(patsubst %,%.c,$(SRCS)) diff --git a/device/lib/pic16/libc/Makefile.rules b/device/lib/pic16/libc/Makefile.rules index 4e11eb3a..b54bc579 100644 --- a/device/lib/pic16/libc/Makefile.rules +++ b/device/lib/pic16/libc/Makefile.rules @@ -18,7 +18,7 @@ PRJDIR = ../../../../.. LIBC_INC_DIR = $(PRJDIR)/device/include/pic16 -COMPILE_FLAGS += $(MODELFLAGS) --pomit-config-words --pomit-ivt --no-peep --i-code-in-asm +COMPILE_FLAGS += $(MODELFLAGS) --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2 --i-code-in-asm CFLAGS = -I$(LIBC_INC_DIR) CFILES = $(patsubst %,%.c,$(SRCS)) diff --git a/device/lib/pic16/libc/ctype/Makefile b/device/lib/pic16/libc/ctype/Makefile index e8160f82..19a7382d 100644 --- a/device/lib/pic16/libc/ctype/Makefile +++ b/device/lib/pic16/libc/ctype/Makefile @@ -29,7 +29,7 @@ OFILES = $(patsubst %.c,%.o,$(CFILES)) DEBUG= -#COMPILE_FLAGS += --pomit-config-words --pomit-ivt --no-peep +#COMPILE_FLAGS += --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2 COMPILE_FLAGS += $(DEBUG) CFILES = $(patsubst %,%.c,$(SRCS)) diff --git a/device/lib/pic16/libc/stdlib/Makefile b/device/lib/pic16/libc/stdlib/Makefile index e0bc36fd..cb2da82d 100644 --- a/device/lib/pic16/libc/stdlib/Makefile +++ b/device/lib/pic16/libc/stdlib/Makefile @@ -29,7 +29,7 @@ OFILES = $(patsubst %.c,%.o,$(CFILES)) DEBUG= -#COMPILE_FLAGS += --pomit-config-words --pomit-ivt --no-peep +#COMPILE_FLAGS += --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2 COMPILE_FLAGS += $(DEBUG) CFILES = $(patsubst %,%.c,$(SRCS)) diff --git a/device/lib/pic16/libc/string/Makefile b/device/lib/pic16/libc/string/Makefile index 93b5c504..4ce5b8a0 100644 --- a/device/lib/pic16/libc/string/Makefile +++ b/device/lib/pic16/libc/string/Makefile @@ -47,7 +47,7 @@ OFILES = $(patsubst %.c,%.o,$(CFILES)) DEBUG= -#COMPILE_FLAGS += --pomit-config-words --pomit-ivt --no-peep +#COMPILE_FLAGS += --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2 COMPILE_FLAGS += $(DEBUG) CFILES = $(patsubst %,%.c,$(SRCS)) diff --git a/device/lib/pic16/libc/utils/Makefile b/device/lib/pic16/libc/utils/Makefile index cd68f02b..258f7c92 100644 --- a/device/lib/pic16/libc/utils/Makefile +++ b/device/lib/pic16/libc/utils/Makefile @@ -46,7 +46,7 @@ OFILES = $(COFILES) OFILES += $(SOFILES) DEBUG= -#COMPILE_FLAGS += --pomit-config-words --pomit-ivt --no-peep +#COMPILE_FLAGS += --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2 COMPILE_FLAGS += $(DEBUG) %.o: %.c diff --git a/device/lib/pic16/libdev/Makefile b/device/lib/pic16/libdev/Makefile index f0c2f073..3d504a63 100644 --- a/device/lib/pic16/libdev/Makefile +++ b/device/lib/pic16/libdev/Makefile @@ -46,7 +46,7 @@ PIC16_INCDIR = $(INCDIR)/pic16 CFLAGS = -I$(PIC16_INCDIR) -#COMPILE_FLAGS = --pomit-config-words --pomit-ivt --no-peep +#COMPILE_FLAGS = --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2 COMPILE_FLAGS += $(MODELFLAGS) --nostdinc diff --git a/device/lib/pic16/libio/Makefile.rules b/device/lib/pic16/libio/Makefile.rules index c571aaf2..4a8e9fbe 100644 --- a/device/lib/pic16/libio/Makefile.rules +++ b/device/lib/pic16/libio/Makefile.rules @@ -18,7 +18,7 @@ PRJDIR = ../../../../.. LIBC_INC_DIR = $(PRJDIR)/device/include/pic16 -COMPILE_FLAGS += $(MODELFLAGS) --pomit-config-words --pomit-ivt --no-peep --i-code-in-asm +COMPILE_FLAGS += $(MODELFLAGS) --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2 --i-code-in-asm CFLAGS = -I$(LIBC_INC_DIR) CFILES = $(patsubst %,%.c,$(SRCS)) diff --git a/device/lib/pic16/libio/adc/Makefile b/device/lib/pic16/libio/adc/Makefile index 03db167a..f83358bf 100644 --- a/device/lib/pic16/libio/adc/Makefile +++ b/device/lib/pic16/libio/adc/Makefile @@ -26,7 +26,7 @@ OFILES = $(patsubst %.c,%.o,$(CFILES)) DEBUG= -#COMPILE_FLAGS += --pomit-config-words --pomit-ivt --no-peep +#COMPILE_FLAGS += --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2 COMPILE_FLAGS += $(DEBUG) CFILES = $(patsubst %,%.c,$(SRCS)) diff --git a/device/lib/pic16/libsdcc/Makefile.rules b/device/lib/pic16/libsdcc/Makefile.rules index bf5f42fd..eba686d7 100644 --- a/device/lib/pic16/libsdcc/Makefile.rules +++ b/device/lib/pic16/libsdcc/Makefile.rules @@ -19,7 +19,7 @@ PRJDIR = ../../../../.. LIBC_INC_DIR = $(PRJDIR)/device/include/pic16 -COMPILE_FLAGS += $(MODELFLAGS) --pomit-config-words --pomit-ivt --no-peep --i-code-in-asm +COMPILE_FLAGS += $(MODELFLAGS) --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2 --i-code-in-asm CFLAGS = --nostdinc -I$(LIBC_INC_DIR) CFILES = $(patsubst %,%.c,$(SRCS)) diff --git a/device/lib/pic16/libsdcc/float/Makefile b/device/lib/pic16/libsdcc/float/Makefile index 58fb3f87..917bac8d 100644 --- a/device/lib/pic16/libsdcc/float/Makefile +++ b/device/lib/pic16/libsdcc/float/Makefile @@ -35,7 +35,7 @@ SRCS = fs2schar \ uint2fs \ ulong2fs -COMPILE_FLAGS += --obanksel=9 +#COMPILE_FLAGS += --obanksel=9 include ../Makefile.rules diff --git a/device/lib/pic16/startup/Makefile b/device/lib/pic16/startup/Makefile index f13ee80d..bd266eb5 100644 --- a/device/lib/pic16/startup/Makefile +++ b/device/lib/pic16/startup/Makefile @@ -22,7 +22,7 @@ SRCS = crt0 \ # add nostdinc and nostdlib for this device libraries -COMPILE_FLAGS += --no-peep --pomit-config-words --pomit-ivt +COMPILE_FLAGS += --denable-peeps --optimize-goto --obanksel=2 --pomit-config-words --pomit-ivt COMPILE_FLAGS += $(MODELFLAGS) --nostdinc --nostdlib CFILES = $(patsubst %,%.c,$(SRCS)) diff --git a/doc/sdccman.lyx b/doc/sdccman.lyx index 0e5c14bb..752113ca 100644 --- a/doc/sdccman.lyx +++ b/doc/sdccman.lyx @@ -15406,8 +15406,15 @@ status Collapsed \layout List \labelwidthstring 00.00.0000 -1 checkes previous used register and if it is the same then doesn't emit +1 checks previous used register and if it is the same then does not emit BANKSEL, accounts only for labels. +\layout List +\labelwidthstring 00.00.0000 + +2 tries to check the location of (even different) symbols and removes BANKSELs + if they are in the same bank. + Important: This will only work properly if the linker script does not have + sections across bank borders! \end_deeper \layout List \labelwidthstring 00.00.0000 @@ -15627,8 +15634,7 @@ status Collapsed / \end_inset --flr-support When entering/leaving a function, call support functions to - store/restore used registers +-optimize-goto Try to use (conditional) BRA instead of GOTO \layout Subsubsection Debugging Options @@ -15961,6 +15967,34 @@ Example: \layout List \labelwidthstring 00.00.0000 +wparam use the WREG to pass one byte of the first function argument. + This improves speed but you may not use this for functions with arguments + that are called via function pointers, otherwise one byte of the first + parameter will get lost. + This pragma should be placed in the header file to propagate the calling + convention to all callers. +\layout LyX-Code + +#pragma wparam function1[, function2, ...] +\layout LyX-Code + +\layout LyX-Code + +Example: +\layout LyX-Code + +\layout LyX-Code + +/* pass one byte via stack and one byte via WREG */ +\layout LyX-Code + +#pragma wparam foo +\layout LyX-Code + +void foo(int x); +\layout List +\labelwidthstring 00.00.0000 + code place a function symbol at static FLASH address \layout LyX-Code diff --git a/src/pic16/pcode.c b/src/pic16/pcode.c index 7d04d89d..98854b6b 100644 --- a/src/pic16/pcode.c +++ b/src/pic16/pcode.c @@ -9148,7 +9148,7 @@ void pic16_OptimizeBanksel () } // while if (maxWeight > 0) { -#if 1 +#if 0 fprintf (stderr, "%s:%d: merging (%4u) %d(%s) and %d(%s)\n", __FUNCTION__, __LINE__, maxWeight, max->src->hash, getSymFromBank (max->src->hash), max->node->hash, getSymFromBank (max->node->hash)); @@ -9188,7 +9188,7 @@ void pic16_OptimizeBanksel () #endif deleteGraph (adj); - fprintf (stderr, "%s:%s:%d: leaving, %u/%u BANKSELs removed...\n", __FILE__, __FUNCTION__, __LINE__, bankselsRemoved, bankselsTotal); + //fprintf (stderr, "%s:%s:%d: leaving, %u/%u BANKSELs removed...\n", __FILE__, __FUNCTION__, __LINE__, bankselsRemoved, bankselsTotal); } /*** END of stuff belonging to the BANKSEL optimization ***/ diff --git a/src/pic16/pcodepeep.c b/src/pic16/pcodepeep.c index dbd3558a..ecd6e11d 100644 --- a/src/pic16/pcodepeep.c +++ b/src/pic16/pcodepeep.c @@ -2243,6 +2243,9 @@ pCodeOp *pic16_pCodeOpCopy(pCodeOp *pcop) case PO_GPR_TEMP: case PO_FSR0: case PO_INDF0: + case PO_WREG: // moved from below + case PO_PRODL: // moved from below + case PO_PRODH: // moved from below //DFPRINTF((stderr,"pCodeOpCopy GPR register\n")); pcopnew = Safe_calloc(1,sizeof(pCodeOpReg) ); PCOR(pcopnew)->r = PCOR(pcop)->r; @@ -2266,13 +2269,13 @@ pCodeOp *pic16_pCodeOpCopy(pCodeOp *pcop) case PO_STR: case PO_NONE: case PO_W: - case PO_WREG: + //case PO_WREG: // moved up case PO_INTCON: case PO_PCL: case PO_PCLATH: case PO_PCLATU: - case PO_PRODL: - case PO_PRODH: + //case PO_PRODL: // moved up + //case PO_PRODH: // moved up case PO_REL_ADDR: //DFPRINTF((stderr,"pCodeOpCopy register type %d\n", pcop->type)); pcopnew = Safe_calloc(1,sizeof(pCodeOp) ); -- 2.47.2