9
9
#include " llvm/IR/RuntimeLibcalls.h"
10
10
#include " llvm/ADT/StringTable.h"
11
11
#include " llvm/Support/Debug.h"
12
+ #include " llvm/TargetParser/ARMTargetParser.h"
12
13
13
14
#define DEBUG_TYPE " runtime-libcalls-info"
14
15
@@ -22,8 +23,39 @@ using namespace RTLIB;
22
23
#undef GET_SET_TARGET_RUNTIME_LIBCALL_SETS
23
24
24
25
static void setARMLibcallNames (RuntimeLibcallsInfo &Info, const Triple &TT,
25
- FloatABI::ABIType FloatABIType,
26
- EABI EABIVersion) {
26
+ FloatABI::ABIType FloatABIType, EABI EABIVersion,
27
+ StringRef ABIName) {
28
+ // The half <-> float conversion functions are always soft-float on
29
+ // non-watchos platforms, but are needed for some targets which use a
30
+ // hard-float calling convention by default.
31
+ if (!TT.isWatchABI ()) {
32
+ ARM::ARMABI TargetABI = ARM::computeTargetABI (TT, ABIName);
33
+
34
+ if (TargetABI == ARM::ARM_ABI_AAPCS || TargetABI == ARM::ARM_ABI_AAPCS16) {
35
+ Info.setLibcallImplCallingConv (RTLIB::__truncsfhf2,
36
+ CallingConv::ARM_AAPCS);
37
+ Info.setLibcallImplCallingConv (RTLIB::__truncdfhf2,
38
+ CallingConv::ARM_AAPCS);
39
+ Info.setLibcallImplCallingConv (RTLIB::__extendhfsf2,
40
+ CallingConv::ARM_AAPCS);
41
+ Info.setLibcallImplCallingConv (RTLIB::__gnu_h2f_ieee,
42
+ CallingConv::ARM_AAPCS);
43
+ Info.setLibcallImplCallingConv (RTLIB::__gnu_f2h_ieee,
44
+ CallingConv::ARM_AAPCS);
45
+ } else {
46
+ Info.setLibcallImplCallingConv (RTLIB::__truncsfhf2,
47
+ CallingConv::ARM_APCS);
48
+ Info.setLibcallImplCallingConv (RTLIB::__truncdfhf2,
49
+ CallingConv::ARM_APCS);
50
+ Info.setLibcallImplCallingConv (RTLIB::__extendhfsf2,
51
+ CallingConv::ARM_APCS);
52
+ Info.setLibcallImplCallingConv (RTLIB::__gnu_h2f_ieee,
53
+ CallingConv::ARM_APCS);
54
+ Info.setLibcallImplCallingConv (RTLIB::__gnu_f2h_ieee,
55
+ CallingConv::ARM_APCS);
56
+ }
57
+ }
58
+
27
59
static const RTLIB::LibcallImpl AAPCS_Libcalls[] = {
28
60
RTLIB::__aeabi_dadd, RTLIB::__aeabi_ddiv,
29
61
RTLIB::__aeabi_dmul, RTLIB::__aeabi_dsub,
@@ -75,7 +107,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
75
107
setLibcallImpl (RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
76
108
77
109
if (TT.isARM () || TT.isThumb ()) {
78
- setARMLibcallNames (*this , TT, FloatABI, EABIVersion);
110
+ setARMLibcallNames (*this , TT, FloatABI, EABIVersion, ABIName );
79
111
return ;
80
112
}
81
113
0 commit comments