git: 47020df00dd8 - stable/14 - libcompiler_rt Makefile.inc: update _Float16/__bf16 checks
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 20 Apr 2024 10:32:52 UTC
The branch stable/14 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=47020df00dd821a8102cfd7358408de0ed9b6f39 commit 47020df00dd821a8102cfd7358408de0ed9b6f39 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-04-17 20:20:47 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-04-20 10:03:26 +0000 libcompiler_rt Makefile.inc: update _Float16/__bf16 checks Clang supports __bf16 for riscv from version 18.0 onwards, so update the checks for it. While here, rewrite the checks so they are hopefully more readable, and also handle gcc a little better. In addition, define COMPILER_RT_HAS_FLOAT16 and COMPILER_RT_HAS_BFLOAT16 when these features should be available, since there are some parts in compiler-rt that check for these defines. PR: 276104 MFC after: 1 month (cherry picked from commit f276adc148433d009d198c2ebccdd3303377e237) --- lib/libcompiler_rt/Makefile.inc | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/lib/libcompiler_rt/Makefile.inc b/lib/libcompiler_rt/Makefile.inc index 47d87b71ea77..9aea0f2b051a 100644 --- a/lib/libcompiler_rt/Makefile.inc +++ b/lib/libcompiler_rt/Makefile.inc @@ -226,13 +226,36 @@ SRCF+= comparedf2 SRCF+= comparesf2 .endif +# Helper to reduce complexity of _Float16 and __bf16 statements below. +.if ${MACHINE_CPUARCH} == "aarch64" || \ + ${MACHINE_CPUARCH} == "amd64" || \ + ${MACHINE_CPUARCH} == "arm" || \ + (${MACHINE_CPUARCH} == "i386" && !empty(MACHINE_CPU:Msse2)) +CRT_COMMON_F16_ARCH=t +.endif + +# +# _Float16 support, only on some architectures, and with certain compiler +# versions. +# +.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \ + (defined(CRT_COMMON_F16_ARCH) || ${MACHINE_CPUARCH} == "riscv")) || \ + ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120000) && \ + (defined(CRT_COMMON_F16_ARCH))) +CFLAGS+= -DCOMPILER_RT_HAS_FLOAT16 +.endif + # -# bfloat16 support, only used on some architectures. +# __bf16 support, only on some architectures, and with certain compiler +# versions. # -.if (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ - ${MACHINE_CPUARCH} == "arm" || (${MACHINE_CPUARCH} == "i386" && \ - !empty(MACHINE_CPU:Msse2)) || ${MACHINE_CPUARCH} == "riscv") && \ - !(${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 130000) +.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \ + (defined(CRT_COMMON_F16_ARCH))) || \ + ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 180000) && \ + ${MACHINE_CPUARCH} == "riscv") || \ + ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 130000) && \ + (defined(CRT_COMMON_F16_ARCH))) +CFLAGS+= -DCOMPILER_RT_HAS_BFLOAT16 SRCF+= truncdfbf2 SRCF+= truncsfbf2 .endif