Skip to content

Commit 67eb146

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 c00b04a commit 67eb146

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

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

1579-
// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI
1580-
// they have a __gnu_ prefix (which is the default).
1581-
def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f),
1582-
isTargetAEABIAndAAPCS_ABI> {
1583-
let CallingConv = ARM_AAPCS;
1584-
}
1585-
15861579
// The half <-> float conversion functions are always soft-float on
15871580
// non-watchos platforms, but are needed for some targets which use a
15881581
// hard-float calling convention by default.
@@ -1591,6 +1584,27 @@ def ARMHalfConvertLibcallCallingConv : LibcallCallingConv<
15911584
(isAAPCS_ABI(TT, ABIName) ? CallingConv::ARM_AAPCS : CallingConv::ARM_APCS)}]
15921585
>;
15931586

1587+
def ARMLibgccHalfConvertCalls :
1588+
LibcallImpls<(add __truncsfhf2, __extendhfsf2),
1589+
RuntimeLibcallPredicate<[{!TT.isTargetAEABI() && TT.isOSBinFormatMachO()}]>> {
1590+
let CallingConv = ARMHalfConvertLibcallCallingConv;
1591+
}
1592+
1593+
// FIXME: These conditions are probably bugged. We're using the
1594+
// default libgcc call when the other cases are replaced.
1595+
def ARMDoubleToHalfCalls :
1596+
LibcallImpls<(add __truncdfhf2),
1597+
RuntimeLibcallPredicate<[{!TT.isTargetAEABI()}]>> {
1598+
let CallingConv = ARMHalfConvertLibcallCallingConv;
1599+
}
1600+
1601+
// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI
1602+
// they have a __gnu_ prefix (which is the default).
1603+
def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f),
1604+
isTargetAEABIAndAAPCS_ABI> {
1605+
let CallingConv = ARM_AAPCS;
1606+
}
1607+
15941608
def GNUEABIHalfConvertCalls :
15951609
LibcallImpls<(add __gnu_f2h_ieee, __gnu_h2f_ieee),
15961610
RuntimeLibcallPredicate<[{!TT.isOSBinFormatMachO() &&
@@ -1717,7 +1731,9 @@ def isARMOrThumb : RuntimeLibcallPredicate<"TT.isARM() || TT.isThumb()">;
17171731

17181732
def ARMSystemLibrary
17191733
: SystemRuntimeLibrary<isARMOrThumb,
1720-
(add WinDefaultLibcallImpls,
1734+
(add (sub WinDefaultLibcallImpls, ARMLibgccHalfConvertCalls,
1735+
GNUEABIHalfConvertCalls,
1736+
ARMDoubleToHalfCalls),
17211737
LibcallImpls<(add __powisf2, __powidf2), isNotOSMSVCRT>,
17221738
LibmHasFrexpF32, LibmHasLdexpF32,
17231739
LibmHasFrexpF128, LibmHasLdexpF128,
@@ -1731,8 +1747,10 @@ def ARMSystemLibrary
17311747

17321748
AEABICalls,
17331749
AEABI45MemCalls,
1750+
ARMLibgccHalfConvertCalls,
17341751
EABIHalfConvertCalls,
17351752
GNUEABIHalfConvertCalls,
1753+
ARMDoubleToHalfCalls,
17361754

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

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +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::__truncsfhf2, CallingConv::ARM_AAPCS);
44-
setLibcallImplCallingConv(RTLIB::__truncdfhf2, CallingConv::ARM_AAPCS);
45-
setLibcallImplCallingConv(RTLIB::__extendhfsf2, CallingConv::ARM_AAPCS);
46-
} else {
47-
setLibcallImplCallingConv(RTLIB::__truncsfhf2, CallingConv::ARM_APCS);
48-
setLibcallImplCallingConv(RTLIB::__truncdfhf2, CallingConv::ARM_APCS);
49-
setLibcallImplCallingConv(RTLIB::__extendhfsf2, CallingConv::ARM_APCS);
50-
}
51-
}
52-
53-
return;
54-
}
5536
}
5637

5738
LLVM_ATTRIBUTE_ALWAYS_INLINE

0 commit comments

Comments
 (0)