LLVM 24.0.0git
LibcallLoweringInfo.cpp
Go to the documentation of this file.
1//===- LibcallLoweringInfo.cpp - Runtime libcall lowering info ------------===//
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
11
12using namespace llvm;
13
15 const RTLIB::RuntimeLibcallsInfo &RTLCI,
16 ApplyContextRulesFn ApplyContextRules)
17 : RTLCI(RTLCI) {
18 // TODO: This should be generated with lowering predicates, and assert the
19 // call is available.
20 for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
21 if (RTLCI.isAvailable(Impl)) {
22 RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
23 // FIXME: Hack, assume the first available libcall wins.
24 if (LibcallImpls[LC] == RTLIB::Unsupported)
25 LibcallImpls[LC] = Impl;
26 }
27 }
28
29 // Apply the caller's context-specific (e.g. subtarget) libcall rules.
30 if (ApplyContextRules)
31 ApplyContextRules(*this);
32}
33
34AnalysisKey LibcallLoweringModuleAnalysis::Key;
35
37 Module &, const PreservedAnalyses &PA,
38 ModuleAnalysisManager::Invalidator &) {
39 // Passes that change the runtime libcall set must explicitly invalidate this
40 // pass.
42 return !PAC.preservedWhenStateless();
43}
44
47 LibcallLoweringMap.init(&MAM.getResult<RuntimeLibraryAnalysis>(M));
48 return LibcallLoweringMap;
49}
ModuleAnalysisManager MAM
function_ref< void(LibcallLoweringInfo &)> ApplyContextRulesFn
Callback applying the caller's context-specific (e.g.
LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI, ApplyContextRulesFn ApplyContextRules={})
Construct the lowering info from the module-level RTLCI, seeding the default implementation for every...
LLVM_ABI Result run(Module &M, ModuleAnalysisManager &)
Records a mapping from an opaque lowering context to its LibcallLoweringInfo.
void init(const RTLIB::RuntimeLibcallsInfo *RT)
LLVM_ABI bool invalidate(Module &, const PreservedAnalyses &, ModuleAnalysisManager::Invalidator &)
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
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
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.