LLVM 22.0.0git
LibcallLoweringInfo.h
Go to the documentation of this file.
1//===- LibcallLoweringInfo.h ------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CODEGEN_LIBCALLLOWERINGINFO_H
10#define LLVM_CODEGEN_LIBCALLLOWERINGINFO_H
11
13
14namespace llvm {
15
17private:
18 const RTLIB::RuntimeLibcallsInfo &RTLCI;
19 /// Stores the implementation choice for each each libcall.
20 RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
21 RTLIB::Unsupported};
22
23public:
25
26 /// Get the libcall routine name for the specified libcall.
27 // FIXME: This should be removed. Only LibcallImpl should have a name.
28 LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
29 // FIXME: Return StringRef
31 .data();
32 }
33
34 /// Return the lowering's selection of implementation call for \p Call
35 LLVM_ABI RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
36 return LibcallImpls[Call];
37 }
38
39 /// Rename the default libcall routine name for the specified libcall.
40 LLVM_ABI void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
41 LibcallImpls[Call] = Impl;
42 }
43
44 // FIXME: Remove this wrapper in favor of directly using
45 // getLibcallImplCallingConv
47 return RTLCI.LibcallImplCallingConvs[LibcallImpls[Call]];
48 }
49
50 /// Get the CallingConv that should be used for the specified libcall.
52 getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const {
53 return RTLCI.LibcallImplCallingConvs[Call];
54 }
55
56 /// Return a function impl compatible with RTLIB::MEMCPY, or
57 /// RTLIB::Unsupported if fully unsupported.
58 RTLIB::LibcallImpl getMemcpyImpl() const {
59 RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
60 if (Memcpy == RTLIB::Unsupported) {
61 // Fallback to memmove if memcpy isn't available.
62 return getLibcallImpl(RTLIB::MEMMOVE);
63 }
64
65 return Memcpy;
66 }
67};
68
69} // end namespace llvm
70
71#endif // LLVM_CODEGEN_LIBCALLLOWERINGINFO_H
#define LLVM_ABI
Definition Compiler.h:213
LLVM_ABI void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl)
Rename the default libcall routine name for the specified libcall.
LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI)
LLVM_ABI CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const
Get the CallingConv that should be used for the specified libcall.
LLVM_ABI const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
RTLIB::LibcallImpl getMemcpyImpl() const
Return a function impl compatible with RTLIB::MEMCPY, or RTLIB::Unsupported if fully unsupported.
LLVM_ABI RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const
Return the lowering's selection of implementation call for Call.
LLVM_ABI CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition StringRef.h:140
CallInst * Call
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
A simple container for information about the supported runtime calls.
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.