* [PATCH 0/1] LoongArch: Add soft float support @ 2022-08-30 11:02 caiyinyu 2022-08-30 11:02 ` [PATCH 1/1] " caiyinyu 0 siblings, 1 reply; 5+ messages in thread From: caiyinyu @ 2022-08-30 11:02 UTC (permalink / raw) To: adhemerval.zanella, libc-alpha, joseph_myers, carlos, i.swmail, xry111 Cc: xuchenghua, caiyinyu Tested on LoongArch machine: gcc 12.0.1, Linux kernel 5.19.0 rc5, binutils 2.39[2] and all passed besides ifunc related tests. UNSUPPORTED: assert/tst-assert-c++ UNSUPPORTED: assert/tst-assert-g++ UNSUPPORTED: crypt/cert UNSUPPORTED: debug/tst-fortify-cc-default-1 UNSUPPORTED: debug/tst-fortify-cc-default-2 UNSUPPORTED: debug/tst-fortify-cc-default-3 UNSUPPORTED: debug/tst-fortify-cc-lfs-1 UNSUPPORTED: debug/tst-fortify-cc-lfs-2 UNSUPPORTED: debug/tst-fortify-cc-lfs-3 UNSUPPORTED: debug/tst-fortify-cc-nongnu-1 UNSUPPORTED: debug/tst-fortify-cc-nongnu-2 UNSUPPORTED: debug/tst-fortify-cc-nongnu-3 UNSUPPORTED: dlfcn/bug-atexit3 UNSUPPORTED: elf/tst-env-setuid UNSUPPORTED: elf/tst-env-setuid-tunables XPASS: elf/tst-protected1a XPASS: elf/tst-protected1b UNSUPPORTED: elf/tst-valgrind-smoke UNSUPPORTED: math/test-fesetexcept-traps UNSUPPORTED: math/test-fexcept-traps UNSUPPORTED: math/test-nearbyint-except UNSUPPORTED: math/test-nearbyint-except-2 UNSUPPORTED: misc/tst-adjtimex UNSUPPORTED: misc/tst-clock_adjtime UNSUPPORTED: misc/tst-ntp_adjtime UNSUPPORTED: misc/tst-pkey UNSUPPORTED: misc/tst-rseq UNSUPPORTED: misc/tst-rseq-disable UNSUPPORTED: nptl/test-cond-printers UNSUPPORTED: nptl/test-condattr-printers UNSUPPORTED: nptl/test-mutex-printers UNSUPPORTED: nptl/test-mutexattr-printers UNSUPPORTED: nptl/test-rwlock-printers UNSUPPORTED: nptl/test-rwlockattr-printers UNSUPPORTED: nptl/tst-cancel24 UNSUPPORTED: nptl/tst-cancel24-static UNSUPPORTED: nptl/tst-minstack-throw UNSUPPORTED: nptl/tst-once5 UNSUPPORTED: nptl/tst-rseq-nptl UNSUPPORTED: nptl/tst-thread-exit-clobber UNSUPPORTED: nptl/tst-thread_local1 UNSUPPORTED: resolv/tst-resolv-ai_idn UNSUPPORTED: resolv/tst-resolv-ai_idn-latin1 UNSUPPORTED: stdlib/tst-quick_exit UNSUPPORTED: stdlib/tst-secure-getenv UNSUPPORTED: stdlib/tst-thread-quick_exit UNSUPPORTED: time/tst-clock_settime UNSUPPORTED: time/tst-settimeofday Summary of test results: 4466 PASS 46 UNSUPPORTED 16 XFAIL 2 XPASS caiyinyu (1): LoongArch: Add soft float support. scripts/build-many-glibcs.py | 4 ++ sysdeps/loongarch/Makefile | 8 --- sysdeps/loongarch/__longjmp.S | 2 + sysdeps/loongarch/bits/setjmp.h | 3 ++ sysdeps/loongarch/dl-trampoline.S | 11 +++- sysdeps/loongarch/fpu_control.h | 13 +++++ sysdeps/loongarch/nofpu/Implies | 1 + .../loongarch/nofpu/math-tests-exceptions.h | 28 ++++++++++ sysdeps/loongarch/nofpu/math-tests-rounding.h | 27 ++++++++++ sysdeps/loongarch/preconfigure | 1 - sysdeps/loongarch/preconfigure.ac | 1 - sysdeps/loongarch/setjmp.S | 2 + sysdeps/unix/sysv/linux/loongarch/Makefile | 9 ++++ sysdeps/unix/sysv/linux/loongarch/configure | 51 +++++++++++++++++-- .../unix/sysv/linux/loongarch/configure.ac | 22 ++++++-- .../unix/sysv/linux/loongarch/ldd-rewrite.sed | 2 +- .../unix/sysv/linux/loongarch/shlib-versions | 2 + 17 files changed, 168 insertions(+), 19 deletions(-) create mode 100644 sysdeps/loongarch/nofpu/Implies create mode 100644 sysdeps/loongarch/nofpu/math-tests-exceptions.h create mode 100644 sysdeps/loongarch/nofpu/math-tests-rounding.h -- 2.31.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1] LoongArch: Add soft float support. 2022-08-30 11:02 [PATCH 0/1] LoongArch: Add soft float support caiyinyu @ 2022-08-30 11:02 ` caiyinyu 2022-08-30 13:00 ` Adhemerval Zanella Netto 0 siblings, 1 reply; 5+ messages in thread From: caiyinyu @ 2022-08-30 11:02 UTC (permalink / raw) To: adhemerval.zanella, libc-alpha, joseph_myers, carlos, i.swmail, xry111 Cc: xuchenghua, caiyinyu --- scripts/build-many-glibcs.py | 4 ++ sysdeps/loongarch/Makefile | 8 --- sysdeps/loongarch/__longjmp.S | 2 + sysdeps/loongarch/bits/setjmp.h | 3 ++ sysdeps/loongarch/dl-trampoline.S | 11 +++- sysdeps/loongarch/fpu_control.h | 13 +++++ sysdeps/loongarch/nofpu/Implies | 1 + .../loongarch/nofpu/math-tests-exceptions.h | 28 ++++++++++ sysdeps/loongarch/nofpu/math-tests-rounding.h | 27 ++++++++++ sysdeps/loongarch/preconfigure | 1 - sysdeps/loongarch/preconfigure.ac | 1 - sysdeps/loongarch/setjmp.S | 2 + sysdeps/unix/sysv/linux/loongarch/Makefile | 9 ++++ sysdeps/unix/sysv/linux/loongarch/configure | 51 +++++++++++++++++-- .../unix/sysv/linux/loongarch/configure.ac | 22 ++++++-- .../unix/sysv/linux/loongarch/ldd-rewrite.sed | 2 +- .../unix/sysv/linux/loongarch/shlib-versions | 2 + 17 files changed, 168 insertions(+), 19 deletions(-) create mode 100644 sysdeps/loongarch/nofpu/Implies create mode 100644 sysdeps/loongarch/nofpu/math-tests-exceptions.h create mode 100644 sysdeps/loongarch/nofpu/math-tests-rounding.h diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py index 98f02104a2..db632b18a3 100755 --- a/scripts/build-many-glibcs.py +++ b/scripts/build-many-glibcs.py @@ -222,6 +222,10 @@ class Context(object): os_name='linux-gnu', variant='lp64d', gcc_cfg=['--with-abi=lp64d','--disable-multilib']) + self.add_config(arch='loongarch64', + os_name='linux-gnu', + variant='lp64s', + gcc_cfg=['--with-abi=lp64s','--disable-multilib']) self.add_config(arch='m68k', os_name='linux-gnu', gcc_cfg=['--disable-multilib']) diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile index 41c3449670..746d4c2c8f 100644 --- a/sysdeps/loongarch/Makefile +++ b/sysdeps/loongarch/Makefile @@ -5,11 +5,3 @@ endif # LoongArch's assembler also needs to know about PIC as it changes the # definition of some assembler macros. ASFLAGS-.os += $(pic-ccflag) - -abi-variants := lp64 - -ifeq (,$(filter $(default-abi),$(abi-variants))) -$(error Unknown ABI $(default-abi), must be one of $(abi-variants)) -endif - -abi-lp64-condition := defined __loongarch_lp64 diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S index 4207376f5e..d6a99fcbc8 100644 --- a/sysdeps/loongarch/__longjmp.S +++ b/sysdeps/loongarch/__longjmp.S @@ -41,6 +41,7 @@ ENTRY (__longjmp) REG_L s7, a0, 11*SZREG REG_L s8, a0, 12*SZREG +#ifndef __loongarch_soft_float FREG_L $f24, a0, 13*SZREG + 0*SZFREG FREG_L $f25, a0, 13*SZREG + 1*SZFREG FREG_L $f26, a0, 13*SZREG + 2*SZFREG @@ -49,6 +50,7 @@ ENTRY (__longjmp) FREG_L $f29, a0, 13*SZREG + 5*SZFREG FREG_L $f30, a0, 13*SZREG + 6*SZFREG FREG_L $f31, a0, 13*SZREG + 7*SZFREG +#endif sltui a0,a1,1 ADD a0, a0, a1 # a0 = (a1 == 0) ? 1 : a1 diff --git a/sysdeps/loongarch/bits/setjmp.h b/sysdeps/loongarch/bits/setjmp.h index 42f8fa7657..8b323ad2b6 100644 --- a/sysdeps/loongarch/bits/setjmp.h +++ b/sysdeps/loongarch/bits/setjmp.h @@ -31,8 +31,11 @@ typedef struct __jmp_buf_internal_tag long int __fp; /* Callee-saved registers. */ long int __regs[9]; + +#ifndef __loongarch_soft_float /* Callee-saved floating point registers. */ double __fpregs[8]; +#endif } __jmp_buf[1]; diff --git a/sysdeps/loongarch/dl-trampoline.S b/sysdeps/loongarch/dl-trampoline.S index ad8ab0fda7..9a8f580971 100644 --- a/sysdeps/loongarch/dl-trampoline.S +++ b/sysdeps/loongarch/dl-trampoline.S @@ -21,8 +21,11 @@ /* Assembler veneer called from the PLT header code for lazy loading. The PLT header passes its own args in t0-t2. */ - -# define FRAME_SIZE (-((-10 * SZREG - 8 * SZFREG) & ALMASK)) +#ifdef __loongarch_soft_float +#define FRAME_SIZE (-((-10 * SZREG) & ALMASK)) +#else +#define FRAME_SIZE (-((-10 * SZREG - 8 * SZFREG) & ALMASK)) +#endif ENTRY (_dl_runtime_resolve) @@ -39,6 +42,7 @@ ENTRY (_dl_runtime_resolve) REG_S a6, sp, 7*SZREG REG_S a7, sp, 8*SZREG +#ifndef __loongarch_soft_float FREG_S fa0, sp, 10*SZREG + 0*SZFREG FREG_S fa1, sp, 10*SZREG + 1*SZFREG FREG_S fa2, sp, 10*SZREG + 2*SZFREG @@ -47,6 +51,7 @@ ENTRY (_dl_runtime_resolve) FREG_S fa5, sp, 10*SZREG + 5*SZFREG FREG_S fa6, sp, 10*SZREG + 6*SZFREG FREG_S fa7, sp, 10*SZREG + 7*SZFREG +#endif /* Update .got.plt and obtain runtime address of callee */ SLLI a1, t1, 1 @@ -67,6 +72,7 @@ ENTRY (_dl_runtime_resolve) REG_L a6, sp, 7*SZREG REG_L a7, sp, 8*SZREG +#ifndef __loongarch_soft_float FREG_L fa0, sp, 10*SZREG + 0*SZFREG FREG_L fa1, sp, 10*SZREG + 1*SZFREG FREG_L fa2, sp, 10*SZREG + 2*SZFREG @@ -75,6 +81,7 @@ ENTRY (_dl_runtime_resolve) FREG_L fa5, sp, 10*SZREG + 5*SZFREG FREG_L fa6, sp, 10*SZREG + 6*SZFREG FREG_L fa7, sp, 10*SZREG + 7*SZFREG +#endif ADDI sp, sp, FRAME_SIZE diff --git a/sysdeps/loongarch/fpu_control.h b/sysdeps/loongarch/fpu_control.h index 1cccc933a5..f482395dba 100644 --- a/sysdeps/loongarch/fpu_control.h +++ b/sysdeps/loongarch/fpu_control.h @@ -51,6 +51,17 @@ #include <features.h> +#ifdef __loongarch_soft_float + +#define _FPU_RESERVED 0xffffffff +#define _FPU_DEFAULT 0x00000000 +typedef unsigned int fpu_control_t; +#define _FPU_GETCW(cw) (cw) = 0 +#define _FPU_SETCW(cw) (void) (cw) +extern fpu_control_t __fpu_control; + +#else /* __loongarch_soft_float */ + /* Masks for interrupts. */ #define _FPU_MASK_V 0x10 /* Invalid operation */ #define _FPU_MASK_Z 0x08 /* Division by zero */ @@ -86,4 +97,6 @@ extern void __loongarch_fpu_setcw (fpu_control_t) __THROW; /* Default control word set at startup. */ extern fpu_control_t __fpu_control; +#endif /* __loongarch_soft_float */ + #endif /* fpu_control.h */ diff --git a/sysdeps/loongarch/nofpu/Implies b/sysdeps/loongarch/nofpu/Implies new file mode 100644 index 0000000000..abcbadb25f --- /dev/null +++ b/sysdeps/loongarch/nofpu/Implies @@ -0,0 +1 @@ +ieee754/soft-fp diff --git a/sysdeps/loongarch/nofpu/math-tests-exceptions.h b/sysdeps/loongarch/nofpu/math-tests-exceptions.h new file mode 100644 index 0000000000..b22bb01d0e --- /dev/null +++ b/sysdeps/loongarch/nofpu/math-tests-exceptions.h @@ -0,0 +1,28 @@ +/* Configuration for math tests: support for exceptions. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef LOONGARCH_NOFPU_MATH_TESTS_EXCEPTIONS_H +#define LOONGARCH_NOFPU_MATH_TESTS_EXCEPTIONS_H 1 + +/* We support setting floating-point exception flags on hard-float + targets. These are not supported on soft-float targets. */ +#define EXCEPTION_TESTS_float 0 +#define EXCEPTION_TESTS_double 0 +#define EXCEPTION_TESTS_long_double 0 + +#endif /* math-tests-exceptions.h. */ diff --git a/sysdeps/loongarch/nofpu/math-tests-rounding.h b/sysdeps/loongarch/nofpu/math-tests-rounding.h new file mode 100644 index 0000000000..5322e481b9 --- /dev/null +++ b/sysdeps/loongarch/nofpu/math-tests-rounding.h @@ -0,0 +1,27 @@ +/* Configuration for math tests: rounding mode support. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef LOONGARCH_NOFPU_MATH_TESTS_ROUNDING_H +#define LOONGARCH_NOFPU_MATH_TESTS_ROUNDING_H 1 + +/* On soft-float targets we only support the "to nearest" rounding mode. */ +#define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST) +#define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST) +#define ROUNDING_TESTS_long_double(MODE) ((MODE) == FE_TONEAREST) + +#endif /* math-tests-rounding.h. */ diff --git a/sysdeps/loongarch/preconfigure b/sysdeps/loongarch/preconfigure index 118963cda6..f2d1a0d87b 100644 --- a/sysdeps/loongarch/preconfigure +++ b/sysdeps/loongarch/preconfigure @@ -12,7 +12,6 @@ loongarch*) case "$float_abi" in soft) abi_flen=0 - as_fn_error 1 "loongarch does not yet support soft floating-point ABI!!" "$LINENO" 5 ;; single) as_fn_error 1 "glibc does not yet support the single floating-point ABI!!" "$LINENO" 5 diff --git a/sysdeps/loongarch/preconfigure.ac b/sysdeps/loongarch/preconfigure.ac index 1aba743c15..67e4357013 100644 --- a/sysdeps/loongarch/preconfigure.ac +++ b/sysdeps/loongarch/preconfigure.ac @@ -12,7 +12,6 @@ loongarch*) case "$float_abi" in soft) abi_flen=0 - AC_MSG_ERROR([loongarch does not yet support soft floating-point ABI!!], 1) ;; single) AC_MSG_ERROR([glibc does not yet support the single floating-point ABI!!], 1) diff --git a/sysdeps/loongarch/setjmp.S b/sysdeps/loongarch/setjmp.S index 298bb02a82..9b1cdea48c 100644 --- a/sysdeps/loongarch/setjmp.S +++ b/sysdeps/loongarch/setjmp.S @@ -50,6 +50,7 @@ ENTRY (__sigsetjmp) REG_S s7, a0, 11*SZREG REG_S s8, a0, 12*SZREG +#ifndef __loongarch_soft_float FREG_S $f24, a0, 13*SZREG + 0*SZFREG FREG_S $f25, a0, 13*SZREG + 1*SZFREG FREG_S $f26, a0, 13*SZREG + 2*SZFREG @@ -58,6 +59,7 @@ ENTRY (__sigsetjmp) FREG_S $f29, a0, 13*SZREG + 5*SZFREG FREG_S $f30, a0, 13*SZREG + 6*SZFREG FREG_S $f31, a0, 13*SZREG + 7*SZFREG +#endif #if !IS_IN (libc) && IS_IN(rtld) li.w v0, 0 diff --git a/sysdeps/unix/sysv/linux/loongarch/Makefile b/sysdeps/unix/sysv/linux/loongarch/Makefile index 91bd35800a..c84a1762ed 100644 --- a/sysdeps/unix/sysv/linux/loongarch/Makefile +++ b/sysdeps/unix/sysv/linux/loongarch/Makefile @@ -1,3 +1,12 @@ ifeq ($(subdir),stdlib) gen-as-const-headers += ucontext_i.sym endif + +abi-variants := lp64s lp64d + +ifeq (,$(filter $(default-abi),$(abi-variants))) +$(error Unknown ABI $(default-abi), must be one of $(abi-variants)) +endif + +abi-lp64s-condition := __WORDSIZE == 64 && defined __loongarch_soft_float +abi-lp64d-condition := __WORDSIZE == 64 && defined __loongarch_double_float diff --git a/sysdeps/unix/sysv/linux/loongarch/configure b/sysdeps/unix/sysv/linux/loongarch/configure index 60a410303e..28216c165e 100644 --- a/sysdeps/unix/sysv/linux/loongarch/configure +++ b/sysdeps/unix/sysv/linux/loongarch/configure @@ -151,11 +151,56 @@ if test $libc_cv_loongarch_int_abi = no; then as_fn_error $? "Unable to determine integer ABI" "$LINENO" 5 fi +libc_cv_loongarch_float_abi=no +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __loongarch_double_float + yes + #endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + libc_cv_loongarch_float_abi=d +fi +rm -f conftest* + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __loongarch_soft_float + yes + #endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + libc_cv_loongarch_float_abi=s +fi +rm -f conftest* + +if test "$libc_cv_loongarch_float_abi" = no; then + as_fn_error $? "Unable to determine floating-point ABI" "$LINENO" 5 +fi + config_vars="$config_vars -default-abi = $libc_cv_loongarch_int_abi" +default-abi = $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi" -case $libc_cv_loongarch_int_abi in -lp64) +case $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi in +lp64s) + test -n "$libc_cv_slibdir" || +case "$prefix" in +/usr | /usr/) + libc_cv_slibdir='/lib64/sf' + libc_cv_rtlddir='/lib64' + if test "$libdir" = '${exec_prefix}/lib'; then + libdir='${exec_prefix}/lib64/sf'; + # Locale data can be shared between 32-bit and 64-bit libraries. + libc_cv_complocaledir='${exec_prefix}/lib/locale' + fi + ;; +esac + ;; +lp64d) test -n "$libc_cv_slibdir" || case "$prefix" in /usr | /usr/) diff --git a/sysdeps/unix/sysv/linux/loongarch/configure.ac b/sysdeps/unix/sysv/linux/loongarch/configure.ac index 7de1e95ff6..04e9150a9b 100644 --- a/sysdeps/unix/sysv/linux/loongarch/configure.ac +++ b/sysdeps/unix/sysv/linux/loongarch/configure.ac @@ -11,10 +11,26 @@ if test $libc_cv_loongarch_int_abi = no; then AC_MSG_ERROR([Unable to determine integer ABI]) fi -LIBC_CONFIG_VAR([default-abi], [$libc_cv_loongarch_int_abi]) +libc_cv_loongarch_float_abi=no +AC_EGREP_CPP(yes, [#ifdef __loongarch_double_float + yes + #endif + ],libc_cv_loongarch_float_abi=d) +AC_EGREP_CPP(yes, [#ifdef __loongarch_soft_float + yes + #endif + ],libc_cv_loongarch_float_abi=s) +if test "$libc_cv_loongarch_float_abi" = no; then + AC_MSG_ERROR([Unable to determine floating-point ABI]) +fi + +LIBC_CONFIG_VAR([default-abi], [$libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi]) -case $libc_cv_loongarch_int_abi in -lp64) +case $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi in +lp64s) + LIBC_SLIBDIR_RTLDDIR([lib64/sf], [lib64]) + ;; +lp64d) LIBC_SLIBDIR_RTLDDIR([lib64], [lib64]) ;; esac diff --git a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed index f8976fd239..cdbe5c3dc5 100644 --- a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed +++ b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed @@ -1 +1 @@ -s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|32\)\(/[^/]*\)\(-loongarch\)\(64\|32\)\(\.so\.[0-9.]*\)[[:blank:]]*$_\1"\2\4\7 \264\4-loongarch64\7 \232\4-loongarch32\7"_ +s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|32\)\(/ld-linux-loongarch-\)\(lp\|ilp\)\(64\|32\)\(d\|s\)\(\.so\.[0-9.]*\)[[:blank:]]*$_\1"\264\4lp64d\8 \264\4lp64s\8"_ diff --git a/sysdeps/unix/sysv/linux/loongarch/shlib-versions b/sysdeps/unix/sysv/linux/loongarch/shlib-versions index dc2220b4be..5f40e7f5ec 100644 --- a/sysdeps/unix/sysv/linux/loongarch/shlib-versions +++ b/sysdeps/unix/sysv/linux/loongarch/shlib-versions @@ -2,6 +2,8 @@ DEFAULT GLIBC_2.36 %if LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 64 ld=ld-linux-loongarch-lp64d.so.1 +%elif LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 0 +ld=ld-linux-loongarch-lp64s.so.1 %else %error cannot determine ABI %endif -- 2.31.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] LoongArch: Add soft float support. 2022-08-30 11:02 ` [PATCH 1/1] " caiyinyu @ 2022-08-30 13:00 ` Adhemerval Zanella Netto 2022-08-31 12:00 ` caiyinyu 0 siblings, 1 reply; 5+ messages in thread From: Adhemerval Zanella Netto @ 2022-08-30 13:00 UTC (permalink / raw) To: caiyinyu, libc-alpha, joseph_myers, carlos, i.swmail, xry111; +Cc: xuchenghua On 30/08/22 08:02, caiyinyu wrote: > --- > scripts/build-many-glibcs.py | 4 ++ > sysdeps/loongarch/Makefile | 8 --- > sysdeps/loongarch/__longjmp.S | 2 + > sysdeps/loongarch/bits/setjmp.h | 3 ++ > sysdeps/loongarch/dl-trampoline.S | 11 +++- > sysdeps/loongarch/fpu_control.h | 13 +++++ > sysdeps/loongarch/nofpu/Implies | 1 + > .../loongarch/nofpu/math-tests-exceptions.h | 28 ++++++++++ > sysdeps/loongarch/nofpu/math-tests-rounding.h | 27 ++++++++++ > sysdeps/loongarch/preconfigure | 1 - > sysdeps/loongarch/preconfigure.ac | 1 - > sysdeps/loongarch/setjmp.S | 2 + > sysdeps/unix/sysv/linux/loongarch/Makefile | 9 ++++ > sysdeps/unix/sysv/linux/loongarch/configure | 51 +++++++++++++++++-- > .../unix/sysv/linux/loongarch/configure.ac | 22 ++++++-- > .../unix/sysv/linux/loongarch/ldd-rewrite.sed | 2 +- > .../unix/sysv/linux/loongarch/shlib-versions | 2 + > 17 files changed, 168 insertions(+), 19 deletions(-) > create mode 100644 sysdeps/loongarch/nofpu/Implies > create mode 100644 sysdeps/loongarch/nofpu/math-tests-exceptions.h > create mode 100644 sysdeps/loongarch/nofpu/math-tests-rounding.h > > diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py > index 98f02104a2..db632b18a3 100755 > --- a/scripts/build-many-glibcs.py > +++ b/scripts/build-many-glibcs.py > @@ -222,6 +222,10 @@ class Context(object): > os_name='linux-gnu', > variant='lp64d', > gcc_cfg=['--with-abi=lp64d','--disable-multilib']) > + self.add_config(arch='loongarch64', > + os_name='linux-gnu', > + variant='lp64s', > + gcc_cfg=['--with-abi=lp64s','--disable-multilib']) > self.add_config(arch='m68k', > os_name='linux-gnu', > gcc_cfg=['--disable-multilib']) > diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile > index 41c3449670..746d4c2c8f 100644 > --- a/sysdeps/loongarch/Makefile > +++ b/sysdeps/loongarch/Makefile > @@ -5,11 +5,3 @@ endif > # LoongArch's assembler also needs to know about PIC as it changes the > # definition of some assembler macros. > ASFLAGS-.os += $(pic-ccflag) > - > -abi-variants := lp64 > - > -ifeq (,$(filter $(default-abi),$(abi-variants))) > -$(error Unknown ABI $(default-abi), must be one of $(abi-variants)) > -endif > - > -abi-lp64-condition := defined __loongarch_lp64 Why move this to be Linux specific? It won't matter in the end though. The rest looks ok. > diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S > index 4207376f5e..d6a99fcbc8 100644 > --- a/sysdeps/loongarch/__longjmp.S > +++ b/sysdeps/loongarch/__longjmp.S > @@ -41,6 +41,7 @@ ENTRY (__longjmp) > REG_L s7, a0, 11*SZREG > REG_L s8, a0, 12*SZREG > > +#ifndef __loongarch_soft_float > FREG_L $f24, a0, 13*SZREG + 0*SZFREG > FREG_L $f25, a0, 13*SZREG + 1*SZFREG > FREG_L $f26, a0, 13*SZREG + 2*SZFREG > @@ -49,6 +50,7 @@ ENTRY (__longjmp) > FREG_L $f29, a0, 13*SZREG + 5*SZFREG > FREG_L $f30, a0, 13*SZREG + 6*SZFREG > FREG_L $f31, a0, 13*SZREG + 7*SZFREG > +#endif > > sltui a0,a1,1 > ADD a0, a0, a1 # a0 = (a1 == 0) ? 1 : a1 > diff --git a/sysdeps/loongarch/bits/setjmp.h b/sysdeps/loongarch/bits/setjmp.h > index 42f8fa7657..8b323ad2b6 100644 > --- a/sysdeps/loongarch/bits/setjmp.h > +++ b/sysdeps/loongarch/bits/setjmp.h > @@ -31,8 +31,11 @@ typedef struct __jmp_buf_internal_tag > long int __fp; > /* Callee-saved registers. */ > long int __regs[9]; > + > +#ifndef __loongarch_soft_float > /* Callee-saved floating point registers. */ > double __fpregs[8]; > +#endif > > } __jmp_buf[1]; > > diff --git a/sysdeps/loongarch/dl-trampoline.S b/sysdeps/loongarch/dl-trampoline.S > index ad8ab0fda7..9a8f580971 100644 > --- a/sysdeps/loongarch/dl-trampoline.S > +++ b/sysdeps/loongarch/dl-trampoline.S > @@ -21,8 +21,11 @@ > > /* Assembler veneer called from the PLT header code for lazy loading. > The PLT header passes its own args in t0-t2. */ > - > -# define FRAME_SIZE (-((-10 * SZREG - 8 * SZFREG) & ALMASK)) > +#ifdef __loongarch_soft_float > +#define FRAME_SIZE (-((-10 * SZREG) & ALMASK)) > +#else > +#define FRAME_SIZE (-((-10 * SZREG - 8 * SZFREG) & ALMASK)) > +#endif > > ENTRY (_dl_runtime_resolve) > > @@ -39,6 +42,7 @@ ENTRY (_dl_runtime_resolve) > REG_S a6, sp, 7*SZREG > REG_S a7, sp, 8*SZREG > > +#ifndef __loongarch_soft_float > FREG_S fa0, sp, 10*SZREG + 0*SZFREG > FREG_S fa1, sp, 10*SZREG + 1*SZFREG > FREG_S fa2, sp, 10*SZREG + 2*SZFREG > @@ -47,6 +51,7 @@ ENTRY (_dl_runtime_resolve) > FREG_S fa5, sp, 10*SZREG + 5*SZFREG > FREG_S fa6, sp, 10*SZREG + 6*SZFREG > FREG_S fa7, sp, 10*SZREG + 7*SZFREG > +#endif > > /* Update .got.plt and obtain runtime address of callee */ > SLLI a1, t1, 1 > @@ -67,6 +72,7 @@ ENTRY (_dl_runtime_resolve) > REG_L a6, sp, 7*SZREG > REG_L a7, sp, 8*SZREG > > +#ifndef __loongarch_soft_float > FREG_L fa0, sp, 10*SZREG + 0*SZFREG > FREG_L fa1, sp, 10*SZREG + 1*SZFREG > FREG_L fa2, sp, 10*SZREG + 2*SZFREG > @@ -75,6 +81,7 @@ ENTRY (_dl_runtime_resolve) > FREG_L fa5, sp, 10*SZREG + 5*SZFREG > FREG_L fa6, sp, 10*SZREG + 6*SZFREG > FREG_L fa7, sp, 10*SZREG + 7*SZFREG > +#endif > > ADDI sp, sp, FRAME_SIZE > > diff --git a/sysdeps/loongarch/fpu_control.h b/sysdeps/loongarch/fpu_control.h > index 1cccc933a5..f482395dba 100644 > --- a/sysdeps/loongarch/fpu_control.h > +++ b/sysdeps/loongarch/fpu_control.h > @@ -51,6 +51,17 @@ > > #include <features.h> > > +#ifdef __loongarch_soft_float > + > +#define _FPU_RESERVED 0xffffffff > +#define _FPU_DEFAULT 0x00000000 > +typedef unsigned int fpu_control_t; > +#define _FPU_GETCW(cw) (cw) = 0 > +#define _FPU_SETCW(cw) (void) (cw) > +extern fpu_control_t __fpu_control; > + > +#else /* __loongarch_soft_float */ > + > /* Masks for interrupts. */ > #define _FPU_MASK_V 0x10 /* Invalid operation */ > #define _FPU_MASK_Z 0x08 /* Division by zero */ > @@ -86,4 +97,6 @@ extern void __loongarch_fpu_setcw (fpu_control_t) __THROW; > /* Default control word set at startup. */ > extern fpu_control_t __fpu_control; > > +#endif /* __loongarch_soft_float */ > + > #endif /* fpu_control.h */ > diff --git a/sysdeps/loongarch/nofpu/Implies b/sysdeps/loongarch/nofpu/Implies > new file mode 100644 > index 0000000000..abcbadb25f > --- /dev/null > +++ b/sysdeps/loongarch/nofpu/Implies > @@ -0,0 +1 @@ > +ieee754/soft-fp > diff --git a/sysdeps/loongarch/nofpu/math-tests-exceptions.h b/sysdeps/loongarch/nofpu/math-tests-exceptions.h > new file mode 100644 > index 0000000000..b22bb01d0e > --- /dev/null > +++ b/sysdeps/loongarch/nofpu/math-tests-exceptions.h > @@ -0,0 +1,28 @@ > +/* Configuration for math tests: support for exceptions. > + Copyright (C) 2022 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + <https://www.gnu.org/licenses/>. */ > + > +#ifndef LOONGARCH_NOFPU_MATH_TESTS_EXCEPTIONS_H > +#define LOONGARCH_NOFPU_MATH_TESTS_EXCEPTIONS_H 1 > + > +/* We support setting floating-point exception flags on hard-float > + targets. These are not supported on soft-float targets. */ > +#define EXCEPTION_TESTS_float 0 > +#define EXCEPTION_TESTS_double 0 > +#define EXCEPTION_TESTS_long_double 0 > + > +#endif /* math-tests-exceptions.h. */ > diff --git a/sysdeps/loongarch/nofpu/math-tests-rounding.h b/sysdeps/loongarch/nofpu/math-tests-rounding.h > new file mode 100644 > index 0000000000..5322e481b9 > --- /dev/null > +++ b/sysdeps/loongarch/nofpu/math-tests-rounding.h > @@ -0,0 +1,27 @@ > +/* Configuration for math tests: rounding mode support. > + Copyright (C) 2022 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + <https://www.gnu.org/licenses/>. */ > + > +#ifndef LOONGARCH_NOFPU_MATH_TESTS_ROUNDING_H > +#define LOONGARCH_NOFPU_MATH_TESTS_ROUNDING_H 1 > + > +/* On soft-float targets we only support the "to nearest" rounding mode. */ > +#define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST) > +#define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST) > +#define ROUNDING_TESTS_long_double(MODE) ((MODE) == FE_TONEAREST) > + > +#endif /* math-tests-rounding.h. */ > diff --git a/sysdeps/loongarch/preconfigure b/sysdeps/loongarch/preconfigure > index 118963cda6..f2d1a0d87b 100644 > --- a/sysdeps/loongarch/preconfigure > +++ b/sysdeps/loongarch/preconfigure > @@ -12,7 +12,6 @@ loongarch*) > case "$float_abi" in > soft) > abi_flen=0 > - as_fn_error 1 "loongarch does not yet support soft floating-point ABI!!" "$LINENO" 5 > ;; > single) > as_fn_error 1 "glibc does not yet support the single floating-point ABI!!" "$LINENO" 5 > diff --git a/sysdeps/loongarch/preconfigure.ac b/sysdeps/loongarch/preconfigure.ac > index 1aba743c15..67e4357013 100644 > --- a/sysdeps/loongarch/preconfigure.ac > +++ b/sysdeps/loongarch/preconfigure.ac > @@ -12,7 +12,6 @@ loongarch*) > case "$float_abi" in > soft) > abi_flen=0 > - AC_MSG_ERROR([loongarch does not yet support soft floating-point ABI!!], 1) > ;; > single) > AC_MSG_ERROR([glibc does not yet support the single floating-point ABI!!], 1) > diff --git a/sysdeps/loongarch/setjmp.S b/sysdeps/loongarch/setjmp.S > index 298bb02a82..9b1cdea48c 100644 > --- a/sysdeps/loongarch/setjmp.S > +++ b/sysdeps/loongarch/setjmp.S > @@ -50,6 +50,7 @@ ENTRY (__sigsetjmp) > REG_S s7, a0, 11*SZREG > REG_S s8, a0, 12*SZREG > > +#ifndef __loongarch_soft_float > FREG_S $f24, a0, 13*SZREG + 0*SZFREG > FREG_S $f25, a0, 13*SZREG + 1*SZFREG > FREG_S $f26, a0, 13*SZREG + 2*SZFREG > @@ -58,6 +59,7 @@ ENTRY (__sigsetjmp) > FREG_S $f29, a0, 13*SZREG + 5*SZFREG > FREG_S $f30, a0, 13*SZREG + 6*SZFREG > FREG_S $f31, a0, 13*SZREG + 7*SZFREG > +#endif > > #if !IS_IN (libc) && IS_IN(rtld) > li.w v0, 0 > diff --git a/sysdeps/unix/sysv/linux/loongarch/Makefile b/sysdeps/unix/sysv/linux/loongarch/Makefile > index 91bd35800a..c84a1762ed 100644 > --- a/sysdeps/unix/sysv/linux/loongarch/Makefile > +++ b/sysdeps/unix/sysv/linux/loongarch/Makefile > @@ -1,3 +1,12 @@ > ifeq ($(subdir),stdlib) > gen-as-const-headers += ucontext_i.sym > endif > + > +abi-variants := lp64s lp64d > + > +ifeq (,$(filter $(default-abi),$(abi-variants))) > +$(error Unknown ABI $(default-abi), must be one of $(abi-variants)) > +endif > + > +abi-lp64s-condition := __WORDSIZE == 64 && defined __loongarch_soft_float > +abi-lp64d-condition := __WORDSIZE == 64 && defined __loongarch_double_float > diff --git a/sysdeps/unix/sysv/linux/loongarch/configure b/sysdeps/unix/sysv/linux/loongarch/configure > index 60a410303e..28216c165e 100644 > --- a/sysdeps/unix/sysv/linux/loongarch/configure > +++ b/sysdeps/unix/sysv/linux/loongarch/configure > @@ -151,11 +151,56 @@ if test $libc_cv_loongarch_int_abi = no; then > as_fn_error $? "Unable to determine integer ABI" "$LINENO" 5 > fi > > +libc_cv_loongarch_float_abi=no > +cat confdefs.h - <<_ACEOF >conftest.$ac_ext > +/* end confdefs.h. */ > +#ifdef __loongarch_double_float > + yes > + #endif > + > +_ACEOF > +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | > + $EGREP "yes" >/dev/null 2>&1; then : > + libc_cv_loongarch_float_abi=d > +fi > +rm -f conftest* > + > +cat confdefs.h - <<_ACEOF >conftest.$ac_ext > +/* end confdefs.h. */ > +#ifdef __loongarch_soft_float > + yes > + #endif > + > +_ACEOF > +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | > + $EGREP "yes" >/dev/null 2>&1; then : > + libc_cv_loongarch_float_abi=s > +fi > +rm -f conftest* > + > +if test "$libc_cv_loongarch_float_abi" = no; then > + as_fn_error $? "Unable to determine floating-point ABI" "$LINENO" 5 > +fi > + > config_vars="$config_vars > -default-abi = $libc_cv_loongarch_int_abi" > +default-abi = $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi" > > -case $libc_cv_loongarch_int_abi in > -lp64) > +case $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi in > +lp64s) > + test -n "$libc_cv_slibdir" || > +case "$prefix" in > +/usr | /usr/) > + libc_cv_slibdir='/lib64/sf' > + libc_cv_rtlddir='/lib64' > + if test "$libdir" = '${exec_prefix}/lib'; then > + libdir='${exec_prefix}/lib64/sf'; > + # Locale data can be shared between 32-bit and 64-bit libraries. > + libc_cv_complocaledir='${exec_prefix}/lib/locale' > + fi > + ;; > +esac > + ;; > +lp64d) > test -n "$libc_cv_slibdir" || > case "$prefix" in > /usr | /usr/) > diff --git a/sysdeps/unix/sysv/linux/loongarch/configure.ac b/sysdeps/unix/sysv/linux/loongarch/configure.ac > index 7de1e95ff6..04e9150a9b 100644 > --- a/sysdeps/unix/sysv/linux/loongarch/configure.ac > +++ b/sysdeps/unix/sysv/linux/loongarch/configure.ac > @@ -11,10 +11,26 @@ if test $libc_cv_loongarch_int_abi = no; then > AC_MSG_ERROR([Unable to determine integer ABI]) > fi > > -LIBC_CONFIG_VAR([default-abi], [$libc_cv_loongarch_int_abi]) > +libc_cv_loongarch_float_abi=no > +AC_EGREP_CPP(yes, [#ifdef __loongarch_double_float > + yes > + #endif > + ],libc_cv_loongarch_float_abi=d) > +AC_EGREP_CPP(yes, [#ifdef __loongarch_soft_float > + yes > + #endif > + ],libc_cv_loongarch_float_abi=s) > +if test "$libc_cv_loongarch_float_abi" = no; then > + AC_MSG_ERROR([Unable to determine floating-point ABI]) > +fi > + > +LIBC_CONFIG_VAR([default-abi], [$libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi]) > > -case $libc_cv_loongarch_int_abi in > -lp64) > +case $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi in > +lp64s) > + LIBC_SLIBDIR_RTLDDIR([lib64/sf], [lib64]) > + ;; > +lp64d) > LIBC_SLIBDIR_RTLDDIR([lib64], [lib64]) > ;; > esac > diff --git a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed > index f8976fd239..cdbe5c3dc5 100644 > --- a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed > +++ b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed > @@ -1 +1 @@ > -s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|32\)\(/[^/]*\)\(-loongarch\)\(64\|32\)\(\.so\.[0-9.]*\)[[:blank:]]*$_\1"\2\4\7 \264\4-loongarch64\7 \232\4-loongarch32\7"_ > +s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|32\)\(/ld-linux-loongarch-\)\(lp\|ilp\)\(64\|32\)\(d\|s\)\(\.so\.[0-9.]*\)[[:blank:]]*$_\1"\264\4lp64d\8 \264\4lp64s\8"_ > diff --git a/sysdeps/unix/sysv/linux/loongarch/shlib-versions b/sysdeps/unix/sysv/linux/loongarch/shlib-versions > index dc2220b4be..5f40e7f5ec 100644 > --- a/sysdeps/unix/sysv/linux/loongarch/shlib-versions > +++ b/sysdeps/unix/sysv/linux/loongarch/shlib-versions > @@ -2,6 +2,8 @@ DEFAULT GLIBC_2.36 > > %if LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 64 > ld=ld-linux-loongarch-lp64d.so.1 > +%elif LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 0 > +ld=ld-linux-loongarch-lp64s.so.1 > %else > %error cannot determine ABI > %endif ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] LoongArch: Add soft float support. 2022-08-30 13:00 ` Adhemerval Zanella Netto @ 2022-08-31 12:00 ` caiyinyu 2022-08-31 12:28 ` Adhemerval Zanella Netto 0 siblings, 1 reply; 5+ messages in thread From: caiyinyu @ 2022-08-31 12:00 UTC (permalink / raw) To: Adhemerval Zanella Netto, libc-alpha, joseph_myers, carlos, i.swmail, xry111 Cc: xuchenghua diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile index 41c3449670..746d4c2c8f 100644 --- a/sysdeps/loongarch/Makefile +++ b/sysdeps/loongarch/Makefile @@ -5,11 +5,3 @@ endif # LoongArch's assembler also needs to know about PIC as it changes the # definition of some assembler macros. ASFLAGS-.os += $(pic-ccflag) - -abi-variants := lp64 - -ifeq (,$(filter $(default-abi),$(abi-variants))) -$(error Unknown ABI $(default-abi), must be one of $(abi-variants)) -endif - -abi-lp64-condition := defined __loongarch_lp64 Why move this to be Linux specific? It won't matter in the end though. The rest looks ok. I did this to follow the example of other architectures (like riscv arc aarch64 arm mips...) though there seems to be no difference. I need help to include this patch since there are some changes in common file build-many-glibcs.py. 在 2022/8/30 下午9:00, Adhemerval Zanella Netto 写道: > > On 30/08/22 08:02, caiyinyu wrote: >> --- >> scripts/build-many-glibcs.py | 4 ++ >> sysdeps/loongarch/Makefile | 8 --- >> sysdeps/loongarch/__longjmp.S | 2 + >> sysdeps/loongarch/bits/setjmp.h | 3 ++ >> sysdeps/loongarch/dl-trampoline.S | 11 +++- >> sysdeps/loongarch/fpu_control.h | 13 +++++ >> sysdeps/loongarch/nofpu/Implies | 1 + >> .../loongarch/nofpu/math-tests-exceptions.h | 28 ++++++++++ >> sysdeps/loongarch/nofpu/math-tests-rounding.h | 27 ++++++++++ >> sysdeps/loongarch/preconfigure | 1 - >> sysdeps/loongarch/preconfigure.ac | 1 - >> sysdeps/loongarch/setjmp.S | 2 + >> sysdeps/unix/sysv/linux/loongarch/Makefile | 9 ++++ >> sysdeps/unix/sysv/linux/loongarch/configure | 51 +++++++++++++++++-- >> .../unix/sysv/linux/loongarch/configure.ac | 22 ++++++-- >> .../unix/sysv/linux/loongarch/ldd-rewrite.sed | 2 +- >> .../unix/sysv/linux/loongarch/shlib-versions | 2 + >> 17 files changed, 168 insertions(+), 19 deletions(-) >> create mode 100644 sysdeps/loongarch/nofpu/Implies >> create mode 100644 sysdeps/loongarch/nofpu/math-tests-exceptions.h >> create mode 100644 sysdeps/loongarch/nofpu/math-tests-rounding.h >> >> diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py >> index 98f02104a2..db632b18a3 100755 >> --- a/scripts/build-many-glibcs.py >> +++ b/scripts/build-many-glibcs.py >> @@ -222,6 +222,10 @@ class Context(object): >> os_name='linux-gnu', >> variant='lp64d', >> gcc_cfg=['--with-abi=lp64d','--disable-multilib']) >> + self.add_config(arch='loongarch64', >> + os_name='linux-gnu', >> + variant='lp64s', >> + gcc_cfg=['--with-abi=lp64s','--disable-multilib']) >> self.add_config(arch='m68k', >> os_name='linux-gnu', >> gcc_cfg=['--disable-multilib']) >> diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile >> index 41c3449670..746d4c2c8f 100644 >> --- a/sysdeps/loongarch/Makefile >> +++ b/sysdeps/loongarch/Makefile >> @@ -5,11 +5,3 @@ endif >> # LoongArch's assembler also needs to know about PIC as it changes the >> # definition of some assembler macros. >> ASFLAGS-.os += $(pic-ccflag) >> - >> -abi-variants := lp64 >> - >> -ifeq (,$(filter $(default-abi),$(abi-variants))) >> -$(error Unknown ABI $(default-abi), must be one of $(abi-variants)) >> -endif >> - >> -abi-lp64-condition := defined __loongarch_lp64 > Why move this to be Linux specific? It won't matter in the end though. > > The rest looks ok. > >> diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S >> index 4207376f5e..d6a99fcbc8 100644 >> --- a/sysdeps/loongarch/__longjmp.S >> +++ b/sysdeps/loongarch/__longjmp.S >> @@ -41,6 +41,7 @@ ENTRY (__longjmp) >> REG_L s7, a0, 11*SZREG >> REG_L s8, a0, 12*SZREG >> >> +#ifndef __loongarch_soft_float >> FREG_L $f24, a0, 13*SZREG + 0*SZFREG >> FREG_L $f25, a0, 13*SZREG + 1*SZFREG >> FREG_L $f26, a0, 13*SZREG + 2*SZFREG >> @@ -49,6 +50,7 @@ ENTRY (__longjmp) >> FREG_L $f29, a0, 13*SZREG + 5*SZFREG >> FREG_L $f30, a0, 13*SZREG + 6*SZFREG >> FREG_L $f31, a0, 13*SZREG + 7*SZFREG >> +#endif >> >> sltui a0,a1,1 >> ADD a0, a0, a1 # a0 = (a1 == 0) ? 1 : a1 >> diff --git a/sysdeps/loongarch/bits/setjmp.h b/sysdeps/loongarch/bits/setjmp.h >> index 42f8fa7657..8b323ad2b6 100644 >> --- a/sysdeps/loongarch/bits/setjmp.h >> +++ b/sysdeps/loongarch/bits/setjmp.h >> @@ -31,8 +31,11 @@ typedef struct __jmp_buf_internal_tag >> long int __fp; >> /* Callee-saved registers. */ >> long int __regs[9]; >> + >> +#ifndef __loongarch_soft_float >> /* Callee-saved floating point registers. */ >> double __fpregs[8]; >> +#endif >> >> } __jmp_buf[1]; >> >> diff --git a/sysdeps/loongarch/dl-trampoline.S b/sysdeps/loongarch/dl-trampoline.S >> index ad8ab0fda7..9a8f580971 100644 >> --- a/sysdeps/loongarch/dl-trampoline.S >> +++ b/sysdeps/loongarch/dl-trampoline.S >> @@ -21,8 +21,11 @@ >> >> /* Assembler veneer called from the PLT header code for lazy loading. >> The PLT header passes its own args in t0-t2. */ >> - >> -# define FRAME_SIZE (-((-10 * SZREG - 8 * SZFREG) & ALMASK)) >> +#ifdef __loongarch_soft_float >> +#define FRAME_SIZE (-((-10 * SZREG) & ALMASK)) >> +#else >> +#define FRAME_SIZE (-((-10 * SZREG - 8 * SZFREG) & ALMASK)) >> +#endif >> >> ENTRY (_dl_runtime_resolve) >> >> @@ -39,6 +42,7 @@ ENTRY (_dl_runtime_resolve) >> REG_S a6, sp, 7*SZREG >> REG_S a7, sp, 8*SZREG >> >> +#ifndef __loongarch_soft_float >> FREG_S fa0, sp, 10*SZREG + 0*SZFREG >> FREG_S fa1, sp, 10*SZREG + 1*SZFREG >> FREG_S fa2, sp, 10*SZREG + 2*SZFREG >> @@ -47,6 +51,7 @@ ENTRY (_dl_runtime_resolve) >> FREG_S fa5, sp, 10*SZREG + 5*SZFREG >> FREG_S fa6, sp, 10*SZREG + 6*SZFREG >> FREG_S fa7, sp, 10*SZREG + 7*SZFREG >> +#endif >> >> /* Update .got.plt and obtain runtime address of callee */ >> SLLI a1, t1, 1 >> @@ -67,6 +72,7 @@ ENTRY (_dl_runtime_resolve) >> REG_L a6, sp, 7*SZREG >> REG_L a7, sp, 8*SZREG >> >> +#ifndef __loongarch_soft_float >> FREG_L fa0, sp, 10*SZREG + 0*SZFREG >> FREG_L fa1, sp, 10*SZREG + 1*SZFREG >> FREG_L fa2, sp, 10*SZREG + 2*SZFREG >> @@ -75,6 +81,7 @@ ENTRY (_dl_runtime_resolve) >> FREG_L fa5, sp, 10*SZREG + 5*SZFREG >> FREG_L fa6, sp, 10*SZREG + 6*SZFREG >> FREG_L fa7, sp, 10*SZREG + 7*SZFREG >> +#endif >> >> ADDI sp, sp, FRAME_SIZE >> >> diff --git a/sysdeps/loongarch/fpu_control.h b/sysdeps/loongarch/fpu_control.h >> index 1cccc933a5..f482395dba 100644 >> --- a/sysdeps/loongarch/fpu_control.h >> +++ b/sysdeps/loongarch/fpu_control.h >> @@ -51,6 +51,17 @@ >> >> #include <features.h> >> >> +#ifdef __loongarch_soft_float >> + >> +#define _FPU_RESERVED 0xffffffff >> +#define _FPU_DEFAULT 0x00000000 >> +typedef unsigned int fpu_control_t; >> +#define _FPU_GETCW(cw) (cw) = 0 >> +#define _FPU_SETCW(cw) (void) (cw) >> +extern fpu_control_t __fpu_control; >> + >> +#else /* __loongarch_soft_float */ >> + >> /* Masks for interrupts. */ >> #define _FPU_MASK_V 0x10 /* Invalid operation */ >> #define _FPU_MASK_Z 0x08 /* Division by zero */ >> @@ -86,4 +97,6 @@ extern void __loongarch_fpu_setcw (fpu_control_t) __THROW; >> /* Default control word set at startup. */ >> extern fpu_control_t __fpu_control; >> >> +#endif /* __loongarch_soft_float */ >> + >> #endif /* fpu_control.h */ >> diff --git a/sysdeps/loongarch/nofpu/Implies b/sysdeps/loongarch/nofpu/Implies >> new file mode 100644 >> index 0000000000..abcbadb25f >> --- /dev/null >> +++ b/sysdeps/loongarch/nofpu/Implies >> @@ -0,0 +1 @@ >> +ieee754/soft-fp >> diff --git a/sysdeps/loongarch/nofpu/math-tests-exceptions.h b/sysdeps/loongarch/nofpu/math-tests-exceptions.h >> new file mode 100644 >> index 0000000000..b22bb01d0e >> --- /dev/null >> +++ b/sysdeps/loongarch/nofpu/math-tests-exceptions.h >> @@ -0,0 +1,28 @@ >> +/* Configuration for math tests: support for exceptions. >> + Copyright (C) 2022 Free Software Foundation, Inc. >> + This file is part of the GNU C Library. >> + >> + The GNU C Library is free software; you can redistribute it and/or >> + modify it under the terms of the GNU Lesser General Public >> + License as published by the Free Software Foundation; either >> + version 2.1 of the License, or (at your option) any later version. >> + >> + The GNU C Library is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> + Lesser General Public License for more details. >> + >> + You should have received a copy of the GNU Lesser General Public >> + License along with the GNU C Library; if not, see >> + <https://www.gnu.org/licenses/>. */ >> + >> +#ifndef LOONGARCH_NOFPU_MATH_TESTS_EXCEPTIONS_H >> +#define LOONGARCH_NOFPU_MATH_TESTS_EXCEPTIONS_H 1 >> + >> +/* We support setting floating-point exception flags on hard-float >> + targets. These are not supported on soft-float targets. */ >> +#define EXCEPTION_TESTS_float 0 >> +#define EXCEPTION_TESTS_double 0 >> +#define EXCEPTION_TESTS_long_double 0 >> + >> +#endif /* math-tests-exceptions.h. */ >> diff --git a/sysdeps/loongarch/nofpu/math-tests-rounding.h b/sysdeps/loongarch/nofpu/math-tests-rounding.h >> new file mode 100644 >> index 0000000000..5322e481b9 >> --- /dev/null >> +++ b/sysdeps/loongarch/nofpu/math-tests-rounding.h >> @@ -0,0 +1,27 @@ >> +/* Configuration for math tests: rounding mode support. >> + Copyright (C) 2022 Free Software Foundation, Inc. >> + This file is part of the GNU C Library. >> + >> + The GNU C Library is free software; you can redistribute it and/or >> + modify it under the terms of the GNU Lesser General Public >> + License as published by the Free Software Foundation; either >> + version 2.1 of the License, or (at your option) any later version. >> + >> + The GNU C Library is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> + Lesser General Public License for more details. >> + >> + You should have received a copy of the GNU Lesser General Public >> + License along with the GNU C Library; if not, see >> + <https://www.gnu.org/licenses/>. */ >> + >> +#ifndef LOONGARCH_NOFPU_MATH_TESTS_ROUNDING_H >> +#define LOONGARCH_NOFPU_MATH_TESTS_ROUNDING_H 1 >> + >> +/* On soft-float targets we only support the "to nearest" rounding mode. */ >> +#define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST) >> +#define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST) >> +#define ROUNDING_TESTS_long_double(MODE) ((MODE) == FE_TONEAREST) >> + >> +#endif /* math-tests-rounding.h. */ >> diff --git a/sysdeps/loongarch/preconfigure b/sysdeps/loongarch/preconfigure >> index 118963cda6..f2d1a0d87b 100644 >> --- a/sysdeps/loongarch/preconfigure >> +++ b/sysdeps/loongarch/preconfigure >> @@ -12,7 +12,6 @@ loongarch*) >> case "$float_abi" in >> soft) >> abi_flen=0 >> - as_fn_error 1 "loongarch does not yet support soft floating-point ABI!!" "$LINENO" 5 >> ;; >> single) >> as_fn_error 1 "glibc does not yet support the single floating-point ABI!!" "$LINENO" 5 >> diff --git a/sysdeps/loongarch/preconfigure.ac b/sysdeps/loongarch/preconfigure.ac >> index 1aba743c15..67e4357013 100644 >> --- a/sysdeps/loongarch/preconfigure.ac >> +++ b/sysdeps/loongarch/preconfigure.ac >> @@ -12,7 +12,6 @@ loongarch*) >> case "$float_abi" in >> soft) >> abi_flen=0 >> - AC_MSG_ERROR([loongarch does not yet support soft floating-point ABI!!], 1) >> ;; >> single) >> AC_MSG_ERROR([glibc does not yet support the single floating-point ABI!!], 1) >> diff --git a/sysdeps/loongarch/setjmp.S b/sysdeps/loongarch/setjmp.S >> index 298bb02a82..9b1cdea48c 100644 >> --- a/sysdeps/loongarch/setjmp.S >> +++ b/sysdeps/loongarch/setjmp.S >> @@ -50,6 +50,7 @@ ENTRY (__sigsetjmp) >> REG_S s7, a0, 11*SZREG >> REG_S s8, a0, 12*SZREG >> >> +#ifndef __loongarch_soft_float >> FREG_S $f24, a0, 13*SZREG + 0*SZFREG >> FREG_S $f25, a0, 13*SZREG + 1*SZFREG >> FREG_S $f26, a0, 13*SZREG + 2*SZFREG >> @@ -58,6 +59,7 @@ ENTRY (__sigsetjmp) >> FREG_S $f29, a0, 13*SZREG + 5*SZFREG >> FREG_S $f30, a0, 13*SZREG + 6*SZFREG >> FREG_S $f31, a0, 13*SZREG + 7*SZFREG >> +#endif >> >> #if !IS_IN (libc) && IS_IN(rtld) >> li.w v0, 0 >> diff --git a/sysdeps/unix/sysv/linux/loongarch/Makefile b/sysdeps/unix/sysv/linux/loongarch/Makefile >> index 91bd35800a..c84a1762ed 100644 >> --- a/sysdeps/unix/sysv/linux/loongarch/Makefile >> +++ b/sysdeps/unix/sysv/linux/loongarch/Makefile >> @@ -1,3 +1,12 @@ >> ifeq ($(subdir),stdlib) >> gen-as-const-headers += ucontext_i.sym >> endif >> + >> +abi-variants := lp64s lp64d >> + >> +ifeq (,$(filter $(default-abi),$(abi-variants))) >> +$(error Unknown ABI $(default-abi), must be one of $(abi-variants)) >> +endif >> + >> +abi-lp64s-condition := __WORDSIZE == 64 && defined __loongarch_soft_float >> +abi-lp64d-condition := __WORDSIZE == 64 && defined __loongarch_double_float >> diff --git a/sysdeps/unix/sysv/linux/loongarch/configure b/sysdeps/unix/sysv/linux/loongarch/configure >> index 60a410303e..28216c165e 100644 >> --- a/sysdeps/unix/sysv/linux/loongarch/configure >> +++ b/sysdeps/unix/sysv/linux/loongarch/configure >> @@ -151,11 +151,56 @@ if test $libc_cv_loongarch_int_abi = no; then >> as_fn_error $? "Unable to determine integer ABI" "$LINENO" 5 >> fi >> >> +libc_cv_loongarch_float_abi=no >> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext >> +/* end confdefs.h. */ >> +#ifdef __loongarch_double_float >> + yes >> + #endif >> + >> +_ACEOF >> +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | >> + $EGREP "yes" >/dev/null 2>&1; then : >> + libc_cv_loongarch_float_abi=d >> +fi >> +rm -f conftest* >> + >> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext >> +/* end confdefs.h. */ >> +#ifdef __loongarch_soft_float >> + yes >> + #endif >> + >> +_ACEOF >> +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | >> + $EGREP "yes" >/dev/null 2>&1; then : >> + libc_cv_loongarch_float_abi=s >> +fi >> +rm -f conftest* >> + >> +if test "$libc_cv_loongarch_float_abi" = no; then >> + as_fn_error $? "Unable to determine floating-point ABI" "$LINENO" 5 >> +fi >> + >> config_vars="$config_vars >> -default-abi = $libc_cv_loongarch_int_abi" >> +default-abi = $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi" >> >> -case $libc_cv_loongarch_int_abi in >> -lp64) >> +case $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi in >> +lp64s) >> + test -n "$libc_cv_slibdir" || >> +case "$prefix" in >> +/usr | /usr/) >> + libc_cv_slibdir='/lib64/sf' >> + libc_cv_rtlddir='/lib64' >> + if test "$libdir" = '${exec_prefix}/lib'; then >> + libdir='${exec_prefix}/lib64/sf'; >> + # Locale data can be shared between 32-bit and 64-bit libraries. >> + libc_cv_complocaledir='${exec_prefix}/lib/locale' >> + fi >> + ;; >> +esac >> + ;; >> +lp64d) >> test -n "$libc_cv_slibdir" || >> case "$prefix" in >> /usr | /usr/) >> diff --git a/sysdeps/unix/sysv/linux/loongarch/configure.ac b/sysdeps/unix/sysv/linux/loongarch/configure.ac >> index 7de1e95ff6..04e9150a9b 100644 >> --- a/sysdeps/unix/sysv/linux/loongarch/configure.ac >> +++ b/sysdeps/unix/sysv/linux/loongarch/configure.ac >> @@ -11,10 +11,26 @@ if test $libc_cv_loongarch_int_abi = no; then >> AC_MSG_ERROR([Unable to determine integer ABI]) >> fi >> >> -LIBC_CONFIG_VAR([default-abi], [$libc_cv_loongarch_int_abi]) >> +libc_cv_loongarch_float_abi=no >> +AC_EGREP_CPP(yes, [#ifdef __loongarch_double_float >> + yes >> + #endif >> + ],libc_cv_loongarch_float_abi=d) >> +AC_EGREP_CPP(yes, [#ifdef __loongarch_soft_float >> + yes >> + #endif >> + ],libc_cv_loongarch_float_abi=s) >> +if test "$libc_cv_loongarch_float_abi" = no; then >> + AC_MSG_ERROR([Unable to determine floating-point ABI]) >> +fi >> + >> +LIBC_CONFIG_VAR([default-abi], [$libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi]) >> >> -case $libc_cv_loongarch_int_abi in >> -lp64) >> +case $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi in >> +lp64s) >> + LIBC_SLIBDIR_RTLDDIR([lib64/sf], [lib64]) >> + ;; >> +lp64d) >> LIBC_SLIBDIR_RTLDDIR([lib64], [lib64]) >> ;; >> esac >> diff --git a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed >> index f8976fd239..cdbe5c3dc5 100644 >> --- a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed >> +++ b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed >> @@ -1 +1 @@ >> -s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|32\)\(/[^/]*\)\(-loongarch\)\(64\|32\)\(\.so\.[0-9.]*\)[[:blank:]]*$_\1"\2\4\7 \264\4-loongarch64\7 \232\4-loongarch32\7"_ >> +s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|32\)\(/ld-linux-loongarch-\)\(lp\|ilp\)\(64\|32\)\(d\|s\)\(\.so\.[0-9.]*\)[[:blank:]]*$_\1"\264\4lp64d\8 \264\4lp64s\8"_ >> diff --git a/sysdeps/unix/sysv/linux/loongarch/shlib-versions b/sysdeps/unix/sysv/linux/loongarch/shlib-versions >> index dc2220b4be..5f40e7f5ec 100644 >> --- a/sysdeps/unix/sysv/linux/loongarch/shlib-versions >> +++ b/sysdeps/unix/sysv/linux/loongarch/shlib-versions >> @@ -2,6 +2,8 @@ DEFAULT GLIBC_2.36 >> >> %if LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 64 >> ld=ld-linux-loongarch-lp64d.so.1 >> +%elif LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 0 >> +ld=ld-linux-loongarch-lp64s.so.1 >> %else >> %error cannot determine ABI >> %endif ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] LoongArch: Add soft float support. 2022-08-31 12:00 ` caiyinyu @ 2022-08-31 12:28 ` Adhemerval Zanella Netto 0 siblings, 0 replies; 5+ messages in thread From: Adhemerval Zanella Netto @ 2022-08-31 12:28 UTC (permalink / raw) To: caiyinyu, libc-alpha, joseph_myers, carlos, i.swmail, xry111; +Cc: xuchenghua On 31/08/22 09:00, caiyinyu wrote: > diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile > index 41c3449670..746d4c2c8f 100644 > --- a/sysdeps/loongarch/Makefile > +++ b/sysdeps/loongarch/Makefile > @@ -5,11 +5,3 @@ endif > # LoongArch's assembler also needs to know about PIC as it changes the > # definition of some assembler macros. > ASFLAGS-.os += $(pic-ccflag) > - > -abi-variants := lp64 > - > -ifeq (,$(filter $(default-abi),$(abi-variants))) > -$(error Unknown ABI $(default-abi), must be one of $(abi-variants)) > -endif > - > -abi-lp64-condition := defined __loongarch_lp64 > > Why move this to be Linux specific? It won't matter in the end though. > > The rest looks ok. > > > I did this to follow the example of other architectures (like riscv arc > > aarch64 arm mips...) though there seems to be no difference. Fair enough, the patch looks ok as it. PS: Usually we reply with bottom-posting. > > I need help to include this patch since there are some changes in common > > file build-many-glibcs.py. > > > > 在 2022/8/30 下午9:00, Adhemerval Zanella Netto 写道: >> >> On 30/08/22 08:02, caiyinyu wrote: >>> --- >>> scripts/build-many-glibcs.py | 4 ++ >>> sysdeps/loongarch/Makefile | 8 --- >>> sysdeps/loongarch/__longjmp.S | 2 + >>> sysdeps/loongarch/bits/setjmp.h | 3 ++ >>> sysdeps/loongarch/dl-trampoline.S | 11 +++- >>> sysdeps/loongarch/fpu_control.h | 13 +++++ >>> sysdeps/loongarch/nofpu/Implies | 1 + >>> .../loongarch/nofpu/math-tests-exceptions.h | 28 ++++++++++ >>> sysdeps/loongarch/nofpu/math-tests-rounding.h | 27 ++++++++++ >>> sysdeps/loongarch/preconfigure | 1 - >>> sysdeps/loongarch/preconfigure.ac | 1 - >>> sysdeps/loongarch/setjmp.S | 2 + >>> sysdeps/unix/sysv/linux/loongarch/Makefile | 9 ++++ >>> sysdeps/unix/sysv/linux/loongarch/configure | 51 +++++++++++++++++-- >>> .../unix/sysv/linux/loongarch/configure.ac | 22 ++++++-- >>> .../unix/sysv/linux/loongarch/ldd-rewrite.sed | 2 +- >>> .../unix/sysv/linux/loongarch/shlib-versions | 2 + >>> 17 files changed, 168 insertions(+), 19 deletions(-) >>> create mode 100644 sysdeps/loongarch/nofpu/Implies >>> create mode 100644 sysdeps/loongarch/nofpu/math-tests-exceptions.h >>> create mode 100644 sysdeps/loongarch/nofpu/math-tests-rounding.h >>> >>> diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py >>> index 98f02104a2..db632b18a3 100755 >>> --- a/scripts/build-many-glibcs.py >>> +++ b/scripts/build-many-glibcs.py >>> @@ -222,6 +222,10 @@ class Context(object): >>> os_name='linux-gnu', >>> variant='lp64d', >>> gcc_cfg=['--with-abi=lp64d','--disable-multilib']) >>> + self.add_config(arch='loongarch64', >>> + os_name='linux-gnu', >>> + variant='lp64s', >>> + gcc_cfg=['--with-abi=lp64s','--disable-multilib']) >>> self.add_config(arch='m68k', >>> os_name='linux-gnu', >>> gcc_cfg=['--disable-multilib']) >>> diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile >>> index 41c3449670..746d4c2c8f 100644 >>> --- a/sysdeps/loongarch/Makefile >>> +++ b/sysdeps/loongarch/Makefile >>> @@ -5,11 +5,3 @@ endif >>> # LoongArch's assembler also needs to know about PIC as it changes the >>> # definition of some assembler macros. >>> ASFLAGS-.os += $(pic-ccflag) >>> - >>> -abi-variants := lp64 >>> - >>> -ifeq (,$(filter $(default-abi),$(abi-variants))) >>> -$(error Unknown ABI $(default-abi), must be one of $(abi-variants)) >>> -endif >>> - >>> -abi-lp64-condition := defined __loongarch_lp64 >> Why move this to be Linux specific? It won't matter in the end though. >> >> The rest looks ok. >> >>> diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S >>> index 4207376f5e..d6a99fcbc8 100644 >>> --- a/sysdeps/loongarch/__longjmp.S >>> +++ b/sysdeps/loongarch/__longjmp.S >>> @@ -41,6 +41,7 @@ ENTRY (__longjmp) >>> REG_L s7, a0, 11*SZREG >>> REG_L s8, a0, 12*SZREG >>> +#ifndef __loongarch_soft_float >>> FREG_L $f24, a0, 13*SZREG + 0*SZFREG >>> FREG_L $f25, a0, 13*SZREG + 1*SZFREG >>> FREG_L $f26, a0, 13*SZREG + 2*SZFREG >>> @@ -49,6 +50,7 @@ ENTRY (__longjmp) >>> FREG_L $f29, a0, 13*SZREG + 5*SZFREG >>> FREG_L $f30, a0, 13*SZREG + 6*SZFREG >>> FREG_L $f31, a0, 13*SZREG + 7*SZFREG >>> +#endif >>> sltui a0,a1,1 >>> ADD a0, a0, a1 # a0 = (a1 == 0) ? 1 : a1 >>> diff --git a/sysdeps/loongarch/bits/setjmp.h b/sysdeps/loongarch/bits/setjmp.h >>> index 42f8fa7657..8b323ad2b6 100644 >>> --- a/sysdeps/loongarch/bits/setjmp.h >>> +++ b/sysdeps/loongarch/bits/setjmp.h >>> @@ -31,8 +31,11 @@ typedef struct __jmp_buf_internal_tag >>> long int __fp; >>> /* Callee-saved registers. */ >>> long int __regs[9]; >>> + >>> +#ifndef __loongarch_soft_float >>> /* Callee-saved floating point registers. */ >>> double __fpregs[8]; >>> +#endif >>> } __jmp_buf[1]; >>> diff --git a/sysdeps/loongarch/dl-trampoline.S b/sysdeps/loongarch/dl-trampoline.S >>> index ad8ab0fda7..9a8f580971 100644 >>> --- a/sysdeps/loongarch/dl-trampoline.S >>> +++ b/sysdeps/loongarch/dl-trampoline.S >>> @@ -21,8 +21,11 @@ >>> /* Assembler veneer called from the PLT header code for lazy loading. >>> The PLT header passes its own args in t0-t2. */ >>> - >>> -# define FRAME_SIZE (-((-10 * SZREG - 8 * SZFREG) & ALMASK)) >>> +#ifdef __loongarch_soft_float >>> +#define FRAME_SIZE (-((-10 * SZREG) & ALMASK)) >>> +#else >>> +#define FRAME_SIZE (-((-10 * SZREG - 8 * SZFREG) & ALMASK)) >>> +#endif >>> ENTRY (_dl_runtime_resolve) >>> @@ -39,6 +42,7 @@ ENTRY (_dl_runtime_resolve) >>> REG_S a6, sp, 7*SZREG >>> REG_S a7, sp, 8*SZREG >>> +#ifndef __loongarch_soft_float >>> FREG_S fa0, sp, 10*SZREG + 0*SZFREG >>> FREG_S fa1, sp, 10*SZREG + 1*SZFREG >>> FREG_S fa2, sp, 10*SZREG + 2*SZFREG >>> @@ -47,6 +51,7 @@ ENTRY (_dl_runtime_resolve) >>> FREG_S fa5, sp, 10*SZREG + 5*SZFREG >>> FREG_S fa6, sp, 10*SZREG + 6*SZFREG >>> FREG_S fa7, sp, 10*SZREG + 7*SZFREG >>> +#endif >>> /* Update .got.plt and obtain runtime address of callee */ >>> SLLI a1, t1, 1 >>> @@ -67,6 +72,7 @@ ENTRY (_dl_runtime_resolve) >>> REG_L a6, sp, 7*SZREG >>> REG_L a7, sp, 8*SZREG >>> +#ifndef __loongarch_soft_float >>> FREG_L fa0, sp, 10*SZREG + 0*SZFREG >>> FREG_L fa1, sp, 10*SZREG + 1*SZFREG >>> FREG_L fa2, sp, 10*SZREG + 2*SZFREG >>> @@ -75,6 +81,7 @@ ENTRY (_dl_runtime_resolve) >>> FREG_L fa5, sp, 10*SZREG + 5*SZFREG >>> FREG_L fa6, sp, 10*SZREG + 6*SZFREG >>> FREG_L fa7, sp, 10*SZREG + 7*SZFREG >>> +#endif >>> ADDI sp, sp, FRAME_SIZE >>> diff --git a/sysdeps/loongarch/fpu_control.h b/sysdeps/loongarch/fpu_control.h >>> index 1cccc933a5..f482395dba 100644 >>> --- a/sysdeps/loongarch/fpu_control.h >>> +++ b/sysdeps/loongarch/fpu_control.h >>> @@ -51,6 +51,17 @@ >>> #include <features.h> >>> +#ifdef __loongarch_soft_float >>> + >>> +#define _FPU_RESERVED 0xffffffff >>> +#define _FPU_DEFAULT 0x00000000 >>> +typedef unsigned int fpu_control_t; >>> +#define _FPU_GETCW(cw) (cw) = 0 >>> +#define _FPU_SETCW(cw) (void) (cw) >>> +extern fpu_control_t __fpu_control; >>> + >>> +#else /* __loongarch_soft_float */ >>> + >>> /* Masks for interrupts. */ >>> #define _FPU_MASK_V 0x10 /* Invalid operation */ >>> #define _FPU_MASK_Z 0x08 /* Division by zero */ >>> @@ -86,4 +97,6 @@ extern void __loongarch_fpu_setcw (fpu_control_t) __THROW; >>> /* Default control word set at startup. */ >>> extern fpu_control_t __fpu_control; >>> +#endif /* __loongarch_soft_float */ >>> + >>> #endif /* fpu_control.h */ >>> diff --git a/sysdeps/loongarch/nofpu/Implies b/sysdeps/loongarch/nofpu/Implies >>> new file mode 100644 >>> index 0000000000..abcbadb25f >>> --- /dev/null >>> +++ b/sysdeps/loongarch/nofpu/Implies >>> @@ -0,0 +1 @@ >>> +ieee754/soft-fp >>> diff --git a/sysdeps/loongarch/nofpu/math-tests-exceptions.h b/sysdeps/loongarch/nofpu/math-tests-exceptions.h >>> new file mode 100644 >>> index 0000000000..b22bb01d0e >>> --- /dev/null >>> +++ b/sysdeps/loongarch/nofpu/math-tests-exceptions.h >>> @@ -0,0 +1,28 @@ >>> +/* Configuration for math tests: support for exceptions. >>> + Copyright (C) 2022 Free Software Foundation, Inc. >>> + This file is part of the GNU C Library. >>> + >>> + The GNU C Library is free software; you can redistribute it and/or >>> + modify it under the terms of the GNU Lesser General Public >>> + License as published by the Free Software Foundation; either >>> + version 2.1 of the License, or (at your option) any later version. >>> + >>> + The GNU C Library is distributed in the hope that it will be useful, >>> + but WITHOUT ANY WARRANTY; without even the implied warranty of >>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >>> + Lesser General Public License for more details. >>> + >>> + You should have received a copy of the GNU Lesser General Public >>> + License along with the GNU C Library; if not, see >>> + <https://www.gnu.org/licenses/>. */ >>> + >>> +#ifndef LOONGARCH_NOFPU_MATH_TESTS_EXCEPTIONS_H >>> +#define LOONGARCH_NOFPU_MATH_TESTS_EXCEPTIONS_H 1 >>> + >>> +/* We support setting floating-point exception flags on hard-float >>> + targets. These are not supported on soft-float targets. */ >>> +#define EXCEPTION_TESTS_float 0 >>> +#define EXCEPTION_TESTS_double 0 >>> +#define EXCEPTION_TESTS_long_double 0 >>> + >>> +#endif /* math-tests-exceptions.h. */ >>> diff --git a/sysdeps/loongarch/nofpu/math-tests-rounding.h b/sysdeps/loongarch/nofpu/math-tests-rounding.h >>> new file mode 100644 >>> index 0000000000..5322e481b9 >>> --- /dev/null >>> +++ b/sysdeps/loongarch/nofpu/math-tests-rounding.h >>> @@ -0,0 +1,27 @@ >>> +/* Configuration for math tests: rounding mode support. >>> + Copyright (C) 2022 Free Software Foundation, Inc. >>> + This file is part of the GNU C Library. >>> + >>> + The GNU C Library is free software; you can redistribute it and/or >>> + modify it under the terms of the GNU Lesser General Public >>> + License as published by the Free Software Foundation; either >>> + version 2.1 of the License, or (at your option) any later version. >>> + >>> + The GNU C Library is distributed in the hope that it will be useful, >>> + but WITHOUT ANY WARRANTY; without even the implied warranty of >>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >>> + Lesser General Public License for more details. >>> + >>> + You should have received a copy of the GNU Lesser General Public >>> + License along with the GNU C Library; if not, see >>> + <https://www.gnu.org/licenses/>. */ >>> + >>> +#ifndef LOONGARCH_NOFPU_MATH_TESTS_ROUNDING_H >>> +#define LOONGARCH_NOFPU_MATH_TESTS_ROUNDING_H 1 >>> + >>> +/* On soft-float targets we only support the "to nearest" rounding mode. */ >>> +#define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST) >>> +#define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST) >>> +#define ROUNDING_TESTS_long_double(MODE) ((MODE) == FE_TONEAREST) >>> + >>> +#endif /* math-tests-rounding.h. */ >>> diff --git a/sysdeps/loongarch/preconfigure b/sysdeps/loongarch/preconfigure >>> index 118963cda6..f2d1a0d87b 100644 >>> --- a/sysdeps/loongarch/preconfigure >>> +++ b/sysdeps/loongarch/preconfigure >>> @@ -12,7 +12,6 @@ loongarch*) >>> case "$float_abi" in >>> soft) >>> abi_flen=0 >>> - as_fn_error 1 "loongarch does not yet support soft floating-point ABI!!" "$LINENO" 5 >>> ;; >>> single) >>> as_fn_error 1 "glibc does not yet support the single floating-point ABI!!" "$LINENO" 5 >>> diff --git a/sysdeps/loongarch/preconfigure.ac b/sysdeps/loongarch/preconfigure.ac >>> index 1aba743c15..67e4357013 100644 >>> --- a/sysdeps/loongarch/preconfigure.ac >>> +++ b/sysdeps/loongarch/preconfigure.ac >>> @@ -12,7 +12,6 @@ loongarch*) >>> case "$float_abi" in >>> soft) >>> abi_flen=0 >>> - AC_MSG_ERROR([loongarch does not yet support soft floating-point ABI!!], 1) >>> ;; >>> single) >>> AC_MSG_ERROR([glibc does not yet support the single floating-point ABI!!], 1) >>> diff --git a/sysdeps/loongarch/setjmp.S b/sysdeps/loongarch/setjmp.S >>> index 298bb02a82..9b1cdea48c 100644 >>> --- a/sysdeps/loongarch/setjmp.S >>> +++ b/sysdeps/loongarch/setjmp.S >>> @@ -50,6 +50,7 @@ ENTRY (__sigsetjmp) >>> REG_S s7, a0, 11*SZREG >>> REG_S s8, a0, 12*SZREG >>> +#ifndef __loongarch_soft_float >>> FREG_S $f24, a0, 13*SZREG + 0*SZFREG >>> FREG_S $f25, a0, 13*SZREG + 1*SZFREG >>> FREG_S $f26, a0, 13*SZREG + 2*SZFREG >>> @@ -58,6 +59,7 @@ ENTRY (__sigsetjmp) >>> FREG_S $f29, a0, 13*SZREG + 5*SZFREG >>> FREG_S $f30, a0, 13*SZREG + 6*SZFREG >>> FREG_S $f31, a0, 13*SZREG + 7*SZFREG >>> +#endif >>> #if !IS_IN (libc) && IS_IN(rtld) >>> li.w v0, 0 >>> diff --git a/sysdeps/unix/sysv/linux/loongarch/Makefile b/sysdeps/unix/sysv/linux/loongarch/Makefile >>> index 91bd35800a..c84a1762ed 100644 >>> --- a/sysdeps/unix/sysv/linux/loongarch/Makefile >>> +++ b/sysdeps/unix/sysv/linux/loongarch/Makefile >>> @@ -1,3 +1,12 @@ >>> ifeq ($(subdir),stdlib) >>> gen-as-const-headers += ucontext_i.sym >>> endif >>> + >>> +abi-variants := lp64s lp64d >>> + >>> +ifeq (,$(filter $(default-abi),$(abi-variants))) >>> +$(error Unknown ABI $(default-abi), must be one of $(abi-variants)) >>> +endif >>> + >>> +abi-lp64s-condition := __WORDSIZE == 64 && defined __loongarch_soft_float >>> +abi-lp64d-condition := __WORDSIZE == 64 && defined __loongarch_double_float >>> diff --git a/sysdeps/unix/sysv/linux/loongarch/configure b/sysdeps/unix/sysv/linux/loongarch/configure >>> index 60a410303e..28216c165e 100644 >>> --- a/sysdeps/unix/sysv/linux/loongarch/configure >>> +++ b/sysdeps/unix/sysv/linux/loongarch/configure >>> @@ -151,11 +151,56 @@ if test $libc_cv_loongarch_int_abi = no; then >>> as_fn_error $? "Unable to determine integer ABI" "$LINENO" 5 >>> fi >>> +libc_cv_loongarch_float_abi=no >>> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext >>> +/* end confdefs.h. */ >>> +#ifdef __loongarch_double_float >>> + yes >>> + #endif >>> + >>> +_ACEOF >>> +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | >>> + $EGREP "yes" >/dev/null 2>&1; then : >>> + libc_cv_loongarch_float_abi=d >>> +fi >>> +rm -f conftest* >>> + >>> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext >>> +/* end confdefs.h. */ >>> +#ifdef __loongarch_soft_float >>> + yes >>> + #endif >>> + >>> +_ACEOF >>> +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | >>> + $EGREP "yes" >/dev/null 2>&1; then : >>> + libc_cv_loongarch_float_abi=s >>> +fi >>> +rm -f conftest* >>> + >>> +if test "$libc_cv_loongarch_float_abi" = no; then >>> + as_fn_error $? "Unable to determine floating-point ABI" "$LINENO" 5 >>> +fi >>> + >>> config_vars="$config_vars >>> -default-abi = $libc_cv_loongarch_int_abi" >>> +default-abi = $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi" >>> -case $libc_cv_loongarch_int_abi in >>> -lp64) >>> +case $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi in >>> +lp64s) >>> + test -n "$libc_cv_slibdir" || >>> +case "$prefix" in >>> +/usr | /usr/) >>> + libc_cv_slibdir='/lib64/sf' >>> + libc_cv_rtlddir='/lib64' >>> + if test "$libdir" = '${exec_prefix}/lib'; then >>> + libdir='${exec_prefix}/lib64/sf'; >>> + # Locale data can be shared between 32-bit and 64-bit libraries. >>> + libc_cv_complocaledir='${exec_prefix}/lib/locale' >>> + fi >>> + ;; >>> +esac >>> + ;; >>> +lp64d) >>> test -n "$libc_cv_slibdir" || >>> case "$prefix" in >>> /usr | /usr/) >>> diff --git a/sysdeps/unix/sysv/linux/loongarch/configure.ac b/sysdeps/unix/sysv/linux/loongarch/configure.ac >>> index 7de1e95ff6..04e9150a9b 100644 >>> --- a/sysdeps/unix/sysv/linux/loongarch/configure.ac >>> +++ b/sysdeps/unix/sysv/linux/loongarch/configure.ac >>> @@ -11,10 +11,26 @@ if test $libc_cv_loongarch_int_abi = no; then >>> AC_MSG_ERROR([Unable to determine integer ABI]) >>> fi >>> -LIBC_CONFIG_VAR([default-abi], [$libc_cv_loongarch_int_abi]) >>> +libc_cv_loongarch_float_abi=no >>> +AC_EGREP_CPP(yes, [#ifdef __loongarch_double_float >>> + yes >>> + #endif >>> + ],libc_cv_loongarch_float_abi=d) >>> +AC_EGREP_CPP(yes, [#ifdef __loongarch_soft_float >>> + yes >>> + #endif >>> + ],libc_cv_loongarch_float_abi=s) >>> +if test "$libc_cv_loongarch_float_abi" = no; then >>> + AC_MSG_ERROR([Unable to determine floating-point ABI]) >>> +fi >>> + >>> +LIBC_CONFIG_VAR([default-abi], [$libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi]) >>> -case $libc_cv_loongarch_int_abi in >>> -lp64) >>> +case $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi in >>> +lp64s) >>> + LIBC_SLIBDIR_RTLDDIR([lib64/sf], [lib64]) >>> + ;; >>> +lp64d) >>> LIBC_SLIBDIR_RTLDDIR([lib64], [lib64]) >>> ;; >>> esac >>> diff --git a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed >>> index f8976fd239..cdbe5c3dc5 100644 >>> --- a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed >>> +++ b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed >>> @@ -1 +1 @@ >>> -s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|32\)\(/[^/]*\)\(-loongarch\)\(64\|32\)\(\.so\.[0-9.]*\)[[:blank:]]*$_\1"\2\4\7 \264\4-loongarch64\7 \232\4-loongarch32\7"_ >>> +s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|32\)\(/ld-linux-loongarch-\)\(lp\|ilp\)\(64\|32\)\(d\|s\)\(\.so\.[0-9.]*\)[[:blank:]]*$_\1"\264\4lp64d\8 \264\4lp64s\8"_ >>> diff --git a/sysdeps/unix/sysv/linux/loongarch/shlib-versions b/sysdeps/unix/sysv/linux/loongarch/shlib-versions >>> index dc2220b4be..5f40e7f5ec 100644 >>> --- a/sysdeps/unix/sysv/linux/loongarch/shlib-versions >>> +++ b/sysdeps/unix/sysv/linux/loongarch/shlib-versions >>> @@ -2,6 +2,8 @@ DEFAULT GLIBC_2.36 >>> %if LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 64 >>> ld=ld-linux-loongarch-lp64d.so.1 >>> +%elif LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 0 >>> +ld=ld-linux-loongarch-lp64s.so.1 >>> %else >>> %error cannot determine ABI >>> %endif > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-08-31 12:28 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-08-30 11:02 [PATCH 0/1] LoongArch: Add soft float support caiyinyu 2022-08-30 11:02 ` [PATCH 1/1] " caiyinyu 2022-08-30 13:00 ` Adhemerval Zanella Netto 2022-08-31 12:00 ` caiyinyu 2022-08-31 12:28 ` Adhemerval Zanella Netto
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).