From 0b44824662442b40830512786321baa59f2d3a97 Mon Sep 17 00:00:00 2001 From: michaelh Date: Sat, 2 Mar 2002 03:40:54 +0000 Subject: [PATCH] * src/SDCCsymt.c (initCSupport): Removed managling of support function names. * src/z80/ralloc.c (packRegsForIYUse): Fixed fp bug where four byte operands were packed into IY. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1967 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 6 ++++ src/SDCCsymt.c | 4 +-- src/z80/ralloc.c | 6 ++++ support/regression/tests/bug-477835.c | 31 ++++++++++++++++ support/regression/tests/bug-499644.c | 10 ++++++ support/regression/tests/bug-500536.c | 52 +++++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 support/regression/tests/bug-477835.c create mode 100644 support/regression/tests/bug-499644.c create mode 100644 support/regression/tests/bug-500536.c diff --git a/ChangeLog b/ChangeLog index 2eb3e842..62817d17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-03-01 Michael Hope + + * src/SDCCsymt.c (initCSupport): Removed managling of support function names. + + * src/z80/ralloc.c (packRegsForIYUse): Fixed fp bug where four byte operands were packed into IY. + 2002-03-01 * src/SDCCglue.c (printIvalPtr): fixed bug #524211 diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 7ffa31be..09611d19 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -2540,12 +2540,12 @@ initCSupport () if (tofrom) { sprintf (buffer, "__fs2%s%s", ssu[su], sbwd[bwd]); - __conv[tofrom][bwd][su] = funcOfType (_mangleFunctionName(buffer), __multypes[bwd][su], floatType, 1, options.float_rent); + __conv[tofrom][bwd][su] = funcOfType (buffer, __multypes[bwd][su], floatType, 1, options.float_rent); } else { sprintf (buffer, "__%s%s2fs", ssu[su], sbwd[bwd]); - __conv[tofrom][bwd][su] = funcOfType (_mangleFunctionName(buffer), floatType, __multypes[bwd][su], 1, options.float_rent); + __conv[tofrom][bwd][su] = funcOfType (buffer, floatType, __multypes[bwd][su], 1, options.float_rent); } } } diff --git a/src/z80/ralloc.c b/src/z80/ralloc.c index d73acaa0..6e97b1da 100644 --- a/src/z80/ralloc.c +++ b/src/z80/ralloc.c @@ -2442,6 +2442,12 @@ packRegsForIYUse (iCode * lic, operand * op, eBBlock * ebp) return NULL; } + if (getSize (operandType (op)) != 2) + { + D (D_ACCUSE2, (" + Dropping as operation has size is too big\n")); + return FALSE; + } + /* Nothing else that clashes with this is using the scratch register. Scan through all of the intermediate instructions and see if any of them could nuke HL. diff --git a/support/regression/tests/bug-477835.c b/support/regression/tests/bug-477835.c new file mode 100644 index 00000000..294b4198 --- /dev/null +++ b/support/regression/tests/bug-477835.c @@ -0,0 +1,31 @@ +/* Registers not being saved. + */ +#include + +/* In the following code BC is assigned a copy of fp, but bc is not + saved across the call. +*/ +void +fptr(void (*fp)(void)) +{ + int i; + for (i = 0; i < 50; i++) + (*fp)(); +} + +void dummy(void (*fp)(void)) +{ + UNUSED(fp); +} + +/* This code has the same logic above, but bc is saved. + */ +void +fptr2(void (*fp)(void)) +{ + int i; + void (*fp2)(void) = fp; + + for (i = 0; i < 50; i++) + dummy(fp2); +} diff --git a/support/regression/tests/bug-499644.c b/support/regression/tests/bug-499644.c new file mode 100644 index 00000000..bec16114 --- /dev/null +++ b/support/regression/tests/bug-499644.c @@ -0,0 +1,10 @@ +/* Floats + */ +#include + +const float a = 0.0; + +float f(void) +{ + return a * 5; +} diff --git a/support/regression/tests/bug-500536.c b/support/regression/tests/bug-500536.c new file mode 100644 index 00000000..bd3945da --- /dev/null +++ b/support/regression/tests/bug-500536.c @@ -0,0 +1,52 @@ +/* Bad mangaling of support names. + */ +#include + +/* The original bug */ +float z1(void) +{ + return 5; +} + +float fun( void ) +{ + unsigned long i; + float f; + i=5.5 * z1(); + f=i; + if (i & 1) + f += 1.0; + return f; +} + +/* Tests to check basic conversion */ +void +testfs2long(void) +{ + volatile float f; + volatile unsigned long ul; + volatile long l; + + f = 5.0; + ul = f; + ASSERT(ul == 5); + + l = f; + ASSERT(l == 5); + + f = -134; + l = f; + ASSERT(l == -134); + + l = 4567; + f = l; + ASSERT(f == 4567.0); + + l = -1539; + f = l; + ASSERT(f == -1539.0); + + ul = 9995; + f = ul; + ASSERT(f == 9995.0); +} -- 2.30.2