| 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 | |
| 14 | using namespace llvm; |
| 15 | |
| 16 | const LibcallLoweringInfo & |
| 17 | llvm::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 | |
| 25 | INITIALIZE_PASS_BEGIN(LibcallLoweringInfoWrapper, "libcall-lowering-info" , |
| 26 | "Library Function Lowering Analysis" , false, true) |
| 27 | INITIALIZE_PASS_DEPENDENCY(RuntimeLibraryInfoWrapper) |
| 28 | INITIALIZE_PASS_END(LibcallLoweringInfoWrapper, "libcall-lowering-info" , |
| 29 | "Library Function Lowering Analysis" , false, true) |
| 30 | |
| 31 | char LibcallLoweringInfoWrapper::ID = 0; |
| 32 | |
| 33 | LibcallLoweringInfoWrapper::LibcallLoweringInfoWrapper() : ImmutablePass(ID) {} |
| 34 | |
| 35 | const 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 | |
| 43 | const ModuleLibcallLoweringInfo & |
| 44 | LibcallLoweringInfoWrapper::getResult(const Module &M) { |
| 45 | if (!Result) |
| 46 | Result.init(RT: &RuntimeLibcallsWrapper->getRTLCI(M)); |
| 47 | return Result; |
| 48 | } |
| 49 | |
| 50 | void LibcallLoweringInfoWrapper::initializePass() { |
| 51 | RuntimeLibcallsWrapper = &getAnalysis<RuntimeLibraryInfoWrapper>(); |
| 52 | } |
| 53 | |
| 54 | void LibcallLoweringInfoWrapper::getAnalysisUsage(AnalysisUsage &AU) const { |
| 55 | AU.addRequired<RuntimeLibraryInfoWrapper>(); |
| 56 | AU.setPreservesAll(); |
| 57 | } |
| 58 | |
| 59 | void LibcallLoweringInfoWrapper::releaseMemory() { Result.clear(); } |
| 60 | |
| 61 | ModulePass *llvm::createLibcallLoweringInfoWrapper() { |
| 62 | return new LibcallLoweringInfoWrapper(); |
| 63 | } |
| 64 | |