On Fri, Sep 3, 2021 at 5:01 PM Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Fri, Sep 03, 2021 at 03:41:13PM +0800, liuhongt via Gcc-patches wrote: > > --- a/libgcc/config/i386/64/t-softfp > > +++ b/libgcc/config/i386/64/t-softfp > > @@ -1 +1,6 @@ > > softfp_extras := fixhfti fixunshfti floattihf floatuntihf > > + > > +CFLAGS-fixhfti.c += -msse2 > > +CFLAGS-fixunshfti.c += -msse2 > > +CFLAGS-floattihf.c += -msse2 > > +CFLAGS-floatunstihf.c += -msse2 > > \ No newline at end of file > > Please avoid this. > Changed. > > --- a/libgcc/config/i386/t-softfp > > +++ b/libgcc/config/i386/t-softfp > > @@ -1,6 +1,38 @@ > > LIB2ADD += $(srcdir)/config/i386/sfp-exceptions.c > > > > +# Replace _divhc3 and _mulhc3. > > +libgcc2-hf-functions = _divhc3 _mulhc3 > > +LIB2FUNCS_EXCLUDE += $(libgcc2-hf-functions) > > +libgcc2-hf-extras = $(addsuffix .c, $(libgcc2-hf-functions)) > > +LIB2ADD_ST += $(addprefix $(srcdir)/config/i386/, $(libgcc2-hf-extras)) > > + > > softfp_extensions := hfsf hfdf hftf hfxf sfdf sftf dftf xftf > > softfp_truncations := tfhf xfhf dfhf sfhf tfsf dfsf tfdf tfxf > > > > -softfp_extras += eqhf2 > > \ No newline at end of file > > +softfp_extras += eqhf2 > > + > > +CFLAGS-extendhfsf2.c += -msse2 > > +CFLAGS-extendhfdf2.c += -msse2 > > +CFLAGS-extendhftf2.c += -msse2 > > +CFLAGS-extendhfxf2.c += -msse2 > > + > > +CFLAGS-extendsfdf2.c += -msse2 > > +CFLAGS-extendsftf2.c += -msse2 > > + > > +CFLAGS-extenddftf2.c += -msse2 > > +CFLAGS-extendxftf2.c += -msse2 > > Aren't the [sdxt]f<->[sdxt]f extend/trunc conversions in libgcc for > quite a while? If so, using -msse2 for those seems wrong, it is fine > if we require -msse2 support for anything that uses HF or HC mode > types, but if just trying to convert other types it should work even on > just i386 or i486. Yes, removed. > > > + > > +CFLAGS-truncsfhf2.c += -msse2 > > +CFLAGS-truncdfhf2.c += -msse2 > > +CFLAGS-truncxfhf2.c += -msse2 > > +CFLAGS-trunctfhf2.c += -msse2 > > + > > +CFLAGS-truncdfsf2.c += -msse2 > > +CFLAGS-trunctfsf2.c += -msse2 > > + > > +CFLAGS-trunctfdf2.c += -msse2 > > +CFLAGS-trunctfxf2.c += -msse2 > > + > > +CFLAGS-eqhf2.c += -msse2 > > +CFLAGS-_divhc3.c += -msse2 > > +CFLAGS-_mulhc3.c += -msse2 > > \ No newline at end of file > > See above. Changed. > > Also, shouldn't the *hf* and *hc* APIs be exported from libgcc_s.so.1? > > 254: 0000000000011960 968 FUNC LOCAL DEFAULT 13 __floattihf > 256: 00000000000116f0 315 FUNC LOCAL DEFAULT 13 __fixhfti > 263: 000000000000f950 1358 FUNC LOCAL DEFAULT 13 __truncsfhf2 > 264: 000000000000db10 272 FUNC LOCAL DEFAULT 13 __extendhfsf2 > 265: 000000000000df70 399 FUNC LOCAL DEFAULT 13 __extendhfxf2 > 267: 0000000000011fe0 469 FUNC LOCAL DEFAULT 13 __eqhf2 > 268: 0000000000011d30 681 FUNC LOCAL DEFAULT 13 __floatuntihf > 271: 000000000000dc20 374 FUNC LOCAL DEFAULT 13 __extendhfdf2 > 274: 0000000000011830 292 FUNC LOCAL DEFAULT 13 __fixunshfti > 281: 000000000000dda0 460 FUNC LOCAL DEFAULT 13 __extendhftf2 > 283: 000000000000e860 1439 FUNC LOCAL DEFAULT 13 __trunctfhf2 > 285: 0000000000011fe0 469 FUNC LOCAL DEFAULT 13 __nehf2 > 286: 0000000000006290 1627 FUNC LOCAL DEFAULT 13 __divhc3 > 290: 000000000000ee00 1499 FUNC LOCAL DEFAULT 13 __truncxfhf2 > 292: 000000000000f3e0 1392 FUNC LOCAL DEFAULT 13 __truncdfhf2 > 296: 0000000000005150 1931 FUNC LOCAL DEFAULT 13 __mulhc3 > > So, don't we want GCC_12.0 with those symbols > in config/i386/libgcc-glibc.ver and perhaps others? > > Jakub >
Here is an updated patch. -- BR, Hongtao
From 6a5c7de52269b44222d8b6909827513125264dee Mon Sep 17 00:00:00 2001 From: liuhongt <hongtao....@intel.com> Date: Fri, 3 Sep 2021 13:06:57 +0800 Subject: [PATCH v2] Explicitly add -msse2 to compile HF related libgcc source file. For 32-bit libgcc configure w/o sse2, there's would be an error since GCC only support _Float16 under sse2. Explicitly add -msse2 for those HF related libgcc functions, so users can still link them w/ the upper configuration. libgcc/ChangeLog: * Makefile.in: Adjust to support specific CFLAGS for each libgcc source file. * config/i386/64/t-softfp: Explicitly add -msse2 for HF related libgcc source files. * config/i386/t-softfp: Ditto. * config/i386/_divhc3.c: New file. * config/i386/_mulhc3.c: New file. --- libgcc/Makefile.in | 2 +- libgcc/config/i386/64/t-softfp | 5 +++++ libgcc/config/i386/_divhc3.c | 4 ++++ libgcc/config/i386/_mulhc3.c | 4 ++++ libgcc/config/i386/t-softfp | 22 +++++++++++++++++++++- 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 libgcc/config/i386/_divhc3.c create mode 100644 libgcc/config/i386/_mulhc3.c diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index 7ec97584554..32e329f7764 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -314,7 +314,7 @@ MULTIOSSUBDIR := $(shell if test $(MULTIOSDIR) != .; then echo /$(MULTIOSDIR); f inst_libdir = $(libsubdir)$(MULTISUBDIR) inst_slibdir = $(slibdir)$(MULTIOSSUBDIR) -gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS) +gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS) $(CFLAGS-$(<F)) compile_deps = -MT $@ -MD -MP -MF $(basename $@).dep gcc_compile = $(gcc_compile_bare) -o $@ $(compile_deps) gcc_s_compile = $(gcc_compile) -DSHARED diff --git a/libgcc/config/i386/64/t-softfp b/libgcc/config/i386/64/t-softfp index f9d8b3a945c..3bec464d786 100644 --- a/libgcc/config/i386/64/t-softfp +++ b/libgcc/config/i386/64/t-softfp @@ -1 +1,6 @@ softfp_extras := fixhfti fixunshfti floattihf floatuntihf + +CFLAGS-fixhfti.c += -msse2 +CFLAGS-fixunshfti.c += -msse2 +CFLAGS-floattihf.c += -msse2 +CFLAGS-floatunstihf.c += -msse2 diff --git a/libgcc/config/i386/_divhc3.c b/libgcc/config/i386/_divhc3.c new file mode 100644 index 00000000000..4cf92aa23d9 --- /dev/null +++ b/libgcc/config/i386/_divhc3.c @@ -0,0 +1,4 @@ +#ifdef __SSE2__ +#define L_divhc3 +#include "libgcc2.c" +#endif diff --git a/libgcc/config/i386/_mulhc3.c b/libgcc/config/i386/_mulhc3.c new file mode 100644 index 00000000000..85a8a2f5fb7 --- /dev/null +++ b/libgcc/config/i386/_mulhc3.c @@ -0,0 +1,4 @@ +#ifdef __SSE2__ +#define L_mulhc3 +#include "libgcc2.c" +#endif diff --git a/libgcc/config/i386/t-softfp b/libgcc/config/i386/t-softfp index 4ac214eb0ce..2363ea17194 100644 --- a/libgcc/config/i386/t-softfp +++ b/libgcc/config/i386/t-softfp @@ -1,6 +1,26 @@ LIB2ADD += $(srcdir)/config/i386/sfp-exceptions.c +# Replace _divhc3 and _mulhc3. +libgcc2-hf-functions = _divhc3 _mulhc3 +LIB2FUNCS_EXCLUDE += $(libgcc2-hf-functions) +libgcc2-hf-extras = $(addsuffix .c, $(libgcc2-hf-functions)) +LIB2ADD_ST += $(addprefix $(srcdir)/config/i386/, $(libgcc2-hf-extras)) + softfp_extensions := hfsf hfdf hftf hfxf sfdf sftf dftf xftf softfp_truncations := tfhf xfhf dfhf sfhf tfsf dfsf tfdf tfxf -softfp_extras += eqhf2 \ No newline at end of file +softfp_extras += eqhf2 + +CFLAGS-extendhfsf2.c += -msse2 +CFLAGS-extendhfdf2.c += -msse2 +CFLAGS-extendhftf2.c += -msse2 +CFLAGS-extendhfxf2.c += -msse2 + +CFLAGS-truncsfhf2.c += -msse2 +CFLAGS-truncdfhf2.c += -msse2 +CFLAGS-truncxfhf2.c += -msse2 +CFLAGS-trunctfhf2.c += -msse2 + +CFLAGS-eqhf2.c += -msse2 +CFLAGS-_divhc3.c += -msse2 +CFLAGS-_mulhc3.c += -msse2 -- 2.18.1