This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix float-unsigned long conversion on h8300 (revised)
- To: gcc-patches at gcc dot gnu dot org
- Subject: [patch] Fix float-unsigned long conversion on h8300 (revised)
- From: Kazu Hirata <kazu at hxi dot com>
Hi,
Attached is a patch to fix conversion from float to unsigned long on
the h8300 port.
Without the patch, due to the -DDI=SI thing in t-h8300, a wrong
function, namely __fixunssfDI in libgcc2.c, is used as __fixunssfsi.
We would want to use __fixunssfsi in libgcc2.c, but it also has a
problem. The return type of the function is in unsigned HImode even
though the function is supposed to convert a float to unsigned SImode.
The patch fixes this problem by defining fixunssfsi in
LIB2FUNCS_EXTRA. To prevent the inclusion of fixunssfsi and
fixunssfdi from libgcc2.c, I added those to LIB1ASMFUNCS.
With the patch, execute/980605-1.c and execute/gofast.c pass.
Tested on the branch and the mainline. OK to apply?
This patch obsoletes
http://gcc.gnu.org/ml/gcc-patches/2001-07/msg01530.html
p.s.
I don't know how to present a new file in the form of a patch, so I
simply appended it at the end of this message.
Thanks,
Kazu Hirata
2001-08-29 Kazu Hirata <kazu@hxi.com>
* config/h8300/h8300-fixunssfsi: New.
* config/h8300/t-h8300 (LIB1ASMFUNCS): Add _fixunssfsi and
_fixunssfdi.
(LIB2FUNCS_EXTRA): New.
Index: t-h8300
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/t-h8300,v
retrieving revision 1.7
diff -u -r1.7 t-h8300
--- t-h8300 2001/07/09 22:05:44 1.7
+++ t-h8300 2001/08/29 14:17:32
@@ -1,9 +1,16 @@
+# The floating point functions listed in LIB1ASMFUNCS (_fixunssfsi,
+# _fixunssfdi, _floatdisf, and _fixsfdi) are used to disable the
+# inclusion of those from libgcc2.c. They do not actually exist in
+# lib1funcs.asm.
LIB1ASMSRC = h8300/lib1funcs.asm
LIB1ASMFUNCS = _cmpsi2 _ucmpsi2 _divhi3 _divsi3 _mulhi3 _mulsi3 \
- _floatdisf _fixsfdi
+ _fixunssfsi _fixunssfdi _floatdisf _fixsfdi
# We do not have DF or DI types, so fake out the libgcc2 compilation.
TARGET_LIBGCC2_CFLAGS = -DDF=SF -DDI=SI
+
+# fixunssfsi from libgcc2.c has a wrong return type, so use our own.
+LIB2FUNCS_EXTRA = $(srcdir)/config/h8300/h8300-fixunssfsi.c
# We want fine grained libraries, so use the new code to build the
# floating point emulation libraries.
gcc/config/h8300/h8300-fixunssfi.c
===================================================================
typedef int SItype __attribute__ ((mode (SI)));
typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef float SFtype __attribute__ ((mode (SF)));
#define Wtype SItype
#define UWtype USItype
#define Wtype_MAX ((Wtype) 0x7fffffffL)
#define Wtype_MIN (- Wtype_MAX - 1)
UWtype
__fixunssfsi (SFtype a)
{
if (a >= - (SFtype) Wtype_MIN)
return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
return (Wtype) a;
}