LLVM 22.0.0git
LibcallLoweringInfo.cpp
Go to the documentation of this file.
1//===- LibcallLoweringInfo.cpp - Interface for runtime libcalls -----------===//
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
14
15using namespace llvm;
16
18 const RTLIB::RuntimeLibcallsInfo &RTLCI,
19 const TargetSubtargetInfo &Subtarget)
20 : RTLCI(RTLCI) {
21 // TODO: This should be generated with lowering predicates, and assert the
22 // call is available.
23 for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
24 if (RTLCI.isAvailable(Impl)) {
25 RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
26 // FIXME: Hack, assume the first available libcall wins.
27 if (LibcallImpls[LC] == RTLIB::Unsupported)
28 LibcallImpls[LC] = Impl;
29 }
30 }
31
32 Subtarget.initLibcallLoweringInfo(*this);
33}
34
35AnalysisKey LibcallLoweringModuleAnalysis::Key;
36
38 Module &, const PreservedAnalyses &PA,
39 ModuleAnalysisManager::Invalidator &) {
40 // Passes that change the runtime libcall set must explicitly invalidate this
41 // pass.
43 return !PAC.preservedWhenStateless();
44}
45
48 LibcallLoweringMap.init(&MAM.getResult<RuntimeLibraryAnalysis>(M));
49 return LibcallLoweringMap;
50}
51
53 "Library Function Lowering Analysis", false, true)
56 "Library Function Lowering Analysis", false, true)
57
59
61
63 Result.init(&getAnalysis<RuntimeLibraryInfoWrapper>().getRTLCI(M));
64 return false;
65}
66
71
ModuleAnalysisManager MAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition PassSupport.h:42
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
ImmutablePass(char &pid)
Definition Pass.h:287
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI, const TargetSubtargetInfo &Subtarget)
Record a mapping from subtarget to LibcallLoweringInfo.
void init(const RTLIB::RuntimeLibcallsInfo *RT)
LLVM_ABI bool invalidate(Module &, const PreservedAnalyses &, ModuleAnalysisManager::Invalidator &)
LLVM_ABI Result run(Module &M, ModuleAnalysisManager &)
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition Analysis.h:275
TargetSubtargetInfo - Generic base class for all target subtargets.
virtual void initLibcallLoweringInfo(LibcallLoweringInfo &Info) const
Configure the LibcallLoweringInfo for this subtarget.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
static auto libcall_impls()
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
A simple container for information about the supported runtime calls.
static RTLIB::Libcall getLibcallFromImpl(RTLIB::LibcallImpl Impl)
Return the libcall provided by Impl.