Skip to content

Commit

Permalink
Why do I even bother
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaraldi committed Dec 20, 2023
1 parent 9cb34c6 commit f9a68cc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/runtime_intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,23 +249,25 @@ float julia_half_to_float(uint16_t param) {

// starting with GCC 12 and Clang 15, we have _Float16 on most platforms
// (but not on Windows; this may be a bug in the MSYS2 GCC compilers)
// (but not on x86-darwin, because they reverted the ABI break only for libcalls https://github.com/llvm/llvm-project/commit/2bcf51c7f82ca7752d1bba390a2e0cb5fdd05ca9)
#if ((defined(__GNUC__) && __GNUC__ > 11) || \
(defined(__clang__) && __clang_major__ > 14)) && \
!defined(_CPU_PPC64_) && !defined(_CPU_PPC_) && \
!defined(_OS_WINDOWS_)
!defined(_OS_WINDOWS_) && !(defined(_CPU_X86_64_) && defined(_OS_DARWIN_))
#define FLOAT16_TYPE _Float16
#define FLOAT16_TO_UINT16(x) (*(uint16_t*)&(x))
#define FLOAT16_FROM_UINT16(x) (*(_Float16*)&(x))
// on older compilers, we need to emulate the platform-specific ABI
#elif defined(_CPU_X86_) || (defined(_CPU_X86_64_) && !defined(_OS_WINDOWS_))
#elif defined(_CPU_X86_) || (defined(_CPU_X86_64_) && !(defined(_OS_WINDOWS_) || defined(_OS_DARWIN_)))
// on x86, we can use __m128; except on Windows where x64 calling
// conventions expect to pass __m128 by reference.
#define FLOAT16_TYPE __m128
#define FLOAT16_TO_UINT16(x) take_from_xmm(x)
#define FLOAT16_FROM_UINT16(x) return_in_xmm(x)
#elif defined(_CPU_PPC64_) || defined(_CPU_PPC_)
#elif defined(_CPU_PPC64_) || defined(_CPU_PPC_) || defined(_OS_DARWIN_)
// on PPC, pass Float16 as if it were an integer, similar to the old x86 ABI
// before _Float16
// on Darwin we need to use uint16_t because libcalls use it
#define FLOAT16_TYPE uint16_t
#define FLOAT16_TO_UINT16(x) (x)
#define FLOAT16_FROM_UINT16(x) (x)
Expand Down

0 comments on commit f9a68cc

Please sign in to comment.