Skip to content

Commit

Permalink
Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is …
Browse files Browse the repository at this point in the history
…available"

Disable the build on macOS due to the bot fail.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D131147
  • Loading branch information
phoebewang committed Aug 10, 2022
1 parent e3fcf2e commit 0729d00
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions compiler-rt/cmake/builtin-config-ix.cmake
Expand Up @@ -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\");
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/builtins/CMakeLists.txt
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/builtins/fp_trunc.h
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions compiler-rt/lib/builtins/truncdfbf2.c
Expand Up @@ -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
3 changes: 3 additions & 0 deletions compiler-rt/lib/builtins/truncsfbf2.c
Expand Up @@ -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

0 comments on commit 0729d00

Please sign in to comment.