LLVM  12.0.0git
OrcV2CBindings.cpp
Go to the documentation of this file.
1 //===--------------- OrcV2CBindings.cpp - C bindings OrcV2 APIs -----------===//
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 #include "llvm-c/LLJIT.h"
10 #include "llvm-c/Orc.h"
11 #include "llvm-c/OrcEE.h"
12 #include "llvm-c/TargetMachine.h"
13 
18 
19 using namespace llvm;
20 using namespace llvm::orc;
21 
22 namespace llvm {
23 namespace orc {
24 
26 
28 public:
31 
33  PoolEntryPtr Result = nullptr;
34  std::swap(Result, S.S);
35  return Result;
36  }
37 
39  return SymbolStringPtr(P);
40  }
41 
43  return S.S;
44  }
45 
47  SymbolStringPtr S(P);
48  S.S = nullptr;
49  }
50 
53  S.S = P;
54  }
55 
57  return LS.IPLS.release();
58  }
59 
61  return LS.reset(IPLS);
62  }
63 };
64 
65 } // namespace orc
66 } // namespace llvm
67 
87 
89 
90 namespace llvm {
91 namespace orc {
92 
93 class CAPIDefinitionGenerator final : public DefinitionGenerator {
94 public:
95  CAPIDefinitionGenerator(
96  void *Ctx,
98  : Ctx(Ctx), TryToGenerate(TryToGenerate) {}
99 
100  Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD,
101  JITDylibLookupFlags JDLookupFlags,
102  const SymbolLookupSet &LookupSet) override {
103 
104  // Take the lookup state.
106 
107  // Translate the lookup kind.
108  LLVMOrcLookupKind CLookupKind;
109  switch (K) {
110  case LookupKind::Static:
111  CLookupKind = LLVMOrcLookupKindStatic;
112  break;
113  case LookupKind::DLSym:
114  CLookupKind = LLVMOrcLookupKindDLSym;
115  break;
116  }
117 
118  // Translate the JITDylibSearchFlags.
119  LLVMOrcJITDylibLookupFlags CJDLookupFlags;
120  switch (JDLookupFlags) {
123  break;
126  break;
127  }
128 
129  // Translate the lookup set.
130  std::vector<LLVMOrcCLookupSetElement> CLookupSet;
131  CLookupSet.reserve(LookupSet.size());
132  for (auto &KV : LookupSet) {
136  switch (KV.second) {
139  break;
142  break;
143  }
144  CLookupSet.push_back({Name, SLF});
145  }
146 
147  // Run the C TryToGenerate function.
148  auto Err = unwrap(TryToGenerate(::wrap(this), Ctx, &LSR, CLookupKind,
149  ::wrap(&JD), CJDLookupFlags,
150  CLookupSet.data(), CLookupSet.size()));
151 
152  // Restore the lookup state.
154 
155  return Err;
156  }
157 
158 private:
159  void *Ctx;
161 };
162 
163 } // end namespace orc
164 } // end namespace llvm
165 
168  void *Ctx) {
169  unwrap(ES)->setErrorReporter(
170  [=](Error Err) { ReportError(Ctx, wrap(std::move(Err))); });
171 }
172 
175  return wrap(unwrap(ES)->getSymbolStringPool().get());
176 }
177 
179  unwrap(SSP)->clearDeadEntries();
180 }
181 
184  return wrap(
186 }
187 
190 }
191 
194 }
195 
197  return unwrap(S)->getKey().data();
198 }
199 
202  auto RT = unwrap(JD)->createResourceTracker();
203  // Retain the pointer for the C API client.
204  RT->Retain();
205  return wrap(RT.get());
206 }
207 
210  auto RT = unwrap(JD)->getDefaultResourceTracker();
211  // Retain the pointer for the C API client.
212  return wrap(RT.get());
213 }
214 
216  ResourceTrackerSP TmpRT(unwrap(RT));
217  TmpRT->Release();
218 }
219 
222  ResourceTrackerSP TmpRT(unwrap(SrcRT));
223  TmpRT->transferTo(*unwrap(DstRT));
224 }
225 
227  ResourceTrackerSP TmpRT(unwrap(RT));
228  return wrap(TmpRT->remove());
229 }
230 
232  std::unique_ptr<DefinitionGenerator> TmpDG(unwrap(DG));
233 }
234 
236  std::unique_ptr<MaterializationUnit> TmpMU(unwrap(MU));
237 }
238 
241  SymbolMap SM;
242  for (size_t I = 0; I != NumPairs; ++I) {
243  JITSymbolFlags Flags;
244 
245  if (Syms[I].Sym.Flags.GenericFlags & LLVMJITSymbolGenericFlagsExported)
246  Flags |= JITSymbolFlags::Exported;
247  if (Syms[I].Sym.Flags.GenericFlags & LLVMJITSymbolGenericFlagsWeak)
248  Flags |= JITSymbolFlags::Weak;
249 
250  Flags.getTargetFlags() = Syms[I].Sym.Flags.TargetFlags;
251 
253  JITEvaluatedSymbol(Syms[I].Sym.Address, Flags);
254  }
255 
256  return wrap(absoluteSymbols(std::move(SM)).release());
257 }
258 
261  const char *Name) {
262  return wrap(&unwrap(ES)->createBareJITDylib(Name));
263 }
264 
267  LLVMOrcJITDylibRef *Result,
268  const char *Name) {
269  auto JD = unwrap(ES)->createJITDylib(Name);
270  if (!JD)
271  return wrap(JD.takeError());
272  *Result = wrap(&*JD);
273  return LLVMErrorSuccess;
274 }
275 
278  const char *Name) {
279  return wrap(unwrap(ES)->getJITDylibByName(Name));
280 }
281 
284  std::unique_ptr<MaterializationUnit> TmpMU(unwrap(MU));
285 
286  if (auto Err = unwrap(JD)->define(TmpMU)) {
287  TmpMU.release();
288  return wrap(std::move(Err));
289  }
290  return LLVMErrorSuccess;
291 }
292 
294  return wrap(unwrap(JD)->clear());
295 }
296 
299  unwrap(JD)->addGenerator(std::unique_ptr<DefinitionGenerator>(unwrap(DG)));
300 }
301 
304  auto DG = std::make_unique<CAPIDefinitionGenerator>(Ctx, F);
305  return wrap(DG.release());
306 }
307 
310  LLVMOrcSymbolPredicate Filter, void *FilterCtx) {
311  assert(Result && "Result can not be null");
312  assert((Filter || !FilterCtx) &&
313  "if Filter is null then FilterCtx must also be null");
314 
316  if (Filter)
317  Pred = [=](const SymbolStringPtr &Name) -> bool {
318  return Filter(FilterCtx, wrap(OrcV2CAPIHelper::getRawPoolEntryPtr(Name)));
319  };
320 
321  auto ProcessSymsGenerator =
323 
324  if (!ProcessSymsGenerator) {
325  *Result = 0;
326  return wrap(ProcessSymsGenerator.takeError());
327  }
328 
329  *Result = wrap(ProcessSymsGenerator->release());
330  return LLVMErrorSuccess;
331 }
332 
334  return wrap(new ThreadSafeContext(std::make_unique<LLVMContext>()));
335 }
336 
339  return wrap(unwrap(TSCtx)->getContext());
340 }
341 
343  delete unwrap(TSCtx);
344 }
345 
349  return wrap(
350  new ThreadSafeModule(std::unique_ptr<Module>(unwrap(M)), *unwrap(TSCtx)));
351 }
352 
354  delete unwrap(TSM);
355 }
356 
359  assert(Result && "Result can not be null");
360 
362  if (!JTMB) {
363  Result = 0;
364  return wrap(JTMB.takeError());
365  }
366 
367  *Result = wrap(new JITTargetMachineBuilder(std::move(*JTMB)));
368  return LLVMErrorSuccess;
369 }
370 
373  auto *TemplateTM = unwrap(TM);
374 
375  auto JTMB =
376  std::make_unique<JITTargetMachineBuilder>(TemplateTM->getTargetTriple());
377 
378  (*JTMB)
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);
385 
387 
388  return wrap(JTMB.release());
389 }
390 
393  delete unwrap(JTMB);
394 }
395 
397  delete unwrap(ObjLayer);
398 }
399 
401  return wrap(new LLJITBuilder());
402 }
403 
405  delete unwrap(Builder);
406 }
407 
410  unwrap(Builder)->setJITTargetMachineBuilder(*unwrap(JTMB));
411 }
412 
416  unwrap(Builder)->setObjectLinkingLayerCreator(
417  [=](ExecutionSession &ES, const Triple &TT) {
418  auto TTStr = TT.str();
419  return std::unique_ptr<ObjectLayer>(
420  unwrap(F(Ctx, wrap(&ES), TTStr.c_str())));
421  });
422 }
423 
426  assert(Result && "Result can not be null");
427 
428  if (!Builder)
429  Builder = LLVMOrcCreateLLJITBuilder();
430 
431  auto J = unwrap(Builder)->create();
433 
434  if (!J) {
435  Result = 0;
436  return wrap(J.takeError());
437  }
438 
439  *Result = wrap(J->release());
440  return LLVMErrorSuccess;
441 }
442 
444  delete unwrap(J);
445  return LLVMErrorSuccess;
446 }
447 
449  return wrap(&unwrap(J)->getExecutionSession());
450 }
451 
453  return wrap(&unwrap(J)->getMainJITDylib());
454 }
455 
457  return unwrap(J)->getTargetTriple().str().c_str();
458 }
459 
461  return unwrap(J)->getDataLayout().getGlobalPrefix();
462 }
463 
465 LLVMOrcLLJITMangleAndIntern(LLVMOrcLLJITRef J, const char *UnmangledName) {
467  unwrap(J)->mangleAndIntern(UnmangledName)));
468 }
469 
471  LLVMMemoryBufferRef ObjBuffer) {
472  return wrap(unwrap(J)->addObjectFile(
473  *unwrap(JD), std::unique_ptr<MemoryBuffer>(unwrap(ObjBuffer))));
474 }
475 
478  LLVMMemoryBufferRef ObjBuffer) {
479  return wrap(unwrap(J)->addObjectFile(
481  std::unique_ptr<MemoryBuffer>(unwrap(ObjBuffer))));
482 }
483 
487  std::unique_ptr<ThreadSafeModule> TmpTSM(unwrap(TSM));
488  return wrap(unwrap(J)->addIRModule(*unwrap(JD), std::move(*TmpTSM)));
489 }
490 
494  std::unique_ptr<ThreadSafeModule> TmpTSM(unwrap(TSM));
495  return wrap(unwrap(J)->addIRModule(ResourceTrackerSP(unwrap(RT)),
496  std::move(*TmpTSM)));
497 }
498 
500  LLVMOrcJITTargetAddress *Result,
501  const char *Name) {
502  assert(Result && "Result can not be null");
503 
504  auto Sym = unwrap(J)->lookup(Name);
505  if (!Sym) {
506  *Result = 0;
507  return wrap(Sym.takeError());
508  }
509 
510  *Result = Sym->getAddress();
511  return LLVMErrorSuccess;
512 }
513 
517  assert(ES && "ES must not be null");
518  return wrap(new RTDyldObjectLinkingLayer(
519  *unwrap(ES), [] { return std::make_unique<SectionMemoryManager>(); }));
520 }
521 
523  LLVMOrcObjectLayerRef RTDyldObjLinkingLayer,
524  LLVMJITEventListenerRef Listener) {
525  assert(RTDyldObjLinkingLayer && "RTDyldObjLinkingLayer must not be null");
526  assert(Listener && "Listener must not be null");
527  reinterpret_cast<RTDyldObjectLinkingLayer *>(unwrap(RTDyldObjLinkingLayer))
528  ->registerJITEventListener(*unwrap(Listener));
529 }
static void retainPoolEntry(PoolEntryPtr P)
uint8_t IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP
Definition: Core.h:43
Wraps state for a lookup-in-progress.
Definition: Core.h:847
LLVMOrcMaterializationUnitRef LLVMOrcAbsoluteSymbols(LLVMOrcCSymbolMapPairs Syms, size_t NumPairs)
Create a MaterializationUnit to define the given symbols as pointing to the corresponding raw address...
LookupKind
Describes the kind of lookup being performed.
Definition: Core.h:145
This class represents lattice values for constants.
Definition: AllocatorList.h:23
void LLVMOrcExecutionSessionSetErrorReporter(LLVMOrcExecutionSessionRef ES, LLVMOrcErrorReporterFunction ReportError, void *Ctx)
Attach a custom error reporter function to the ExecutionSession.
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:61
String pool for symbol names used by the JIT.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
struct LLVMOrcOpaqueLLJITBuilder * LLVMOrcLLJITBuilderRef
A reference to an orc::LLJITBuilder instance.
Definition: LLJIT.h:54
void LLVMOrcDisposeJITTargetMachineBuilder(LLVMOrcJITTargetMachineBuilderRef JTMB)
Dispose of a JITTargetMachineBuilder.
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
Definition: Types.h:48
std::function< bool(const SymbolStringPtr &)> SymbolPredicate
LLVMErrorRef LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess(LLVMOrcDefinitionGeneratorRef *Result, char GlobalPrefix, LLVMOrcSymbolPredicate Filter, void *FilterCtx)
Get a DynamicLibrarySearchGenerator that will reflect process symbols into the JITDylib.
Definition generators can be attached to JITDylibs to generate new definitions for otherwise unresolv...
Definition: Core.h:869
An LLVMContext together with an associated mutex that can be used to lock the context to prevent conc...
void LLVMOrcDisposeThreadSafeModule(LLVMOrcThreadSafeModuleRef TSM)
Dispose of a ThreadSafeModule.
static void resetLookupState(LookupState &LS, InProgressLookupState *IPLS)
LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD, LLVMMemoryBufferRef ObjBuffer)
Add a buffer representing an object file to the given JITDylib in the given LLJIT instance...
F(f)
LLVMOrcResourceTrackerRef LLVMOrcJITDylibGetDefaultResourceTracker(LLVMOrcJITDylibRef JD)
Return a reference to the default resource tracker for the given JITDylib.
LLVMOrcExecutionSessionRef LLVMOrcLLJITGetExecutionSession(LLVMOrcLLJITRef J)
Get a reference to the ExecutionSession for this LLJIT instance.
LLVMOrcJITTargetMachineBuilderRef LLVMOrcJITTargetMachineBuilderCreateFromTargetMachine(LLVMTargetMachineRef TM)
Create a JITTargetMachineBuilder from the given TargetMachine template.
static PoolEntryPtr releaseSymbolStringPtr(SymbolStringPtr S)
void LLVMOrcSymbolStringPoolClearDeadEntries(LLVMOrcSymbolStringPoolRef SSP)
Clear all unreferenced symbol string pool entries.
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModuleWithRT(LLVMOrcLLJITRef J, LLVMOrcResourceTrackerRef RT, LLVMOrcThreadSafeModuleRef TSM)
Add an IR module to the given ResourceTracker&#39;s JITDylib in the given LLJIT instance.
LLVMOrcJITDylibRef LLVMOrcExecutionSessionCreateBareJITDylib(LLVMOrcExecutionSessionRef ES, const char *Name)
Create a "bare" JITDylib.
struct LLVMOrcOpaqueSymbolStringPool * LLVMOrcSymbolStringPoolRef
A reference to an orc::SymbolStringPool.
Definition: Orc.h:83
API to remove / transfer ownership of JIT resources.
Definition: Core.h:49
void LLVMOrcReleaseResourceTracker(LLVMOrcResourceTrackerRef RT)
Reduces the ref-count of a ResourceTracker.
LLVMErrorRef LLVMOrcResourceTrackerRemove(LLVMOrcResourceTrackerRef RT)
Remove all resources associated with the given tracker.
void LLVMOrcRetainSymbolStringPoolEntry(LLVMOrcSymbolStringPoolEntryRef S)
Increments the ref-count for a SymbolStringPool entry.
char LLVMOrcLLJITGetGlobalPrefix(LLVMOrcLLJITRef J)
Returns the global prefix character according to the LLJIT&#39;s DataLayout.
struct LLVMOrcOpaqueLLJIT * LLVMOrcLLJITRef
A reference to an orc::LLJIT instance.
Definition: LLJIT.h:59
LLVMErrorRef LLVMOrcLLJITLookup(LLVMOrcLLJITRef J, LLVMOrcJITTargetAddress *Result, const char *Name)
Look up the given symbol in the main JITDylib of the given LLJIT instance.
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:229
LLVMErrorRef LLVMOrcLLJITAddObjectFileWithRT(LLVMOrcLLJITRef J, LLVMOrcResourceTrackerRef RT, LLVMMemoryBufferRef ObjBuffer)
Add a buffer representing an object file to the given ResourceTracker&#39;s JITDylib in the given LLJIT i...
void LLVMOrcLLJITBuilderSetJITTargetMachineBuilder(LLVMOrcLLJITBuilderRef Builder, LLVMOrcJITTargetMachineBuilderRef JTMB)
Set the JITTargetMachineBuilder to be used when constructing the LLJIT instance.
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(OrcV2CAPIHelper::PoolEntry, LLVMOrcSymbolStringPoolEntryRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MaterializationUnit
LLVMErrorRef LLVMOrcCreateLLJIT(LLVMOrcLLJITRef *Result, LLVMOrcLLJITBuilderRef Builder)
Create an LLJIT instance from an LLJITBuilder.
void LLVMOrcReleaseSymbolStringPoolEntry(LLVMOrcSymbolStringPoolEntryRef S)
Reduces the ref-count for of a SymbolStringPool entry.
const char * LLVMOrcSymbolStringPoolEntryStr(LLVMOrcSymbolStringPoolEntryRef S)
void LLVMOrcLLJITBuilderSetObjectLinkingLayerCreator(LLVMOrcLLJITBuilderRef Builder, LLVMOrcLLJITBuilderObjectLinkingLayerCreatorFunction F, void *Ctx)
Set an ObjectLinkingLayer creator function for this LLJIT instance.
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...
Definition: LLJIT.h:48
int(* LLVMOrcSymbolPredicate)(void *Ctx, LLVMOrcSymbolStringPoolEntryRef Sym)
Predicate function for SymbolStringPoolEntries.
Definition: Orc.h:234
LLVMOrcLookupKind
Lookup kind.
Definition: Orc.h:111
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
Definition: Types.h:53
void LLVMOrcJITDylibAddGenerator(LLVMOrcJITDylibRef JD, LLVMOrcDefinitionGeneratorRef DG)
Add a DefinitionGenerator to the given JITDylib.
LLVMContextRef LLVMOrcThreadSafeContextGetContext(LLVMOrcThreadSafeContextRef TSCtx)
Get a reference to the wrapped LLVMContext.
const std::string & str() const
Definition: Triple.h:369
Pointer to a pooled string representing a symbol name.
struct LLVMOrcOpaqueThreadSafeContext * LLVMOrcThreadSafeContextRef
A reference to an orc::ThreadSafeContext instance.
Definition: Orc.h:240
struct LLVMOpaqueError * LLVMErrorRef
Opaque reference to an error instance.
Definition: Error.h:26
static Expected< JITTargetMachineBuilder > detectHost()
Create a JITTargetMachineBuilder for the host system.
#define P(N)
LLVMOrcDefinitionGeneratorRef LLVMOrcCreateCustomCAPIDefinitionGenerator(LLVMOrcCAPIDefinitionGeneratorTryToGenerateFunction F, void *Ctx)
Create a custom generator.
LLVMOrcSymbolStringPoolEntryRef LLVMOrcExecutionSessionIntern(LLVMOrcExecutionSessionRef ES, const char *Name)
Intern a string in the ExecutionSession&#39;s SymbolStringPool and return a reference to it...
LLVMOrcLLJITBuilderRef LLVMOrcCreateLLJITBuilder(void)
Create an LLVMOrcLLJITBuilder.
static SymbolStringPtr retainSymbolStringPtr(PoolEntryPtr P)
struct LLVMOrcOpaqueObjectLayer * LLVMOrcObjectLayerRef
A reference to an orc::ObjectLayer instance.
Definition: Orc.h:256
#define LLVMErrorSuccess
Definition: Error.h:21
uint8_t TargetFlags
Definition: Orc.h:59
LLVMErrorRef LLVMOrcDisposeLLJIT(LLVMOrcLLJITRef J)
Dispose of an LLJIT instance.
LLVMErrorRef LLVMOrcExecutionSessionCreateJITDylib(LLVMOrcExecutionSessionRef ES, LLVMOrcJITDylibRef *Result, const char *Name)
Create a JITDylib.
void LLVMOrcDisposeLLJITBuilder(LLVMOrcLLJITBuilderRef Builder)
Dispose of an LLVMOrcLLJITBuilderRef.
Flags for symbols in the JIT.
Definition: JITSymbol.h:74
Represents a pair of a symbol name and an evaluated symbol.
Definition: Orc.h:94
struct LLVMOrcOpaqueResourceTracker * LLVMOrcResourceTrackerRef
A reference to an orc::ResourceTracker instance.
Definition: Orc.h:170
An LLVM Module together with a shared ThreadSafeContext.
typedefLLVM_C_EXTERN_C_BEGIN struct LLVMOpaqueTargetMachine * LLVMTargetMachineRef
Definition: TargetMachine.h:28
assume Assume Builder
LLVMOrcJITDylibRef LLVMOrcExecutionSessionGetJITDylibByName(LLVMOrcExecutionSessionRef ES, const char *Name)
struct LLVMOrcOpaqueDefinitionGenerator * LLVMOrcDefinitionGeneratorRef
A reference to an orc::DefinitionGenerator.
Definition: Orc.h:175
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
static void releasePoolEntry(PoolEntryPtr P)
struct LLVMOrcOpaqueJITDylib * LLVMOrcJITDylibRef
A reference to an orc::JITDylib instance.
Definition: Orc.h:165
void LLVMDisposeTargetMachine(LLVMTargetMachineRef T)
Dispose the LLVMTargetMachineRef instance generated by LLVMCreateTargetMachine.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group...
Definition: Core.h:634
void LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(LLVMOrcObjectLayerRef RTDyldObjLinkingLayer, LLVMJITEventListenerRef Listener)
Add the given listener to the given RTDyldObjectLinkingLayer.
LLVMErrorRef(* LLVMOrcCAPIDefinitionGeneratorTryToGenerateFunction)(LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx, LLVMOrcLookupStateRef *LookupState, LLVMOrcLookupKind Kind, LLVMOrcJITDylibRef JD, LLVMOrcJITDylibLookupFlags JDLookupFlags, LLVMOrcCLookupSet LookupSet, size_t LookupSetSize)
A custom generator function.
Definition: Orc.h:225
struct LLVMOrcOpaqueLookupState * LLVMOrcLookupStateRef
An opaque lookup state object.
Definition: Orc.h:190
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
Definition: Core.h:715
LLVMOrcResourceTrackerRef LLVMOrcJITDylibCreateResourceTracker(LLVMOrcJITDylibRef JD)
Return a reference to a newly created resource tracker associated with JD.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:171
LLVMJITEvaluatedSymbol Sym
Definition: Orc.h:96
struct LLVMOrcOpaqueMaterializationUnit * LLVMOrcMaterializationUnitRef
A reference to an orc::MaterializationUnit.
Definition: Orc.h:160
void LLVMOrcDisposeMaterializationUnit(LLVMOrcMaterializationUnitRef MU)
Dispose of a MaterializationUnit.
void LLVMOrcDisposeDefinitionGenerator(LLVMOrcDefinitionGeneratorRef DG)
Dispose of a JITDylib::DefinitionGenerator.
LLVM_C_EXTERN_C_BEGIN typedef uint64_t LLVMOrcJITTargetAddress
Represents an address in the target process.
Definition: Orc.h:39
A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
Definition: LLJIT.h:37
An ExecutionSession represents a running JIT program.
Definition: Core.h:1216
struct LLVMOrcOpaqueThreadSafeModule * LLVMOrcThreadSafeModuleRef
A reference to an orc::ThreadSafeModule instance.
Definition: Orc.h:245
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:944
LLVMJITSymbolFlags Flags
Definition: Orc.h:67
Represents a symbol that has been evaluated to an address already.
Definition: JITSymbol.h:229
LLVMOrcJITDylibLookupFlags
JITDylib lookup flags.
Definition: Orc.h:122
static void clear(coro::Shape &Shape)
Definition: Coroutines.cpp:231
static PoolEntryPtr getRawPoolEntryPtr(const SymbolStringPtr &S)
struct LLVMOrcOpaqueExecutionSession * LLVMOrcExecutionSessionRef
A reference to an orc::ExecutionSession instance.
Definition: Orc.h:73
LLVMErrorRef LLVMOrcJITDylibClear(LLVMOrcJITDylibRef JD)
Calls remove on all trackers associated with this JITDylib, see JITDylib::clear().
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:224
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD, LLVMOrcThreadSafeModuleRef TSM)
Add an IR module to the given JITDylib in the given LLJIT instance.
LLVMOrcJITDylibRef LLVMOrcLLJITGetMainJITDylib(LLVMOrcLLJITRef J)
Return a reference to the Main JITDylib.
#define I(x, y, z)
Definition: MD5.cpp:59
UnderlyingVector::size_type size() const
Definition: Core.h:235
void LLVMOrcResourceTrackerTransferTo(LLVMOrcResourceTrackerRef SrcRT, LLVMOrcResourceTrackerRef DstRT)
Transfers tracking of all resources associated with resource tracker SrcRT to resource tracker DstRT...
Constructs LLJIT instances.
Definition: LLJIT.h:380
LLVMErrorRef LLVMOrcJITTargetMachineBuilderDetectHost(LLVMOrcJITTargetMachineBuilderRef *Result)
Create a JITTargetMachineBuilder by detecting the host.
LLVMOrcSymbolStringPoolRef LLVMOrcExecutionSessionGetSymbolStringPool(LLVMOrcExecutionSessionRef ES)
Return a reference to the SymbolStringPool for an ExecutionSession.
TargetFlagsType & getTargetFlags()
Return a reference to the target-specific flags.
Definition: JITSymbol.h:172
LLVMOrcThreadSafeModuleRef LLVMOrcCreateNewThreadSafeModule(LLVMModuleRef M, LLVMOrcThreadSafeContextRef TSCtx)
Create a ThreadSafeModule wrapper around the given LLVM module.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
struct LLVMOpaqueJITEventListener * LLVMJITEventListenerRef
Definition: Types.h:163
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
Interface for Layers that accept object files.
Definition: Layer.h:132
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:66
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1556
void(* LLVMOrcErrorReporterFunction)(void *Ctx, LLVMErrorRef Err)
Error reporter function.
Definition: Orc.h:78
static Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > GetForCurrentProcess(char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate())
Creates a DynamicLibrarySearchGenerator that searches for symbols in the current process.
LLVMOrcSymbolLookupFlags
Symbol lookup flags for lookup sets.
Definition: Orc.h:131
static InProgressLookupState * extractLookupState(LookupState &LS)
void lLVMOrcDisposeObjectLayer(LLVMOrcObjectLayerRef ObjLayer)
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
Definition: Core.h:123
struct LLVMOrcOpaqueJITTargetMachineBuilder * LLVMOrcJITTargetMachineBuilderRef
A reference to an orc::JITTargetMachineBuilder instance.
Definition: Orc.h:250
struct LLVMOrcOpaqueSymbolStringPoolEntry * LLVMOrcSymbolStringPoolEntryRef
A reference to an orc::SymbolStringPool table entry.
Definition: Orc.h:88
void LLVMOrcDisposeThreadSafeContext(LLVMOrcThreadSafeContextRef TSCtx)
Dispose of a ThreadSafeContext.
LLVMOrcObjectLayerRef LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager(LLVMOrcExecutionSessionRef ES)
Create a RTDyldObjectLinkingLayer instance using the standard SectionMemoryManager for memory managem...
LLVMErrorRef LLVMOrcJITDylibDefine(LLVMOrcJITDylibRef JD, LLVMOrcMaterializationUnitRef MU)
Add the given MaterializationUnit to the given JITDylib.
const char * LLVMOrcLLJITGetTripleString(LLVMOrcLLJITRef J)
Return the target triple for this LLJIT instance.
LLVMOrcThreadSafeContextRef LLVMOrcCreateNewThreadSafeContext(void)
Create a ThreadSafeContext containing a new LLVMContext.
A symbol table that supports asynchoronous symbol queries.
Definition: Core.h:890
A utility class for building TargetMachines for JITs.
LLVMOrcSymbolStringPoolEntryRef LLVMOrcLLJITMangleAndIntern(LLVMOrcLLJITRef J, const char *UnmangledName)
Mangles the given string according to the LLJIT instance&#39;s DataLayout, then interns the result in the...