]> git.ipfire.org Git - thirdparty/glibc.git/commit
or1k: Add hard float support
authorStafford Horne <shorne@gmail.com>
Sat, 27 Apr 2024 05:35:09 +0000 (06:35 +0100)
committerStafford Horne <shorne@gmail.com>
Fri, 3 May 2024 17:28:18 +0000 (18:28 +0100)
commit643d9d38d50b32b5f20fb8ff5da17bff412821b6
tree7c9b975e8e0df861663aca7a73489ff88704b0fc
parentb57adfa49b7ec75fad94548fb66fddc3bd92f457
or1k: Add hard float support

This patch adds hardware floating point support to OpenRISC.  Hardware
floating point toolchain builds are enabled by passing the machine
specific argument -mhard-float to gcc via CFLAGS.  With this enabled GCC
generates floating point instructions for single-precision operations
and exports __or1k_hard_float__.

There are 2 main parts to this patch.

 - Implement fenv functions to update the FPCSR flags keeping it in sync
   with sfp (software floating point).
 - Update machine context functions to store and restore the FPCSR
   state.

*On mcontext_t ABI*

This patch adds __fpcsr to mcontext_t.  This is an ABI change, but also
an ABI fix.  The Linux kernel has always defined padding in mcontext_t
that space was missing from the glibc ABI.  In Linux this unused space
has now been re-purposed for storing the FPCSR.  This patch brings
OpenRISC glibc in line with the Linux kernel and other libc
implementation (musl).

Compatibility getcontext, setcontext, etc symbols have been added to
allow for binaries expecting the old ABI to continue to work.

*Hard float ABI*

The calling conventions and types do not change with OpenRISC hard-float
so glibc hard-float builds continue to use dynamic linker
/lib/ld-linux-or1k.so.1.

*Testing*

I have tested this patch both with hard-float and soft-float builds and
the test results look fine to me.  Results are as follows:

Hard Float

    # failures
    FAIL: elf/tst-sprof-basic (Haven't figured out yet, not related to hard-float)
    FAIL: gmon/tst-gmon-pie (PIE bug in or1k toolchain)
    FAIL: gmon/tst-gmon-pie-gprof (PIE bug in or1k toolchain)
    FAIL: iconvdata/iconv-test (timeout, passed when run manually)
    FAIL: nptl/tst-cond24 (Timeout)
    FAIL: nptl/tst-mutex10 (Timeout)

    # summary
  6 FAIL
       4289 PASS
 86 UNSUPPORTED
 16 XFAIL
  2 XPASS

    # versions
    Toolchain: or1k-smhfpu-linux-gnu
    Compiler:  gcc version 14.0.1 20240324 (experimental) [master r14-9649-gbb04a11418f] (GCC)
    Binutils:  GNU assembler version 2.42.0 (or1k-smhfpu-linux-gnu) using BFD version (GNU Binutils) 2.42.0.20240324
    Linux:     Linux buildroot 6.9.0-rc1-00008-g4dc70e1aadfa #112 SMP Sat Apr 27 06:43:11 BST 2024 openrisc GNU/Linux
    Tester:    shorne
    Glibc:     2024-04-25 b62928f907 Florian Weimer   x86: In ld.so, diagnose missing APX support in APX-only builds  (origin/master, origin/HEAD)

Soft Float

    # failures
    FAIL: elf/tst-sprof-basic
    FAIL: gmon/tst-gmon-pie
    FAIL: gmon/tst-gmon-pie-gprof
    FAIL: nptl/tst-cond24
    FAIL: nptl/tst-mutex10

    # summary
  5 FAIL
       4295 PASS
 81 UNSUPPORTED
 16 XFAIL
  2 XPASS

    # versions
    Toolchain: or1k-smh-linux-gnu
    Compiler:  gcc version 14.0.1 20240324 (experimental) [master r14-9649-gbb04a11418f] (GCC)
    Binutils:  GNU assembler version 2.42.0 (or1k-smh-linux-gnu) using BFD version (GNU Binutils) 2.42.0.20240324
    Linux:     Linux buildroot 6.9.0-rc1-00008-g4dc70e1aadfa #112 SMP Sat Apr 27 06:43:11 BST 2024 openrisc GNU/Linux
    Tester:    shorne
    Glibc:     2024-04-25 b62928f907 Florian Weimer   x86: In ld.so, diagnose missing APX support in APX-only builds  (origin/master, origin/HEAD)

Documentation: https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.4-rev0.pdf
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
32 files changed:
sysdeps/or1k/fpu/fclrexcpt.c [new file with mode: 0644]
sysdeps/or1k/fpu/fegetenv.c [new file with mode: 0644]
sysdeps/or1k/fpu/fegetmode.c [new file with mode: 0644]
sysdeps/or1k/fpu/fegetround.c [new file with mode: 0644]
sysdeps/or1k/fpu/feholdexcpt.c [new file with mode: 0644]
sysdeps/or1k/fpu/fenv_private.h [new file with mode: 0644]
sysdeps/or1k/fpu/fesetenv.c [new file with mode: 0644]
sysdeps/or1k/fpu/fesetexcept.c [new file with mode: 0644]
sysdeps/or1k/fpu/fesetmode.c [new file with mode: 0644]
sysdeps/or1k/fpu/fesetround.c [new file with mode: 0644]
sysdeps/or1k/fpu/feupdateenv.c [new file with mode: 0644]
sysdeps/or1k/fpu/fgetexcptflg.c [new file with mode: 0644]
sysdeps/or1k/fpu/fix-fp-int-convert-overflow.h [new file with mode: 0644]
sysdeps/or1k/fpu/fraiseexcpt.c [new file with mode: 0644]
sysdeps/or1k/fpu/fsetexcptflg.c [new file with mode: 0644]
sysdeps/or1k/fpu/ftestexcept.c [new file with mode: 0644]
sysdeps/or1k/fpu/get-rounding-mode.h [new file with mode: 0644]
sysdeps/or1k/fpu_control.h [new file with mode: 0644]
sysdeps/or1k/math-tests-snan-payload.h [new file with mode: 0644]
sysdeps/or1k/math-tests-trap.h [new file with mode: 0644]
sysdeps/or1k/sfp-machine.h
sysdeps/unix/sysv/linux/or1k/Versions [new file with mode: 0644]
sysdeps/unix/sysv/linux/or1k/getcontext-common.S [new file with mode: 0644]
sysdeps/unix/sysv/linux/or1k/getcontext.S
sysdeps/unix/sysv/linux/or1k/libc.abilist
sysdeps/unix/sysv/linux/or1k/makecontext.c
sysdeps/unix/sysv/linux/or1k/setcontext-common.S [new file with mode: 0644]
sysdeps/unix/sysv/linux/or1k/setcontext.S
sysdeps/unix/sysv/linux/or1k/swapcontext-common.S [new file with mode: 0644]
sysdeps/unix/sysv/linux/or1k/swapcontext.S
sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
sysdeps/unix/sysv/linux/or1k/ucontext_i.sym