Go to the documentation of this file.
13 #ifndef LLVM_EXECUTIONENGINE_ORC_LLJIT_H
14 #define LLVM_EXECUTIONENGINE_ORC_LLJIT_H
29 class LLJITBuilderState;
30 class LLLazyJITBuilderState;
31 class ObjectTransformLayer;
32 class ExecutorProcessControl;
76 return ES->getJITDylibByName(Name);
151 dbgs() <<
"LLJIT running initializers for JITDylib \"" << JD.
getName()
154 assert(
PS &&
"PlatformSupport must be set to run initializers.");
155 return PS->initialize(JD);
161 dbgs() <<
"LLJIT running deinitializers for JITDylib \"" << JD.
getName()
164 assert(
PS &&
"PlatformSupport must be set to run initializers.");
165 return PS->deinitialize(JD);
185 return ES->intern(
mangle(UnmangledName));
202 std::unique_ptr<ExecutionSession>
ES;
203 std::unique_ptr<PlatformSupport>
PS;
228 CODLayer->setPartitionFunction(
std::move(Partition));
247 std::unique_ptr<LazyCallThroughManager> LCTMgr;
248 std::unique_ptr<CompileOnDemandLayer> CODLayer;
258 std::function<Expected<std::unique_ptr<IRCompileLayer::IRCompiler>>(
263 std::unique_ptr<ExecutorProcessControl>
EPC;
264 std::unique_ptr<ExecutionSession>
ES;
265 std::optional<JITTargetMachineBuilder>
JTMB;
266 std::optional<DataLayout>
DL;
276 template <
typename JITType,
typename SetterImpl,
typename State>
285 "setExecutorProcessControl should not be called if an ExecutionSession "
286 "has already been set");
325 impl().CreateObjectLinkingLayer =
std::move(CreateObjectLinkingLayer);
337 impl().CreateCompileFunction =
std::move(CreateCompileFunction);
360 impl().NumCompileThreads = NumCompileThreads;
377 if (
auto Err =
impl().prepareForConstruction())
381 std::unique_ptr<JITType> J(
new JITType(
impl(), Err));
388 SetterImpl &
impl() {
return static_cast<SetterImpl &
>(*this); }
401 std::function<std::unique_ptr<IndirectStubsManager>()>;
405 std::unique_ptr<LazyCallThroughManager>
LCTMgr;
411 template <
typename JITType,
typename SetterImpl,
typename State>
419 this->
impl().LazyCompileFailureAddr =
Addr;
448 LLLazyJITBuilderState> {};
468 #endif // LLVM_EXECUTIONENGINE_ORC_LLJIT_H
Represents an address in the executor process.
void recordCtorDtors(Module &M)
std::unique_ptr< ExecutorProcessControl > EPC
unsigned NumCompileThreads
A utility class for building TargetMachines for JITs.
This is an optimization pass for GlobalISel generic memory operations.
Represents a JIT'd dynamic library.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Expected< JITDylib & > createJITDylib(std::string Name)
Create a new JITDylib with the given name and return a reference to it.
A parsed version of the target data layout string in and methods for querying it.
JITDylib & getMainJITDylib()
Returns a reference to the JITDylib representing the JIT'd main program.
Constructs LLJIT instances.
PlatformSupport * getPlatformSupport()
Get the PlatformSupport instance.
Error prepareForConstruction()
LLJIT(LLJITBuilderState &S, Error &Err)
Create an LLJIT instance with a single compile thread.
const std::string & getName() const
Get the name for this JITLinkDylib.
Pointer to a pooled string representing a symbol name.
std::function< std::optional< GlobalValueSet >(GlobalValueSet Requested)> PartitionFunction
Partitioning function.
static ErrorSuccess success()
Create a success value.
std::unique_ptr< IRTransformLayer > InitHelperTransformLayer
void setPartitionFunction(CompileOnDemandLayer::PartitionFunction Partition)
Sets the partition function.
const Triple & getTargetTriple() const
Returns a reference to the triple for this instance.
Error addObjectFile(ResourceTrackerSP RT, std::unique_ptr< MemoryBuffer > Obj)
Adds an object file to the given JITDylib.
Triple - Helper class for working with autoconf configuration names.
SetterImpl & setLazyCallthroughManager(std::unique_ptr< LazyCallThroughManager > LCTMgr)
Set the lazy-callthrough manager.
friend void setUpGenericLLVMIRPlatform(LLJIT &J)
Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables ...
SetterImpl & setObjectLinkingLayerCreator(LLJITBuilderState::ObjectLinkingLayerCreator CreateObjectLinkingLayer)
Set an ObjectLinkingLayer creation function.
Error addLazyIRModule(JITDylib &JD, ThreadSafeModule M)
Add a module to be lazily compiled to JITDylib JD.
ExecutorProcessControl supports interaction with a JIT target process.
std::function< Expected< std::unique_ptr< IRCompileLayer::IRCompiler > >(JITTargetMachineBuilder JTMB)> CompileFunctionCreator
A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
void setPlatformSupport(std::unique_ptr< PlatformSupport > PS)
Set the PlatformSupport instance.
SetterImpl & setIndirectStubsManagerBuilder(LLLazyJITBuilderState::IndirectStubsManagerBuilderFunction ISMBuilder)
Set the IndirectStubsManager builder function.
Tagged union holding either a T or a Error.
SetterImpl & setDataLayout(std::optional< DataLayout > DL)
Set a DataLayout for this instance.
static Expected< std::unique_ptr< IRCompileLayer::IRCompiler > > createCompileFunction(LLJITBuilderState &S, JITTargetMachineBuilder JTMB)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Expected< ExecutorAddr > lookupLinkerMangled(JITDylib &JD, SymbolStringPtr Name)
Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on thei...
ObjectLinkingLayerCreator CreateObjectLinkingLayer
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
Error addIRModule(ResourceTrackerSP RT, ThreadSafeModule TSM)
Adds an IR module with the given ResourceTracker.
std::string mangle(StringRef UnmangledName) const
Returns a linker-mangled version of UnmangledName.
Expected< ExecutorAddr > lookup(JITDylib &JD, StringRef UnmangledName)
Look up a symbol in JITDylib JD based on its IR symbol name.
SetterImpl & setExecutionSession(std::unique_ptr< ExecutionSession > ES)
Set an ExecutionSession for this instance.
SymbolStringPtr mangleAndIntern(StringRef UnmangledName) const
Returns an interned, linker-mangled version of UnmangledName.
An extended version of LLJIT that supports lazy function-at-a-time compilation of LLVM IR.
Error initialize(JITDylib &JD)
Run the initializers for the given JITDylib.
Constructs LLLazyJIT instances.
Interface for Layers that accept object files.
static Expected< std::unique_ptr< ObjectLayer > > createObjectLinkingLayer(LLJITBuilderState &S, ExecutionSession &ES)
SetterImpl & setJITTargetMachineBuilder(JITTargetMachineBuilder JTMB)
Set the JITTargetMachineBuilder for this instance.
Expected< std::unique_ptr< JITType > > create()
Create an instance of the JIT.
Expected< ExecutorAddr > lookupLinkerMangled(JITDylib &JD, StringRef Name)
Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on thei...
SetterImpl & setLazyCompileFailureAddr(ExecutorAddr Addr)
Set the address in the target address to call if a lazy compile fails.
std::function< Expected< std::unique_ptr< ObjectLayer > >(ExecutionSession &, const Triple &)> ObjectLinkingLayerCreator
std::unique_ptr< ObjectTransformLayer > ObjTransformLayer
SetterImpl & setNumCompileThreads(unsigned NumCompileThreads)
Set the number of compile threads to use.
JITDylib * getJITDylibByName(StringRef Name)
Returns the JITDylib with the given name, or nullptr if no JITDylib with that name exists.
IRCompileLayer & getIRCompileLayer()
Returns a reference to the IR compile layer.
std::unique_ptr< ExecutionSession > ES
std::unique_ptr< ThreadPool > CompileThreads
ExecutorAddr LazyCompileFailureAddr
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
void setUpGenericLLVMIRPlatform(LLJIT &J)
Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables ...
std::optional< JITTargetMachineBuilder > JTMB
std::unique_ptr< IRCompileLayer > CompileLayer
uint8_t IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP
PlatformSetupFunction SetUpPlatform
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SetterImpl & setExecutorProcessControl(ExecutorProcessControl &EPC)
Set an ExecutorProcessControl object.
std::function< std::unique_ptr< IndirectStubsManager >()> IndirectStubsManagerBuilderFunction
print Print MemDeps of function
std::unique_ptr< ExecutionSession > ES
A Module instance is used to store all the information related to an LLVM module.
virtual ~LLJIT()
Destruct this instance.
StringRef - Represent a constant reference to a string, i.e.
Error setUpOrcPlatform(LLJIT &J)
Configure the LLJIT instance to use orc runtime support.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
std::function< Error(LLJIT &J)> PlatformSetupFunction
ObjectLayer & getObjLinkingLayer()
Returns a reference to the ObjLinkingLayer.
Error prepareForConstruction()
Called prior to JIT class construcion to fix up defaults.
std::unique_ptr< IRTransformLayer > TransformLayer
Error addLazyIRModule(ThreadSafeModule M)
Add a module to be lazily compiled to the main JITDylib.
Lightweight error class with error context and mandatory checking.
std::unique_ptr< LazyCallThroughManager > LCTMgr
An ExecutionSession represents a running JIT program.
Error addIRModule(ThreadSafeModule TSM)
Adds an IR module to the Main JITDylib.
ObjectTransformLayer & getObjTransformLayer()
Returns a reference to the object transform layer.
SetterImpl & setExecutorProcessControl(std::unique_ptr< ExecutorProcessControl > EPC)
Set a ExecutorProcessControl for this instance.
SetterImpl & setCompileFunctionCreator(LLJITBuilderState::CompileFunctionCreator CreateCompileFunction)
Set a CompileFunctionCreator.
IRTransformLayer & getIRTransformLayer()
Returns a reference to the IR transform layer.
SetterImpl & setPlatformSetUp(LLJITBuilderState::PlatformSetupFunction SetUpPlatform)
Set up an PlatformSetupFunction.
An LLVM Module together with a shared ThreadSafeContext.
Expected< ExecutorAddr > lookup(StringRef UnmangledName)
Look up a symbol in the main JITDylib based on its IR symbol name.
std::unique_ptr< PlatformSupport > PS
Expected< ExecutorAddr > lookupLinkerMangled(StringRef Name)
Look up a symbol in the main JITDylib by the symbol's linker-mangled name (to look up symbols based o...
Error applyDataLayout(Module &M)
CompileFunctionCreator CreateCompileFunction
std::optional< DataLayout > DL
Error setUpInactivePlatform(LLJIT &J)
Configure the LLJIT instance to disable platform support explicitly.
Error deinitialize(JITDylib &JD)
Run the deinitializers for the given JITDylib.
Error addObjectFile(std::unique_ptr< MemoryBuffer > Obj)
Adds an object file to the given JITDylib.
CompileOnDemandLayer & getCompileOnDemandLayer()
Returns a reference to the on-demand layer.
IndirectStubsManagerBuilderFunction ISMBuilder
std::unique_ptr< ObjectLayer > ObjLinkingLayer
std::optional< JITTargetMachineBuilder > & getJITTargetMachineBuilder()
Return a reference to the JITTargetMachineBuilder.
ExecutionSession & getExecutionSession()
Returns the ExecutionSession for this instance.
const DataLayout & getDataLayout() const
Returns a reference to the DataLayout for this instance.