From: maartenbrock Date: Tue, 5 Oct 2004 10:59:23 +0000 (+0000) Subject: * src/port.h: made reset_regparms prototype void parameter explicit. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;ds=sidebyside;h=fe37b31ed6385e317511c76eb6812acf37e96d57;p=fw%2Fsdcc * src/port.h: made reset_regparms prototype void parameter explicit. * src/SDCCsymt.c (processFuncArgs): removed argument "func". * src/mcs51/ralloc.c (packRegisters): new fix for bugs 898889 & 979599. * doc/sdccman.lyx: documented warning disabling and how to use printf_large to make it print floats. * device/include/stdbool.h: NEW * device/lib/_atof.c, * device/lib/_divuint.c, * device/lib/_divulong.c, * device/lib/expf.c, * device/lib/printf_large.c, * device/lib/sincosf.c, * device/lib/sincoshf.c: used stdbool.h, all compile with stack-auto now * device/lib/Makefile.in: added target for model-mcs51-reentrant to build a completely reentrant lib. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3524 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 2e440d92..37acf3dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2004-10-05 Maarten Brock + + * src/port.h: made reset_regparms prototype void parameter explicit. + * src/SDCCsymt.c (processFuncArgs): removed argument "func". + * src/mcs51/ralloc.c (packRegisters): new fix for bugs 898889 & 979599. + * doc/sdccman.lyx: documented warning disabling and how to use + printf_large to make it print floats. + * device/include/stdbool.h: NEW + * device/lib/_atof.c, + * device/lib/_divuint.c, + * device/lib/_divulong.c, + * device/lib/expf.c, + * device/lib/printf_large.c, + * device/lib/sincosf.c, + * device/lib/sincoshf.c: used stdbool.h, all compile with stack-auto now + * device/lib/Makefile.in: added target for model-mcs51-reentrant to build + a completely reentrant lib. + 2004-10-05 Vangelis Rokas * device/lib/pic16/libsdcc/gptr/gptr*.c: added return statements @@ -23,7 +41,7 @@ * support/Util/SDCCerr.h: added warning W_POSSBUG2. * support/Util/SDCCerr.c (messages structure): added entry for W_POSSBUG2 - + Large cumulative patch for pic16 port and libraries. * device/include/pic16/sdcc-lib.h, * device/include/pic16/stdarg.h, @@ -94,7 +112,7 @@ * debugger/mcs51/cmd.c: set PC if a symbol at pc reg is set * debugger/mcs51/simi.c: addapt new syntax of s51 - + 2004-09-23 Vangelis Rokas * src/pic16/genutils.c (pic16_genNot): fixed bug #1032265, diff --git a/device/include/stdbool.h b/device/include/stdbool.h new file mode 100644 index 00000000..8b9beecd --- /dev/null +++ b/device/include/stdbool.h @@ -0,0 +1,38 @@ +/*------------------------------------------------------------------------- + stdbool.h - ANSI functions forward declarations + + Written By - Maarten Brock, sourceforge.brock@dse.nl (2004) + + 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 +-------------------------------------------------------------------------*/ + +#ifndef __SDC51_STDBOOL_H +#define __SDC51_STDBOOL_H 1 + +#define _Bool bit + +#define bool _Bool +#define true 1 +#define false 0 +#define __bool_true_false_are_defined 1 + +#if defined (SDCC_STACK_AUTO) || defined (SDCC_hc08) || defined (SDCC_z80) + //as long as bit/bool cannot be used reentrant + #define BOOL char +#else + #define BOOL bit +#endif + +#endif diff --git a/device/lib/Makefile.in b/device/lib/Makefile.in index 2a6b6f99..e8e33845 100644 --- a/device/lib/Makefile.in +++ b/device/lib/Makefile.in @@ -173,6 +173,13 @@ models: done \ fi +model-mcs51-reentrant: + if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \ + for model in $(MODELS); do \ + $(MAKE) MODELFLAGS="--model-$$model --stack-auto --int-long-reent --float-reent" PORT=reent-$$model objects; \ + done \ + fi + model-ds390: if [ "`grep ds390 ../../ports.build`" = ds390 ]; then \ $(MAKE) MODELFLAGS="-mds390" PORT=ds390 objects; \ diff --git a/device/lib/_atof.c b/device/lib/_atof.c index 63cc5082..0b897cbe 100644 --- a/device/lib/_atof.c +++ b/device/lib/_atof.c @@ -1,6 +1,6 @@ /* atof.c: converts an ASCII string to float - Copyright (C) 2003 Jesus Calvino-Fraga, jesusc@ieee.org + Copyright (C) 2003 Jesus Calvino-Fraga, jesusc@ieee.org This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -18,16 +18,13 @@ #include #include +#include float atof(char * s) { float value, fraction; char iexp; -#ifdef SDCC_mcs51 - bit sign; -#else - char sign; -#endif + BOOL sign; //Skip leading blanks while (isspace(*s)) s++; diff --git a/device/lib/_divuint.c b/device/lib/_divuint.c index 9cb36f0e..fc839c55 100644 --- a/device/lib/_divuint.c +++ b/device/lib/_divuint.c @@ -27,6 +27,8 @@ mcs51 small stack-auto */ +#include + #if !defined(SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS) # if defined(SDCC_mcs51) # if defined(SDCC_MODEL_SMALL) @@ -150,11 +152,7 @@ _divuint (unsigned int a, unsigned int b) { unsigned int reste = 0; unsigned char count = 16; - #if defined(SDCC_STACK_AUTO) || defined(SDCC_z80) - char c; - #else - bit c; - #endif + BOOL c; do { diff --git a/device/lib/_divulong.c b/device/lib/_divulong.c index 94d8e9f4..de60a849 100644 --- a/device/lib/_divulong.c +++ b/device/lib/_divulong.c @@ -27,6 +27,8 @@ mcs51 small stack-auto */ +#include + #if !defined(SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS) # if defined(SDCC_mcs51) # if defined(SDCC_MODEL_SMALL) @@ -328,11 +330,7 @@ _divulong (unsigned long a, unsigned long b) { unsigned long reste = 0L; unsigned char count = 32; - #if defined(SDCC_STACK_AUTO) || defined(SDCC_z80) - char c; - #else - bit c; - #endif + BOOL c; do { diff --git a/device/lib/expf.c b/device/lib/expf.c index d6557bc0..1bcd8145 100644 --- a/device/lib/expf.c +++ b/device/lib/expf.c @@ -1,6 +1,6 @@ /* expf.c: Computes e**x of a 32-bit float as outlined in [1] - Copyright (C) 2001, 2002 Jesus Calvino-Fraga, jesusc@ieee.org + Copyright (C) 2001, 2002 Jesus Calvino-Fraga, jesusc@ieee.org This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,6 +23,7 @@ #include #include +#include #define P0 0.2499999995E+0 #define P1 0.4160288626E-2 @@ -43,11 +44,7 @@ float expf(const float x) { int n; float xn, g, r, z, y; -#ifdef SDCC_mcs51 - bit sign; -#else - char sign; -#endif + BOOL sign; if(x>=0.0) { y=x; sign=0; } diff --git a/device/lib/printf_large.c b/device/lib/printf_large.c index d5055272..ac621e03 100644 --- a/device/lib/printf_large.c +++ b/device/lib/printf_large.c @@ -42,6 +42,7 @@ #include #include #include +#include #define PTR value.ptr @@ -62,13 +63,6 @@ //#define toupper(c) ((c)&=~0x20) #define toupper(c) ((c)&=0xDF) -#if defined (SDCC_STACK_AUTO) || defined (SDCC_hc08) - //as long as bit/bool cannot be used reentrant - #define BOOL char -#else - #define BOOL bit -#endif - typedef union { unsigned char byte[5]; @@ -86,7 +80,7 @@ static const char memory_id[] = "IXCP-"; static void* p; #ifdef ASM_ALLOWED - static bit lsd; + static bool lsd; /* this one NEEDS to be in data */ static data value_t value; diff --git a/device/lib/sincosf.c b/device/lib/sincosf.c index f3788ba0..90aca4af 100644 --- a/device/lib/sincosf.c +++ b/device/lib/sincosf.c @@ -1,6 +1,6 @@ /* sincosf.c: Computes sin or cos of a 32-bit float as outlined in [1] - Copyright (C) 2001, 2002 Jesus Calvino-Fraga, jesusc@ieee.org + Copyright (C) 2001, 2002 Jesus Calvino-Fraga, jesusc@ieee.org This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,6 +23,7 @@ #include #include +#include #define r1 -0.1666665668E+0 #define r2 0.8333025139E-2 @@ -40,11 +41,7 @@ float sincosf(const float x, const int iscos) { float y, f, r, g, XN; int N; -#ifdef SDCC_mcs51 - bit sign; -#else - char sign; -#endif + BOOL sign; if(iscos) { diff --git a/device/lib/sincoshf.c b/device/lib/sincoshf.c index 5143665d..644baf6a 100644 --- a/device/lib/sincoshf.c +++ b/device/lib/sincoshf.c @@ -1,6 +1,6 @@ /* sincoshf.c: Computes sinh or cosh of a 32-bit float as outlined in [1] - Copyright (C) 2001, 2002 Jesus Calvino-Fraga, jesusc@ieee.org + Copyright (C) 2001, 2002 Jesus Calvino-Fraga, jesusc@ieee.org This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,6 +23,7 @@ #include #include +#include #define P0 -0.713793159E+1 #define P1 -0.190333999E+0 @@ -45,12 +46,8 @@ float sincoshf(const float x, const int iscosh) { float y, w, z; -#ifdef SDCC_mcs51 - bit sign; -#else - char sign; -#endif - + BOOL sign; + if (x<0.0) { y=-x; sign=1; } else { y=x; sign=0; } diff --git a/doc/sdccman.lyx b/doc/sdccman.lyx index ae5c8cae..6ff9b92a 100644 --- a/doc/sdccman.lyx +++ b/doc/sdccman.lyx @@ -3,6 +3,7 @@ \textclass book \begin_preamble + \usepackage[ pdftitle={SDCC Compiler User Guide}, pdfauthor={SDCC development team}, @@ -7366,6 +7367,30 @@ status Collapsed \labelwidthstring 00.00.0000 +\series bold +- +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +-disable-warning\SpecialChar ~ + +\begin_inset LatexCommand \index{-\/-disable-warning} + +\end_inset + + +\series default + Disable specific warning with number . +\layout List +\labelwidthstring 00.00.0000 + + \series bold - \begin_inset ERT @@ -13671,6 +13696,62 @@ putchar() in sdcc/device/lib. \layout Standard +The default +\family typewriter + printf() +\begin_inset LatexCommand \index{printf()} + +\end_inset + + +\family default +implementation in +\family typewriter + printf_large.c +\family default + does not support float (except on ds390). + To enable this recompile it with the option +\emph on +- +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +DUSE_FLOATS=1 +\begin_inset LatexCommand \index{USE\_FLOATS} + +\end_inset + + +\emph default + on the command line. + Use +\emph on +- +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +-model-large +\begin_inset LatexCommand \index{-\/-model-large} + +\end_inset + + +\emph default + for the mcs51 port, since this uses a lot of memory. +\layout Standard + If you're short on memory you might want to use \family typewriter printf_small() @@ -13681,12 +13762,7 @@ instead \emph default of \family typewriter - printf() -\begin_inset LatexCommand \index{printf()} - -\end_inset - -. + printf(). \family default For the mcs51 there is an assembly version @@ -14151,6 +14227,14 @@ less_pedantic your own now ;-( \layout Itemize +disable_warning +\begin_inset LatexCommand \index{\#pragma disable\_warning} + +\end_inset + + - the compiler will not warn you anymore about warning number . +\layout Itemize + nogcse \begin_inset LatexCommand \index{\#pragma nogcse} diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 2b39b153..d4376dc1 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1496,7 +1496,7 @@ checkSClass (symbol * sym, int isProto) else { /* hack-o-matic! I see no reason why the useXstack option should ever - * control this allcoation, but the code was originally that way, and + * control this allocation, but the code was originally that way, and * changing it for non-390 ports breaks the compiler badly. */ bool useXdata = (TARGET_IS_DS390 || TARGET_IS_DS400) ? @@ -1566,7 +1566,6 @@ copyLinkChain (sym_link * p) return head; } - /*------------------------------------------------------------------*/ /* cleanUpBlock - cleansup the symbol table specified for all the */ /* symbols in the given block */ @@ -2470,7 +2469,8 @@ processFuncArgs (symbol * func) } /* reset regparm for the port */ - (*port->reset_regparms) ( func ); + (*port->reset_regparms) (); + /* if any of the arguments is an aggregate */ /* change it to pointer to the same type */ while (val) diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index 5ec469ba..de24507b 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -620,8 +620,6 @@ spillThis (symbol * sym) return; } - - /*-----------------------------------------------------------------*/ /* selectSpil - select a iTemp to spil : rather a simple procedure */ /*-----------------------------------------------------------------*/ @@ -2812,6 +2810,47 @@ packRegisters (eBBlock ** ebpp, int blockno) for (ic = ebp->sch; ic; ic = ic->next) { + /* Fix for bug #979599: */ + /* P0 &= ~1; */ + + /* Look for two subsequent iCodes with */ + /* iTemp := _c; */ + /* _c = iTemp & op; */ + /* and replace them by */ + /* iTemp := _c; */ + /* _c = _c & op; */ + if ((ic->op == BITWISEAND || ic->op == '|' || ic->op == '^') && + ic->prev && + ic->prev->op == '=' && + IS_ITEMP (IC_LEFT (ic)) && + IC_LEFT (ic) == IC_RESULT (ic->prev) && + isOperandEqual (IC_RESULT(ic), IC_RIGHT(ic->prev))) + { + iCode* ic_prev = ic->prev; + symbol* prev_result_sym = OP_SYMBOL (IC_RESULT (ic_prev)); + + ReplaceOpWithCheaperOp (&IC_LEFT (ic), IC_RESULT (ic)); + if (IC_RESULT (ic_prev) != IC_RIGHT (ic)) + { + bitVectUnSetBit (OP_USES (IC_RESULT (ic_prev)), ic->key); + if (/*IS_ITEMP (IC_RESULT (ic_prev)) && */ + prev_result_sym->liveTo == ic->seq) + { + prev_result_sym->liveTo = ic_prev->seq; + } + } + bitVectSetBit (OP_USES (IC_RESULT (ic)), ic->key); + + bitVectSetBit (ic->rlive, IC_RESULT (ic)->key); + + if (bitVectIsZero (OP_USES (IC_RESULT (ic_prev)))) + { + bitVectUnSetBit (ic->rlive, IC_RESULT (ic)->key); + bitVectUnSetBit (OP_DEFS (IC_RESULT (ic_prev)), ic_prev->key); + remiCodeFromeBBlock (ebp, ic_prev); + hTabDeleteItem (&iCodehTab, ic_prev->key, ic_prev, DELETE_ITEM, NULL); + } + } /* if this is an itemp & result of an address of a true sym then mark this as rematerialisable */ @@ -2980,8 +3019,8 @@ packRegisters (eBBlock ** ebpp, int blockno) packRegsForOneuse (ic, IC_LEFT (ic), ebp); - /* if this is cast for intergral promotion then - check if only use of the definition of the + /* if this is a cast for intergral promotion then + check if it's the only use of the definition of the operand being casted/ if yes then replace the result of that arithmetic operation with this result and get rid of the cast */ diff --git a/src/port.h b/src/port.h index 778d67b4..58cb554f 100644 --- a/src/port.h +++ b/src/port.h @@ -272,7 +272,7 @@ typedef struct void (*genInitStartup) (FILE * of); /* parameter passing in register related functions */ - void (*reset_regparms) (); /* reset the register count */ + void (*reset_regparms) (void); /* reset the register count */ int (*reg_parm) (struct sym_link *); /* will return 1 if can be passed in register */ /** Process the pragma string 'sz'. Returns 0 if recognised and