Go to the documentation of this file.
57 return LS.IPLS.release();
61 return LS.reset(IPLS);
95 CAPIDefinitionGenerator(
98 : Ctx(Ctx), TryToGenerate(TryToGenerate) {}
120 switch (JDLookupFlags) {
130 std::vector<LLVMOrcCLookupSetElement> CLookupSet;
131 CLookupSet.reserve(LookupSet.
size());
132 for (
auto &KV : LookupSet) {
144 CLookupSet.push_back({
Name, SLF});
148 auto Err =
unwrap(TryToGenerate(::
wrap(
this), Ctx, &
LSR, CLookupKind,
149 ::
wrap(&JD), CJDLookupFlags,
150 CLookupSet.data(), CLookupSet.size()));
169 unwrap(ES)->setErrorReporter(
179 unwrap(SSP)->clearDeadEntries();
197 return unwrap(
S)->getKey().data();
202 auto RT =
unwrap(JD)->createResourceTracker();
205 return wrap(RT.get());
210 auto RT =
unwrap(JD)->getDefaultResourceTracker();
212 return wrap(RT.get());
223 TmpRT->transferTo(*
unwrap(DstRT));
228 return wrap(TmpRT->remove());
232 std::unique_ptr<DefinitionGenerator> TmpDG(
unwrap(DG));
236 std::unique_ptr<MaterializationUnit> TmpMU(
unwrap(MU));
242 for (
size_t I = 0;
I != NumPairs; ++
I) {
271 return wrap(JD.takeError());
272 *Result =
wrap(&*JD);
284 std::unique_ptr<MaterializationUnit> TmpMU(
unwrap(MU));
286 if (
auto Err =
unwrap(JD)->define(TmpMU)) {
299 unwrap(JD)->addGenerator(std::unique_ptr<DefinitionGenerator>(
unwrap(DG)));
304 auto DG = std::make_unique<CAPIDefinitionGenerator>(Ctx,
F);
305 return wrap(DG.release());
311 assert(Result &&
"Result can not be null");
313 "if Filter is null then FilterCtx must also be null");
321 auto ProcessSymsGenerator =
324 if (!ProcessSymsGenerator) {
326 return wrap(ProcessSymsGenerator.takeError());
329 *Result =
wrap(ProcessSymsGenerator->release());
359 assert(Result &&
"Result can not be null");
364 return wrap(JTMB.takeError());
376 std::make_unique<JITTargetMachineBuilder>(TemplateTM->getTargetTriple());
379 .setCPU(TemplateTM->getTargetCPU().str())
380 .setRelocationModel(TemplateTM->getRelocationModel())
381 .setCodeModel(TemplateTM->getCodeModel())
382 .setCodeGenOptLevel(TemplateTM->getOptLevel())
383 .setFeatures(TemplateTM->getTargetFeatureString())
384 .setOptions(TemplateTM->Options);
388 return wrap(JTMB.release());
418 auto TTStr = TT.str();
419 return std::unique_ptr<ObjectLayer>(
426 assert(Result &&
"Result can not be null");
436 return wrap(J.takeError());
439 *Result =
wrap(J->release());
449 return wrap(&
unwrap(J)->getExecutionSession());
457 return unwrap(J)->getTargetTriple().str().c_str();
461 return unwrap(J)->getDataLayout().getGlobalPrefix();
467 unwrap(J)->mangleAndIntern(UnmangledName)));
473 *
unwrap(JD), std::unique_ptr<MemoryBuffer>(
unwrap(ObjBuffer))));
481 std::unique_ptr<MemoryBuffer>(
unwrap(ObjBuffer))));
487 std::unique_ptr<ThreadSafeModule> TmpTSM(
unwrap(TSM));
494 std::unique_ptr<ThreadSafeModule> TmpTSM(
unwrap(TSM));
502 assert(Result &&
"Result can not be null");
507 return wrap(Sym.takeError());
510 *Result = Sym->getAddress();
517 assert(ES &&
"ES must not be null");
519 *
unwrap(ES), [] {
return std::make_unique<SectionMemoryManager>(); }));
525 assert(RTDyldObjLinkingLayer &&
"RTDyldObjLinkingLayer must not be null");
526 assert(Listener &&
"Listener must not be null");
528 ->registerJITEventListener(*
unwrap(Listener));
LLVMOrcSymbolStringPoolEntryRef LLVMOrcExecutionSessionIntern(LLVMOrcExecutionSessionRef ES, const char *Name)
Intern a string in the ExecutionSession's SymbolStringPool and return a reference to it.
struct LLVMOrcOpaqueResourceTracker * LLVMOrcResourceTrackerRef
A reference to an orc::ResourceTracker instance.
A utility class for building TargetMachines for JITs.
This class represents lattice values for constants.
LLVMOrcMaterializationUnitRef LLVMOrcAbsoluteSymbols(LLVMOrcCSymbolMapPairs Syms, size_t NumPairs)
Create a MaterializationUnit to define the given symbols as pointing to the corresponding raw address...
A symbol table that supports asynchoronous symbol queries.
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
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
static void retainPoolEntry(PoolEntryPtr P)
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
LLVMOrcJITDylibRef LLVMOrcExecutionSessionCreateBareJITDylib(LLVMOrcExecutionSessionRef ES, const char *Name)
Create a "bare" JITDylib.
Constructs LLJIT instances.
LLVMOrcResourceTrackerRef LLVMOrcJITDylibCreateResourceTracker(LLVMOrcJITDylibRef JD)
Return a reference to a newly created resource tracker associated with JD.
@ LLVMJITSymbolGenericFlagsExported
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
void LLVMOrcJITDylibAddGenerator(LLVMOrcJITDylibRef JD, LLVMOrcDefinitionGeneratorRef DG)
Add a DefinitionGenerator to the given JITDylib.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Pointer to a pooled string representing a symbol name.
@ LLVMOrcLookupKindStatic
static void releasePoolEntry(PoolEntryPtr P)
Triple - Helper class for working with autoconf configuration names.
LLVMErrorRef LLVMOrcResourceTrackerRemove(LLVMOrcResourceTrackerRef RT)
Remove all resources associated with the given tracker.
API to remove / transfer ownership of JIT resources.
A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
struct LLVMOrcOpaqueJITTargetMachineBuilder * LLVMOrcJITTargetMachineBuilderRef
A reference to an orc::JITTargetMachineBuilder instance.
LookupKind
Describes the kind of lookup being performed.
struct LLVMOrcOpaqueSymbolStringPoolEntry * LLVMOrcSymbolStringPoolEntryRef
A reference to an orc::SymbolStringPool table entry.
void LLVMOrcDisposeThreadSafeContext(LLVMOrcThreadSafeContextRef TSCtx)
Dispose of a ThreadSafeContext.
Flags for symbols in the JIT.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
Represents a symbol that has been evaluated to an address already.
LLVMContextRef LLVMOrcThreadSafeContextGetContext(LLVMOrcThreadSafeContextRef TSCtx)
Get a reference to the wrapped LLVMContext.
static void clear(coro::Shape &Shape)
const char * LLVMOrcSymbolStringPoolEntryStr(LLVMOrcSymbolStringPoolEntryRef S)
struct LLVMOrcOpaqueLLJITBuilder * LLVMOrcLLJITBuilderRef
A reference to an orc::LLJITBuilder instance.
LLVMOrcThreadSafeModuleRef LLVMOrcCreateNewThreadSafeModule(LLVMModuleRef M, LLVMOrcThreadSafeContextRef TSCtx)
Create a ThreadSafeModule wrapper around the given LLVM module.
struct LLVMOrcOpaqueJITDylib * LLVMOrcJITDylibRef
A reference to an orc::JITDylib instance.
LLVMOrcResourceTrackerRef LLVMOrcJITDylibGetDefaultResourceTracker(LLVMOrcJITDylibRef JD)
Return a reference to the default resource tracker for the given JITDylib.
TargetFlagsType & getTargetFlags()
Return a reference to the target-specific flags.
LLVMErrorRef LLVMOrcCreateLLJIT(LLVMOrcLLJITRef *Result, LLVMOrcLLJITBuilderRef Builder)
Create an LLJIT instance from an LLJITBuilder.
@ LLVMJITSymbolGenericFlagsWeak
String pool for symbol names used by the JIT.
@ LLVMOrcJITDylibLookupFlagsMatchAllSymbols
void LLVMOrcReleaseSymbolStringPoolEntry(LLVMOrcSymbolStringPoolEntryRef S)
Reduces the ref-count for of a SymbolStringPool entry.
const char * LLVMOrcLLJITGetTripleString(LLVMOrcLLJITRef J)
Return the target triple for this LLJIT instance.
void LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(LLVMOrcObjectLayerRef RTDyldObjLinkingLayer, LLVMJITEventListenerRef Listener)
Add the given listener to the given RTDyldObjectLinkingLayer.
Attribute unwrap(LLVMAttributeRef Attr)
Interface for Layers that accept object files.
void LLVMOrcDisposeThreadSafeModule(LLVMOrcThreadSafeModuleRef TSM)
Dispose of a ThreadSafeModule.
LLVMErrorRef LLVMOrcExecutionSessionCreateJITDylib(LLVMOrcExecutionSessionRef ES, LLVMOrcJITDylibRef *Result, const char *Name)
Create a JITDylib.
int(* LLVMOrcSymbolPredicate)(void *Ctx, LLVMOrcSymbolStringPoolEntryRef Sym)
Predicate function for SymbolStringPoolEntries.
struct LLVMOrcOpaqueLLJIT * LLVMOrcLLJITRef
A reference to an orc::LLJIT instance.
static Expected< JITTargetMachineBuilder > detectHost()
Create a JITTargetMachineBuilder for the host system.
@ LLVMOrcJITDylibLookupFlagsMatchExportedSymbolsOnly
static InProgressLookupState * extractLookupState(LookupState &LS)
UnderlyingVector::size_type size() const
void LLVMOrcRetainSymbolStringPoolEntry(LLVMOrcSymbolStringPoolEntryRef S)
Increments the ref-count for a SymbolStringPool entry.
LLVMErrorRef LLVMOrcJITTargetMachineBuilderDetectHost(LLVMOrcJITTargetMachineBuilderRef *Result)
Create a JITTargetMachineBuilder by detecting the host.
LLVMErrorRef(* LLVMOrcCAPIDefinitionGeneratorTryToGenerateFunction)(LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx, LLVMOrcLookupStateRef *LookupState, LLVMOrcLookupKind Kind, LLVMOrcJITDylibRef JD, LLVMOrcJITDylibLookupFlags JDLookupFlags, LLVMOrcCLookupSet LookupSet, size_t LookupSetSize)
A custom generator function.
typedefLLVM_C_EXTERN_C_BEGIN struct LLVMOpaqueTargetMachine * LLVMTargetMachineRef
LLVMErrorRef LLVMOrcLLJITAddObjectFileWithRT(LLVMOrcLLJITRef J, LLVMOrcResourceTrackerRef RT, LLVMMemoryBufferRef ObjBuffer)
Add a buffer representing an object file to the given ResourceTracker's JITDylib in the given LLJIT i...
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD, LLVMOrcThreadSafeModuleRef TSM)
Add an IR module to the given JITDylib in the given LLJIT instance.
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
struct LLVMOrcOpaqueDefinitionGenerator * LLVMOrcDefinitionGeneratorRef
A reference to an orc::DefinitionGenerator.
LLVM_C_EXTERN_C_BEGIN typedef LLVMOrcObjectLayerRef(* LLVMOrcLLJITBuilderObjectLinkingLayerCreatorFunction)(void *Ctx, LLVMOrcExecutionSessionRef ES, const char *Triple)
A function for constructing an ObjectLinkingLayer instance to be used by an LLJIT instance.
uint8_t IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP
LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD, LLVMMemoryBufferRef ObjBuffer)
Add a buffer representing an object file to the given JITDylib in the given LLJIT instance.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Primary interface to the complete machine description for the target machine.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static void resetLookupState(LookupState &LS, InProgressLookupState *IPLS)
An LLVMContext together with an associated mutex that can be used to lock the context to prevent conc...
Definition generators can be attached to JITDylibs to generate new definitions for otherwise unresolv...
void LLVMOrcDisposeMaterializationUnit(LLVMOrcMaterializationUnitRef MU)
Dispose of a MaterializationUnit.
@ LLVMOrcSymbolLookupFlagsRequiredSymbol
LLVM_C_EXTERN_C_BEGIN typedef uint64_t LLVMOrcJITTargetAddress
Represents an address in the target process.
LLVMAttributeRef wrap(Attribute Attr)
LLVMErrorRef LLVMOrcJITDylibClear(LLVMOrcJITDylibRef JD)
Calls remove on all trackers associated with this JITDylib, see JITDylib::clear().
static PoolEntryPtr releaseSymbolStringPtr(SymbolStringPtr S)
char LLVMOrcLLJITGetGlobalPrefix(LLVMOrcLLJITRef J)
Returns the global prefix character according to the LLJIT's DataLayout.
struct LLVMOrcOpaqueSymbolStringPool * LLVMOrcSymbolStringPoolRef
A reference to an orc::SymbolStringPool.
void LLVMOrcDisposeLLJITBuilder(LLVMOrcLLJITBuilderRef Builder)
Dispose of an LLVMOrcLLJITBuilderRef.
LLVMErrorRef LLVMOrcDisposeLLJIT(LLVMOrcLLJITRef J)
Dispose of an LLJIT instance.
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
Wraps state for a lookup-in-progress.
LLVMOrcJITDylibLookupFlags
JITDylib lookup flags.
LLVMOrcJITDylibRef LLVMOrcLLJITGetMainJITDylib(LLVMOrcLLJITRef J)
Return a reference to the Main JITDylib.
void LLVMOrcDisposeDefinitionGenerator(LLVMOrcDefinitionGeneratorRef DG)
Dispose of a JITDylib::DefinitionGenerator.
void LLVMOrcSymbolStringPoolClearDeadEntries(LLVMOrcSymbolStringPoolRef SSP)
Clear all unreferenced symbol string pool entries.
static SymbolStringPtr retainSymbolStringPtr(PoolEntryPtr P)
void LLVMOrcLLJITBuilderSetJITTargetMachineBuilder(LLVMOrcLLJITBuilderRef Builder, LLVMOrcJITTargetMachineBuilderRef JTMB)
Set the JITTargetMachineBuilder to be used when constructing the LLJIT instance.
static Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > GetForCurrentProcess(char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate())
Creates a DynamicLibrarySearchGenerator that searches for symbols in the current process.
void LLVMOrcLLJITBuilderSetObjectLinkingLayerCreator(LLVMOrcLLJITBuilderRef Builder, LLVMOrcLLJITBuilderObjectLinkingLayerCreatorFunction F, void *Ctx)
Set an ObjectLinkingLayer creator function for this LLJIT instance.
struct LLVMOpaqueError * LLVMErrorRef
Opaque reference to an error instance.
struct LLVMOrcOpaqueObjectLayer * LLVMOrcObjectLayerRef
A reference to an orc::ObjectLayer instance.
@ LLVMOrcSymbolLookupFlagsWeaklyReferencedSymbol
Should compile to something r4 addze r3 instead we get
Lightweight error class with error context and mandatory checking.
LLVMErrorRef LLVMOrcJITDylibDefine(LLVMOrcJITDylibRef JD, LLVMOrcMaterializationUnitRef MU)
Add the given MaterializationUnit to the given JITDylib.
An ExecutionSession represents a running JIT program.
@ MatchExportedSymbolsOnly
LLVMOrcSymbolLookupFlags
Symbol lookup flags for lookup sets.
void lLVMOrcDisposeObjectLayer(LLVMOrcObjectLayerRef ObjLayer)
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModuleWithRT(LLVMOrcLLJITRef J, LLVMOrcResourceTrackerRef RT, LLVMOrcThreadSafeModuleRef TSM)
Add an IR module to the given ResourceTracker's JITDylib in the given LLJIT instance.
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(OrcV2CAPIHelper::PoolEntry, LLVMOrcSymbolStringPoolEntryRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MaterializationUnit
void(* LLVMOrcErrorReporterFunction)(void *Ctx, LLVMErrorRef Err)
Error reporter function.
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
LLVMOrcSymbolStringPoolRef LLVMOrcExecutionSessionGetSymbolStringPool(LLVMOrcExecutionSessionRef ES)
Return a reference to the SymbolStringPool for an ExecutionSession.
void LLVMOrcReleaseResourceTracker(LLVMOrcResourceTrackerRef RT)
Reduces the ref-count of a ResourceTracker.
LLVMJITEvaluatedSymbol Sym
LLVMOrcJITDylibRef LLVMOrcExecutionSessionGetJITDylibByName(LLVMOrcExecutionSessionRef ES, const char *Name)
LLVMOrcJITTargetMachineBuilderRef LLVMOrcJITTargetMachineBuilderCreateFromTargetMachine(LLVMTargetMachineRef TM)
Create a JITTargetMachineBuilder from the given TargetMachine template.
void LLVMDisposeTargetMachine(LLVMTargetMachineRef T)
Dispose the LLVMTargetMachineRef instance generated by LLVMCreateTargetMachine.
LLVMOrcThreadSafeContextRef LLVMOrcCreateNewThreadSafeContext(void)
Create a ThreadSafeContext containing a new LLVMContext.
void LLVMOrcExecutionSessionSetErrorReporter(LLVMOrcExecutionSessionRef ES, LLVMOrcErrorReporterFunction ReportError, void *Ctx)
Attach a custom error reporter function to the ExecutionSession.
static PoolEntryPtr getRawPoolEntryPtr(const SymbolStringPtr &S)
void LLVMOrcResourceTrackerTransferTo(LLVMOrcResourceTrackerRef SrcRT, LLVMOrcResourceTrackerRef DstRT)
Transfers tracking of all resources associated with resource tracker SrcRT to resource tracker DstRT.
LLVMOrcDefinitionGeneratorRef LLVMOrcCreateCustomCAPIDefinitionGenerator(LLVMOrcCAPIDefinitionGeneratorTryToGenerateFunction F, void *Ctx)
Create a custom generator.
struct LLVMOrcOpaqueThreadSafeModule * LLVMOrcThreadSafeModuleRef
A reference to an orc::ThreadSafeModule instance.
std::function< bool(const SymbolStringPtr &)> SymbolPredicate
void LLVMOrcDisposeJITTargetMachineBuilder(LLVMOrcJITTargetMachineBuilderRef JTMB)
Dispose of a JITTargetMachineBuilder.
LLVMOrcSymbolStringPoolEntryRef LLVMOrcLLJITMangleAndIntern(LLVMOrcLLJITRef J, const char *UnmangledName)
Mangles the given string according to the LLJIT instance's DataLayout, then interns the result in the...
LLVMOrcLookupKind
Lookup kind.
struct LLVMOrcOpaqueLookupState * LLVMOrcLookupStateRef
An opaque lookup state object.
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
An LLVM Module together with a shared ThreadSafeContext.
struct LLVMOrcOpaqueExecutionSession * LLVMOrcExecutionSessionRef
A reference to an orc::ExecutionSession instance.
LLVMErrorRef LLVMOrcLLJITLookup(LLVMOrcLLJITRef J, LLVMOrcJITTargetAddress *Result, const char *Name)
Look up the given symbol in the main JITDylib of the given LLJIT instance.
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
struct LLVMOrcOpaqueThreadSafeContext * LLVMOrcThreadSafeContextRef
A reference to an orc::ThreadSafeContext instance.
struct LLVMOrcOpaqueMaterializationUnit * LLVMOrcMaterializationUnitRef
A reference to an orc::MaterializationUnit.
LLVMOrcExecutionSessionRef LLVMOrcLLJITGetExecutionSession(LLVMOrcLLJITRef J)
Get a reference to the ExecutionSession for this LLJIT instance.
Represents a pair of a symbol name and an evaluated symbol.
LLVMOrcLLJITBuilderRef LLVMOrcCreateLLJITBuilder(void)
Create an LLVMOrcLLJITBuilder.
struct LLVMOpaqueJITEventListener * LLVMJITEventListenerRef
LLVMErrorRef LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess(LLVMOrcDefinitionGeneratorRef *Result, char GlobalPrefix, LLVMOrcSymbolPredicate Filter, void *FilterCtx)
Get a DynamicLibrarySearchGenerator that will reflect process symbols into the JITDylib.
LLVMOrcObjectLayerRef LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager(LLVMOrcExecutionSessionRef ES)
Create a RTDyldObjectLinkingLayer instance using the standard SectionMemoryManager for memory managem...
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.