Skip to content

Commit 3128daa

Browse files
committed
ARM: Remove remaining half convert libcall config into tablegen
The __truncdfhf2 handling is kind of convoluted, but reproduces the existing, likely wrong, handling.
1 parent b159631 commit 3128daa

File tree

2 files changed

+26
-33
lines changed

2 files changed

+26
-33
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,13 +1614,6 @@ def __aeabi_h2f : RuntimeLibcallImpl<FPEXT_F16_F32>; // CallingConv::ARM_AAPCS
16141614
def __gnu_f2h_ieee : RuntimeLibcallImpl<FPROUND_F32_F16>;
16151615
def __gnu_h2f_ieee : RuntimeLibcallImpl<FPEXT_F16_F32>;
16161616

1617-
// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI
1618-
// they have a __gnu_ prefix (which is the default).
1619-
def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f),
1620-
isTargetAEABIAndAAPCS_ABI> {
1621-
let CallingConv = ARM_AAPCS;
1622-
}
1623-
16241617
// The half <-> float conversion functions are always soft-float on
16251618
// non-watchos platforms, but are needed for some targets which use a
16261619
// hard-float calling convention by default.
@@ -1629,6 +1622,27 @@ def ARMHalfConvertLibcallCallingConv : LibcallCallingConv<
16291622
(isAAPCS_ABI(TT, ABIName) ? CallingConv::ARM_AAPCS : CallingConv::ARM_APCS)}]
16301623
>;
16311624

1625+
def ARMLibgccHalfConvertCalls :
1626+
LibcallImpls<(add __truncsfhf2, __extendhfsf2),
1627+
RuntimeLibcallPredicate<[{!TT.isTargetAEABI() && TT.isOSBinFormatMachO()}]>> {
1628+
let CallingConv = ARMHalfConvertLibcallCallingConv;
1629+
}
1630+
1631+
// FIXME: These conditions are probably bugged. We're using the
1632+
// default libgcc call when the other cases are replaced.
1633+
def ARMDoubleToHalfCalls :
1634+
LibcallImpls<(add __truncdfhf2),
1635+
RuntimeLibcallPredicate<[{!TT.isTargetAEABI()}]>> {
1636+
let CallingConv = ARMHalfConvertLibcallCallingConv;
1637+
}
1638+
1639+
// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI
1640+
// they have a __gnu_ prefix (which is the default).
1641+
def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f),
1642+
isTargetAEABIAndAAPCS_ABI> {
1643+
let CallingConv = ARM_AAPCS;
1644+
}
1645+
16321646
def GNUEABIHalfConvertCalls :
16331647
LibcallImpls<(add __gnu_f2h_ieee, __gnu_h2f_ieee),
16341648
RuntimeLibcallPredicate<[{!TT.isOSBinFormatMachO() &&
@@ -1755,7 +1769,9 @@ def isARMOrThumb : RuntimeLibcallPredicate<"TT.isARM() || TT.isThumb()">;
17551769

17561770
def ARMSystemLibrary
17571771
: SystemRuntimeLibrary<isARMOrThumb,
1758-
(add WinDefaultLibcallImpls,
1772+
(add (sub WinDefaultLibcallImpls, ARMLibgccHalfConvertCalls,
1773+
GNUEABIHalfConvertCalls,
1774+
ARMDoubleToHalfCalls),
17591775
LibcallImpls<(add __powisf2, __powidf2), isNotOSMSVCRT>,
17601776
LibmHasFrexpF32, LibmHasLdexpF32,
17611777
LibmHasFrexpF128, LibmHasLdexpF128,
@@ -1769,8 +1785,10 @@ def ARMSystemLibrary
17691785

17701786
AEABICalls,
17711787
AEABI45MemCalls,
1788+
ARMLibgccHalfConvertCalls,
17721789
EABIHalfConvertCalls,
17731790
GNUEABIHalfConvertCalls,
1791+
ARMDoubleToHalfCalls,
17741792

17751793
// Use divmod compiler-rt calls for iOS 5.0 and later.
17761794
LibcallImpls<(add __divmodsi4, __udivmodsi4),

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,6 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
3333
EABI EABIVersion, StringRef ABIName) {
3434
setTargetRuntimeLibcallSets(TT, ExceptionModel, FloatABI, EABIVersion,
3535
ABIName);
36-
37-
if (TT.isARM() || TT.isThumb()) {
38-
// The half <-> float conversion functions are always soft-float on
39-
// non-watchos platforms, but are needed for some targets which use a
40-
// hard-float calling convention by default.
41-
if (!TT.isWatchABI()) {
42-
if (isAAPCS_ABI(TT, ABIName)) {
43-
setLibcallImplCallingConv(RTLIB::impl___truncsfhf2,
44-
CallingConv::ARM_AAPCS);
45-
setLibcallImplCallingConv(RTLIB::impl___truncdfhf2,
46-
CallingConv::ARM_AAPCS);
47-
setLibcallImplCallingConv(RTLIB::impl___extendhfsf2,
48-
CallingConv::ARM_AAPCS);
49-
} else {
50-
setLibcallImplCallingConv(RTLIB::impl___truncsfhf2,
51-
CallingConv::ARM_APCS);
52-
setLibcallImplCallingConv(RTLIB::impl___truncdfhf2,
53-
CallingConv::ARM_APCS);
54-
setLibcallImplCallingConv(RTLIB::impl___extendhfsf2,
55-
CallingConv::ARM_APCS);
56-
}
57-
}
58-
59-
return;
60-
}
6136
}
6237

6338
LLVM_ATTRIBUTE_ALWAYS_INLINE

0 commit comments

Comments
 (0)