LLVM
22.0.0git
lib
Transforms
Utils
DeclareRuntimeLibcalls.cpp
Go to the documentation of this file.
1
//===- DeclareRuntimeLibcalls.cpp -----------------------------------------===//
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
// Insert declarations for all runtime library calls known for the target.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "
llvm/Transforms/Utils/DeclareRuntimeLibcalls.h
"
14
#include "
llvm/IR/Module.h
"
15
#include "
llvm/IR/RuntimeLibcalls.h
"
16
17
using namespace
llvm
;
18
19
PreservedAnalyses
DeclareRuntimeLibcallsPass::run
(
Module
&M,
20
ModuleAnalysisManager
&
MAM
) {
21
RTLIB::RuntimeLibcallsInfo
RTLCI(M.getTargetTriple());
22
LLVMContext
&Ctx = M.getContext();
23
24
for
(RTLIB::LibcallImpl Impl : RTLCI.
getLibcallImpls
()) {
25
if
(Impl == RTLIB::Unsupported)
26
continue
;
27
28
// TODO: Declare with correct type, calling convention, and attributes.
29
30
FunctionType
*FuncTy =
31
FunctionType::get
(
Type::getVoidTy
(Ctx), {},
/*IsVarArgs=*/
true
);
32
33
StringRef
FuncName = RTLCI.
getLibcallImplName
(Impl);
34
M.getOrInsertFunction(FuncName, FuncTy);
35
}
36
37
return
PreservedAnalyses::none
();
38
}
DeclareRuntimeLibcalls.h
Module.h
Module.h This file contains the declarations for the Module class.
MAM
ModuleAnalysisManager MAM
Definition
PassBuilderBindings.cpp:63
RuntimeLibcalls.h
llvm::DeclareRuntimeLibcallsPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
Definition
DeclareRuntimeLibcalls.cpp:19
llvm::FunctionType
Class to represent function types.
Definition
DerivedTypes.h:105
llvm::FunctionType::get
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition
LLVMContext.h:68
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition
Module.h:67
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition
Analysis.h:112
llvm::PreservedAnalyses::none
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition
Analysis.h:115
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition
StringRef.h:55
llvm::Type::getVoidTy
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Definition
Type.cpp:281
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition
AddressRanges.h:18
llvm::ModuleAnalysisManager
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition
MIRParser.h:39
llvm::RTLIB::RuntimeLibcallsInfo
A simple container for information about the supported runtime calls.
Definition
RuntimeLibcalls.h:58
llvm::RTLIB::RuntimeLibcallsInfo::getLibcallImplName
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.
Definition
RuntimeLibcalls.h:86
llvm::RTLIB::RuntimeLibcallsInfo::getLibcallImpls
ArrayRef< RTLIB::LibcallImpl > getLibcallImpls() const
Definition
RuntimeLibcalls.h:116
Generated on
for LLVM by
1.14.0