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 TargetProcessControl;
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<ExecutionSession>
ES;
276 template <
typename JITType,
typename SetterImpl,
typename State>
314 impl().CreateObjectLinkingLayer =
std::move(CreateObjectLinkingLayer);
326 impl().CreateCompileFunction =
std::move(CreateCompileFunction);
349 impl().NumCompileThreads = NumCompileThreads;
366 if (
auto Err =
impl().prepareForConstruction())
370 std::unique_ptr<JITType> J(
new JITType(
impl(), Err));
377 SetterImpl &
impl() {
return static_cast<SetterImpl &>(*
this); }
390 std::function<std::unique_ptr<IndirectStubsManager>()>;
394 std::unique_ptr<LazyCallThroughManager>
LCTMgr;
400 template <
typename JITType,
typename SetterImpl,
typename State>
408 this->
impl().LazyCompileFailureAddr =
Addr;
437 LLLazyJITBuilderState> {};
462 #endif // LLVM_EXECUTIONENGINE_ORC_LLJIT_H Constructs LLLazyJIT instances.
Error deinitialize(JITDylib &JD)
Run the deinitializers for the given JITDylib.
SetterImpl & setPlatformSetUp(LLJITBuilderState::PlatformSetupFunction SetUpPlatform)
Set up an PlatformSetupFunction.
ExecutionSession & getExecutionSession()
Returns the ExecutionSession for this instance.
A parsed version of the target data layout string in and methods for querying it.
SetterImpl & setLazyCallthroughManager(std::unique_ptr< LazyCallThroughManager > LCTMgr)
Set the lazy-callthrough manager.
Expected< JITEvaluatedSymbol > 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...
Error addObjectFile(std::unique_ptr< MemoryBuffer > Obj)
Adds an object file to the given JITDylib.
uint8_t IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP
friend void setUpGenericLLVMIRPlatform(LLJIT &J)
Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables ...
This class represents lattice values for constants.
std::function< Expected< std::unique_ptr< ObjectLayer > >(ExecutionSession &, const Triple &)> ObjectLinkingLayerCreator
A Module instance is used to store all the information related to an LLVM module.
LLJIT(LLJITBuilderState &S, Error &Err)
Create an LLJIT instance with a single compile thread.
std::unique_ptr< ExecutionSession > ES
IRCompileLayer & getIRCompileLayer()
Returns a reference to the IR compile layer.
const DataLayout & getDataLayout() const
Returns a reference to the DataLayout for this instance.
Optional< JITTargetMachineBuilder > & getJITTargetMachineBuilder()
Return a reference to the JITTargetMachineBuilder.
std::unique_ptr< PlatformSupport > PS
static Expected< std::unique_ptr< ObjectLayer > > createObjectLinkingLayer(LLJITBuilderState &S, ExecutionSession &ES)
const Triple & getTargetTriple() const
Returns a reference to the triple for this instance.
Expected< JITEvaluatedSymbol > 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 & setDataLayout(Optional< DataLayout > DL)
Set a DataLayout for this instance.
Error addLazyIRModule(JITDylib &JD, ThreadSafeModule M)
Add a module to be lazily compiled to JITDylib JD.
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
Optional< DataLayout > DL
std::function< Optional< GlobalValueSet >(GlobalValueSet Requested)> PartitionFunction
Partitioning function.
ObjectTransformLayer & getObjTransformLayer()
Returns a reference to the object transform layer.
std::unique_ptr< IRTransformLayer > TransformLayer
Tagged union holding either a T or a Error.
void setPlatformSupport(std::unique_ptr< PlatformSupport > PS)
Set the PlatformSupport instance.
SetterImpl & setIndirectStubsManagerBuilder(LLLazyJITBuilderState::IndirectStubsManagerBuilderFunction ISMBuilder)
Set the IndirectStubsManager builder function.
PlatformSetupFunction SetUpPlatform
unsigned NumCompileThreads
SetterImpl & setExecutionSession(std::unique_ptr< ExecutionSession > ES)
Set an ExecutionSession for this instance.
SetterImpl & setObjectLinkingLayerCreator(LLJITBuilderState::ObjectLinkingLayerCreator CreateObjectLinkingLayer)
Set an ObjectLinkingLayer creation function.
ObjectLayer & getObjLinkingLayer()
Returns a reference to the ObjLinkingLayer.
std::function< Expected< std::unique_ptr< IRCompileLayer::IRCompiler > >(JITTargetMachineBuilder JTMB)> CompileFunctionCreator
SetterImpl & setNumCompileThreads(unsigned NumCompileThreads)
Set the number of compile threads to use.
uint64_t JITTargetAddress
Represents an address in the target process's address space.
PlatformSupport * getPlatformSupport()
Get the PlatformSupport instance.
IRTransformLayer & getIRTransformLayer()
Returns a reference to the IR transform layer.
Pointer to a pooled string representing a symbol name.
Error addLazyIRModule(ThreadSafeModule M)
Add a module to be lazily compiled to the main JITDylib.
static Expected< std::unique_ptr< IRCompileLayer::IRCompiler > > createCompileFunction(LLJITBuilderState &S, JITTargetMachineBuilder JTMB)
Error addIRModule(ResourceTrackerSP RT, ThreadSafeModule TSM)
Adds an IR module with the given ResourceTracker.
Error setUpMachOPlatform(LLJIT &J)
Configure the LLJIT instance to use MachOPlatform support.
Expected< JITEvaluatedSymbol > lookup(StringRef UnmangledName)
Look up a symbol in the main JITDylib based on its IR symbol name.
std::unique_ptr< IRTransformLayer > InitHelperTransformLayer
TargetProcessControl supports interaction with a JIT target process.
JITDylib * getJITDylibByName(StringRef Name)
Returns the JITDylib with the given name, or nullptr if no JITDylib with that name exists.
std::unique_ptr< ObjectTransformLayer > ObjTransformLayer
std::unique_ptr< IRCompileLayer > CompileLayer
CompileFunctionCreator CreateCompileFunction
An LLVM Module together with a shared ThreadSafeContext.
Expected< JITEvaluatedSymbol > lookup(JITDylib &JD, StringRef UnmangledName)
Look up a symbol in JITDylib JD based on its IR symbol name.
std::function< Error(LLJIT &J)> PlatformSetupFunction
void setUpGenericLLVMIRPlatform(LLJIT &J)
Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables ...
SymbolStringPtr mangleAndIntern(StringRef UnmangledName) const
Returns an interned, linker-mangled version of UnmangledName.
Triple - Helper class for working with autoconf configuration names.
ObjectLinkingLayerCreator CreateObjectLinkingLayer
SetterImpl & setJITTargetMachineBuilder(JITTargetMachineBuilder JTMB)
Set the JITTargetMachineBuilder for this instance.
SetterImpl & setLazyCompileFailureAddr(JITTargetAddress Addr)
Set the address in the target address to call if a lazy compile fails.
std::unique_ptr< ThreadPool > CompileThreads
Error prepareForConstruction()
std::unique_ptr< ExecutionSession > ES
static ErrorSuccess success()
Create a success value.
void recordCtorDtors(Module &M)
Error initialize(JITDylib &JD)
Run the initializers for the given JITDylib.
Expected< JITEvaluatedSymbol > lookupLinkerMangled(StringRef Name)
Look up a symbol in the main JITDylib by the symbol's linker-mangled name (to look up symbols based o...
TargetProcessControl * TPC
Expected< std::unique_ptr< JITType > > create()
Create an instance of the JIT.
std::function< std::unique_ptr< IndirectStubsManager >()> IndirectStubsManagerBuilderFunction
A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
An ExecutionSession represents a running JIT program.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
An extended version of LLJIT that supports lazy function-at-a-time compilation of LLVM IR.
std::unique_ptr< ObjectLayer > ObjLinkingLayer
void setPartitionFunction(CompileOnDemandLayer::PartitionFunction Partition)
Sets the partition function.
Error addObjectFile(ResourceTrackerSP RT, std::unique_ptr< MemoryBuffer > Obj)
Adds an object file to the given JITDylib.
SetterImpl & setTargetProcessControl(TargetProcessControl &TPC)
Set a TargetProcessControl object.
Error addIRModule(ThreadSafeModule TSM)
Adds an IR module to the Main JITDylib.
const std::string & getName() const
Get the name for this JITDylib.
Constructs LLJIT instances.
Error applyDataLayout(Module &M)
~LLJIT()
Destruct this instance.
SetterImpl & setCompileFunctionCreator(LLJITBuilderState::CompileFunctionCreator CreateCompileFunction)
Set a CompileFunctionCreator.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::string mangle(StringRef UnmangledName) const
Returns a linker-mangled version of UnmangledName.
std::unique_ptr< LazyCallThroughManager > LCTMgr
CompileOnDemandLayer & getCompileOnDemandLayer()
Returns a reference to the on-demand layer.
Expected< JITDylib & > createJITDylib(std::string Name)
Create a new JITDylib with the given name and return a reference to it.
Error prepareForConstruction()
Called prior to JIT class construcion to fix up defaults.
Lightweight error class with error context and mandatory checking.
JITTargetAddress LazyCompileFailureAddr
Interface for Layers that accept object files.
print Print MemDeps of function
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
StringRef - Represent a constant reference to a string, i.e.
JITDylib & getMainJITDylib()
Returns a reference to the JITDylib representing the JIT'd main program.
Optional< JITTargetMachineBuilder > JTMB
IndirectStubsManagerBuilderFunction ISMBuilder
A symbol table that supports asynchoronous symbol queries.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
A utility class for building TargetMachines for JITs.