Skip to content

Commit 368d66a

Browse files
authored
Merge pull request #30888 from compnerd/android-shims
runtime: provide AEABI shims for floating point conversion
2 parents a5fa431 + dce9614 commit 368d66a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

stdlib/public/runtime/Float16Support.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
//
2828
//===----------------------------------------------------------------------===//
2929

30-
#if defined(__x86_64__) && !defined(__APPLE__)
30+
// Android NDK <r21 do not provide `__aeabi_d2h` in the compiler runtime,
31+
// provide shims in that case.
32+
#if (defined(ANDROID) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
33+
(defined(__x86_64__) && !defined(__APPLE__))
3134

3235
#include "../SwiftShims/Visibility.h"
3336

@@ -45,7 +48,7 @@ static float fromEncoding(unsigned int e) {
4548
return f;
4649
}
4750

48-
#if defined __F16C__
51+
#if defined(__x86_64__) && defined(__F16C__)
4952

5053
// If we're compiling the runtime for a target that has the conversion
5154
// instruction, we might as well just use those. In theory, we'd also be
@@ -161,4 +164,10 @@ SWIFT_RUNTIME_EXPORT unsigned short __truncdfhf2(double d) {
161164
return __gnu_f2h_ieee(f);
162165
}
163166

167+
#if defined(__ARM_EABI__)
168+
SWIFT_RUNTIME_EXPORT unsigned short __aeabi_d2h(double d) {
169+
return __truncdfhf2(d);
170+
}
171+
#endif
172+
164173
#endif // defined(__x86_64__) && !defined(__APPLE__)

0 commit comments

Comments
 (0)