Skip to content

Commit c97e4cd

Browse files
committed
CodeGen: Move LibcallLoweringInfo to be with RuntimeLibcallInfo
Eventually this will be program dependent state, so it should not be part of TargetLowering. It's easiest to have this as part of the analysis that will provide RuntimeLibcallInfo. In principle we would also need this to more precisely refine the set of libcalls that full LTO could trim based on the subtarget.
1 parent 0d40671 commit c97e4cd

File tree

4 files changed

+70
-69
lines changed

4 files changed

+70
-69
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -193,58 +193,6 @@ struct MemOp {
193193
}
194194
};
195195

196-
class LibcallLoweringInfo {
197-
private:
198-
LLVM_ABI const RTLIB::RuntimeLibcallsInfo &RTLCI;
199-
/// Stores the implementation choice for each each libcall.
200-
LLVM_ABI RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
201-
RTLIB::Unsupported};
202-
203-
public:
204-
LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI);
205-
206-
/// Get the libcall routine name for the specified libcall.
207-
// FIXME: This should be removed. Only LibcallImpl should have a name.
208-
LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
209-
// FIXME: Return StringRef
210-
return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LibcallImpls[Call])
211-
.data();
212-
}
213-
214-
/// Return the lowering's selection of implementation call for \p Call
215-
LLVM_ABI RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
216-
return LibcallImpls[Call];
217-
}
218-
219-
/// Rename the default libcall routine name for the specified libcall.
220-
LLVM_ABI void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
221-
LibcallImpls[Call] = Impl;
222-
}
223-
224-
// FIXME: Remove this wrapper in favor of directly using
225-
// getLibcallImplCallingConv
226-
LLVM_ABI CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
227-
return RTLCI.LibcallImplCallingConvs[LibcallImpls[Call]];
228-
}
229-
230-
/// Get the CallingConv that should be used for the specified libcall.
231-
LLVM_ABI CallingConv::ID
232-
getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const {
233-
return RTLCI.LibcallImplCallingConvs[Call];
234-
}
235-
236-
/// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
237-
/// unsupported.
238-
LLVM_ABI StringRef getMemcpyName() const {
239-
RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
240-
if (Memcpy != RTLIB::Unsupported)
241-
return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Memcpy);
242-
243-
// Fallback to memmove if memcpy isn't available.
244-
return getLibcallName(RTLIB::MEMMOVE);
245-
}
246-
};
247-
248196
/// This base class for TargetLowering contains the SelectionDAG-independent
249197
/// parts that can be used from the rest of CodeGen.
250198
class LLVM_ABI TargetLoweringBase {

llvm/include/llvm/IR/RuntimeLibcalls.h

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434

3535
namespace llvm {
3636

37-
class LibcallLoweringInfo;
38-
3937
template <> struct enum_iteration_traits<RTLIB::Libcall> {
4038
static constexpr bool is_iterable = true;
4139
};
@@ -44,6 +42,8 @@ template <> struct enum_iteration_traits<RTLIB::LibcallImpl> {
4442
static constexpr bool is_iterable = true;
4543
};
4644

45+
class LibcallLoweringInfo;
46+
4747
namespace RTLIB {
4848

4949
// Return an iterator over all Libcall values.
@@ -230,6 +230,59 @@ struct RuntimeLibcallsInfo {
230230
};
231231

232232
} // namespace RTLIB
233+
234+
class LibcallLoweringInfo {
235+
private:
236+
LLVM_ABI const RTLIB::RuntimeLibcallsInfo &RTLCI;
237+
/// Stores the implementation choice for each each libcall.
238+
LLVM_ABI RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
239+
RTLIB::Unsupported};
240+
241+
public:
242+
LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI);
243+
244+
/// Get the libcall routine name for the specified libcall.
245+
// FIXME: This should be removed. Only LibcallImpl should have a name.
246+
LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
247+
// FIXME: Return StringRef
248+
return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LibcallImpls[Call])
249+
.data();
250+
}
251+
252+
/// Return the lowering's selection of implementation call for \p Call
253+
LLVM_ABI RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
254+
return LibcallImpls[Call];
255+
}
256+
257+
/// Rename the default libcall routine name for the specified libcall.
258+
LLVM_ABI void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
259+
LibcallImpls[Call] = Impl;
260+
}
261+
262+
// FIXME: Remove this wrapper in favor of directly using
263+
// getLibcallImplCallingConv
264+
LLVM_ABI CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
265+
return RTLCI.LibcallImplCallingConvs[LibcallImpls[Call]];
266+
}
267+
268+
/// Get the CallingConv that should be used for the specified libcall.
269+
LLVM_ABI CallingConv::ID
270+
getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const {
271+
return RTLCI.LibcallImplCallingConvs[Call];
272+
}
273+
274+
/// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
275+
/// unsupported.
276+
LLVM_ABI StringRef getMemcpyName() const {
277+
RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
278+
if (Memcpy != RTLIB::Unsupported)
279+
return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Memcpy);
280+
281+
// Fallback to memmove if memcpy isn't available.
282+
return getLibcallName(RTLIB::MEMMOVE);
283+
}
284+
};
285+
233286
} // namespace llvm
234287

235288
#endif // LLVM_IR_RUNTIME_LIBCALLS_H

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -695,21 +695,6 @@ ISD::CondCode TargetLoweringBase::getSoftFloatCmpLibcallPredicate(
695695
}
696696
}
697697

698-
LibcallLoweringInfo::LibcallLoweringInfo(
699-
const RTLIB::RuntimeLibcallsInfo &RTLCI)
700-
: RTLCI(RTLCI) {
701-
// TODO: This should be generated with lowering predicates, and assert the
702-
// call is available.
703-
for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
704-
if (RTLCI.isAvailable(Impl)) {
705-
RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
706-
// FIXME: Hack, assume the first available libcall wins.
707-
if (LibcallImpls[LC] == RTLIB::Unsupported)
708-
LibcallImpls[LC] = Impl;
709-
}
710-
}
711-
}
712-
713698
/// NOTE: The TargetMachine owns TLOF.
714699
TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm)
715700
: TM(tm),

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,18 @@ bool RuntimeLibcallsInfo::darwinHasExp10(const Triple &TT) {
7373
return false;
7474
}
7575
}
76+
77+
LibcallLoweringInfo::LibcallLoweringInfo(
78+
const RTLIB::RuntimeLibcallsInfo &RTLCI)
79+
: RTLCI(RTLCI) {
80+
// TODO: This should be generated with lowering predicates, and assert the
81+
// call is available.
82+
for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
83+
if (RTLCI.isAvailable(Impl)) {
84+
RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
85+
// FIXME: Hack, assume the first available libcall wins.
86+
if (LibcallImpls[LC] == RTLIB::Unsupported)
87+
LibcallImpls[LC] = Impl;
88+
}
89+
}
90+
}

0 commit comments

Comments
 (0)