[llvm-branch-commits] [compiler-rt] 54d0758 - [compiler-rt][BF16] Provide __truncdfbf2 and __truncsfbf2 only when __bf16 is available
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 11 23:40:46 PDT 2022
Author: Phoebe Wang
Date: 2022-08-12T08:39:37+02:00
New Revision: 54d0758c44d5fabca9e6cca09329b510d8c1eafc
URL: https://github.com/llvm/llvm-project/commit/54d0758c44d5fabca9e6cca09329b510d8c1eafc
DIFF: https://github.com/llvm/llvm-project/commit/54d0758c44d5fabca9e6cca09329b510d8c1eafc.diff
LOG: [compiler-rt][BF16] Provide __truncdfbf2 and __truncsfbf2 only when __bf16 is available
Differential Revision: https://reviews.llvm.org/D131147
(cherry picked from commit f061cfb31730b72b7d8920bb4a306a1d2ce7f2e4)
Added:
Modified:
compiler-rt/cmake/builtin-config-ix.cmake
compiler-rt/lib/builtins/CMakeLists.txt
compiler-rt/lib/builtins/fp_trunc.h
Removed:
################################################################################
diff --git a/compiler-rt/cmake/builtin-config-ix.cmake b/compiler-rt/cmake/builtin-config-ix.cmake
index 9cbadf33e2574..439abc713bad9 100644
--- a/compiler-rt/cmake/builtin-config-ix.cmake
+++ b/compiler-rt/cmake/builtin-config-ix.cmake
@@ -30,6 +30,14 @@ _Float16 foo(_Float16 x) {
"
)
+builtin_check_c_compiler_source(COMPILER_RT_HAS_BFLOAT16
+"
+__bf16 foo(__bf16 x) {
+ return x;
+}
+"
+)
+
builtin_check_c_compiler_source(COMPILER_RT_HAS_ASM_LSE
"
asm(\".arch armv8-a+lse\");
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index 795fe2ab316d8..ec668e294d6d7 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -165,10 +165,8 @@ set(GENERIC_SOURCES
subvsi3.c
subvti3.c
trampoline_setup.c
- truncdfbf2.c
truncdfhf2.c
truncdfsf2.c
- truncsfbf2.c
truncsfhf2.c
ucmpdi2.c
ucmpti2.c
@@ -183,6 +181,15 @@ set(GENERIC_SOURCES
umodti3.c
)
+# Build BF16 files only when "__bf16" is available.
+if(COMPILER_RT_HAS_BFLOAT16 AND NOT APPLE)
+ set(GENERIC_SOURCES
+ ${GENERIC_SOURCES}
+ truncdfbf2.c
+ truncsfbf2.c
+ )
+endif()
+
# TODO: Several "tf" files (and divtc3.c, but not multc3.c) are in
# GENERIC_SOURCES instead of here.
set(GENERIC_TF_SOURCES
diff --git a/compiler-rt/lib/builtins/fp_trunc.h b/compiler-rt/lib/builtins/fp_trunc.h
index 7a54564a3520a..91f614528ab3f 100644
--- a/compiler-rt/lib/builtins/fp_trunc.h
+++ b/compiler-rt/lib/builtins/fp_trunc.h
@@ -60,7 +60,7 @@ typedef uint16_t dst_rep_t;
static const int dstSigBits = 10;
#elif defined DST_BFLOAT
-typedef uint16_t dst_t;
+typedef __bf16 dst_t;
typedef uint16_t dst_rep_t;
#define DST_REP_C UINT16_C
static const int dstSigBits = 7;
More information about the llvm-branch-commits
mailing list