mirror of
https://github.com/siemens-mobile-hacks/llvm-c166.git
synced 2026-11-26 06:28:13 +00:00
Middle end passes need to be able to reason about library call availability and potentially emit them without depending on codegen. TargetLibraryInfo already lives in Analysis, and this is a step towards the eventual merger. For now this is a mostly mechanical move, type erasing the reference to TargetSubtargetInfo. The per-subtarget customization (TargetSubtargetInfo::initLibcallLoweringInfo) is inverted into a caller-supplied function_ref, so the Analysis types carry no CodeGen/TargetSubtargetInfo reference. The module map is keyed on an opaque erased pointer. CodeGen continues looking up based on the subtarget. It is not yet in a state where it is usable from middle end passes; that will come later. In principle we should be able to write arbitrary rules based on a function's ABI attributes for which calls can be used. Co-authored-by: Claude (Claude Opus 4.8) <noreply@anthropic.com>
63 lines
2.2 KiB
C++
63 lines
2.2 KiB
C++
//===- LibcallLoweringInfo.cpp - Legacy wrapper for libcall lowering ------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/CodeGen/LibcallLoweringInfo.h"
|
|
#include "llvm/Analysis/RuntimeLibcallInfo.h"
|
|
#include "llvm/CodeGen/TargetSubtargetInfo.h"
|
|
#include "llvm/InitializePasses.h"
|
|
|
|
using namespace llvm;
|
|
|
|
const LibcallLoweringInfo &
|
|
llvm::getLibcallLowering(const ModuleLibcallLoweringInfo &ModuleInfo,
|
|
const TargetSubtargetInfo &Subtarget) {
|
|
return ModuleInfo.getLibcallLowering(
|
|
&Subtarget, [&](LibcallLoweringInfo &Info) {
|
|
Subtarget.initLibcallLoweringInfo(Info);
|
|
});
|
|
}
|
|
|
|
INITIALIZE_PASS_BEGIN(LibcallLoweringInfoWrapper, "libcall-lowering-info",
|
|
"Library Function Lowering Analysis", false, true)
|
|
INITIALIZE_PASS_DEPENDENCY(RuntimeLibraryInfoWrapper)
|
|
INITIALIZE_PASS_END(LibcallLoweringInfoWrapper, "libcall-lowering-info",
|
|
"Library Function Lowering Analysis", false, true)
|
|
|
|
char LibcallLoweringInfoWrapper::ID = 0;
|
|
|
|
LibcallLoweringInfoWrapper::LibcallLoweringInfoWrapper() : ImmutablePass(ID) {}
|
|
|
|
const LibcallLoweringInfo &LibcallLoweringInfoWrapper::getLibcallLowering(
|
|
const Module &M, const TargetSubtargetInfo &Subtarget) {
|
|
return getResult(M).getLibcallLowering(
|
|
&Subtarget, [&](LibcallLoweringInfo &Info) {
|
|
Subtarget.initLibcallLoweringInfo(Info);
|
|
});
|
|
}
|
|
|
|
const ModuleLibcallLoweringInfo &
|
|
LibcallLoweringInfoWrapper::getResult(const Module &M) {
|
|
if (!Result)
|
|
Result.init(&RuntimeLibcallsWrapper->getRTLCI(M));
|
|
return Result;
|
|
}
|
|
|
|
void LibcallLoweringInfoWrapper::initializePass() {
|
|
RuntimeLibcallsWrapper = &getAnalysis<RuntimeLibraryInfoWrapper>();
|
|
}
|
|
|
|
void LibcallLoweringInfoWrapper::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
AU.addRequired<RuntimeLibraryInfoWrapper>();
|
|
AU.setPreservesAll();
|
|
}
|
|
|
|
void LibcallLoweringInfoWrapper::releaseMemory() { Result.clear(); }
|
|
|
|
ModulePass *llvm::createLibcallLoweringInfoWrapper() {
|
|
return new LibcallLoweringInfoWrapper();
|
|
}
|