LLVM  13.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 
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 {
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)
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 }
LLVMOrcExecutionSessionIntern
LLVMOrcSymbolStringPoolEntryRef LLVMOrcExecutionSessionIntern(LLVMOrcExecutionSessionRef ES, const char *Name)
Intern a string in the ExecutionSession's SymbolStringPool and return a reference to it.
Definition: OrcV2CBindings.cpp:183
LLVMOrcResourceTrackerRef
struct LLVMOrcOpaqueResourceTracker * LLVMOrcResourceTrackerRef
A reference to an orc::ResourceTracker instance.
Definition: Orc.h:170
llvm::orc::JITTargetMachineBuilder
A utility class for building TargetMachines for JITs.
Definition: JITTargetMachineBuilder.h:34
llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:23
LLVMOrcAbsoluteSymbols
LLVMOrcMaterializationUnitRef LLVMOrcAbsoluteSymbols(LLVMOrcCSymbolMapPairs Syms, size_t NumPairs)
Create a MaterializationUnit to define the given symbols as pointing to the corresponding raw address...
Definition: OrcV2CBindings.cpp:240
llvm::orc::JITDylib
A symbol table that supports asynchoronous symbol queries.
Definition: Core.h:894
LLVMContextRef
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
Definition: Types.h:53
M
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
Definition: README.txt:252
llvm::SystemZISD::TM
@ TM
Definition: SystemZISelLowering.h:65
llvm::orc::RTDyldObjectLinkingLayer
Definition: RTDyldObjectLinkingLayer.h:38
llvm::orc::OrcV2CAPIHelper::retainPoolEntry
static void retainPoolEntry(PoolEntryPtr P)
Definition: OrcV2CBindings.cpp:46
llvm::StringMapEntry
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMapEntry.h:69
llvm::orc::InProgressLookupState
Definition: Core.cpp:465
LLVMOrcExecutionSessionCreateBareJITDylib
LLVMOrcJITDylibRef LLVMOrcExecutionSessionCreateBareJITDylib(LLVMOrcExecutionSessionRef ES, const char *Name)
Create a "bare" JITDylib.
Definition: OrcV2CBindings.cpp:260
llvm::orc::LLJITBuilder
Constructs LLJIT instances.
Definition: LLJIT.h:381
LLVMOrcJITDylibCreateResourceTracker
LLVMOrcResourceTrackerRef LLVMOrcJITDylibCreateResourceTracker(LLVMOrcJITDylibRef JD)
Return a reference to a newly created resource tracker associated with JD.
Definition: OrcV2CBindings.cpp:201
LLVMJITSymbolGenericFlagsExported
@ LLVMJITSymbolGenericFlagsExported
Definition: Orc.h:45
P
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
Definition: README-SSE.txt:411
LLVMOrcJITDylibAddGenerator
void LLVMOrcJITDylibAddGenerator(LLVMOrcJITDylibRef JD, LLVMOrcDefinitionGeneratorRef DG)
Add a DefinitionGenerator to the given JITDylib.
Definition: OrcV2CBindings.cpp:297
llvm::orc::SymbolLookupSet
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:172
llvm::orc::LookupKind::Static
@ Static
llvm::orc::SymbolStringPtr
Pointer to a pooled string representing a symbol name.
Definition: SymbolStringPool.h:50
LLVMOrcLookupKindStatic
@ LLVMOrcLookupKindStatic
Definition: Orc.h:112
llvm::orc::OrcV2CAPIHelper::releasePoolEntry
static void releasePoolEntry(PoolEntryPtr P)
Definition: OrcV2CBindings.cpp:51
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
LLJIT.h
GlobalPrefix
@ GlobalPrefix
Definition: AsmWriter.cpp:407
LLVMOrcResourceTrackerRemove
LLVMErrorRef LLVMOrcResourceTrackerRemove(LLVMOrcResourceTrackerRef RT)
Remove all resources associated with the given tracker.
Definition: OrcV2CBindings.cpp:226
llvm::AtomicOrderingCABI::release
@ release
llvm::orc::ResourceTracker
API to remove / transfer ownership of JIT resources.
Definition: Core.h:50
llvm::orc::LLJIT
A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
Definition: LLJIT.h:37
LLVMOrcJITTargetMachineBuilderRef
struct LLVMOrcOpaqueJITTargetMachineBuilder * LLVMOrcJITTargetMachineBuilderRef
A reference to an orc::JITTargetMachineBuilder instance.
Definition: Orc.h:250
llvm::orc::LookupKind
LookupKind
Describes the kind of lookup being performed.
Definition: Core.h:146
LLVMOrcSymbolStringPoolEntryRef
struct LLVMOrcOpaqueSymbolStringPoolEntry * LLVMOrcSymbolStringPoolEntryRef
A reference to an orc::SymbolStringPool table entry.
Definition: Orc.h:88
LLVMOrcDisposeThreadSafeContext
void LLVMOrcDisposeThreadSafeContext(LLVMOrcThreadSafeContextRef TSCtx)
Dispose of a ThreadSafeContext.
Definition: OrcV2CBindings.cpp:342
llvm::JITSymbolFlags
Flags for symbols in the JIT.
Definition: JITSymbol.h:74
llvm::orc::MaterializationUnit
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
Definition: Core.h:635
llvm::JITEvaluatedSymbol
Represents a symbol that has been evaluated to an address already.
Definition: JITSymbol.h:229
LLVMOrcThreadSafeContextGetContext
LLVMContextRef LLVMOrcThreadSafeContextGetContext(LLVMOrcThreadSafeContextRef TSCtx)
Get a reference to the wrapped LLVMContext.
Definition: OrcV2CBindings.cpp:338
F
#define F(x, y, z)
Definition: MD5.cpp:56
clear
static void clear(coro::Shape &Shape)
Definition: Coroutines.cpp:233
LLVMOrcSymbolStringPoolEntryStr
const char * LLVMOrcSymbolStringPoolEntryStr(LLVMOrcSymbolStringPoolEntryRef S)
Definition: OrcV2CBindings.cpp:196
LLVMOrcLLJITBuilderRef
struct LLVMOrcOpaqueLLJITBuilder * LLVMOrcLLJITBuilderRef
A reference to an orc::LLJITBuilder instance.
Definition: LLJIT.h:54
LLVMOrcCreateNewThreadSafeModule
LLVMOrcThreadSafeModuleRef LLVMOrcCreateNewThreadSafeModule(LLVMModuleRef M, LLVMOrcThreadSafeContextRef TSCtx)
Create a ThreadSafeModule wrapper around the given LLVM module.
Definition: OrcV2CBindings.cpp:347
LLVMOrcJITDylibRef
struct LLVMOrcOpaqueJITDylib * LLVMOrcJITDylibRef
A reference to an orc::JITDylib instance.
Definition: Orc.h:165
LLVMOrcJITDylibGetDefaultResourceTracker
LLVMOrcResourceTrackerRef LLVMOrcJITDylibGetDefaultResourceTracker(LLVMOrcJITDylibRef JD)
Return a reference to the default resource tracker for the given JITDylib.
Definition: OrcV2CBindings.cpp:209
llvm::JITSymbolFlags::getTargetFlags
TargetFlagsType & getTargetFlags()
Return a reference to the target-specific flags.
Definition: JITSymbol.h:172
LLVMOrcCreateLLJIT
LLVMErrorRef LLVMOrcCreateLLJIT(LLVMOrcLLJITRef *Result, LLVMOrcLLJITBuilderRef Builder)
Create an LLJIT instance from an LLJITBuilder.
Definition: OrcV2CBindings.cpp:424
LLVMJITSymbolGenericFlagsWeak
@ LLVMJITSymbolGenericFlagsWeak
Definition: Orc.h:46
llvm::orc::SymbolStringPool
String pool for symbol names used by the JIT.
Definition: SymbolStringPool.h:27
LLVMOrcJITDylibLookupFlagsMatchAllSymbols
@ LLVMOrcJITDylibLookupFlagsMatchAllSymbols
Definition: Orc.h:124
llvm::orc
Definition: CompileOnDemandLayer.h:58
LLVMOrcReleaseSymbolStringPoolEntry
void LLVMOrcReleaseSymbolStringPoolEntry(LLVMOrcSymbolStringPoolEntryRef S)
Reduces the ref-count for of a SymbolStringPool entry.
Definition: OrcV2CBindings.cpp:192
LLVMOrcLLJITGetTripleString
const char * LLVMOrcLLJITGetTripleString(LLVMOrcLLJITRef J)
Return the target triple for this LLJIT instance.
Definition: OrcV2CBindings.cpp:456
LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener
void LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(LLVMOrcObjectLayerRef RTDyldObjLinkingLayer, LLVMJITEventListenerRef Listener)
Add the given listener to the given RTDyldObjectLinkingLayer.
Definition: OrcV2CBindings.cpp:522
llvm::AArch64_AM::LSR
@ LSR
Definition: AArch64AddressingModes.h:35
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:229
llvm::orc::ObjectLayer
Interface for Layers that accept object files.
Definition: Layer.h:134
LLVMOrcDisposeThreadSafeModule
void LLVMOrcDisposeThreadSafeModule(LLVMOrcThreadSafeModuleRef TSM)
Dispose of a ThreadSafeModule.
Definition: OrcV2CBindings.cpp:353
LLVMOrcExecutionSessionCreateJITDylib
LLVMErrorRef LLVMOrcExecutionSessionCreateJITDylib(LLVMOrcExecutionSessionRef ES, LLVMOrcJITDylibRef *Result, const char *Name)
Create a JITDylib.
Definition: OrcV2CBindings.cpp:266
LLVMOrcSymbolPredicate
int(* LLVMOrcSymbolPredicate)(void *Ctx, LLVMOrcSymbolStringPoolEntryRef Sym)
Predicate function for SymbolStringPoolEntries.
Definition: Orc.h:234
llvm::orc::LookupKind::DLSym
@ DLSym
LLVMOrcLLJITRef
struct LLVMOrcOpaqueLLJIT * LLVMOrcLLJITRef
A reference to an orc::LLJIT instance.
Definition: LLJIT.h:59
Orc.h
llvm::orc::JITTargetMachineBuilder::detectHost
static Expected< JITTargetMachineBuilder > detectHost()
Create a JITTargetMachineBuilder for the host system.
Definition: JITTargetMachineBuilder.cpp:24
LLVMOrcJITDylibLookupFlagsMatchExportedSymbolsOnly
@ LLVMOrcJITDylibLookupFlagsMatchExportedSymbolsOnly
Definition: Orc.h:123
llvm::orc::SymbolLookupFlags::WeaklyReferencedSymbol
@ WeaklyReferencedSymbol
RTDyldObjectLinkingLayer.h
llvm::orc::OrcV2CAPIHelper::extractLookupState
static InProgressLookupState * extractLookupState(LookupState &LS)
Definition: OrcV2CBindings.cpp:56
llvm::orc::SymbolLookupSet::size
UnderlyingVector::size_type size() const
Definition: Core.h:236
LLVMOrcRetainSymbolStringPoolEntry
void LLVMOrcRetainSymbolStringPoolEntry(LLVMOrcSymbolStringPoolEntryRef S)
Increments the ref-count for a SymbolStringPool entry.
Definition: OrcV2CBindings.cpp:188
LLVMOrcJITTargetMachineBuilderDetectHost
LLVMErrorRef LLVMOrcJITTargetMachineBuilderDetectHost(LLVMOrcJITTargetMachineBuilderRef *Result)
Create a JITTargetMachineBuilder by detecting the host.
Definition: OrcV2CBindings.cpp:357
llvm::ClrHandlerType::Filter
@ Filter
LLVMOrcCAPIDefinitionGeneratorTryToGenerateFunction
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
LLVMTargetMachineRef
typedefLLVM_C_EXTERN_C_BEGIN struct LLVMOpaqueTargetMachine * LLVMTargetMachineRef
Definition: TargetMachine.h:28
LLVMOrcLLJITAddObjectFileWithRT
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...
Definition: OrcV2CBindings.cpp:476
LLVMOrcLLJITAddLLVMIRModule
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD, LLVMOrcThreadSafeModuleRef TSM)
Add an IR module to the given JITDylib in the given LLJIT instance.
Definition: OrcV2CBindings.cpp:484
move
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
Definition: README.txt:546
llvm::DenseMap< SymbolStringPtr, JITEvaluatedSymbol >
LLVMJITEvaluatedSymbol::Flags
LLVMJITSymbolFlags Flags
Definition: Orc.h:67
LLVMOrcDefinitionGeneratorRef
struct LLVMOrcOpaqueDefinitionGenerator * LLVMOrcDefinitionGeneratorRef
A reference to an orc::DefinitionGenerator.
Definition: Orc.h:175
I
#define I(x, y, z)
Definition: MD5.cpp:59
LLVMOrcLLJITBuilderObjectLinkingLayerCreatorFunction
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
llvm::orc::ResourceTrackerSP
uint8_t IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP
Definition: Core.h:44
LLVMOrcLLJITAddObjectFile
LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD, LLVMMemoryBufferRef ObjBuffer)
Add a buffer representing an object file to the given JITDylib in the given LLJIT instance.
Definition: OrcV2CBindings.cpp:470
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
std::swap
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:944
llvm::orc::OrcV2CAPIHelper::resetLookupState
static void resetLookupState(LookupState &LS, InProgressLookupState *IPLS)
Definition: OrcV2CBindings.cpp:60
llvm::orc::ThreadSafeContext
An LLVMContext together with an associated mutex that can be used to lock the context to prevent conc...
Definition: ThreadSafeModule.h:29
llvm::orc::DefinitionGenerator
Definition generators can be attached to JITDylibs to generate new definitions for otherwise unresolv...
Definition: Core.h:873
LLVMOrcDisposeMaterializationUnit
void LLVMOrcDisposeMaterializationUnit(LLVMOrcMaterializationUnitRef MU)
Dispose of a MaterializationUnit.
Definition: OrcV2CBindings.cpp:235
LLVMOrcSymbolLookupFlagsRequiredSymbol
@ LLVMOrcSymbolLookupFlagsRequiredSymbol
Definition: Orc.h:132
LLVMOrcJITTargetAddress
LLVM_C_EXTERN_C_BEGIN typedef uint64_t LLVMOrcJITTargetAddress
Represents an address in the target process.
Definition: Orc.h:39
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:643
llvm::wrap
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:224
LLVMOrcJITDylibClear
LLVMErrorRef LLVMOrcJITDylibClear(LLVMOrcJITDylibRef JD)
Calls remove on all trackers associated with this JITDylib, see JITDylib::clear().
Definition: OrcV2CBindings.cpp:293
llvm::orc::OrcV2CAPIHelper::releaseSymbolStringPtr
static PoolEntryPtr releaseSymbolStringPtr(SymbolStringPtr S)
Definition: OrcV2CBindings.cpp:32
LLVMOrcLLJITGetGlobalPrefix
char LLVMOrcLLJITGetGlobalPrefix(LLVMOrcLLJITRef J)
Returns the global prefix character according to the LLJIT's DataLayout.
Definition: OrcV2CBindings.cpp:460
llvm::JITSymbolFlags::Weak
@ Weak
Definition: JITSymbol.h:82
LLVMOrcSymbolStringPoolRef
struct LLVMOrcOpaqueSymbolStringPool * LLVMOrcSymbolStringPoolRef
A reference to an orc::SymbolStringPool.
Definition: Orc.h:83
LLVMOrcDisposeLLJITBuilder
void LLVMOrcDisposeLLJITBuilder(LLVMOrcLLJITBuilderRef Builder)
Dispose of an LLVMOrcLLJITBuilderRef.
Definition: OrcV2CBindings.cpp:404
LLJIT.h
LLVMOrcDisposeLLJIT
LLVMErrorRef LLVMOrcDisposeLLJIT(LLVMOrcLLJITRef J)
Dispose of an LLJIT instance.
Definition: OrcV2CBindings.cpp:443
S
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
Definition: README.txt:210
llvm::orc::LookupState
Wraps state for a lookup-in-progress.
Definition: Core.h:848
LLVMOrcJITDylibLookupFlags
LLVMOrcJITDylibLookupFlags
JITDylib lookup flags.
Definition: Orc.h:122
LLVMOrcLLJITGetMainJITDylib
LLVMOrcJITDylibRef LLVMOrcLLJITGetMainJITDylib(LLVMOrcLLJITRef J)
Return a reference to the Main JITDylib.
Definition: OrcV2CBindings.cpp:452
LLVMOrcDisposeDefinitionGenerator
void LLVMOrcDisposeDefinitionGenerator(LLVMOrcDefinitionGeneratorRef DG)
Dispose of a JITDylib::DefinitionGenerator.
Definition: OrcV2CBindings.cpp:231
LLVMErrorSuccess
#define LLVMErrorSuccess
Definition: Error.h:21
LLVMOrcSymbolStringPoolClearDeadEntries
void LLVMOrcSymbolStringPoolClearDeadEntries(LLVMOrcSymbolStringPoolRef SSP)
Clear all unreferenced symbol string pool entries.
Definition: OrcV2CBindings.cpp:178
llvm::orc::OrcV2CAPIHelper::retainSymbolStringPtr
static SymbolStringPtr retainSymbolStringPtr(PoolEntryPtr P)
Definition: OrcV2CBindings.cpp:38
LLVMOrcLLJITBuilderSetJITTargetMachineBuilder
void LLVMOrcLLJITBuilderSetJITTargetMachineBuilder(LLVMOrcLLJITBuilderRef Builder, LLVMOrcJITTargetMachineBuilderRef JTMB)
Set the JITTargetMachineBuilder to be used when constructing the LLJIT instance.
Definition: OrcV2CBindings.cpp:408
LLVMOrcLookupKindDLSym
@ LLVMOrcLookupKindDLSym
Definition: Orc.h:113
llvm::orc::DynamicLibrarySearchGenerator::GetForCurrentProcess
static Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > GetForCurrentProcess(char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate())
Creates a DynamicLibrarySearchGenerator that searches for symbols in the current process.
Definition: ExecutionUtils.h:241
LLVMOrcLLJITBuilderSetObjectLinkingLayerCreator
void LLVMOrcLLJITBuilderSetObjectLinkingLayerCreator(LLVMOrcLLJITBuilderRef Builder, LLVMOrcLLJITBuilderObjectLinkingLayerCreatorFunction F, void *Ctx)
Set an ObjectLinkingLayer creator function for this LLJIT instance.
Definition: OrcV2CBindings.cpp:413
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
LLVMErrorRef
struct LLVMOpaqueError * LLVMErrorRef
Opaque reference to an error instance.
Definition: Error.h:26
TargetMachine.h
LLVMOrcObjectLayerRef
struct LLVMOrcOpaqueObjectLayer * LLVMOrcObjectLayerRef
A reference to an orc::ObjectLayer instance.
Definition: Orc.h:256
LLVMOrcSymbolLookupFlagsWeaklyReferencedSymbol
@ LLVMOrcSymbolLookupFlagsWeaklyReferencedSymbol
Definition: Orc.h:133
get
Should compile to something r4 addze r3 instead we get
Definition: README.txt:24
llvm::orc::OrcV2CAPIHelper
Definition: OrcV2CBindings.cpp:27
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
LLVMOrcJITDylibDefine
LLVMErrorRef LLVMOrcJITDylibDefine(LLVMOrcJITDylibRef JD, LLVMOrcMaterializationUnitRef MU)
Add the given MaterializationUnit to the given JITDylib.
Definition: OrcV2CBindings.cpp:282
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1221
llvm::orc::JITDylibLookupFlags::MatchExportedSymbolsOnly
@ MatchExportedSymbolsOnly
llvm::AArch64CC::LS
@ LS
Definition: AArch64BaseInfo.h:245
LLVMOrcSymbolLookupFlags
LLVMOrcSymbolLookupFlags
Symbol lookup flags for lookup sets.
Definition: Orc.h:131
lLVMOrcDisposeObjectLayer
void lLVMOrcDisposeObjectLayer(LLVMOrcObjectLayerRef ObjLayer)
Definition: OrcV2CBindings.cpp:396
LLVMOrcLLJITAddLLVMIRModuleWithRT
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModuleWithRT(LLVMOrcLLJITRef J, LLVMOrcResourceTrackerRef RT, LLVMOrcThreadSafeModuleRef TSM)
Add an IR module to the given ResourceTracker's JITDylib in the given LLJIT instance.
Definition: OrcV2CBindings.cpp:491
DEFINE_SIMPLE_CONVERSION_FUNCTIONS
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(OrcV2CAPIHelper::PoolEntry, LLVMOrcSymbolStringPoolEntryRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MaterializationUnit
LLVMOrcErrorReporterFunction
void(* LLVMOrcErrorReporterFunction)(void *Ctx, LLVMErrorRef Err)
Error reporter function.
Definition: Orc.h:78
llvm::orc::absoluteSymbols
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
Definition: Core.h:716
LLVMOrcExecutionSessionGetSymbolStringPool
LLVMOrcSymbolStringPoolRef LLVMOrcExecutionSessionGetSymbolStringPool(LLVMOrcExecutionSessionRef ES)
Return a reference to the SymbolStringPool for an ExecutionSession.
Definition: OrcV2CBindings.cpp:174
LLVMOrcReleaseResourceTracker
void LLVMOrcReleaseResourceTracker(LLVMOrcResourceTrackerRef RT)
Reduces the ref-count of a ResourceTracker.
Definition: OrcV2CBindings.cpp:215
LLVMJITCSymbolMapPair::Sym
LLVMJITEvaluatedSymbol Sym
Definition: Orc.h:96
LLVMOrcExecutionSessionGetJITDylibByName
LLVMOrcJITDylibRef LLVMOrcExecutionSessionGetJITDylibByName(LLVMOrcExecutionSessionRef ES, const char *Name)
Definition: OrcV2CBindings.cpp:277
LLVMOrcJITTargetMachineBuilderCreateFromTargetMachine
LLVMOrcJITTargetMachineBuilderRef LLVMOrcJITTargetMachineBuilderCreateFromTargetMachine(LLVMTargetMachineRef TM)
Create a JITTargetMachineBuilder from the given TargetMachine template.
Definition: OrcV2CBindings.cpp:372
LLVMDisposeTargetMachine
void LLVMDisposeTargetMachine(LLVMTargetMachineRef T)
Dispose the LLVMTargetMachineRef instance generated by LLVMCreateTargetMachine.
Definition: TargetMachineC.cpp:154
LLVMOrcCreateNewThreadSafeContext
LLVMOrcThreadSafeContextRef LLVMOrcCreateNewThreadSafeContext(void)
Create a ThreadSafeContext containing a new LLVMContext.
Definition: OrcV2CBindings.cpp:333
LLVMOrcExecutionSessionSetErrorReporter
void LLVMOrcExecutionSessionSetErrorReporter(LLVMOrcExecutionSessionRef ES, LLVMOrcErrorReporterFunction ReportError, void *Ctx)
Attach a custom error reporter function to the ExecutionSession.
Definition: OrcV2CBindings.cpp:166
llvm::orc::OrcV2CAPIHelper::getRawPoolEntryPtr
static PoolEntryPtr getRawPoolEntryPtr(const SymbolStringPtr &S)
Definition: OrcV2CBindings.cpp:42
LLVMOrcResourceTrackerTransferTo
void LLVMOrcResourceTrackerTransferTo(LLVMOrcResourceTrackerRef SrcRT, LLVMOrcResourceTrackerRef DstRT)
Transfers tracking of all resources associated with resource tracker SrcRT to resource tracker DstRT.
Definition: OrcV2CBindings.cpp:220
LLVMOrcCreateCustomCAPIDefinitionGenerator
LLVMOrcDefinitionGeneratorRef LLVMOrcCreateCustomCAPIDefinitionGenerator(LLVMOrcCAPIDefinitionGeneratorTryToGenerateFunction F, void *Ctx)
Create a custom generator.
Definition: OrcV2CBindings.cpp:302
LLVMOrcThreadSafeModuleRef
struct LLVMOrcOpaqueThreadSafeModule * LLVMOrcThreadSafeModuleRef
A reference to an orc::ThreadSafeModule instance.
Definition: Orc.h:245
llvm::orc::DynamicLibrarySearchGenerator::SymbolPredicate
std::function< bool(const SymbolStringPtr &)> SymbolPredicate
Definition: ExecutionUtils.h:220
OrcEE.h
SectionMemoryManager.h
LLVMOrcDisposeJITTargetMachineBuilder
void LLVMOrcDisposeJITTargetMachineBuilder(LLVMOrcJITTargetMachineBuilderRef JTMB)
Dispose of a JITTargetMachineBuilder.
Definition: OrcV2CBindings.cpp:391
LLVMOrcLLJITMangleAndIntern
LLVMOrcSymbolStringPoolEntryRef LLVMOrcLLJITMangleAndIntern(LLVMOrcLLJITRef J, const char *UnmangledName)
Mangles the given string according to the LLJIT instance's DataLayout, then interns the result in the...
Definition: OrcV2CBindings.cpp:465
LLVMOrcLookupKind
LLVMOrcLookupKind
Lookup kind.
Definition: Orc.h:111
LLVMOrcLookupStateRef
struct LLVMOrcOpaqueLookupState * LLVMOrcLookupStateRef
An opaque lookup state object.
Definition: Orc.h:190
LLVMMemoryBufferRef
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
Definition: Types.h:48
llvm::orc::ThreadSafeModule
An LLVM Module together with a shared ThreadSafeContext.
Definition: ThreadSafeModule.h:77
LLVMOrcExecutionSessionRef
struct LLVMOrcOpaqueExecutionSession * LLVMOrcExecutionSessionRef
A reference to an orc::ExecutionSession instance.
Definition: Orc.h:73
LLVMOrcLLJITLookup
LLVMErrorRef LLVMOrcLLJITLookup(LLVMOrcLLJITRef J, LLVMOrcJITTargetAddress *Result, const char *Name)
Look up the given symbol in the main JITDylib of the given LLJIT instance.
Definition: OrcV2CBindings.cpp:499
llvm::orc::JITDylibLookupFlags
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
Definition: Core.h:124
LLVMOrcThreadSafeContextRef
struct LLVMOrcOpaqueThreadSafeContext * LLVMOrcThreadSafeContextRef
A reference to an orc::ThreadSafeContext instance.
Definition: Orc.h:240
LLVMOrcMaterializationUnitRef
struct LLVMOrcOpaqueMaterializationUnit * LLVMOrcMaterializationUnitRef
A reference to an orc::MaterializationUnit.
Definition: Orc.h:160
LLVMOrcLLJITGetExecutionSession
LLVMOrcExecutionSessionRef LLVMOrcLLJITGetExecutionSession(LLVMOrcLLJITRef J)
Get a reference to the ExecutionSession for this LLJIT instance.
Definition: OrcV2CBindings.cpp:448
llvm::orc::JITDylibLookupFlags::MatchAllSymbols
@ MatchAllSymbols
llvm::orc::SymbolLookupFlags::RequiredSymbol
@ RequiredSymbol
LLVMJITCSymbolMapPair
Represents a pair of a symbol name and an evaluated symbol.
Definition: Orc.h:94
LLVMJITSymbolFlags::TargetFlags
uint8_t TargetFlags
Definition: Orc.h:59
LLVMOrcCreateLLJITBuilder
LLVMOrcLLJITBuilderRef LLVMOrcCreateLLJITBuilder(void)
Create an LLVMOrcLLJITBuilder.
Definition: OrcV2CBindings.cpp:400
LLVMJITEventListenerRef
struct LLVMOpaqueJITEventListener * LLVMJITEventListenerRef
Definition: Types.h:163
JITTargetMachineBuilder.h
LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess
LLVMErrorRef LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess(LLVMOrcDefinitionGeneratorRef *Result, char GlobalPrefix, LLVMOrcSymbolPredicate Filter, void *FilterCtx)
Get a DynamicLibrarySearchGenerator that will reflect process symbols into the JITDylib.
Definition: OrcV2CBindings.cpp:308
LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager
LLVMOrcObjectLayerRef LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager(LLVMOrcExecutionSessionRef ES)
Create a RTDyldObjectLinkingLayer instance using the standard SectionMemoryManager for memory managem...
Definition: OrcV2CBindings.cpp:515
LLVMModuleRef
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:61
llvm::JITSymbolFlags::Exported
@ Exported
Definition: JITSymbol.h:85