]> git.gag.com Git - fw/sdcc/commitdiff
* src/SDCCicode.c (operandOperation): really fixed problem with bitops
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 25 Jul 2003 21:16:39 +0000 (21:16 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 25 Jul 2003 21:16:39 +0000 (21:16 +0000)
* support/regression/tests/bitopcse.c: added
fixed warning:
* src/avr/gen.c:
* src/pic/gen.c:
* src/pic16/gen.c:
* src/z80/gen.c:
* src/xa51/gen.c:

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2775 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCicode.c
src/avr/gen.c
src/pic/gen.c
src/pic16/gen.c
src/xa51/gen.c
src/z80/gen.c
support/regression/tests/bitopcse.c [new file with mode: 0644]

index ebbeb40ac10dbaf643d56e581cde6e166cc1e74e..b457b2f12c754ecbb082f0bc630dc148be43ac43 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2003-07-24  Bernhard Held <bernhard@bernhardheld.de>
+
+       * src/SDCCicode.c (operandOperation): really fixed problem with bitops
+       * support/regression/tests/bitopcse.c: added
+       fixed warning:
+       * src/avr/gen.c:
+       * src/pic/gen.c:
+       * src/pic16/gen.c:
+       * src/z80/gen.c:
+       * src/xa51/gen.c:
+
 2003-07-24  Jesus Calvino-Fraga <jesusc@ece.ubc.ca>
 
     added support for new library format to z80, gbz80 linkers:
@@ -38,7 +49,7 @@
 
 2003-07-20  Bernhard Held <bernhard@bernhardheld.de>
 
-        * src/pic16/glue.c: minor cleanup by Vangelis
+       * src/pic16/glue.c: minor cleanup by Vangelis
 
 2003-07-19  Frieder Ferlemann <Frieder.Ferlemann@web.de>
 
@@ -49,7 +60,7 @@
         * device/lib/_ser.c: process RX bytes earlier than TX bytes
         * device/lib/serial.c: process RX bytes earlier than TX bytes
         * src/mcs51/gen.c(genGenPointerGet/Set): removed writing of type after postincrement
-        
+
 2003-07-18  Erik Petrich <epetrich@ivorytower.norman.ok.us>
 
        * src/z80/gen.c: fixed some right shift bugs (#772726 among them)
 
 2003-07-17  Bernhard Held <bernhard@bernhardheld.de>
 
-        * device/lib/Makefile.in: bad fix, reverted to 1.43
-       
+       * device/lib/Makefile.in: bad fix, reverted to 1.43
+
 2003-07-16  Bernhard Held <bernhard@bernhardheld.de>
 
        * device/lib/Makefile.in: added missing z80 object files
 
 2003-07-14  Bernhard Held <bernhard@bernhardheld.de>
 
-        * src/SDCCcse.c (algebraicOpts): CSE fun with &|^ and 0x00/0xff literals
+       * src/SDCCcse.c (algebraicOpts): CSE fun with &|^ and 0x00/0xff literals
        pic16 progress by Vangelis:
        * src/SDCCglobl.h:
        * src/SDCCmain.c:
 2003-06-08  Jesus Calvino-Fraga <jesusc@ece.ubc.ca>
 
        * support/Util/SDCCerr.c, src/SDCCglobl.h, src/SDCCmain.c, doc/sdccman.lyx:
-       added option --vc, so sdcc errors and warnings are compatible with 
+       added option --vc, so sdcc errors and warnings are compatible with
        Microsoft Visual Studio.
 
 2003-06-07  Jesus Calvino-Fraga <jesusc@ece.ubc.ca>
 2003-05-29  Bernhard Held <bernhard@bernhardheld.de>
 
        * src/pic/device.c: added 16F819, patch by "David I. Lehn" <dlehn@vt.edu>
-       * src/SDCCcse.c (algebraicOpts): fixed "c * 1" 
+       * src/SDCCcse.c (algebraicOpts): fixed "c * 1"
 
 2003-05-28  Bernhard Held <bernhard@bernhardheld.de>
 
index e4e54e7c68ea7121a7642fdb7e7e55b646e30416..7eea91c05e319efb8672eaeb546a19939c3ceaeb 100644 (file)
@@ -1143,16 +1143,19 @@ operandOperation (operand * left, operand * right,
                               operandLitValue (right));
       break;
     case BITWISEAND:
-      retval = operandFromLit ((unsigned long)operandLitValue(left) & 
-                              (unsigned long)operandLitValue(right));
+      retval = operandFromValue (valCastLiteral (type,
+                                                 (unsigned long)operandLitValue(left) &
+                                                (unsigned long)operandLitValue(right)));
       break;
     case '|':
-      retval = operandFromLit ((unsigned long)operandLitValue (left) |
-                              (unsigned long)operandLitValue (right));
+      retval = operandFromValue (valCastLiteral (type,
+                                                 (unsigned long)operandLitValue(left) |
+                                                (unsigned long)operandLitValue(right)));
       break;
     case '^':
-      retval = operandFromLit ((unsigned long)operandLitValue (left) ^
-                              (unsigned long)operandLitValue (right));
+      retval = operandFromValue (valCastLiteral (type,
+                                                 (unsigned long)operandLitValue(left) ^
+                                                (unsigned long)operandLitValue(right)));
       break;
     case AND_OP:
       retval = operandFromLit (operandLitValue (left) &&
index 12ca14d3e0adaa3ac450422cf2bd591da15f9655..68eca463be1d66aa408c97230b59cff87579db25 100644 (file)
@@ -5095,7 +5095,7 @@ genDummyRead (iCode * ic)
   emitcode (";     genDummyRead","");
   emitcode (";     not implemented","");
 
-  ic;
+  ic = ic;
 }
 
 /*-----------------------------------------------------------------*/
index 28d5db4e1663222fc8112aba877a1cac824271d4..9979c39a4d4816033592a68a4ebd6f099b85a99a 100644 (file)
@@ -9912,7 +9912,7 @@ genDummyRead (iCode * ic)
   pic14_emitcode ("; genDummyRead","");
   pic14_emitcode ("; not implemented","");
 
-  ic;
+  ic = ic;
 }
 
 /*-----------------------------------------------------------------*/
index 35eebd89c4a0358db87a6b734875e77861824951..cf80da3c1f5357f48c60b2fa4ee539a20f97745c 100644 (file)
@@ -9972,7 +9972,7 @@ genDummyRead (iCode * ic)
   pic16_emitcode ("; genDummyRead","");
   pic16_emitcode ("; not implemented","");
 
-  ic;
+  ic = ic;
 }
 
 /*-----------------------------------------------------------------*/
index 08e68fc36810e82c694416e73f0a019ed82c6079..8a5a2b16bc54c24d1758e5d1423cc188c305f803 100755 (executable)
@@ -1896,6 +1896,8 @@ static void
 genDummyRead (iCode * ic)
 {
   emitcode (";     genDummyRead","");
+
+  ic = ic;
 }
 
 /*-----------------------------------------------------------------*/
index 127c0b20b09788c75613b9e79b2929a7116e948b..7231edf2b9ef1cf9894c46ede6d6745f1fbb0149 100644 (file)
@@ -6714,7 +6714,7 @@ genDummyRead (iCode * ic)
 {
   emit2 ("; genDummyRead not implemented");
 
-  ic;
+  ic = ic;
 }
 
 enum
diff --git a/support/regression/tests/bitopcse.c b/support/regression/tests/bitopcse.c
new file mode 100644 (file)
index 0000000..2769d0a
--- /dev/null
@@ -0,0 +1,140 @@
+/* Test CSE with |&^
+
+    type: bit, char, short, long
+ */
+#include <testfwk.h>
+
+/* This is not only a regression test, the focus of this test
+   is more on the generated code (volatile!). */
+
+
+#define _{type}
+
+#if defined(_bit)
+#  define MASK 1
+#  define idata
+#elif defined(_char)
+#  define MASK 0xff
+#elif defined(_short)
+#  define MASK 0xffff
+#elif defined(_long)
+#  define MASK 0xffffffff
+#else
+#  warn Unknow type
+#endif
+
+#if defined(PORT_HOST) || defined(SDCC_z80) || defined(SDCC_gbz80)
+# define idata
+# define code
+#endif
+
+/* the variable 'mask' is only define to see if MASK is correctly set up */
+code unsigned long mask = MASK;
+
+      volatile          {type}  v;
+      volatile unsigned {type} uv;
+/* an array would be nicer, but an array of bits isn't possible */
+idata                   {type}  a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 ,
+                               a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
+                               a20;
+idata          unsigned {type} ua0, ua1, ua2, ua3, ua4, ua5, ua6;
+idata                   {type}  b;
+idata volatile unsigned {type} ub = 0xbe;
+
+void
+testcse(void)
+{
+   b = 0xeb;
+  ub = 0xbe;
+   v = 0x33;
+  uv = 0xab;
+
+   a0   =    0 & b;
+   a1   =    0 & v;
+
+   a2   = MASK &  b;
+   a3   = MASK &  v;
+  ua0   = MASK & ub;
+  ua1   = MASK & uv;
+
+   a4   =    b & b;
+   a5   =    v & v;
+
+   a6  &= 0;
+   v   &= 0;
+   a7  &= MASK;
+   v   &= MASK;
+  ua2  &= MASK;
+  uv   &= MASK;
+
+
+   a8   =    0 | b;
+   a9   =    0 | v;
+
+   a10  = MASK |  b;
+   a11  = MASK |  v;
+  ua3   = MASK | ub;
+  ua4   = MASK | uv;
+
+   a12  =   b | b;
+   a13  =   v | v;
+
+   a14 |= 0;
+   v   |= 0;
+   a15 |= MASK;
+   v   |= MASK;
+  ua5  |= MASK;
+  uv   |= MASK;
+
+
+   a16  = 0 ^ b;
+   a17  = 0 ^ v;
+
+   a18  = b ^ b;
+   a19  = v ^ v;
+
+   a20 ^= 0;
+   v   ^= 0;
+
+   ASSERT( a0  ==  0);
+   ASSERT( a1  ==  0);
+   ASSERT( a2  ==  b);
+#if defined(_bit)
+   ASSERT( a3  == 1);
+#else
+   ASSERT( a3  == ({type}) 0x33);
+#endif
+   ASSERT(ua0  == ub);
+#if defined(_bit)
+   ASSERT(ua1  == 1);
+#else
+   ASSERT(ua1  == ({type}) 0xab);
+#endif
+   ASSERT( a4  ==  b);
+#if defined(_bit)
+   ASSERT( a5  == 1);
+#else
+   ASSERT( a5  == ({type}) 0x33);
+#endif
+   ASSERT( a6  ==  0);
+   // ASSERT( a7 == );
+   // ASSERT(ua2 == );
+   ASSERT( a8  ==  b);
+   ASSERT( a9  ==  0);
+   ASSERT( a10 == ({type}) MASK);
+   ASSERT( a11 == ({type}) MASK);
+   ASSERT(ua3  == MASK);
+   ASSERT(ua4  == MASK);
+   ASSERT( a12 ==  b);
+   ASSERT( a13 ==  0);
+   // ASSERT( a14 == );
+   ASSERT( a15 == ({type}) MASK);
+   ASSERT(ua5 == MASK);
+   ASSERT( a16 == b);
+   ASSERT( a17 == ({type}) MASK);
+   ASSERT( a18 == 0);
+   ASSERT( a19 == 0);
+   // ASSERT( a20 == );
+   ASSERT( v   == ({type}) MASK);
+   ASSERT(uv   == MASK);
+}