Skip to content

Commit bf4e8a6

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 7bda763 commit bf4e8a6

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
@@ -1482,13 +1482,6 @@ def __aeabi_h2f : RuntimeLibcallImpl<FPEXT_F16_F32>; // CallingConv::ARM_AAPCS
14821482
def __gnu_f2h_ieee : RuntimeLibcallImpl<FPROUND_F32_F16>;
14831483
def __gnu_h2f_ieee : RuntimeLibcallImpl<FPEXT_F16_F32>;
14841484

1485-
// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI
1486-
// they have a __gnu_ prefix (which is the default).
1487-
def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f),
1488-
isTargetAEABIAndAAPCS_ABI> {
1489-
let CallingConv = ARM_AAPCS;
1490-
}
1491-
14921485
// The half <-> float conversion functions are always soft-float on
14931486
// non-watchos platforms, but are needed for some targets which use a
14941487
// hard-float calling convention by default.
@@ -1497,6 +1490,27 @@ def ARMHalfConvertLibcallCallingConv : LibcallCallingConv<
14971490
(isAAPCS_ABI(TT, ABIName) ? CallingConv::ARM_AAPCS : CallingConv::ARM_APCS)}]
14981491
>;
14991492

1493+
def ARMLibgccHalfConvertCalls :
1494+
LibcallImpls<(add __truncsfhf2, __extendhfsf2),
1495+
RuntimeLibcallPredicate<[{!TT.isTargetAEABI() && TT.isOSBinFormatMachO()}]>> {
1496+
let CallingConv = ARMHalfConvertLibcallCallingConv;
1497+
}
1498+
1499+
// FIXME: These conditions are probably bugged. We're using the
1500+
// default libgcc call when the other cases are replaced.
1501+
def ARMDoubleToHalfCalls :
1502+
LibcallImpls<(add __truncdfhf2),
1503+
RuntimeLibcallPredicate<[{!TT.isTargetAEABI()}]>> {
1504+
let CallingConv = ARMHalfConvertLibcallCallingConv;
1505+
}
1506+
1507+
// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI
1508+
// they have a __gnu_ prefix (which is the default).
1509+
def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f),
1510+
isTargetAEABIAndAAPCS_ABI> {
1511+
let CallingConv = ARM_AAPCS;
1512+
}
1513+
15001514
def GNUEABIHalfConvertCalls :
15011515
LibcallImpls<(add __gnu_f2h_ieee, __gnu_h2f_ieee),
15021516
RuntimeLibcallPredicate<[{!TT.isOSBinFormatMachO() &&
@@ -1623,7 +1637,9 @@ def isARMOrThumb : RuntimeLibcallPredicate<"TT.isARM() || TT.isThumb()">;
16231637

16241638
def ARMSystemLibrary
16251639
: SystemRuntimeLibrary<isARMOrThumb,
1626-
(add WinDefaultLibcallImpls,
1640+
(add (sub WinDefaultLibcallImpls, ARMLibgccHalfConvertCalls,
1641+
GNUEABIHalfConvertCalls,
1642+
ARMDoubleToHalfCalls),
16271643
LibcallImpls<(add __powisf2, __powidf2), isNotOSMSVCRT>,
16281644
LibmHasFrexpF32, LibmHasLdexpF32,
16291645
LibmHasFrexpF128, LibmHasLdexpF128,
@@ -1637,8 +1653,10 @@ def ARMSystemLibrary
16371653

16381654
AEABICalls,
16391655
AEABI45MemCalls,
1656+
ARMLibgccHalfConvertCalls,
16401657
EABIHalfConvertCalls,
16411658
GNUEABIHalfConvertCalls,
1659+
ARMDoubleToHalfCalls,
16421660

16431661
// Use divmod compiler-rt calls for iOS 5.0 and later.
16441662
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
if (ExceptionModel == ExceptionHandling::SjLj)
3434
setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
3535

36-
if (TT.isARM() || TT.isThumb()) {
37-
// The half <-> float conversion functions are always soft-float on
38-
// non-watchos platforms, but are needed for some targets which use a
39-
// hard-float calling convention by default.
40-
if (!TT.isWatchABI()) {
41-
if (isAAPCS_ABI(TT, ABIName)) {
42-
setLibcallImplCallingConv(RTLIB::__truncsfhf2, CallingConv::ARM_AAPCS);
43-
setLibcallImplCallingConv(RTLIB::__truncdfhf2, CallingConv::ARM_AAPCS);
44-
setLibcallImplCallingConv(RTLIB::__extendhfsf2, CallingConv::ARM_AAPCS);
45-
} else {
46-
setLibcallImplCallingConv(RTLIB::__truncsfhf2, CallingConv::ARM_APCS);
47-
setLibcallImplCallingConv(RTLIB::__truncdfhf2, CallingConv::ARM_APCS);
48-
setLibcallImplCallingConv(RTLIB::__extendhfsf2, CallingConv::ARM_APCS);
49-
}
50-
}
51-
52-
return;
53-
}
54-
5536
if (TT.getArch() == Triple::ArchType::msp430) {
5637
setLibcallImplCallingConv(RTLIB::__mspabi_mpyll,
5738
CallingConv::MSP430_BUILTIN);

0 commit comments

Comments
 (0)