Skip to content

RuntimeLibcalls: Use iterable enum for libcall types #143075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
13 changes: 13 additions & 0 deletions llvm/include/llvm/IR/RuntimeLibcalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define LLVM_IR_RUNTIME_LIBCALLS_H

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Compiler.h"
Expand All @@ -36,6 +37,18 @@ enum Libcall {
#include "llvm/IR/RuntimeLibcalls.def"
#undef HANDLE_LIBCALL
};
} // namespace RTLIB

template <> struct enum_iteration_traits<RTLIB::Libcall> {
static constexpr bool is_iterable = true;
};

namespace RTLIB {

// Return an iterator over all Libcall values.
static inline auto libcalls() {
return enum_seq(static_cast<RTLIB::Libcall>(0), RTLIB::UNKNOWN_LIBCALL);
}

/// A simple container for information about the supported runtime calls.
struct RuntimeLibcallsInfo {
Expand Down
17 changes: 5 additions & 12 deletions llvm/lib/IR/RuntimeLibcalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,21 +208,14 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
setLibcallName(RTLIB::FREXP_PPCF128, nullptr);
}

// Disable most libcalls on AMDGPU.
if (TT.isAMDGPU()) {
for (int I = 0; I < RTLIB::UNKNOWN_LIBCALL; ++I) {
if (I < RTLIB::ATOMIC_LOAD || I > RTLIB::ATOMIC_FETCH_NAND_16)
setLibcallName(static_cast<RTLIB::Libcall>(I), nullptr);
// Disable most libcalls on AMDGPU and NVPTX.
if (TT.isAMDGPU() || TT.isNVPTX()) {
for (RTLIB::Libcall LC : RTLIB::libcalls()) {
if (LC < RTLIB::ATOMIC_LOAD || LC > RTLIB::ATOMIC_FETCH_NAND_16)
setLibcallName(LC, nullptr);
}
}

// Disable most libcalls on NVPTX.
if (TT.isNVPTX()) {
for (int I = 0; I < RTLIB::UNKNOWN_LIBCALL; ++I)
if (I < RTLIB::ATOMIC_LOAD || I > RTLIB::ATOMIC_FETCH_NAND_16)
setLibcallName(static_cast<RTLIB::Libcall>(I), nullptr);
}

if (TT.isOSMSVCRT()) {
// MSVCRT doesn't have powi; fall back to pow
setLibcallName(RTLIB::POWI_F32, nullptr);
Expand Down
9 changes: 5 additions & 4 deletions llvm/lib/Target/ARM/ARMISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,11 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
if (!Subtarget->isTargetDarwin() && !Subtarget->isTargetIOS() &&
!Subtarget->isTargetWatchOS() && !Subtarget->isTargetDriverKit()) {
bool IsHFTarget = TM.Options.FloatABIType == FloatABI::Hard;
for (int LCID = 0; LCID < RTLIB::UNKNOWN_LIBCALL; ++LCID)
setLibcallCallingConv(static_cast<RTLIB::Libcall>(LCID),
IsHFTarget ? CallingConv::ARM_AAPCS_VFP
: CallingConv::ARM_AAPCS);

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

if (Subtarget->isTargetMachO()) {
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Target/Lanai/LanaiISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ LanaiTargetLowering::LanaiTargetLowering(const TargetMachine &TM,
setMinimumJumpTableEntries(100);

// Use fast calling convention for library functions.
for (int I = 0; I < RTLIB::UNKNOWN_LIBCALL; ++I) {
setLibcallCallingConv(static_cast<RTLIB::Libcall>(I), CallingConv::Fast);
}
for (RTLIB::Libcall LC : RTLIB::libcalls())
setLibcallCallingConv(LC, CallingConv::Fast);

MaxStoresPerMemset = 16; // For @llvm.memset -> sequence of stores
MaxStoresPerMemsetOptSize = 8;
Expand Down
Loading