* src/port.h: made reset_regparms prototype void parameter explicit.
authormaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 5 Oct 2004 10:59:23 +0000 (10:59 +0000)
committermaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 5 Oct 2004 10:59:23 +0000 (10:59 +0000)
* 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

14 files changed:
ChangeLog
device/include/stdbool.h [new file with mode: 0644]
device/lib/Makefile.in
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
doc/sdccman.lyx
src/SDCCsymt.c
src/mcs51/ralloc.c
src/port.h

index 2e440d923ca5d6a6915214c7d124bc2e5f215db1..37acf3dc5e5a3564d7000d35f19db8fcf55fe924 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2004-10-05 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * 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 <vrokas AT otenet.gr>
 
        * 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,
 
        * 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 <vrokas AT otenet.gr>
 
        * 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 (file)
index 0000000..8b9beec
--- /dev/null
@@ -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
index 2a6b6f9995efd8e14168517fa9add0db5053f5ad..e8e33845b0716c5dbc5341faf171f7f1a5df53c7 100644 (file)
@@ -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; \
index 63cc5082e23a455f097315e47657f7f932acfbef..0b897cbe29cd69fed79bc89584b44651ec722f73 100644 (file)
@@ -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
 
 #include <ctype.h>
 #include <stdlib.h>
+#include <stdbool.h>
 
 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++;
index 9cb36f0e69df2aef9bc6a2f095dbd4eed3185a0f..fc839c55da71a9d504c1263845a089bf20912d2d 100644 (file)
@@ -27,6 +27,8 @@
      mcs51 small stack-auto
 */
 
+#include <stdbool.h>
+
 #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
   {
index 94d8e9f403852ed0fc7f9d7de4182480dfdf7002..de60a849e2b27b87667c5e25ee11f39c731d26e6 100644 (file)
@@ -27,6 +27,8 @@
      mcs51 small stack-auto
 */
 
+#include <stdbool.h>
+
 #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
   {
index d6557bc0a138a640958655fa50383f8570a1bd9a..1bcd8145cb93007b1d882d3c3206e3ac83ba875f 100644 (file)
@@ -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 <math.h>
 #include <errno.h>
+#include <stdbool.h>
 
 #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; }
index d50552725c61ecf0ffecb3c4293a0d1907304e81..ac621e036baef50e235a34e4c2bc2a6840b5d24e 100644 (file)
@@ -42,6 +42,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <stdio.h>
+#include <stdbool.h>
 
 #define PTR value.ptr
 
 //#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;
index f3788ba0b9e241fb41198d935ff4b1e18005395c..90aca4af8077556c221c0e6cb5e444236da7d481 100644 (file)
@@ -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 <math.h>
 #include <errno.h>
+#include <stdbool.h>
 
 #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)
     {
index 5143665d48e3846cff7e9f4702c67da917b21959..644baf6a5134e28d58317f34661cfd7aa145def5 100644 (file)
@@ -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 <math.h>
 #include <errno.h>
+#include <stdbool.h>
 
 #define P0 -0.713793159E+1
 #define P1 -0.190333999E+0
 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; }
 
index ae5c8cae4da7094caf504d06930682019fee4dab..6ff9b92ad933ebb25d8ee57c16b872afda5a2278 100644 (file)
@@ -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 ~
+<nnnn>
+\begin_inset LatexCommand \index{-\/-disable-warning}
+
+\end_inset 
+
+
+\series default 
+ Disable specific warning with number <nnnn>.
+\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 <nnnn>
+\begin_inset LatexCommand \index{\#pragma disable\_warning}
+
+\end_inset 
+
+ - the compiler will not warn you anymore about warning number <nnnn>.
+\layout Itemize
+
 nogcse
 \begin_inset LatexCommand \index{\#pragma nogcse}
 
index 2b39b153e9054a3622716090650a8adba568692e..d4376dc18fca08d19ed211c1b8cff96e57e5c4d5 100644 (file)
@@ -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)
index 5ec469bab7a86bc72b1b541145d1393d8ed58151..de24507bba53c5034ce91b6f0dba32fd7bcc7fb1 100644 (file)
@@ -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 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 */
index 778d67b4ccbadd2a0c451b4a5ef8c9e2f11ae134..58cb554f81383a8d9320233893beccf5807d7894 100644 (file)
@@ -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