Skip to content

Commit 3bf268a

Browse files
committed
RuntimeLibcalls: Pass in FloatABI and EABI type
We need the full set of ABI options to accurately compute the full set of libcalls. This partially resolves missing information required to compute the set of ARM calls.
1 parent a1c2a71 commit 3bf268a

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/IR/CallingConv.h"
2020
#include "llvm/IR/InstrTypes.h"
2121
#include "llvm/Support/AtomicOrdering.h"
22+
#include "llvm/Support/CodeGen.h"
2223
#include "llvm/Support/Compiler.h"
2324
#include "llvm/TargetParser/Triple.h"
2425

@@ -53,8 +54,10 @@ static inline auto libcalls() {
5354

5455
/// A simple container for information about the supported runtime calls.
5556
struct RuntimeLibcallsInfo {
56-
explicit RuntimeLibcallsInfo(const Triple &TT) {
57-
initLibcalls(TT);
57+
explicit RuntimeLibcallsInfo(const Triple &TT,
58+
FloatABI::ABIType FloatABI = FloatABI::Default,
59+
EABI EABIVersion = EABI::Default) {
60+
initLibcalls(TT, FloatABI, EABIVersion);
5861
}
5962

6063
/// Rename the default libcall routine name for the specified libcall.
@@ -144,7 +147,8 @@ struct RuntimeLibcallsInfo {
144147

145148
/// Set default libcall names. If a target wants to opt-out of a libcall it
146149
/// should be placed here.
147-
LLVM_ABI void initLibcalls(const Triple &TT);
150+
LLVM_ABI void initLibcalls(const Triple &TT, FloatABI::ABIType FloatABI,
151+
EABI ABIType);
148152
};
149153

150154
} // namespace RTLIB

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,8 @@ void RTLIB::initCmpLibcallCCs(ISD::CondCode *CmpLibcallCCs) {
632632

633633
/// NOTE: The TargetMachine owns TLOF.
634634
TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm)
635-
: TM(tm), Libcalls(TM.getTargetTriple()) {
635+
: TM(tm), Libcalls(TM.getTargetTriple(), TM.Options.FloatABIType,
636+
TM.Options.EABIVersion) {
636637
initActions();
637638

638639
// Perform these initializations only once.

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,17 @@ static void setAArch64LibcallNames(RuntimeLibcallsInfo &Info,
6565
#undef LCALLNAME5
6666
}
6767

68-
static void setARMLibcallNames(RuntimeLibcallsInfo &Info, const Triple &TT) {
68+
static void setARMLibcallNames(RuntimeLibcallsInfo &Info, const Triple &TT,
69+
FloatABI::ABIType FloatABIType,
70+
EABI EABIVersion) {
71+
if (!TT.isOSDarwin() && !TT.isiOS() && !TT.isWatchOS() && !TT.isDriverKit()) {
72+
CallingConv::ID DefaultCC = FloatABIType == FloatABI::Hard
73+
? CallingConv::ARM_AAPCS_VFP
74+
: CallingConv::ARM_AAPCS;
75+
for (RTLIB::Libcall LC : RTLIB::libcalls())
76+
Info.setLibcallCallingConv(LC, DefaultCC);
77+
}
78+
6979
// Register based DivRem for AEABI (RTABI 4.2)
7080
if (TT.isTargetAEABI() || TT.isAndroid() || TT.isTargetGNUAEABI() ||
7181
TT.isTargetMuslAEABI() || TT.isOSWindows()) {
@@ -346,7 +356,9 @@ static void setLongDoubleIsF128Libm(RuntimeLibcallsInfo &Info,
346356

347357
/// Set default libcall names. If a target wants to opt-out of a libcall it
348358
/// should be placed here.
349-
void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
359+
void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
360+
FloatABI::ABIType FloatABI,
361+
EABI EABIVersion) {
350362
initSoftFloatCmpLibcallPredicates();
351363

352364
initSoftFloatCmpLibcallPredicates();
@@ -539,7 +551,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
539551
if (TT.isAArch64())
540552
setAArch64LibcallNames(*this, TT);
541553
else if (TT.isARM() || TT.isThumb())
542-
setARMLibcallNames(*this, TT);
554+
setARMLibcallNames(*this, TT, FloatABI, EABIVersion);
543555
else if (TT.getArch() == Triple::ArchType::avr) {
544556
// Division rtlib functions (not supported), use divmod functions instead
545557
setLibcallName(RTLIB::SDIV_I8, nullptr);

llvm/lib/Object/IRSymtab.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Expected<int> Builder::getComdatIndex(const Comdat *C, const Module *M) {
216216
static DenseSet<StringRef> buildPreservedSymbolsSet(const Triple &TT) {
217217
DenseSet<StringRef> PreservedSymbolSet(std::begin(PreservedSymbols),
218218
std::end(PreservedSymbols));
219-
219+
// FIXME: Do we need to pass in ABI fields from TargetOptions?
220220
RTLIB::RuntimeLibcallsInfo Libcalls(TT);
221221
for (const char *Name : Libcalls.getLibcallNames()) {
222222
if (Name)

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -508,16 +508,6 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
508508
setBooleanContents(ZeroOrOneBooleanContent);
509509
setBooleanVectorContents(ZeroOrNegativeOneBooleanContent);
510510

511-
if (!Subtarget->isTargetDarwin() && !Subtarget->isTargetIOS() &&
512-
!Subtarget->isTargetWatchOS() && !Subtarget->isTargetDriverKit()) {
513-
bool IsHFTarget = TM.Options.FloatABIType == FloatABI::Hard;
514-
515-
for (RTLIB::Libcall LC : RTLIB::libcalls()) {
516-
setLibcallCallingConv(LC, IsHFTarget ? CallingConv::ARM_AAPCS_VFP
517-
: CallingConv::ARM_AAPCS);
518-
}
519-
}
520-
521511
if (Subtarget->isTargetMachO()) {
522512
// Uses VFP for Thumb libfuncs if available.
523513
if (Subtarget->isThumb() && Subtarget->hasVFP2Base() &&

0 commit comments

Comments
 (0)