99#include " llvm/IR/RuntimeLibcalls.h"
1010#include " llvm/ADT/StringTable.h"
1111#include " llvm/Support/Debug.h"
12+ #include " llvm/TargetParser/ARMTargetParser.h"
1213
1314#define DEBUG_TYPE " runtime-libcalls-info"
1415
@@ -22,8 +23,39 @@ using namespace RTLIB;
2223#undef GET_SET_TARGET_RUNTIME_LIBCALL_SETS
2324
2425static 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+
2759 static const RTLIB::LibcallImpl AAPCS_Libcalls[] = {
2860 RTLIB::__aeabi_dadd, RTLIB::__aeabi_ddiv,
2961 RTLIB::__aeabi_dmul, RTLIB::__aeabi_dsub,
@@ -75,7 +107,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
75107 setLibcallImpl (RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
76108
77109 if (TT.isARM () || TT.isThumb ()) {
78- setARMLibcallNames (*this , TT, FloatABI, EABIVersion);
110+ setARMLibcallNames (*this , TT, FloatABI, EABIVersion, ABIName );
79111 return ;
80112 }
81113
0 commit comments