From 51da61d71d46c2b96789bb6f536c48b83964e138 Mon Sep 17 00:00:00 2001 From: bernhardheld Date: Fri, 25 Jul 2003 21:16:39 +0000 Subject: [PATCH] * 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: git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2775 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 25 +++-- src/SDCCicode.c | 15 +-- src/avr/gen.c | 2 +- src/pic/gen.c | 2 +- src/pic16/gen.c | 2 +- src/xa51/gen.c | 2 + src/z80/gen.c | 2 +- support/regression/tests/bitopcse.c | 140 ++++++++++++++++++++++++++++ 8 files changed, 173 insertions(+), 17 deletions(-) create mode 100644 support/regression/tests/bitopcse.c diff --git a/ChangeLog b/ChangeLog index ebbeb40a..b457b2f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-07-24 Bernhard Held + + * 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 added support for new library format to z80, gbz80 linkers: @@ -38,7 +49,7 @@ 2003-07-20 Bernhard Held - * src/pic16/glue.c: minor cleanup by Vangelis + * src/pic16/glue.c: minor cleanup by Vangelis 2003-07-19 Frieder Ferlemann @@ -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 * src/z80/gen.c: fixed some right shift bugs (#772726 among them) @@ -60,15 +71,15 @@ 2003-07-17 Bernhard Held - * 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 * device/lib/Makefile.in: added missing z80 object files 2003-07-14 Bernhard Held - * 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: @@ -201,7 +212,7 @@ 2003-06-08 Jesus Calvino-Fraga * 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 @@ -232,7 +243,7 @@ 2003-05-29 Bernhard Held * src/pic/device.c: added 16F819, patch by "David I. Lehn" - * src/SDCCcse.c (algebraicOpts): fixed "c * 1" + * src/SDCCcse.c (algebraicOpts): fixed "c * 1" 2003-05-28 Bernhard Held diff --git a/src/SDCCicode.c b/src/SDCCicode.c index e4e54e7c..7eea91c0 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -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) && diff --git a/src/avr/gen.c b/src/avr/gen.c index 12ca14d3..68eca463 100644 --- a/src/avr/gen.c +++ b/src/avr/gen.c @@ -5095,7 +5095,7 @@ genDummyRead (iCode * ic) emitcode ("; genDummyRead",""); emitcode ("; not implemented",""); - ic; + ic = ic; } /*-----------------------------------------------------------------*/ diff --git a/src/pic/gen.c b/src/pic/gen.c index 28d5db4e..9979c39a 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -9912,7 +9912,7 @@ genDummyRead (iCode * ic) pic14_emitcode ("; genDummyRead",""); pic14_emitcode ("; not implemented",""); - ic; + ic = ic; } /*-----------------------------------------------------------------*/ diff --git a/src/pic16/gen.c b/src/pic16/gen.c index 35eebd89..cf80da3c 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -9972,7 +9972,7 @@ genDummyRead (iCode * ic) pic16_emitcode ("; genDummyRead",""); pic16_emitcode ("; not implemented",""); - ic; + ic = ic; } /*-----------------------------------------------------------------*/ diff --git a/src/xa51/gen.c b/src/xa51/gen.c index 08e68fc3..8a5a2b16 100755 --- a/src/xa51/gen.c +++ b/src/xa51/gen.c @@ -1896,6 +1896,8 @@ static void genDummyRead (iCode * ic) { emitcode ("; genDummyRead",""); + + ic = ic; } /*-----------------------------------------------------------------*/ diff --git a/src/z80/gen.c b/src/z80/gen.c index 127c0b20..7231edf2 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -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 index 00000000..2769d0a2 --- /dev/null +++ b/support/regression/tests/bitopcse.c @@ -0,0 +1,140 @@ +/* Test CSE with |&^ + + type: bit, char, short, long + */ +#include + +/* 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); +} -- 2.30.2