1//===- LibcallLoweringInfo.cpp - Legacy wrapper for libcall lowering ------===//
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#include "llvm/CodeGen/LibcallLoweringInfo.h"
10#include "llvm/Analysis/RuntimeLibcallInfo.h"
11#include "llvm/CodeGen/TargetSubtargetInfo.h"
12#include "llvm/InitializePasses.h"
13
14using namespace llvm;
15
16const LibcallLoweringInfo &
17llvm::getLibcallLowering(const ModuleLibcallLoweringInfo &ModuleInfo,
18 const TargetSubtargetInfo &Subtarget) {
19 return ModuleInfo.getLibcallLowering(
20 Key: &Subtarget, ApplyContextRules: [&](LibcallLoweringInfo &Info) {
21 Subtarget.initLibcallLoweringInfo(Info);
22 });
23}
24
25INITIALIZE_PASS_BEGIN(LibcallLoweringInfoWrapper, "libcall-lowering-info",
26 "Library Function Lowering Analysis", false, true)
27INITIALIZE_PASS_DEPENDENCY(RuntimeLibraryInfoWrapper)
28INITIALIZE_PASS_END(LibcallLoweringInfoWrapper, "libcall-lowering-info",
29 "Library Function Lowering Analysis", false, true)
30
31char LibcallLoweringInfoWrapper::ID = 0;
32
33LibcallLoweringInfoWrapper::LibcallLoweringInfoWrapper() : ImmutablePass(ID) {}
34
35const LibcallLoweringInfo &LibcallLoweringInfoWrapper::getLibcallLowering(
36 const Module &M, const TargetSubtargetInfo &Subtarget) {
37 return getResult(M).getLibcallLowering(
38 Key: &Subtarget, ApplyContextRules: [&](LibcallLoweringInfo &Info) {
39 Subtarget.initLibcallLoweringInfo(Info);
40 });
41}
42
43const ModuleLibcallLoweringInfo &
44LibcallLoweringInfoWrapper::getResult(const Module &M) {
45 if (!Result)
46 Result.init(RT: &RuntimeLibcallsWrapper->getRTLCI(M));
47 return Result;
48}
49
50void LibcallLoweringInfoWrapper::initializePass() {
51 RuntimeLibcallsWrapper = &getAnalysis<RuntimeLibraryInfoWrapper>();
52}
53
54void LibcallLoweringInfoWrapper::getAnalysisUsage(AnalysisUsage &AU) const {
55 AU.addRequired<RuntimeLibraryInfoWrapper>();
56 AU.setPreservesAll();
57}
58
59void LibcallLoweringInfoWrapper::releaseMemory() { Result.clear(); }
60
61ModulePass *llvm::createLibcallLoweringInfoWrapper() {
62 return new LibcallLoweringInfoWrapper();
63}
64