Skip to content

Commit 4aae7bc

Browse files
authored
ARM: Move half convert libcall config to tablegen (#153389)
1 parent 04aebbf commit 4aae7bc

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,9 @@ def AMDGPUSystemLibrary : SystemRuntimeLibrary<isAMDGPU, (add)>;
12801280
// ARM Runtime Libcalls
12811281
//===----------------------------------------------------------------------===//
12821282

1283+
def isTargetAEABIAndAAPCS_ABI : RuntimeLibcallPredicate<
1284+
[{TT.isTargetAEABI() && isAAPCS_ABI(TT, ABIName)}]>;
1285+
12831286
// if (isTargetMachO()) {
12841287
// if (Subtarget->isThumb() && Subtarget->hasVFP2Base() &&
12851288
// Subtarget->hasARMOps() && !Subtarget->useSoftFloat()) {
@@ -1473,13 +1476,23 @@ def __udivmodsi4 : RuntimeLibcallImpl<UDIVREM_I32>;
14731476
// a __gnu_ prefix (which is the default).
14741477
// isTargetAEABI()
14751478
def __aeabi_f2h : RuntimeLibcallImpl<FPROUND_F32_F16>; // CallingConv::ARM_AAPCS
1476-
//def __aeabi_d2h : RuntimeLibcallImpl<FPROUND_F64_F16>; // CallingConv::ARM_AAPCS
14771479
def __aeabi_h2f : RuntimeLibcallImpl<FPEXT_F16_F32>; // CallingConv::ARM_AAPCS
14781480

14791481
// !isTargetMachO()
14801482
def __gnu_f2h_ieee : RuntimeLibcallImpl<FPROUND_F32_F16>;
14811483
def __gnu_h2f_ieee : RuntimeLibcallImpl<FPEXT_F16_F32>;
14821484

1485+
def GNUEABIHalfConvertCalls :
1486+
LibcallImpls<(add __gnu_f2h_ieee, __gnu_h2f_ieee),
1487+
RuntimeLibcallPredicate<[{!TT.isOSBinFormatMachO() &&
1488+
!TT.isTargetAEABI()}]>>;
1489+
1490+
// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI
1491+
// they have a __gnu_ prefix (which is the default).
1492+
def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f),
1493+
isTargetAEABIAndAAPCS_ABI> {
1494+
let CallingConv = ARM_AAPCS;
1495+
}
14831496

14841497
def WindowARMDivRemCalls : LibcallImpls<
14851498
(add __rt_sdiv, __rt_sdiv64, __rt_udiv, __rt_udiv64),
@@ -1553,8 +1566,8 @@ def AEABICalls : LibcallImpls<
15531566
// RTABI chapter 4.1.2, Table 7
15541567
__aeabi_d2f,
15551568
__aeabi_f2d,
1556-
__aeabi_h2f,
1557-
__aeabi_f2h,
1569+
//__aeabi_h2f added separately
1570+
//__aeabi_f2h added separately
15581571
__aeabi_d2h,
15591572

15601573
// Integer to floating-point conversions.
@@ -1614,6 +1627,8 @@ def ARMSystemLibrary
16141627

16151628
AEABICalls,
16161629
AEABI45MemCalls,
1630+
EABIHalfConvertCalls,
1631+
GNUEABIHalfConvertCalls,
16171632

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

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -587,28 +587,6 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM_,
587587
}
588588
}
589589

590-
// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI they have
591-
// a __gnu_ prefix (which is the default).
592-
if (TT.isTargetAEABI()) {
593-
// FIXME: This does not depend on the subtarget and should go directly into
594-
// RuntimeLibcalls. This is only here because of missing support for setting
595-
// the calling convention of an implementation.
596-
static const struct {
597-
const RTLIB::Libcall Op;
598-
const RTLIB::LibcallImpl Impl;
599-
} LibraryCalls[] = {
600-
{RTLIB::FPROUND_F32_F16, RTLIB::__aeabi_f2h},
601-
{RTLIB::FPEXT_F16_F32, RTLIB::__aeabi_h2f},
602-
};
603-
604-
for (const auto &LC : LibraryCalls) {
605-
setLibcallImpl(LC.Op, LC.Impl);
606-
}
607-
} else if (!TT.isOSBinFormatMachO()) {
608-
setLibcallImpl(RTLIB::FPROUND_F32_F16, RTLIB::__gnu_f2h_ieee);
609-
setLibcallImpl(RTLIB::FPEXT_F16_F32, RTLIB::__gnu_h2f_ieee);
610-
}
611-
612590
if (Subtarget->isThumb1Only())
613591
addRegisterClass(MVT::i32, &ARM::tGPRRegClass);
614592
else

0 commit comments

Comments
 (0)