Skip to content

Commit f012e8f

Browse files
committed
ARM: Move calling conv config to RuntimeLibcalls
Consolidate module level ABI into RuntimeLibcalls
1 parent 1392edc commit f012e8f

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
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

2425
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+
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

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -707,25 +707,6 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM_,
707707
}
708708
}
709709

710-
// The half <-> float conversion functions are always soft-float on
711-
// non-watchos platforms, but are needed for some targets which use a
712-
// hard-float calling convention by default.
713-
if (!TT.isWatchABI()) {
714-
if (TM.isAAPCS_ABI()) {
715-
setLibcallImplCallingConv(RTLIB::__truncsfhf2, CallingConv::ARM_AAPCS);
716-
setLibcallImplCallingConv(RTLIB::__truncdfhf2, CallingConv::ARM_AAPCS);
717-
setLibcallImplCallingConv(RTLIB::__extendhfsf2, CallingConv::ARM_AAPCS);
718-
setLibcallImplCallingConv(RTLIB::__gnu_h2f_ieee, CallingConv::ARM_AAPCS);
719-
setLibcallImplCallingConv(RTLIB::__gnu_f2h_ieee, CallingConv::ARM_AAPCS);
720-
} else {
721-
setLibcallImplCallingConv(RTLIB::__truncsfhf2, CallingConv::ARM_APCS);
722-
setLibcallImplCallingConv(RTLIB::__truncdfhf2, CallingConv::ARM_APCS);
723-
setLibcallImplCallingConv(RTLIB::__extendhfsf2, CallingConv::ARM_APCS);
724-
setLibcallImplCallingConv(RTLIB::__gnu_h2f_ieee, CallingConv::ARM_APCS);
725-
setLibcallImplCallingConv(RTLIB::__gnu_f2h_ieee, CallingConv::ARM_APCS);
726-
}
727-
}
728-
729710
// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI they have
730711
// a __gnu_ prefix (which is the default).
731712
if (TT.isTargetAEABI()) {

0 commit comments

Comments
 (0)