LLVM 24.0.0git
Orc.h
Go to the documentation of this file.
1/*===---------------- llvm-c/Orc.h - OrcV2 C bindings -----------*- C++ -*-===*\
2|* *|
3|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4|* Exceptions. *|
5|* See https://llvm.org/LICENSE.txt for license information. *|
6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* This header declares the C interface to libLLVMOrcJIT.a, which implements *|
11|* JIT compilation of LLVM IR. Minimal documentation of C API specific issues *|
12|* (especially memory ownership rules) is provided. Core Orc concepts are *|
13|* documented in llvm/docs/ORCv2.rst and APIs are documented in the C++ *|
14|* headers *|
15|* *|
16|* Many exotic languages can interoperate with C code but have a harder time *|
17|* with C++ due to name mangling. So in addition to C, this interface enables *|
18|* tools written in such languages. *|
19|* *|
20|* Note: This interface is experimental. It is *NOT* stable, and may be *|
21|* changed without warning. Only C API usage documentation is *|
22|* provided. See the C++ documentation for all higher level ORC API *|
23|* details. *|
24|* *|
25\*===----------------------------------------------------------------------===*/
26
27#ifndef LLVM_C_ORC_H
28#define LLVM_C_ORC_H
29
30#include "llvm-c/Error.h"
32#include "llvm-c/Types.h"
33#include "llvm-c/Visibility.h"
34
36
37/**
38 * @defgroup LLVMCExecutionEngineORC On-Request-Compilation
39 * @ingroup LLVMCExecutionEngine
40 *
41 * @{
42 */
43
44/**
45 * Represents an address in the executor process.
46 */
48
49/**
50 * Represents an address in the executor process.
51 */
53
54/**
55 * Represents generic linkage flags for a symbol definition.
56 */
64
65/**
66 * Represents target specific flags for a symbol definition.
67 */
69
70/**
71 * Represents the linkage flags for a symbol definition.
72 */
77
78/**
79 * Represents an evaluated symbol address and flags.
80 */
85
86/**
87 * A reference to an orc::ExecutionSession instance.
88 */
89typedef struct LLVMOrcOpaqueExecutionSession *LLVMOrcExecutionSessionRef;
90
91/**
92 * Error reporter function.
93 */
94typedef void (*LLVMOrcErrorReporterFunction)(void *Ctx, LLVMErrorRef Err);
95
96/**
97 * A reference to an orc::SymbolStringPool.
98 */
99typedef struct LLVMOrcOpaqueSymbolStringPool *LLVMOrcSymbolStringPoolRef;
100
101/**
102 * A reference to an orc::SymbolStringPool table entry.
103 */
104typedef struct LLVMOrcOpaqueSymbolStringPoolEntry
106
107/**
108 * Represents a pair of a symbol name and LLVMJITSymbolFlags.
109 */
114
115/**
116 * Represents a list of (SymbolStringPtr, JITSymbolFlags) pairs that can be used
117 * to construct a SymbolFlagsMap.
118 */
120
121/**
122 * Represents a pair of a symbol name and an evaluated symbol.
123 */
128
129/**
130 * Represents a list of (SymbolStringPtr, JITEvaluatedSymbol) pairs that can be
131 * used to construct a SymbolMap.
132 */
134
135/**
136 * Represents a SymbolAliasMapEntry
137 */
142
143/**
144 * Represents a pair of a symbol name and SymbolAliasMapEntry.
145 */
150
151/**
152 * Represents a list of (SymbolStringPtr, (SymbolStringPtr, JITSymbolFlags))
153 * pairs that can be used to construct a SymbolFlagsMap.
154 */
156
157/**
158 * A reference to an orc::JITDylib instance.
159 */
160typedef struct LLVMOrcOpaqueJITDylib *LLVMOrcJITDylibRef;
161
162/**
163 * Represents a list of LLVMOrcSymbolStringPoolEntryRef and the associated
164 * length.
165 */
170
171/**
172 * Represents a pair of a JITDylib and LLVMOrcCSymbolsList.
173 */
178
179/**
180 * Represents a list of (JITDylibRef, (LLVMOrcSymbolStringPoolEntryRef*,
181 * size_t)) pairs that can be used to construct a SymbolDependenceMap.
182 */
184
185/**
186 * A set of symbols that share dependencies.
187 */
193
194/**
195 * Lookup kind. This can be used by definition generators when deciding whether
196 * to produce a definition for a requested symbol.
197 *
198 * This enum should be kept in sync with llvm::orc::LookupKind.
199 */
204
205/**
206 * JITDylib lookup flags. This can be used by definition generators when
207 * deciding whether to produce a definition for a requested symbol.
208 *
209 * This enum should be kept in sync with llvm::orc::JITDylibLookupFlags.
210 */
215
216/**
217 * An element type for a JITDylib search order.
218 */
223
224/**
225 * A JITDylib search order.
226 *
227 * The list is terminated with an element containing a null pointer for the JD
228 * field.
229 */
231
232/**
233 * Symbol lookup flags for lookup sets. This should be kept in sync with
234 * llvm::orc::SymbolLookupFlags.
235 */
240
241/**
242 * An element type for a symbol lookup set.
243 */
248
249/**
250 * A set of symbols to look up / generate.
251 *
252 * The list is terminated with an element containing a null pointer for the
253 * Name field.
254 *
255 * If a client creates an instance of this type then they are responsible for
256 * freeing it, and for ensuring that all strings have been retained over the
257 * course of its life. Clients receiving a copy from a callback are not
258 * responsible for managing lifetime or retain counts.
259 */
261
262/**
263 * A reference to a uniquely owned orc::MaterializationUnit instance.
264 */
265typedef struct LLVMOrcOpaqueMaterializationUnit *LLVMOrcMaterializationUnitRef;
266
267/**
268 * A reference to a uniquely owned orc::MaterializationResponsibility instance.
269 *
270 * Ownership must be passed to a lower-level layer in a JIT stack.
271 */
272typedef struct LLVMOrcOpaqueMaterializationResponsibility
274
275/**
276 * A MaterializationUnit materialize callback.
277 *
278 * Ownership of the Ctx and MR arguments passes to the callback which must
279 * adhere to the LLVMOrcMaterializationResponsibilityRef contract (see comment
280 * for that type).
281 *
282 * If this callback is called then the LLVMOrcMaterializationUnitDestroy
283 * callback will NOT be called.
284 */
287
288/**
289 * A MaterializationUnit discard callback.
290 *
291 * Ownership of JD and Symbol remain with the caller: These arguments should
292 * not be disposed of or released.
293 */
296
297/**
298 * A MaterializationUnit destruction callback.
299 *
300 * If a custom MaterializationUnit is destroyed before its Materialize
301 * function is called then this function will be called to provide an
302 * opportunity for the underlying program representation to be destroyed.
303 */
305
306/**
307 * A reference to an orc::ResourceTracker instance.
308 */
309typedef struct LLVMOrcOpaqueResourceTracker *LLVMOrcResourceTrackerRef;
310
311/**
312 * A reference to an orc::DefinitionGenerator.
313 */
314typedef struct LLVMOrcOpaqueDefinitionGenerator
316
317/**
318 * An opaque lookup state object. Instances of this type can be captured to
319 * suspend a lookup while a custom generator function attempts to produce a
320 * definition.
321 *
322 * If a client captures a lookup state object then they must eventually call
323 * LLVMOrcLookupStateContinueLookup to restart the lookup. This is required
324 * in order to release memory allocated for the lookup state, even if errors
325 * have occurred while the lookup was suspended (if these errors have made the
326 * lookup impossible to complete then it will issue its own error before
327 * destruction).
328 */
329typedef struct LLVMOrcOpaqueLookupState *LLVMOrcLookupStateRef;
330
331/**
332 * A custom generator function. This can be used to create a custom generator
333 * object using LLVMOrcCreateCustomCAPIDefinitionGenerator. The resulting
334 * object can be attached to a JITDylib, via LLVMOrcJITDylibAddGenerator, to
335 * receive callbacks when lookups fail to match existing definitions.
336 *
337 * GeneratorObj will contain the address of the custom generator object.
338 *
339 * Ctx will contain the context object passed to
340 * LLVMOrcCreateCustomCAPIDefinitionGenerator.
341 *
342 * LookupState will contain a pointer to an LLVMOrcLookupStateRef object. This
343 * can optionally be modified to make the definition generation process
344 * asynchronous: If the LookupStateRef value is copied, and the original
345 * LLVMOrcLookupStateRef set to null, the lookup will be suspended. Once the
346 * asynchronous definition process has been completed clients must call
347 * LLVMOrcLookupStateContinueLookup to continue the lookup (this should be
348 * done unconditionally, even if errors have occurred in the mean time, to
349 * free the lookup state memory and notify the query object of the failures).
350 * If LookupState is captured this function must return LLVMErrorSuccess.
351 *
352 * The Kind argument can be inspected to determine the lookup kind (e.g.
353 * as-if-during-static-link, or as-if-during-dlsym).
354 *
355 * The JD argument specifies which JITDylib the definitions should be generated
356 * into.
357 *
358 * The JDLookupFlags argument can be inspected to determine whether the original
359 * lookup included non-exported symbols.
360 *
361 * Finally, the LookupSet argument contains the set of symbols that could not
362 * be found in JD already (the set of generation candidates).
363 */
365 LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx,
366 LLVMOrcLookupStateRef *LookupState, LLVMOrcLookupKind Kind,
368 LLVMOrcCLookupSet LookupSet, size_t LookupSetSize);
369
370/**
371 * Disposer for a custom generator.
372 *
373 * Will be called by ORC when the JITDylib that the generator is attached to
374 * is destroyed.
375 */
377
378/**
379 * Predicate function for SymbolStringPoolEntries.
380 */
381typedef int (*LLVMOrcSymbolPredicate)(void *Ctx,
383
384/**
385 * A reference to an orc::ThreadSafeContext instance.
386 */
387typedef struct LLVMOrcOpaqueThreadSafeContext *LLVMOrcThreadSafeContextRef;
388
389/**
390 * A reference to an orc::ThreadSafeModule instance.
391 */
392typedef struct LLVMOrcOpaqueThreadSafeModule *LLVMOrcThreadSafeModuleRef;
393
394/**
395 * A function for inspecting/mutating IR modules, suitable for use with
396 * LLVMOrcThreadSafeModuleWithModuleDo.
397 */
399 void *Ctx, LLVMModuleRef M);
400
401/**
402 * A function for inspecting/mutating LLVM contexts, suitable for use with
403 * LLVMOrcThreadSafeContextWithContextDo.
404 */
406 void *Ctx, LLVMContextRef C);
407
408/**
409 * A reference to an orc::JITTargetMachineBuilder instance.
410 */
411typedef struct LLVMOrcOpaqueJITTargetMachineBuilder
413
414/**
415 * A reference to an orc::ObjectLayer instance.
416 */
417typedef struct LLVMOrcOpaqueObjectLayer *LLVMOrcObjectLayerRef;
418
419/**
420 * A reference to an orc::ObjectLinkingLayer instance.
421 */
422typedef struct LLVMOrcOpaqueObjectLinkingLayer *LLVMOrcObjectLinkingLayerRef;
423
424/**
425 * A reference to an orc::IRTransformLayer instance.
426 */
427typedef struct LLVMOrcOpaqueIRTransformLayer *LLVMOrcIRTransformLayerRef;
428
429/**
430 * A function for applying transformations as part of an transform layer.
431 *
432 * Implementations of this type are responsible for managing the lifetime
433 * of the Module pointed to by ModInOut: If the LLVMModuleRef value is
434 * overwritten then the function is responsible for disposing of the incoming
435 * module. If the module is simply accessed/mutated in-place then ownership
436 * returns to the caller and the function does not need to do any lifetime
437 * management.
438 *
439 * Clients can call LLVMOrcLLJITGetIRTransformLayer to obtain the transform
440 * layer of a LLJIT instance, and use LLVMOrcIRTransformLayerSetTransform
441 * to set the function. This can be used to override the default transform
442 * layer.
443 */
445 void *Ctx, LLVMOrcThreadSafeModuleRef *ModInOut,
447
448/**
449 * A reference to an orc::ObjectTransformLayer instance.
450 */
451typedef struct LLVMOrcOpaqueObjectTransformLayer
453
454/**
455 * A function for applying transformations to an object file buffer.
456 *
457 * Implementations of this type are responsible for managing the lifetime
458 * of the memory buffer pointed to by ObjInOut: If the LLVMMemoryBufferRef
459 * value is overwritten then the function is responsible for disposing of the
460 * incoming buffer. If the buffer is simply accessed/mutated in-place then
461 * ownership returns to the caller and the function does not need to do any
462 * lifetime management.
463 *
464 * The transform is allowed to return an error, in which case the ObjInOut
465 * buffer should be disposed of and set to null.
466 */
468 void *Ctx, LLVMMemoryBufferRef *ObjInOut);
469
470/**
471 * A reference to an orc::IndirectStubsManager instance.
472 */
473typedef struct LLVMOrcOpaqueIndirectStubsManager
475
476/**
477 * A reference to an orc::LazyCallThroughManager instance.
478 */
479typedef struct LLVMOrcOpaqueLazyCallThroughManager
481
482/**
483 * A reference to an orc::DumpObjects object.
484 *
485 * Can be used to dump object files to disk with unique names. Useful as an
486 * ObjectTransformLayer transform.
487 */
488typedef struct LLVMOrcOpaqueDumpObjects *LLVMOrcDumpObjectsRef;
489
490/**
491 * Attach a custom error reporter function to the ExecutionSession.
492 *
493 * The error reporter will be called to deliver failure notices that can not be
494 * directly reported to a caller. For example, failure to resolve symbols in
495 * the JIT linker is typically reported via the error reporter (callers
496 * requesting definitions from the JIT will typically be delivered a
497 * FailureToMaterialize error instead).
498 */
501 void *Ctx);
502
503/**
504 * Return a reference to the SymbolStringPool for an ExecutionSession.
505 *
506 * Ownership of the pool remains with the ExecutionSession: The caller is
507 * not required to free the pool.
508 */
511
512/**
513 * Clear all unreferenced symbol string pool entries.
514 *
515 * This can be called at any time to release unused entries in the
516 * ExecutionSession's string pool. Since it locks the pool (preventing
517 * interning of any new strings) it is recommended that it only be called
518 * infrequently, ideally when the caller has reason to believe that some
519 * entries will have become unreferenced, e.g. after removing a module or
520 * closing a JITDylib.
521 */
522LLVM_C_ABI void
524
525/**
526 * Intern a string in the ExecutionSession's SymbolStringPool and return a
527 * reference to it. This increments the ref-count of the pool entry, and the
528 * returned value should be released once the client is done with it by
529 * calling LLVMOrcReleaseSymbolStringPoolEntry.
530 *
531 * Since strings are uniqued within the SymbolStringPool
532 * LLVMOrcSymbolStringPoolEntryRefs can be compared by value to test string
533 * equality.
534 *
535 * Note that this function does not perform linker-mangling on the string.
536 */
539
540/**
541 * Callback type for ExecutionSession lookups.
542 *
543 * If Err is LLVMErrorSuccess then Result will contain a pointer to a
544 * list of ( SymbolStringPtr, JITEvaluatedSymbol ) pairs of length NumPairs.
545 *
546 * If Err is a failure value then Result and Ctx are undefined and should
547 * not be accessed. The Callback is responsible for handling the error
548 * value (e.g. by calling LLVMGetErrorMessage + LLVMDisposeErrorMessage).
549 *
550 * The caller retains ownership of the Result array and will release all
551 * contained symbol names. Clients are responsible for retaining any symbol
552 * names that they wish to hold after the function returns.
553 */
555 LLVMErrorRef Err, LLVMOrcCSymbolMapPairs Result, size_t NumPairs,
556 void *Ctx);
557
558/**
559 * Look up symbols in an execution session.
560 *
561 * This is a wrapper around the general ExecutionSession::lookup function.
562 *
563 * The SearchOrder argument contains a list of (JITDylibs, JITDylibSearchFlags)
564 * pairs that describe the search order. The JITDylibs will be searched in the
565 * given order to try to find the symbols in the Symbols argument.
566 *
567 * The Symbols argument should contain a null-terminated array of
568 * (SymbolStringPtr, SymbolLookupFlags) pairs describing the symbols to be
569 * searched for. This function takes ownership of the elements of the Symbols
570 * array. The Name fields of the Symbols elements are taken to have been
571 * retained by the client for this function. The client should *not* release the
572 * Name fields, but are still responsible for destroying the array itself.
573 *
574 * The HandleResult function will be called once all searched for symbols have
575 * been found, or an error occurs. The HandleResult function will be passed an
576 * LLVMErrorRef indicating success or failure, and (on success) a
577 * null-terminated LLVMOrcCSymbolMapPairs array containing the function result,
578 * and the Ctx value passed to the lookup function.
579 *
580 * The client is fully responsible for managing the lifetime of the Ctx object.
581 * A common idiom is to allocate the context prior to the lookup and deallocate
582 * it in the handler.
583 *
584 * THIS API IS EXPERIMENTAL AND LIKELY TO CHANGE IN THE NEAR FUTURE!
585 */
588 LLVMOrcCJITDylibSearchOrder SearchOrder, size_t SearchOrderSize,
589 LLVMOrcCLookupSet Symbols, size_t SymbolsSize,
591
592/**
593 * Increments the ref-count for a SymbolStringPool entry.
594 */
595LLVM_C_ABI void
597
598/**
599 * Reduces the ref-count for of a SymbolStringPool entry.
600 */
601LLVM_C_ABI void
603
604/**
605 * Return the c-string for the given symbol. This string will remain valid until
606 * the entry is freed (once all LLVMOrcSymbolStringPoolEntryRefs have been
607 * released).
608 */
609LLVM_C_ABI const char *
611
612/**
613 * Reduces the ref-count of a ResourceTracker.
614 */
616
617/**
618 * Transfers tracking of all resources associated with resource tracker SrcRT
619 * to resource tracker DstRT.
620 */
621LLVM_C_ABI void
624
625/**
626 * Remove all resources associated with the given tracker. See
627 * ResourceTracker::remove().
628 */
631
632/**
633 * Dispose of a JITDylib::DefinitionGenerator. This should only be called if
634 * ownership has not been passed to a JITDylib (e.g. because some error
635 * prevented the client from calling LLVMOrcJITDylibAddGenerator).
636 */
637LLVM_C_ABI void
639
640/**
641 * Dispose of a MaterializationUnit.
642 */
643LLVM_C_ABI void
645
646/**
647 * Create a custom MaterializationUnit.
648 *
649 * Name is a name for this MaterializationUnit to be used for identification
650 * and logging purposes (e.g. if this MaterializationUnit produces an
651 * object buffer then the name of that buffer will be derived from this name).
652 *
653 * The Syms list contains the names and linkages of the symbols provided by this
654 * unit. This function takes ownership of the elements of the Syms array. The
655 * Name fields of the array elements are taken to have been retained for this
656 * function. The client should *not* release the elements of the array, but is
657 * still responsible for destroying the array itself.
658 *
659 * The InitSym argument indicates whether or not this MaterializationUnit
660 * contains static initializers. If three are no static initializers (the common
661 * case) then this argument should be null. If there are static initializers
662 * then InitSym should be set to a unique name that also appears in the Syms
663 * list with the LLVMJITSymbolGenericFlagsMaterializationSideEffectsOnly flag
664 * set. This function takes ownership of the InitSym, which should have been
665 * retained twice on behalf of this function: once for the Syms entry and once
666 * for InitSym. If clients wish to use the InitSym value after this function
667 * returns they must retain it once more for themselves.
668 *
669 * If any of the symbols in the Syms list is looked up then the Materialize
670 * function will be called.
671 *
672 * If any of the symbols in the Syms list is overridden then the Discard
673 * function will be called.
674 *
675 * The caller owns the underling MaterializationUnit and is responsible for
676 * either passing it to a JITDylib (via LLVMOrcJITDylibDefine) or disposing
677 * of it by calling LLVMOrcDisposeMaterializationUnit.
678 */
680 const char *Name, void *Ctx, LLVMOrcCSymbolFlagsMapPairs Syms,
681 size_t NumSyms, LLVMOrcSymbolStringPoolEntryRef InitSym,
685
686/**
687 * Create a MaterializationUnit to define the given symbols as pointing to
688 * the corresponding raw addresses.
689 *
690 * This function takes ownership of the elements of the Syms array. The Name
691 * fields of the array elements are taken to have been retained for this
692 * function. This allows the following pattern...
693 *
694 * size_t NumPairs;
695 * LLVMOrcCSymbolMapPairs Sym;
696 * -- Build Syms array --
697 * LLVMOrcMaterializationUnitRef MU =
698 * LLVMOrcAbsoluteSymbols(Syms, NumPairs);
699 *
700 * ... without requiring cleanup of the elements of the Sym array afterwards.
701 *
702 * The client is still responsible for deleting the Sym array itself.
703 *
704 * If a client wishes to reuse elements of the Sym array after this call they
705 * must explicitly retain each of the elements for themselves.
706 */
709
710/**
711 * Create a MaterializationUnit to define lazy re-expots. These are callable
712 * entry points that call through to the given symbols.
713 *
714 * This function takes ownership of the CallableAliases array. The Name
715 * fields of the array elements are taken to have been retained for this
716 * function. This allows the following pattern...
717 *
718 * size_t NumPairs;
719 * LLVMOrcCSymbolAliasMapPairs CallableAliases;
720 * -- Build CallableAliases array --
721 * LLVMOrcMaterializationUnitRef MU =
722 * LLVMOrcLazyReexports(LCTM, ISM, JD, CallableAliases, NumPairs);
723 *
724 * ... without requiring cleanup of the elements of the CallableAliases array afterwards.
725 *
726 * The client is still responsible for deleting the CallableAliases array itself.
727 *
728 * If a client wishes to reuse elements of the CallableAliases array after this call they
729 * must explicitly retain each of the elements for themselves.
730 */
733 LLVMOrcJITDylibRef SourceRef, LLVMOrcCSymbolAliasMapPairs CallableAliases,
734 size_t NumPairs);
735// TODO: ImplSymbolMad SrcJDLoc
736
737/**
738 * Disposes of the passed MaterializationResponsibility object.
739 *
740 * This should only be done after the symbols covered by the object have either
741 * been resolved and emitted (via
742 * LLVMOrcMaterializationResponsibilityNotifyResolved and
743 * LLVMOrcMaterializationResponsibilityNotifyEmitted) or failed (via
744 * LLVMOrcMaterializationResponsibilityFailMaterialization).
745 */
748
749/**
750 * Returns the target JITDylib that these symbols are being materialized into.
751 */
755
756/**
757 * Returns the ExecutionSession for this MaterializationResponsibility.
758 */
762
763/**
764 * Returns the symbol flags map for this responsibility instance.
765 *
766 * The length of the array is returned in NumPairs and the caller is responsible
767 * for the returned memory and needs to call LLVMOrcDisposeCSymbolFlagsMap.
768 *
769 * To use the returned symbols beyond the livetime of the
770 * MaterializationResponsibility requires the caller to retain the symbols
771 * explicitly.
772 */
775 LLVMOrcMaterializationResponsibilityRef MR, size_t *NumPairs);
776
777/**
778 * Disposes of the passed LLVMOrcCSymbolFlagsMap.
779 *
780 * Does not release the entries themselves.
781 */
782LLVM_C_ABI void
784
785/**
786 * Returns the initialization pseudo-symbol, if any. This symbol will also
787 * be present in the SymbolFlagsMap for this MaterializationResponsibility
788 * object.
789 *
790 * The returned symbol is not retained over any mutating operation of the
791 * MaterializationResponsbility or beyond the lifetime thereof.
792 */
796
797/**
798 * Returns the names of any symbols covered by this
799 * MaterializationResponsibility object that have queries pending. This
800 * information can be used to return responsibility for unrequested symbols
801 * back to the JITDylib via the delegate method.
802 */
805 LLVMOrcMaterializationResponsibilityRef MR, size_t *NumSymbols);
806
807/**
808 * Disposes of the passed LLVMOrcSymbolStringPoolEntryRef* .
809 *
810 * Does not release the symbols themselves.
811 */
813
814/**
815 * Notifies the target JITDylib that the given symbols have been resolved.
816 * This will update the given symbols' addresses in the JITDylib, and notify
817 * any pending queries on the given symbols of their resolution. The given
818 * symbols must be ones covered by this MaterializationResponsibility
819 * instance. Individual calls to this method may resolve a subset of the
820 * symbols, but all symbols must have been resolved prior to calling emit.
821 *
822 * This method will return an error if any symbols being resolved have been
823 * moved to the error state due to the failure of a dependency. If this
824 * method returns an error then clients should log it and call
825 * LLVMOrcMaterializationResponsibilityFailMaterialization. If no dependencies
826 * have been registered for the symbols covered by this
827 * MaterializationResponsibility then this method is guaranteed to return
828 * LLVMErrorSuccess.
829 */
832 size_t NumPairs);
833
834/**
835 * Notifies the target JITDylib (and any pending queries on that JITDylib)
836 * that all symbols covered by this MaterializationResponsibility instance
837 * have been emitted.
838 *
839 * This function takes ownership of the symbols in the Dependencies struct.
840 * This allows the following pattern...
841 *
842 * LLVMOrcSymbolStringPoolEntryRef Names[] = {...};
843 * LLVMOrcCDependenceMapPair Dependence = {JD, {Names, sizeof(Names)}}
844 * LLVMOrcMaterializationResponsibilityAddDependencies(JD, Name, &Dependence,
845 * 1);
846 *
847 * ... without requiring cleanup of the elements of the Names array afterwards.
848 *
849 * The client is still responsible for deleting the Dependencies.Names arrays,
850 * and the Dependencies array itself.
851 *
852 * This method will return an error if any symbols being resolved have been
853 * moved to the error state due to the failure of a dependency. If this
854 * method returns an error then clients should log it and call
855 * LLVMOrcMaterializationResponsibilityFailMaterialization.
856 * If no dependencies have been registered for the symbols covered by this
857 * MaterializationResponsibility then this method is guaranteed to return
858 * LLVMErrorSuccess.
859 */
862 LLVMOrcCSymbolDependenceGroup *SymbolDepGroups, size_t NumSymbolDepGroups);
863
864/**
865 * Attempt to claim responsibility for new definitions. This method can be
866 * used to claim responsibility for symbols that are added to a
867 * materialization unit during the compilation process (e.g. literal pool
868 * symbols). Symbol linkage rules are the same as for symbols that are
869 * defined up front: duplicate strong definitions will result in errors.
870 * Duplicate weak definitions will be discarded (in which case they will
871 * not be added to this responsibility instance).
872 *
873 * This method can be used by materialization units that want to add
874 * additional symbols at materialization time (e.g. stubs, compile
875 * callbacks, metadata)
876 */
879 LLVMOrcCSymbolFlagsMapPairs Pairs, size_t NumPairs);
880
881/**
882 * Notify all not-yet-emitted covered by this MaterializationResponsibility
883 * instance that an error has occurred.
884 * This will remove all symbols covered by this MaterializationResponsibility
885 * from the target JITDylib, and send an error to any queries waiting on
886 * these symbols.
887 */
890
891/**
892 * Transfers responsibility to the given MaterializationUnit for all
893 * symbols defined by that MaterializationUnit. This allows
894 * materializers to break up work based on run-time information (e.g.
895 * by introspecting which symbols have actually been looked up and
896 * materializing only those).
897 */
901
902/**
903 * Delegates responsibility for the given symbols to the returned
904 * materialization responsibility. Useful for breaking up work between
905 * threads, or different kinds of materialization processes.
906 *
907 * The caller retains responsibility of the the passed
908 * MaterializationResponsibility.
909 */
912 LLVMOrcSymbolStringPoolEntryRef *Symbols, size_t NumSymbols,
914
915/**
916 * Create a "bare" JITDylib.
917 *
918 * The client is responsible for ensuring that the JITDylib's name is unique,
919 * e.g. by calling LLVMOrcExecutionSessionGetJTIDylibByName first.
920 *
921 * This call does not install any library code or symbols into the newly
922 * created JITDylib. The client is responsible for all configuration.
923 */
925 LLVMOrcExecutionSessionRef ES, const char *Name);
926
927/**
928 * Create a JITDylib.
929 *
930 * The client is responsible for ensuring that the JITDylib's name is unique,
931 * e.g. by calling LLVMOrcExecutionSessionGetJTIDylibByName first.
932 *
933 * If a Platform is attached to the ExecutionSession then
934 * Platform::setupJITDylib will be called to install standard platform symbols
935 * (e.g. standard library interposes). If no Platform is installed then this
936 * call is equivalent to LLVMExecutionSessionRefCreateBareJITDylib and will
937 * always return success.
938 */
941 const char *Name);
942
943/**
944 * Returns the JITDylib with the given name, or NULL if no such JITDylib
945 * exists.
946 */
948 LLVMOrcExecutionSessionRef ES, const char *Name);
949
950/**
951 * Return a reference to a newly created resource tracker associated with JD.
952 * The tracker is returned with an initial ref-count of 1, and must be released
953 * with LLVMOrcReleaseResourceTracker when no longer needed.
954 */
957
958/**
959 * Return a reference to the default resource tracker for the given JITDylib.
960 * This operation will increase the retain count of the tracker: Clients should
961 * call LLVMOrcReleaseResourceTracker when the result is no longer needed.
962 */
965
966/**
967 * Add the given MaterializationUnit to the given JITDylib.
968 *
969 * If this operation succeeds then JITDylib JD will take ownership of MU.
970 * If the operation fails then ownership remains with the caller who should
971 * call LLVMOrcDisposeMaterializationUnit to destroy it.
972 */
975
976/**
977 * Calls remove on all trackers associated with this JITDylib, see
978 * JITDylib::clear().
979 */
981
982/**
983 * Add a DefinitionGenerator to the given JITDylib.
984 *
985 * The JITDylib will take ownership of the given generator: The client is no
986 * longer responsible for managing its memory.
987 */
990
991/**
992 * Create a custom generator.
993 *
994 * The F argument will be used to implement the DefinitionGenerator's
995 * tryToGenerate method (see
996 * LLVMOrcCAPIDefinitionGeneratorTryToGenerateFunction).
997 *
998 * Ctx is a context object that will be passed to F. This argument is
999 * permitted to be null.
1000 *
1001 * Dispose is the disposal function for Ctx. This argument is permitted to be
1002 * null (in which case the client is responsible for the lifetime of Ctx).
1003 */
1008
1009/**
1010 * Continue a lookup that was suspended in a generator (see
1011 * LLVMOrcCAPIDefinitionGeneratorTryToGenerateFunction).
1012 */
1014 LLVMErrorRef Err);
1015
1016/**
1017 * Get a DynamicLibrarySearchGenerator that will reflect process symbols into
1018 * the JITDylib. On success the resulting generator is owned by the client.
1019 * Ownership is typically transferred by adding the instance to a JITDylib
1020 * using LLVMOrcJITDylibAddGenerator,
1021 *
1022 * The GlobalPrefix argument specifies the character that appears on the front
1023 * of linker-mangled symbols for the target platform (e.g. '_' on MachO).
1024 * If non-null, this character will be stripped from the start of all symbol
1025 * strings before passing the remaining substring to dlsym.
1026 *
1027 * The optional Filter and Ctx arguments can be used to supply a symbol name
1028 * filter: Only symbols for which the filter returns true will be visible to
1029 * JIT'd code. If the Filter argument is null then all process symbols will
1030 * be visible to JIT'd code. Note that the symbol name passed to the Filter
1031 * function is the full mangled symbol: The client is responsible for stripping
1032 * the global prefix if present.
1033 */
1035 LLVMOrcDefinitionGeneratorRef *Result, char GlobalPrefx,
1036 LLVMOrcSymbolPredicate Filter, void *FilterCtx);
1037
1038/**
1039 * Get a LLVMOrcCreateDynamicLibararySearchGeneratorForPath that will reflect
1040 * library symbols into the JITDylib. On success the resulting generator is
1041 * owned by the client. Ownership is typically transferred by adding the
1042 * instance to a JITDylib using LLVMOrcJITDylibAddGenerator,
1043 *
1044 * The GlobalPrefix argument specifies the character that appears on the front
1045 * of linker-mangled symbols for the target platform (e.g. '_' on MachO).
1046 * If non-null, this character will be stripped from the start of all symbol
1047 * strings before passing the remaining substring to dlsym.
1048 *
1049 * The optional Filter and Ctx arguments can be used to supply a symbol name
1050 * filter: Only symbols for which the filter returns true will be visible to
1051 * JIT'd code. If the Filter argument is null then all library symbols will
1052 * be visible to JIT'd code. Note that the symbol name passed to the Filter
1053 * function is the full mangled symbol: The client is responsible for stripping
1054 * the global prefix if present.
1055 *
1056 * THIS API IS EXPERIMENTAL AND LIKELY TO CHANGE IN THE NEAR FUTURE!
1057 *
1058 */
1060 LLVMOrcDefinitionGeneratorRef *Result, const char *FileName,
1061 char GlobalPrefix, LLVMOrcSymbolPredicate Filter, void *FilterCtx);
1062
1063/**
1064 * Get a LLVMOrcCreateStaticLibrarySearchGeneratorForPath that will reflect
1065 * static library symbols into the JITDylib. On success the resulting
1066 * generator is owned by the client. Ownership is typically transferred by
1067 * adding the instance to a JITDylib using LLVMOrcJITDylibAddGenerator,
1068 *
1069 * Call will succeed if the file at the given path is a static library or a
1070 * MachO universal binary containing a static library that is compatible with
1071 * the ExecutionSession's triple. Otherwise it will return an error.
1072 *
1073 * THIS API IS EXPERIMENTAL AND LIKELY TO CHANGE IN THE NEAR FUTURE!
1074 *
1075 */
1078 const char *FileName);
1079
1080/**
1081 * Create a ThreadSafeContextRef containing a new LLVMContext.
1082 *
1083 * Ownership of the underlying ThreadSafeContext data is shared: Clients
1084 * can and should dispose of their ThreadSafeContextRef as soon as they no
1085 * longer need to refer to it directly. Other references (e.g. from
1086 * ThreadSafeModules) will keep the underlying data alive as long as it is
1087 * needed.
1088 */
1090
1091/**
1092 * Create a ThreadSafeContextRef from a given LLVMContext, which must not be
1093 * associated with any existing ThreadSafeContext.
1094 *
1095 * The underlying ThreadSafeContext will take ownership of the LLVMContext
1096 * object, so clients should not free the LLVMContext passed to this
1097 * function.
1098 *
1099 * Ownership of the underlying ThreadSafeContext data is shared: Clients
1100 * can and should dispose of their ThreadSafeContextRef as soon as they no
1101 * longer need to refer to it directly. Other references (e.g. from
1102 * ThreadSafeModules) will keep the underlying data alive as long as it is
1103 * needed.
1104 */
1107
1108/**
1109 * Dispose of a ThreadSafeContext.
1110 */
1111LLVM_C_ABI void
1113
1114/**
1115 * Apply the given function to the LLVMContext contained in this
1116 * ThreadSafeContext.
1117 *
1118 * The context lock is held for the duration of the call, so the function has
1119 * exclusive access to the LLVMContext. The lock is recursive, so the function
1120 * may call LLVMOrcThreadSafeModuleWithModuleDo on modules associated with the
1121 * same ThreadSafeContext.
1122 *
1123 * The LLVMContextRef passed to the function must not be used after the
1124 * function returns.
1125 */
1128 void *Ctx);
1129
1130/**
1131 * Create a ThreadSafeModule wrapper around the given LLVM module. This takes
1132 * ownership of the M argument which should not be disposed of or referenced
1133 * after this function returns.
1134 *
1135 * Ownership of the ThreadSafeModule is unique: If it is transferred to the JIT
1136 * (e.g. by LLVMOrcLLJITAddLLVMIRModule) then the client is no longer
1137 * responsible for it. If it is not transferred to the JIT then the client
1138 * should call LLVMOrcDisposeThreadSafeModule to dispose of it.
1139 */
1142
1143/**
1144 * Dispose of a ThreadSafeModule. This should only be called if ownership has
1145 * not been passed to LLJIT (e.g. because some error prevented the client from
1146 * adding this to the JIT).
1147 */
1149
1150/**
1151 * Apply the given function to the module contained in this ThreadSafeModule.
1152 */
1155 void *Ctx);
1156
1157/**
1158 * Create a JITTargetMachineBuilder by detecting the host.
1159 *
1160 * On success the client owns the resulting JITTargetMachineBuilder. It must be
1161 * passed to a consuming operation (e.g.
1162 * LLVMOrcLLJITBuilderSetJITTargetMachineBuilder) or disposed of by calling
1163 * LLVMOrcDisposeJITTargetMachineBuilder.
1164 */
1167
1168/**
1169 * Create a JITTargetMachineBuilder from the given TargetMachine template.
1170 *
1171 * This operation takes ownership of the given TargetMachine and destroys it
1172 * before returing. The resulting JITTargetMachineBuilder is owned by the client
1173 * and must be passed to a consuming operation (e.g.
1174 * LLVMOrcLLJITBuilderSetJITTargetMachineBuilder) or disposed of by calling
1175 * LLVMOrcDisposeJITTargetMachineBuilder.
1176 */
1179
1180/**
1181 * Dispose of a JITTargetMachineBuilder.
1182 */
1183LLVM_C_ABI void
1185
1186/**
1187 * Returns the target triple for the given JITTargetMachineBuilder as a string.
1188 *
1189 * The caller owns the resulting string as must dispose of it by calling
1190 * LLVMDisposeMessage
1191 */
1194
1195/**
1196 * Sets the target triple for the given JITTargetMachineBuilder to the given
1197 * string.
1198 */
1200 LLVMOrcJITTargetMachineBuilderRef JTMB, const char *TargetTriple);
1201
1202/**
1203 * Add an object to an ObjectLayer to the given JITDylib.
1204 *
1205 * Adds a buffer representing an object file to the given JITDylib using the
1206 * given ObjectLayer instance. This operation transfers ownership of the buffer
1207 * to the ObjectLayer instance. The buffer should not be disposed of or
1208 * referenced once this function returns.
1209 *
1210 * Resources associated with the given object will be tracked by the given
1211 * JITDylib's default ResourceTracker.
1212 */
1215 LLVMMemoryBufferRef ObjBuffer);
1216
1217/**
1218 * Add an object to an ObjectLayer using the given ResourceTracker.
1219 *
1220 * Adds a buffer representing an object file to the given ResourceTracker's
1221 * JITDylib using the given ObjectLayer instance. This operation transfers
1222 * ownership of the buffer to the ObjectLayer instance. The buffer should not
1223 * be disposed of or referenced once this function returns.
1224 *
1225 * Resources associated with the given object will be tracked by
1226 * ResourceTracker RT.
1227 */
1230 LLVMMemoryBufferRef ObjBuffer);
1231
1232/**
1233 * Emit an object buffer to an ObjectLayer.
1234 *
1235 * Ownership of the responsibility object and object buffer pass to this
1236 * function. The client is not responsible for cleanup.
1237 */
1238LLVM_C_ABI void
1241 LLVMMemoryBufferRef ObjBuffer);
1242
1243/**
1244 * Dispose of an ObjectLayer.
1245 */
1247
1248LLVM_C_ABI void
1252
1253/**
1254 * Set the transform function of the provided transform layer, passing through a
1255 * pointer to user provided context.
1256 */
1258 LLVMOrcIRTransformLayerRef IRTransformLayer,
1259 LLVMOrcIRTransformLayerTransformFunction TransformFunction, void *Ctx);
1260
1261/**
1262 * Set the transform function on an LLVMOrcObjectTransformLayer.
1263 */
1265 LLVMOrcObjectTransformLayerRef ObjTransformLayer,
1266 LLVMOrcObjectTransformLayerTransformFunction TransformFunction, void *Ctx);
1267
1268/**
1269 * Create a LocalIndirectStubsManager from the given target triple.
1270 *
1271 * The resulting IndirectStubsManager is owned by the client
1272 * and must be disposed of by calling LLVMOrcDisposeDisposeIndirectStubsManager.
1273 */
1275LLVMOrcCreateLocalIndirectStubsManager(const char *TargetTriple);
1276
1277/**
1278 * Dispose of an IndirectStubsManager.
1279 */
1280LLVM_C_ABI void
1282
1284 const char *TargetTriple, LLVMOrcExecutionSessionRef ES,
1285 LLVMOrcJITTargetAddress ErrorHandlerAddr,
1287
1288/**
1289 * Dispose of an LazyCallThroughManager.
1290 */
1291LLVM_C_ABI void
1293
1294/**
1295 * Create a DumpObjects instance.
1296 *
1297 * DumpDir specifies the path to write dumped objects to. DumpDir may be empty
1298 * in which case files will be dumped to the working directory.
1299 *
1300 * IdentifierOverride specifies a file name stem to use when dumping objects.
1301 * If empty then each MemoryBuffer's identifier will be used (with a .o suffix
1302 * added if not already present). If an identifier override is supplied it will
1303 * be used instead, along with an incrementing counter (since all buffers will
1304 * use the same identifier, the resulting files will be named <ident>.o,
1305 * <ident>.2.o, <ident>.3.o, and so on). IdentifierOverride should not contain
1306 * an extension, as a .o suffix will be added by DumpObjects.
1307 */
1309LLVMOrcCreateDumpObjects(const char *DumpDir, const char *IdentifierOverride);
1310
1311/**
1312 * Dispose of a DumpObjects instance.
1313 */
1315
1316/**
1317 * Dump the contents of the given MemoryBuffer.
1318 */
1320 LLVMOrcDumpObjectsRef DumpObjects, LLVMMemoryBufferRef *ObjBuffer);
1321
1322/**
1323 * @}
1324 */
1325
1327
1328#endif /* LLVM_C_ORC_H */
uint64_t uint64_t
@ GlobalPrefix
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_C_EXTERN_C_BEGIN
Definition ExternC.h:35
#define LLVM_C_EXTERN_C_END
Definition ExternC.h:36
#define F(x, y, z)
Definition MD5.cpp:54
#define LLVM_C_ABI
LLVM_C_ABI is the export/visibility macro used to mark symbols declared in llvm-c as exported when bu...
Definition Visibility.h:40
struct LLVMOpaqueError * LLVMErrorRef
Opaque reference to an error instance.
Definition Error.h:34
uint64_t LLVMOrcJITTargetAddress
Represents an address in the executor process.
Definition Orc.h:47
LLVM_C_ABI void LLVMOrcObjectTransformLayerSetTransform(LLVMOrcObjectTransformLayerRef ObjTransformLayer, LLVMOrcObjectTransformLayerTransformFunction TransformFunction, void *Ctx)
Set the transform function on an LLVMOrcObjectTransformLayer.
LLVM_C_ABI void LLVMOrcDisposeDefinitionGenerator(LLVMOrcDefinitionGeneratorRef DG)
Dispose of a JITDylib::DefinitionGenerator.
LLVMErrorRef(* LLVMOrcGenericIRModuleOperationFunction)(void *Ctx, LLVMModuleRef M)
A function for inspecting/mutating IR modules, suitable for use with LLVMOrcThreadSafeModuleWithModul...
Definition Orc.h:398
LLVM_C_ABI LLVMErrorRef LLVMOrcCreateStaticLibrarySearchGeneratorForPath(LLVMOrcDefinitionGeneratorRef *Result, LLVMOrcObjectLayerRef ObjLayer, const char *FileName)
Get a LLVMOrcCreateStaticLibrarySearchGeneratorForPath that will reflect static library symbols into ...
LLVM_C_ABI void LLVMOrcDisposeSymbols(LLVMOrcSymbolStringPoolEntryRef *Symbols)
Disposes of the passed LLVMOrcSymbolStringPoolEntryRef* .
LLVMOrcLookupKind
Lookup kind.
Definition Orc.h:200
uint8_t LLVMJITSymbolTargetFlags
Represents target specific flags for a symbol definition.
Definition Orc.h:68
LLVM_C_ABI void LLVMOrcDisposeLazyCallThroughManager(LLVMOrcLazyCallThroughManagerRef LCTM)
Dispose of an LazyCallThroughManager.
struct LLVMOrcOpaqueObjectTransformLayer * LLVMOrcObjectTransformLayerRef
A reference to an orc::ObjectTransformLayer instance.
Definition Orc.h:451
LLVM_C_ABI LLVMErrorRef LLVMOrcCreateDynamicLibrarySearchGeneratorForPath(LLVMOrcDefinitionGeneratorRef *Result, const char *FileName, char GlobalPrefix, LLVMOrcSymbolPredicate Filter, void *FilterCtx)
Get a LLVMOrcCreateDynamicLibararySearchGeneratorForPath that will reflect library symbols into the J...
LLVM_C_ABI void LLVMOrcDisposeThreadSafeModule(LLVMOrcThreadSafeModuleRef TSM)
Dispose of a ThreadSafeModule.
LLVM_C_ABI LLVMOrcDumpObjectsRef LLVMOrcCreateDumpObjects(const char *DumpDir, const char *IdentifierOverride)
Create a DumpObjects instance.
LLVM_C_ABI LLVMErrorRef LLVMOrcJITDylibDefine(LLVMOrcJITDylibRef JD, LLVMOrcMaterializationUnitRef MU)
Add the given MaterializationUnit to the given JITDylib.
LLVMErrorRef(* LLVMOrcObjectTransformLayerTransformFunction)(void *Ctx, LLVMMemoryBufferRef *ObjInOut)
A function for applying transformations to an object file buffer.
Definition Orc.h:467
LLVM_C_ABI LLVMOrcSymbolStringPoolEntryRef LLVMOrcMaterializationResponsibilityGetInitializerSymbol(LLVMOrcMaterializationResponsibilityRef MR)
Returns the initialization pseudo-symbol, if any.
LLVM_C_ABI void LLVMOrcReleaseSymbolStringPoolEntry(LLVMOrcSymbolStringPoolEntryRef S)
Reduces the ref-count for of a SymbolStringPool entry.
LLVMOrcCSymbolFlagsMapPair * LLVMOrcCSymbolFlagsMapPairs
Represents a list of (SymbolStringPtr, JITSymbolFlags) pairs that can be used to construct a SymbolFl...
Definition Orc.h:119
LLVM_C_ABI void LLVMOrcDisposeIndirectStubsManager(LLVMOrcIndirectStubsManagerRef ISM)
Dispose of an IndirectStubsManager.
LLVM_C_ABI void LLVMOrcResourceTrackerTransferTo(LLVMOrcResourceTrackerRef SrcRT, LLVMOrcResourceTrackerRef DstRT)
Transfers tracking of all resources associated with resource tracker SrcRT to resource tracker DstRT.
LLVM_C_ABI LLVMOrcMaterializationUnitRef LLVMOrcCreateCustomMaterializationUnit(const char *Name, void *Ctx, LLVMOrcCSymbolFlagsMapPairs Syms, size_t NumSyms, LLVMOrcSymbolStringPoolEntryRef InitSym, LLVMOrcMaterializationUnitMaterializeFunction Materialize, LLVMOrcMaterializationUnitDiscardFunction Discard, LLVMOrcMaterializationUnitDestroyFunction Destroy)
Create a custom MaterializationUnit.
LLVM_C_ABI LLVMOrcMaterializationUnitRef LLVMOrcLazyReexports(LLVMOrcLazyCallThroughManagerRef LCTM, LLVMOrcIndirectStubsManagerRef ISM, LLVMOrcJITDylibRef SourceRef, LLVMOrcCSymbolAliasMapPairs CallableAliases, size_t NumPairs)
Create a MaterializationUnit to define lazy re-expots.
struct LLVMOrcOpaqueObjectLinkingLayer * LLVMOrcObjectLinkingLayerRef
A reference to an orc::ObjectLinkingLayer instance.
Definition Orc.h:422
LLVM_C_ABI LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyEmitted(LLVMOrcMaterializationResponsibilityRef MR, LLVMOrcCSymbolDependenceGroup *SymbolDepGroups, size_t NumSymbolDepGroups)
Notifies the target JITDylib (and any pending queries on that JITDylib) that all symbols covered by t...
LLVMOrcCSymbolAliasMapPair * LLVMOrcCSymbolAliasMapPairs
Represents a list of (SymbolStringPtr, (SymbolStringPtr, JITSymbolFlags)) pairs that can be used to c...
Definition Orc.h:155
LLVMOrcCSymbolMapPair * LLVMOrcCSymbolMapPairs
Represents a list of (SymbolStringPtr, JITEvaluatedSymbol) pairs that can be used to construct a Symb...
Definition Orc.h:133
LLVM_C_ABI void LLVMOrcJITDylibAddGenerator(LLVMOrcJITDylibRef JD, LLVMOrcDefinitionGeneratorRef DG)
Add a DefinitionGenerator to the given JITDylib.
LLVM_C_ABI LLVMErrorRef LLVMOrcExecutionSessionCreateJITDylib(LLVMOrcExecutionSessionRef ES, LLVMOrcJITDylibRef *Result, const char *Name)
Create a JITDylib.
struct LLVMOrcOpaqueJITTargetMachineBuilder * LLVMOrcJITTargetMachineBuilderRef
A reference to an orc::JITTargetMachineBuilder instance.
Definition Orc.h:411
LLVM_C_ABI LLVMOrcJITDylibRef LLVMOrcMaterializationResponsibilityGetTargetDylib(LLVMOrcMaterializationResponsibilityRef MR)
Returns the target JITDylib that these symbols are being materialized into.
LLVM_C_ABI void LLVMOrcRetainSymbolStringPoolEntry(LLVMOrcSymbolStringPoolEntryRef S)
Increments the ref-count for a SymbolStringPool entry.
LLVM_C_ABI LLVMErrorRef LLVMOrcMaterializationResponsibilityReplace(LLVMOrcMaterializationResponsibilityRef MR, LLVMOrcMaterializationUnitRef MU)
Transfers responsibility to the given MaterializationUnit for all symbols defined by that Materializa...
LLVM_C_ABI void LLVMOrcObjectLayerEmit(LLVMOrcObjectLayerRef ObjLayer, LLVMOrcMaterializationResponsibilityRef R, LLVMMemoryBufferRef ObjBuffer)
Emit an object buffer to an ObjectLayer.
LLVM_C_ABI LLVMOrcThreadSafeContextRef LLVMOrcCreateNewThreadSafeContextFromLLVMContext(LLVMContextRef Ctx)
Create a ThreadSafeContextRef from a given LLVMContext, which must not be associated with any existin...
LLVM_C_ABI char * LLVMOrcJITTargetMachineBuilderGetTargetTriple(LLVMOrcJITTargetMachineBuilderRef JTMB)
Returns the target triple for the given JITTargetMachineBuilder as a string.
LLVM_C_ABI void LLVMOrcLookupStateContinueLookup(LLVMOrcLookupStateRef S, LLVMErrorRef Err)
Continue a lookup that was suspended in a generator (see LLVMOrcCAPIDefinitionGeneratorTryToGenerateF...
LLVM_C_ABI LLVMErrorRef LLVMOrcObjectLayerAddObjectFileWithRT(LLVMOrcObjectLayerRef ObjLayer, LLVMOrcResourceTrackerRef RT, LLVMMemoryBufferRef ObjBuffer)
Add an object to an ObjectLayer using the given ResourceTracker.
void(* LLVMOrcErrorReporterFunction)(void *Ctx, LLVMErrorRef Err)
Error reporter function.
Definition Orc.h:94
LLVM_C_ABI void LLVMOrcDisposeObjectLayer(LLVMOrcObjectLayerRef ObjLayer)
Dispose of an ObjectLayer.
LLVM_C_ABI void LLVMOrcExecutionSessionLookup(LLVMOrcExecutionSessionRef ES, LLVMOrcLookupKind K, LLVMOrcCJITDylibSearchOrder SearchOrder, size_t SearchOrderSize, LLVMOrcCLookupSet Symbols, size_t SymbolsSize, LLVMOrcExecutionSessionLookupHandleResultFunction HandleResult, void *Ctx)
Look up symbols in an execution session.
struct LLVMOrcOpaqueMaterializationResponsibility * LLVMOrcMaterializationResponsibilityRef
A reference to a uniquely owned orc::MaterializationResponsibility instance.
Definition Orc.h:272
LLVM_C_ABI void LLVMOrcDisposeMaterializationResponsibility(LLVMOrcMaterializationResponsibilityRef MR)
Disposes of the passed MaterializationResponsibility object.
LLVM_C_ABI LLVMOrcCSymbolFlagsMapPairs LLVMOrcMaterializationResponsibilityGetSymbols(LLVMOrcMaterializationResponsibilityRef MR, size_t *NumPairs)
Returns the symbol flags map for this responsibility instance.
LLVM_C_ABI LLVMOrcJITTargetMachineBuilderRef LLVMOrcJITTargetMachineBuilderCreateFromTargetMachine(LLVMTargetMachineRef TM)
Create a JITTargetMachineBuilder from the given TargetMachine template.
void(* LLVMOrcDisposeCAPIDefinitionGeneratorFunction)(void *Ctx)
Disposer for a custom generator.
Definition Orc.h:376
struct LLVMOrcOpaqueThreadSafeModule * LLVMOrcThreadSafeModuleRef
A reference to an orc::ThreadSafeModule instance.
Definition Orc.h:392
struct LLVMOrcOpaqueExecutionSession * LLVMOrcExecutionSessionRef
A reference to an orc::ExecutionSession instance.
Definition Orc.h:89
LLVM_C_ABI LLVMOrcMaterializationUnitRef LLVMOrcAbsoluteSymbols(LLVMOrcCSymbolMapPairs Syms, size_t NumPairs)
Create a MaterializationUnit to define the given symbols as pointing to the corresponding raw address...
struct LLVMOrcOpaqueIndirectStubsManager * LLVMOrcIndirectStubsManagerRef
A reference to an orc::IndirectStubsManager instance.
Definition Orc.h:473
void(* LLVMOrcExecutionSessionLookupHandleResultFunction)(LLVMErrorRef Err, LLVMOrcCSymbolMapPairs Result, size_t NumPairs, void *Ctx)
Callback type for ExecutionSession lookups.
Definition Orc.h:554
LLVM_C_ABI LLVMErrorRef LLVMOrcJITDylibClear(LLVMOrcJITDylibRef JD)
Calls remove on all trackers associated with this JITDylib, see JITDylib::clear().
LLVM_C_ABI LLVMOrcThreadSafeModuleRef LLVMOrcCreateNewThreadSafeModule(LLVMModuleRef M, LLVMOrcThreadSafeContextRef TSCtx)
Create a ThreadSafeModule wrapper around the given LLVM module.
LLVM_C_ABI void LLVMOrcReleaseResourceTracker(LLVMOrcResourceTrackerRef RT)
Reduces the ref-count of a ResourceTracker.
LLVM_C_ABI LLVMOrcSymbolStringPoolRef LLVMOrcExecutionSessionGetSymbolStringPool(LLVMOrcExecutionSessionRef ES)
Return a reference to the SymbolStringPool for an ExecutionSession.
LLVM_C_ABI void LLVMOrcSymbolStringPoolClearDeadEntries(LLVMOrcSymbolStringPoolRef SSP)
Clear all unreferenced symbol string pool entries.
LLVM_C_ABI LLVMOrcExecutionSessionRef LLVMOrcMaterializationResponsibilityGetExecutionSession(LLVMOrcMaterializationResponsibilityRef MR)
Returns the ExecutionSession for this MaterializationResponsibility.
LLVM_C_ABI LLVMOrcIndirectStubsManagerRef LLVMOrcCreateLocalIndirectStubsManager(const char *TargetTriple)
Create a LocalIndirectStubsManager from the given target triple.
LLVM_C_ABI 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.
Definition Orc.h:364
LLVM_C_ABI void LLVMOrcIRTransformLayerEmit(LLVMOrcIRTransformLayerRef IRTransformLayer, LLVMOrcMaterializationResponsibilityRef MR, LLVMOrcThreadSafeModuleRef TSM)
LLVMOrcCJITDylibSearchOrderElement * LLVMOrcCJITDylibSearchOrder
A JITDylib search order.
Definition Orc.h:230
LLVMErrorRef(* LLVMOrcIRTransformLayerTransformFunction)(void *Ctx, LLVMOrcThreadSafeModuleRef *ModInOut, LLVMOrcMaterializationResponsibilityRef MR)
A function for applying transformations as part of an transform layer.
Definition Orc.h:444
struct LLVMOrcOpaqueSymbolStringPool * LLVMOrcSymbolStringPoolRef
A reference to an orc::SymbolStringPool.
Definition Orc.h:99
void(* LLVMOrcMaterializationUnitDestroyFunction)(void *Ctx)
A MaterializationUnit destruction callback.
Definition Orc.h:304
LLVM_C_ABI void LLVMOrcDisposeDumpObjects(LLVMOrcDumpObjectsRef DumpObjects)
Dispose of a DumpObjects instance.
struct LLVMOrcOpaqueResourceTracker * LLVMOrcResourceTrackerRef
A reference to an orc::ResourceTracker instance.
Definition Orc.h:309
LLVM_C_ABI void LLVMOrcIRTransformLayerSetTransform(LLVMOrcIRTransformLayerRef IRTransformLayer, LLVMOrcIRTransformLayerTransformFunction TransformFunction, void *Ctx)
Set the transform function of the provided transform layer, passing through a pointer to user provide...
LLVM_C_ABI void LLVMOrcDisposeThreadSafeContext(LLVMOrcThreadSafeContextRef TSCtx)
Dispose of a ThreadSafeContext.
LLVMOrcCDependenceMapPair * LLVMOrcCDependenceMapPairs
Represents a list of (JITDylibRef, (LLVMOrcSymbolStringPoolEntryRef*, size_t)) pairs that can be used...
Definition Orc.h:183
LLVM_C_ABI const char * LLVMOrcSymbolStringPoolEntryStr(LLVMOrcSymbolStringPoolEntryRef S)
Return the c-string for the given symbol.
LLVMErrorRef(* LLVMOrcGenericContextOperationFunction)(void *Ctx, LLVMContextRef C)
A function for inspecting/mutating LLVM contexts, suitable for use with LLVMOrcThreadSafeContextWithC...
Definition Orc.h:405
LLVM_C_ABI LLVMErrorRef LLVMOrcThreadSafeContextWithContextDo(LLVMOrcThreadSafeContextRef TSCtx, LLVMOrcGenericContextOperationFunction F, void *Ctx)
Apply the given function to the LLVMContext contained in this ThreadSafeContext.
LLVM_C_ABI LLVMErrorRef LLVMOrcThreadSafeModuleWithModuleDo(LLVMOrcThreadSafeModuleRef TSM, LLVMOrcGenericIRModuleOperationFunction F, void *Ctx)
Apply the given function to the module contained in this ThreadSafeModule.
LLVM_C_ABI LLVMErrorRef LLVMOrcObjectLayerAddObjectFile(LLVMOrcObjectLayerRef ObjLayer, LLVMOrcJITDylibRef JD, LLVMMemoryBufferRef ObjBuffer)
Add an object to an ObjectLayer to the given JITDylib.
uint64_t LLVMOrcExecutorAddress
Represents an address in the executor process.
Definition Orc.h:52
LLVM_C_ABI LLVMErrorRef LLVMOrcMaterializationResponsibilityDelegate(LLVMOrcMaterializationResponsibilityRef MR, LLVMOrcSymbolStringPoolEntryRef *Symbols, size_t NumSymbols, LLVMOrcMaterializationResponsibilityRef *Result)
Delegates responsibility for the given symbols to the returned materialization responsibility.
LLVMJITSymbolGenericFlags
Represents generic linkage flags for a symbol definition.
Definition Orc.h:57
LLVMOrcCLookupSetElement * LLVMOrcCLookupSet
A set of symbols to look up / generate.
Definition Orc.h:260
LLVM_C_ABI LLVMOrcResourceTrackerRef LLVMOrcJITDylibCreateResourceTracker(LLVMOrcJITDylibRef JD)
Return a reference to a newly created resource tracker associated with JD.
struct LLVMOrcOpaqueObjectLayer * LLVMOrcObjectLayerRef
A reference to an orc::ObjectLayer instance.
Definition Orc.h:417
int(* LLVMOrcSymbolPredicate)(void *Ctx, LLVMOrcSymbolStringPoolEntryRef Sym)
Predicate function for SymbolStringPoolEntries.
Definition Orc.h:381
LLVM_C_ABI void LLVMOrcDisposeJITTargetMachineBuilder(LLVMOrcJITTargetMachineBuilderRef JTMB)
Dispose of a JITTargetMachineBuilder.
LLVM_C_ABI void LLVMOrcJITTargetMachineBuilderSetTargetTriple(LLVMOrcJITTargetMachineBuilderRef JTMB, const char *TargetTriple)
Sets the target triple for the given JITTargetMachineBuilder to the given string.
struct LLVMOrcOpaqueDefinitionGenerator * LLVMOrcDefinitionGeneratorRef
A reference to an orc::DefinitionGenerator.
Definition Orc.h:314
LLVM_C_ABI LLVMOrcJITDylibRef LLVMOrcExecutionSessionGetJITDylibByName(LLVMOrcExecutionSessionRef ES, const char *Name)
Returns the JITDylib with the given name, or NULL if no such JITDylib exists.
LLVM_C_ABI void LLVMOrcMaterializationResponsibilityFailMaterialization(LLVMOrcMaterializationResponsibilityRef MR)
Notify all not-yet-emitted covered by this MaterializationResponsibility instance that an error has o...
struct LLVMOrcOpaqueSymbolStringPoolEntry * LLVMOrcSymbolStringPoolEntryRef
A reference to an orc::SymbolStringPool table entry.
Definition Orc.h:104
LLVMOrcSymbolLookupFlags
Symbol lookup flags for lookup sets.
Definition Orc.h:236
LLVM_C_ABI void LLVMOrcDisposeCSymbolFlagsMap(LLVMOrcCSymbolFlagsMapPairs Pairs)
Disposes of the passed LLVMOrcCSymbolFlagsMap.
LLVM_C_ABI LLVMErrorRef LLVMOrcMaterializationResponsibilityDefineMaterializing(LLVMOrcMaterializationResponsibilityRef MR, LLVMOrcCSymbolFlagsMapPairs Pairs, size_t NumPairs)
Attempt to claim responsibility for new definitions.
LLVM_C_ABI LLVMOrcThreadSafeContextRef LLVMOrcCreateNewThreadSafeContext(void)
Create a ThreadSafeContextRef containing a new LLVMContext.
void(* LLVMOrcMaterializationUnitDiscardFunction)(void *Ctx, LLVMOrcJITDylibRef JD, LLVMOrcSymbolStringPoolEntryRef Symbol)
A MaterializationUnit discard callback.
Definition Orc.h:294
LLVM_C_ABI LLVMOrcResourceTrackerRef LLVMOrcJITDylibGetDefaultResourceTracker(LLVMOrcJITDylibRef JD)
Return a reference to the default resource tracker for the given JITDylib.
LLVM_C_ABI LLVMOrcSymbolStringPoolEntryRef * LLVMOrcMaterializationResponsibilityGetRequestedSymbols(LLVMOrcMaterializationResponsibilityRef MR, size_t *NumSymbols)
Returns the names of any symbols covered by this MaterializationResponsibility object that have queri...
void(* LLVMOrcMaterializationUnitMaterializeFunction)(void *Ctx, LLVMOrcMaterializationResponsibilityRef MR)
A MaterializationUnit materialize callback.
Definition Orc.h:285
struct LLVMOrcOpaqueDumpObjects * LLVMOrcDumpObjectsRef
A reference to an orc::DumpObjects object.
Definition Orc.h:488
LLVM_C_ABI LLVMErrorRef LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess(LLVMOrcDefinitionGeneratorRef *Result, char GlobalPrefx, LLVMOrcSymbolPredicate Filter, void *FilterCtx)
Get a DynamicLibrarySearchGenerator that will reflect process symbols into the JITDylib.
struct LLVMOrcOpaqueIRTransformLayer * LLVMOrcIRTransformLayerRef
A reference to an orc::IRTransformLayer instance.
Definition Orc.h:427
struct LLVMOrcOpaqueLookupState * LLVMOrcLookupStateRef
An opaque lookup state object.
Definition Orc.h:329
LLVM_C_ABI LLVMOrcDefinitionGeneratorRef LLVMOrcCreateCustomCAPIDefinitionGenerator(LLVMOrcCAPIDefinitionGeneratorTryToGenerateFunction F, void *Ctx, LLVMOrcDisposeCAPIDefinitionGeneratorFunction Dispose)
Create a custom generator.
LLVM_C_ABI LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyResolved(LLVMOrcMaterializationResponsibilityRef MR, LLVMOrcCSymbolMapPairs Symbols, size_t NumPairs)
Notifies the target JITDylib that the given symbols have been resolved.
LLVM_C_ABI LLVMErrorRef LLVMOrcCreateLocalLazyCallThroughManager(const char *TargetTriple, LLVMOrcExecutionSessionRef ES, LLVMOrcJITTargetAddress ErrorHandlerAddr, LLVMOrcLazyCallThroughManagerRef *LCTM)
LLVM_C_ABI void LLVMOrcDisposeMaterializationUnit(LLVMOrcMaterializationUnitRef MU)
Dispose of a MaterializationUnit.
LLVM_C_ABI LLVMErrorRef LLVMOrcResourceTrackerRemove(LLVMOrcResourceTrackerRef RT)
Remove all resources associated with the given tracker.
struct LLVMOrcOpaqueMaterializationUnit * LLVMOrcMaterializationUnitRef
A reference to a uniquely owned orc::MaterializationUnit instance.
Definition Orc.h:265
LLVM_C_ABI LLVMOrcJITDylibRef LLVMOrcExecutionSessionCreateBareJITDylib(LLVMOrcExecutionSessionRef ES, const char *Name)
Create a "bare" JITDylib.
LLVM_C_ABI LLVMOrcSymbolStringPoolEntryRef LLVMOrcExecutionSessionIntern(LLVMOrcExecutionSessionRef ES, const char *Name)
Intern a string in the ExecutionSession's SymbolStringPool and return a reference to it.
LLVM_C_ABI void LLVMOrcExecutionSessionSetErrorReporter(LLVMOrcExecutionSessionRef ES, LLVMOrcErrorReporterFunction ReportError, void *Ctx)
Attach a custom error reporter function to the ExecutionSession.
LLVM_C_ABI LLVMErrorRef LLVMOrcDumpObjects_CallOperator(LLVMOrcDumpObjectsRef DumpObjects, LLVMMemoryBufferRef *ObjBuffer)
Dump the contents of the given MemoryBuffer.
struct LLVMOrcOpaqueJITDylib * LLVMOrcJITDylibRef
A reference to an orc::JITDylib instance.
Definition Orc.h:160
struct LLVMOrcOpaqueThreadSafeContext * LLVMOrcThreadSafeContextRef
A reference to an orc::ThreadSafeContext instance.
Definition Orc.h:387
LLVMOrcJITDylibLookupFlags
JITDylib lookup flags.
Definition Orc.h:211
@ LLVMOrcLookupKindDLSym
Definition Orc.h:202
@ LLVMOrcLookupKindStatic
Definition Orc.h:201
@ LLVMJITSymbolGenericFlagsNone
Definition Orc.h:58
@ LLVMJITSymbolGenericFlagsWeak
Definition Orc.h:60
@ LLVMJITSymbolGenericFlagsExported
Definition Orc.h:59
@ LLVMJITSymbolGenericFlagsCallable
Definition Orc.h:61
@ LLVMJITSymbolGenericFlagsMaterializationSideEffectsOnly
Definition Orc.h:62
@ LLVMOrcSymbolLookupFlagsRequiredSymbol
Definition Orc.h:237
@ LLVMOrcSymbolLookupFlagsWeaklyReferencedSymbol
Definition Orc.h:238
@ LLVMOrcJITDylibLookupFlagsMatchAllSymbols
Definition Orc.h:213
@ LLVMOrcJITDylibLookupFlagsMatchExportedSymbolsOnly
Definition Orc.h:212
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
Definition Types.h:48
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
Definition Types.h:53
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition Types.h:61
struct LLVMOpaqueTargetMachine * LLVMTargetMachineRef
Represents an evaluated symbol address and flags.
Definition Orc.h:81
LLVMOrcExecutorAddress Address
Definition Orc.h:82
LLVMJITSymbolFlags Flags
Definition Orc.h:83
Represents the linkage flags for a symbol definition.
Definition Orc.h:73
uint8_t GenericFlags
Definition Orc.h:74
uint8_t TargetFlags
Definition Orc.h:75
Represents a pair of a JITDylib and LLVMOrcCSymbolsList.
Definition Orc.h:174
LLVMOrcJITDylibRef JD
Definition Orc.h:175
LLVMOrcCSymbolsList Names
Definition Orc.h:176
An element type for a JITDylib search order.
Definition Orc.h:219
LLVMOrcJITDylibRef JD
Definition Orc.h:220
LLVMOrcJITDylibLookupFlags JDLookupFlags
Definition Orc.h:221
An element type for a symbol lookup set.
Definition Orc.h:244
LLVMOrcSymbolLookupFlags LookupFlags
Definition Orc.h:246
LLVMOrcSymbolStringPoolEntryRef Name
Definition Orc.h:245
Represents a SymbolAliasMapEntry.
Definition Orc.h:138
LLVMOrcSymbolStringPoolEntryRef Name
Definition Orc.h:139
LLVMJITSymbolFlags Flags
Definition Orc.h:140
Represents a pair of a symbol name and SymbolAliasMapEntry.
Definition Orc.h:146
LLVMOrcCSymbolAliasMapEntry Entry
Definition Orc.h:148
LLVMOrcSymbolStringPoolEntryRef Name
Definition Orc.h:147
A set of symbols that share dependencies.
Definition Orc.h:188
LLVMOrcCSymbolsList Symbols
Definition Orc.h:189
LLVMOrcCDependenceMapPairs Dependencies
Definition Orc.h:190
Represents a pair of a symbol name and LLVMJITSymbolFlags.
Definition Orc.h:110
LLVMJITSymbolFlags Flags
Definition Orc.h:112
LLVMOrcSymbolStringPoolEntryRef Name
Definition Orc.h:111
Represents a pair of a symbol name and an evaluated symbol.
Definition Orc.h:124
LLVMJITEvaluatedSymbol Sym
Definition Orc.h:126
LLVMOrcSymbolStringPoolEntryRef Name
Definition Orc.h:125
Represents a list of LLVMOrcSymbolStringPoolEntryRef and the associated length.
Definition Orc.h:166
LLVMOrcSymbolStringPoolEntryRef * Symbols
Definition Orc.h:167
size_t Length
Definition Orc.h:168