LLVM 22.0.0git
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
14#include "llvm/IR/Module.h"
16
17using namespace llvm;
18
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
38}
Module.h This file contains the declarations for the Module class.
ModuleAnalysisManager MAM
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:255
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
Class to represent function types.
Definition: DerivedTypes.h:105
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
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
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition: Analysis.h:115
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
A simple container for information about the supported runtime calls.
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.
ArrayRef< RTLIB::LibcallImpl > getLibcallImpls() const