[compiler-rt] ab4e5ed - Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 9 19:23:06 PDT 2022
Author: Phoebe Wang
Date: 2022-08-10T10:22:15+08:00
New Revision: ab4e5ed441d475ead43bc4ce1cdef842688292f4
URL: https://github.com/llvm/llvm-project/commit/ab4e5ed441d475ead43bc4ce1cdef842688292f4
DIFF: https://github.com/llvm/llvm-project/commit/ab4e5ed441d475ead43bc4ce1cdef842688292f4.diff
LOG: Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"
Fix the mising change for truncdfbf2.c
Reviewed By: bkramer
Differential Revision: https://reviews.llvm.org/D131147
Added:
Modified:
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
compiler-rt/cmake/builtin-config-ix.cmake
compiler-rt/lib/builtins/CMakeLists.txt
compiler-rt/lib/builtins/fp_trunc.h
compiler-rt/lib/builtins/truncdfbf2.c
compiler-rt/lib/builtins/truncsfbf2.c
Removed:
################################################################################
diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index 2c9983c6a1ae3..9ece3c2c38559 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -406,6 +406,8 @@ macro(darwin_add_builtin_libraries)
append_list_if(COMPILER_RT_HAS_ASM_LSE -DHAS_ASM_LSE CFLAGS)
+ append_list_if(COMPILER_RT_HAS_BFLOAT16 -DCOMPILER_RT_HAS_BFLOAT16 CFLAGS)
+
set(PROFILE_SOURCES ../profile/InstrProfiling.c
../profile/InstrProfilingBuffer.c
../profile/InstrProfilingPlatformDarwin.c
diff --git a/compiler-rt/cmake/builtin-config-ix.cmake b/compiler-rt/cmake/builtin-config-ix.cmake
index 5aa2114fab93f..62e8281b919cf 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 6143457cc9339..05c37930dae83 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -699,6 +699,8 @@ else ()
append_list_if(COMPILER_RT_HAS_FLOAT16 -DCOMPILER_RT_HAS_FLOAT16 BUILTIN_CFLAGS)
+ append_list_if(COMPILER_RT_HAS_BFLOAT16 -DCOMPILER_RT_HAS_BFLOAT16 BUILTIN_CFLAGS)
+
append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 BUILTIN_CFLAGS)
# These flags would normally be added to CMAKE_C_FLAGS by the llvm
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;
diff --git a/compiler-rt/lib/builtins/truncdfbf2.c b/compiler-rt/lib/builtins/truncdfbf2.c
index dbd54dcd50caf..b87385eeaca05 100644
--- a/compiler-rt/lib/builtins/truncdfbf2.c
+++ b/compiler-rt/lib/builtins/truncdfbf2.c
@@ -6,8 +6,11 @@
//
//===----------------------------------------------------------------------===//
+#if defined(COMPILER_RT_HAS_BFLOAT16)
#define SRC_DOUBLE
#define DST_BFLOAT
#include "fp_trunc_impl.inc"
COMPILER_RT_ABI dst_t __truncdfbf2(double a) { return __truncXfYf2__(a); }
+
+#endif
diff --git a/compiler-rt/lib/builtins/truncsfbf2.c b/compiler-rt/lib/builtins/truncsfbf2.c
index 6bed116af9868..42ddab32a2f1c 100644
--- a/compiler-rt/lib/builtins/truncsfbf2.c
+++ b/compiler-rt/lib/builtins/truncsfbf2.c
@@ -6,8 +6,11 @@
//
//===----------------------------------------------------------------------===//
+#if defined(COMPILER_RT_HAS_BFLOAT16)
#define SRC_SINGLE
#define DST_BFLOAT
#include "fp_trunc_impl.inc"
COMPILER_RT_ABI dst_t __truncsfbf2(float a) { return __truncXfYf2__(a); }
+
+#endif
More information about the llvm-commits
mailing list