Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions llvm/include/llvm/IR/RuntimeLibcalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Compiler.h"
#include "llvm/TargetParser/Triple.h"

Expand Down Expand Up @@ -53,8 +54,10 @@ static inline auto libcalls() {

/// A simple container for information about the supported runtime calls.
struct RuntimeLibcallsInfo {
explicit RuntimeLibcallsInfo(const Triple &TT) {
initLibcalls(TT);
explicit RuntimeLibcallsInfo(const Triple &TT,
FloatABI::ABIType FloatABI = FloatABI::Default,
EABI EABIVersion = EABI::Default) {
initLibcalls(TT, FloatABI, EABIVersion);
}

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

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

} // namespace RTLIB
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/CodeGen/TargetLoweringBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,8 @@ void RTLIB::initCmpLibcallCCs(ISD::CondCode *CmpLibcallCCs) {

/// NOTE: The TargetMachine owns TLOF.
TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm)
: TM(tm), Libcalls(TM.getTargetTriple()) {
: TM(tm), Libcalls(TM.getTargetTriple(), TM.Options.FloatABIType,
TM.Options.EABIVersion) {
initActions();

// Perform these initializations only once.
Expand Down
18 changes: 15 additions & 3 deletions llvm/lib/IR/RuntimeLibcalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,17 @@ static void setAArch64LibcallNames(RuntimeLibcallsInfo &Info,
#undef LCALLNAME5
}

static void setARMLibcallNames(RuntimeLibcallsInfo &Info, const Triple &TT) {
static void setARMLibcallNames(RuntimeLibcallsInfo &Info, const Triple &TT,
FloatABI::ABIType FloatABIType,
EABI EABIVersion) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EABIVersion doesn't seem to be used by this function, or at least not yet.

Looks like it is only used in https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/ARM/ARMISelLowering.cpp#L693

Is the intention to move that part of the code to here at some point?

My apologies if I've missed some context, just seeing these reviews for the first time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, eventually the full list of possible libcalls should be recorded here. Later there will also need to be a separate mechanism for making context dependent lowering selections from the full set

if (!TT.isOSDarwin() && !TT.isiOS() && !TT.isWatchOS() && !TT.isDriverKit()) {
CallingConv::ID DefaultCC = FloatABIType == FloatABI::Hard
? CallingConv::ARM_AAPCS_VFP
: CallingConv::ARM_AAPCS;
for (RTLIB::Libcall LC : RTLIB::libcalls())
Info.setLibcallCallingConv(LC, DefaultCC);
}

// Register based DivRem for AEABI (RTABI 4.2)
if (TT.isTargetAEABI() || TT.isAndroid() || TT.isTargetGNUAEABI() ||
TT.isTargetMuslAEABI() || TT.isOSWindows()) {
Expand Down Expand Up @@ -346,7 +356,9 @@ static void setLongDoubleIsF128Libm(RuntimeLibcallsInfo &Info,

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

initSoftFloatCmpLibcallPredicates();
Expand Down Expand Up @@ -539,7 +551,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
if (TT.isAArch64())
setAArch64LibcallNames(*this, TT);
else if (TT.isARM() || TT.isThumb())
setARMLibcallNames(*this, TT);
setARMLibcallNames(*this, TT, FloatABI, EABIVersion);
else if (TT.getArch() == Triple::ArchType::avr) {
// Division rtlib functions (not supported), use divmod functions instead
setLibcallName(RTLIB::SDIV_I8, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Object/IRSymtab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Expected<int> Builder::getComdatIndex(const Comdat *C, const Module *M) {
static DenseSet<StringRef> buildPreservedSymbolsSet(const Triple &TT) {
DenseSet<StringRef> PreservedSymbolSet(std::begin(PreservedSymbols),
std::end(PreservedSymbols));

// FIXME: Do we need to pass in ABI fields from TargetOptions?
RTLIB::RuntimeLibcallsInfo Libcalls(TT);
for (const char *Name : Libcalls.getLibcallNames()) {
if (Name)
Expand Down
10 changes: 0 additions & 10 deletions llvm/lib/Target/ARM/ARMISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,16 +515,6 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM_,
setBooleanContents(ZeroOrOneBooleanContent);
setBooleanVectorContents(ZeroOrNegativeOneBooleanContent);

if (!Subtarget->isTargetDarwin() && !Subtarget->isTargetIOS() &&
!Subtarget->isTargetWatchOS() && !Subtarget->isTargetDriverKit()) {
bool IsHFTarget = TM.Options.FloatABIType == FloatABI::Hard;

for (RTLIB::Libcall LC : RTLIB::libcalls()) {
setLibcallCallingConv(LC, IsHFTarget ? CallingConv::ARM_AAPCS_VFP
: CallingConv::ARM_AAPCS);
}
}

if (Subtarget->isTargetMachO()) {
// Uses VFP for Thumb libfuncs if available.
if (Subtarget->isThumb() && Subtarget->hasVFP2Base() &&
Expand Down
Loading