diff options
Diffstat (limited to 'contrib/llvm-project/llvm/include/llvm-c')
10 files changed, 790 insertions, 34 deletions
diff --git a/contrib/llvm-project/llvm/include/llvm-c/Comdat.h b/contrib/llvm-project/llvm/include/llvm-c/Comdat.h index 45b4007695fd..81cde1107fa4 100644 --- a/contrib/llvm-project/llvm/include/llvm-c/Comdat.h +++ b/contrib/llvm-project/llvm/include/llvm-c/Comdat.h @@ -25,8 +25,7 @@ typedef enum { ///< be the same. LLVMLargestComdatSelectionKind, ///< The linker will choose the largest ///< COMDAT. - LLVMNoDuplicatesComdatSelectionKind, ///< No other Module may specify this - ///< COMDAT. + LLVMNoDeduplicateComdatSelectionKind, ///< No deduplication is performed. LLVMSameSizeComdatSelectionKind ///< The data referenced by the COMDAT must be ///< the same size. } LLVMComdatSelectionKind; diff --git a/contrib/llvm-project/llvm/include/llvm-c/Core.h b/contrib/llvm-project/llvm/include/llvm-c/Core.h index 2901ab715810..1a5e763cfc60 100644 --- a/contrib/llvm-project/llvm/include/llvm-c/Core.h +++ b/contrib/llvm-project/llvm/include/llvm-c/Core.h @@ -872,11 +872,11 @@ void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len); * * @see InlineAsm::get() */ -LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, - char *AsmString, size_t AsmStringSize, - char *Constraints, size_t ConstraintsSize, - LLVMBool HasSideEffects, LLVMBool IsAlignStack, - LLVMInlineAsmDialect Dialect); +LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, char *AsmString, + size_t AsmStringSize, char *Constraints, + size_t ConstraintsSize, LLVMBool HasSideEffects, + LLVMBool IsAlignStack, + LLVMInlineAsmDialect Dialect, LLVMBool CanThrow); /** * Obtain the context to which this module is associated. @@ -2261,6 +2261,8 @@ void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr); * @see llvm::AllocaInst::getAlignment() * @see llvm::LoadInst::getAlignment() * @see llvm::StoreInst::getAlignment() + * @see llvm::AtomicRMWInst::setAlignment() + * @see llvm::AtomicCmpXchgInst::setAlignment() * @see llvm::GlobalValue::getAlignment() */ unsigned LLVMGetAlignment(LLVMValueRef V); @@ -2270,6 +2272,8 @@ unsigned LLVMGetAlignment(LLVMValueRef V); * @see llvm::AllocaInst::setAlignment() * @see llvm::LoadInst::setAlignment() * @see llvm::StoreInst::setAlignment() + * @see llvm::AtomicRMWInst::setAlignment() + * @see llvm::AtomicCmpXchgInst::setAlignment() * @see llvm::GlobalValue::setAlignment() */ void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes); @@ -2510,6 +2514,12 @@ LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID, */ const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength); +/** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */ +const char *LLVMIntrinsicCopyOverloadedName(unsigned ID, + LLVMTypeRef *ParamTypes, + size_t ParamCount, + size_t *NameLength); + /** * Copies the name of an overloaded intrinsic identified by a given list of * parameter types. @@ -2517,12 +2527,14 @@ const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength); * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the * returned string. * + * This version also supports unnamed types. + * * @see llvm::Intrinsic::getName() */ -const char *LLVMIntrinsicCopyOverloadedName(unsigned ID, - LLVMTypeRef *ParamTypes, - size_t ParamCount, - size_t *NameLength); +const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID, + LLVMTypeRef *ParamTypes, + size_t ParamCount, + size_t *NameLength); /** * Obtain if the intrinsic identified by the given ID is overloaded. diff --git a/contrib/llvm-project/llvm/include/llvm-c/DebugInfo.h b/contrib/llvm-project/llvm/include/llvm-c/DebugInfo.h index 5a9cd8e2ee63..8c085807914b 100644 --- a/contrib/llvm-project/llvm/include/llvm-c/DebugInfo.h +++ b/contrib/llvm-project/llvm/include/llvm-c/DebugInfo.h @@ -161,7 +161,8 @@ enum { LLVMDIMacroFileMetadataKind, LLVMDICommonBlockMetadataKind, LLVMDIStringTypeMetadataKind, - LLVMDIGenericSubrangeMetadataKind + LLVMDIGenericSubrangeMetadataKind, + LLVMDIArgListMetadataKind }; typedef unsigned LLVMMetadataKind; diff --git a/contrib/llvm-project/llvm/include/llvm-c/DisassemblerTypes.h b/contrib/llvm-project/llvm/include/llvm-c/DisassemblerTypes.h index 389e5ee454a8..ae5c68227594 100644 --- a/contrib/llvm-project/llvm/include/llvm-c/DisassemblerTypes.h +++ b/contrib/llvm-project/llvm/include/llvm-c/DisassemblerTypes.h @@ -7,8 +7,8 @@ |* *| |*===----------------------------------------------------------------------===*/ -#ifndef LLVM_DISASSEMBLER_TYPES_H -#define LLVM_DISASSEMBLER_TYPES_H +#ifndef LLVM_C_DISASSEMBLERTYPES_H +#define LLVM_C_DISASSEMBLERTYPES_H #include "llvm-c/DataTypes.h" #ifdef __cplusplus diff --git a/contrib/llvm-project/llvm/include/llvm-c/ErrorHandling.h b/contrib/llvm-project/llvm/include/llvm-c/ErrorHandling.h index c6f7ff3ed693..5ba099c209c0 100644 --- a/contrib/llvm-project/llvm/include/llvm-c/ErrorHandling.h +++ b/contrib/llvm-project/llvm/include/llvm-c/ErrorHandling.h @@ -11,8 +11,8 @@ |* *| \*===----------------------------------------------------------------------===*/ -#ifndef LLVM_C_ERROR_HANDLING_H -#define LLVM_C_ERROR_HANDLING_H +#ifndef LLVM_C_ERRORHANDLING_H +#define LLVM_C_ERRORHANDLING_H #include "llvm-c/ExternC.h" diff --git a/contrib/llvm-project/llvm/include/llvm-c/ExternC.h b/contrib/llvm-project/llvm/include/llvm-c/ExternC.h index 4240f7c31a3b..dfa21bdc0857 100644 --- a/contrib/llvm-project/llvm/include/llvm-c/ExternC.h +++ b/contrib/llvm-project/llvm/include/llvm-c/ExternC.h @@ -11,8 +11,8 @@ |* *| \*===----------------------------------------------------------------------===*/ -#ifndef LLVM_C_EXTERN_C_H -#define LLVM_C_EXTERN_C_H +#ifndef LLVM_C_EXTERNC_H +#define LLVM_C_EXTERNC_H #ifdef __clang__ #define LLVM_C_STRICT_PROTOTYPES_BEGIN \ diff --git a/contrib/llvm-project/llvm/include/llvm-c/LLJIT.h b/contrib/llvm-project/llvm/include/llvm-c/LLJIT.h index 28eb8bbff96b..f689ca0f1cf0 100644 --- a/contrib/llvm-project/llvm/include/llvm-c/LLJIT.h +++ b/contrib/llvm-project/llvm/include/llvm-c/LLJIT.h @@ -78,6 +78,9 @@ void LLVMOrcDisposeLLJITBuilder(LLVMOrcLLJITBuilderRef Builder); * instance. Calling this function is optional: if it is not called then the * LLJITBuilder will use JITTargeTMachineBuilder::detectHost to construct a * JITTargetMachineBuilder. + * + * This function takes ownership of the JTMB argument: clients should not + * dispose of the JITTargetMachineBuilder after calling this function. */ void LLVMOrcLLJITBuilderSetJITTargetMachineBuilder( LLVMOrcLLJITBuilderRef Builder, LLVMOrcJITTargetMachineBuilderRef JTMB); @@ -205,9 +208,33 @@ LLVMErrorRef LLVMOrcLLJITAddLLVMIRModuleWithRT(LLVMOrcLLJITRef J, * This operation does not take ownership of the Name argument. */ LLVMErrorRef LLVMOrcLLJITLookup(LLVMOrcLLJITRef J, - LLVMOrcJITTargetAddress *Result, + LLVMOrcExecutorAddress *Result, const char *Name); +/** + * Returns a non-owning reference to the LLJIT instance's object linking layer. + */ +LLVMOrcObjectLayerRef LLVMOrcLLJITGetObjLinkingLayer(LLVMOrcLLJITRef J); + +/** + * Returns a non-owning reference to the LLJIT instance's object linking layer. + */ +LLVMOrcObjectTransformLayerRef +LLVMOrcLLJITGetObjTransformLayer(LLVMOrcLLJITRef J); + +/** + * Returns a non-owning reference to the LLJIT instance's IR transform layer. + */ +LLVMOrcIRTransformLayerRef LLVMOrcLLJITGetIRTransformLayer(LLVMOrcLLJITRef J); + +/** + * Get the LLJIT instance's default data layout string. + * + * This string is owned by the LLJIT instance and does not need to be freed + * by the caller. + */ +const char *LLVMOrcLLJITGetDataLayoutStr(LLVMOrcLLJITRef J); + LLVM_C_EXTERN_C_END #endif /* LLVM_C_LLJIT_H */ diff --git a/contrib/llvm-project/llvm/include/llvm-c/Orc.h b/contrib/llvm-project/llvm/include/llvm-c/Orc.h index 9beef44c89dd..1790afbcecc7 100644 --- a/contrib/llvm-project/llvm/include/llvm-c/Orc.h +++ b/contrib/llvm-project/llvm/include/llvm-c/Orc.h @@ -34,22 +34,29 @@ LLVM_C_EXTERN_C_BEGIN /** - * Represents an address in the target process. + * Represents an address in the executor process. */ typedef uint64_t LLVMOrcJITTargetAddress; /** + * Represents an address in the executor process. + */ +typedef uint64_t LLVMOrcExecutorAddress; + +/** * Represents generic linkage flags for a symbol definition. */ typedef enum { LLVMJITSymbolGenericFlagsExported = 1U << 0, - LLVMJITSymbolGenericFlagsWeak = 1U << 1 + LLVMJITSymbolGenericFlagsWeak = 1U << 1, + LLVMJITSymbolGenericFlagsCallable = 1U << 2, + LLVMJITSymbolGenericFlagsMaterializationSideEffectsOnly = 1U << 3 } LLVMJITSymbolGenericFlags; /** * Represents target specific flags for a symbol definition. */ -typedef uint8_t LLVMJITTargetSymbolFlags; +typedef uint8_t LLVMJITSymbolTargetFlags; /** * Represents the linkage flags for a symbol definition. @@ -63,7 +70,7 @@ typedef struct { * Represents an evaluated symbol address and flags. */ typedef struct { - LLVMOrcJITTargetAddress Address; + LLVMOrcExecutorAddress Address; LLVMJITSymbolFlags Flags; } LLVMJITEvaluatedSymbol; @@ -89,6 +96,20 @@ typedef struct LLVMOrcOpaqueSymbolStringPoolEntry *LLVMOrcSymbolStringPoolEntryRef; /** + * Represents a pair of a symbol name and LLVMJITSymbolFlags. + */ +typedef struct { + LLVMOrcSymbolStringPoolEntryRef Name; + LLVMJITSymbolFlags Flags; +} LLVMOrcCSymbolFlagsMapPair; + +/** + * Represents a list of (SymbolStringPtr, JITSymbolFlags) pairs that can be used + * to construct a SymbolFlagsMap. + */ +typedef LLVMOrcCSymbolFlagsMapPair *LLVMOrcCSymbolFlagsMapPairs; + +/** * Represents a pair of a symbol name and an evaluated symbol. */ typedef struct { @@ -103,6 +124,56 @@ typedef struct { typedef LLVMJITCSymbolMapPair *LLVMOrcCSymbolMapPairs; /** + * Represents a SymbolAliasMapEntry + */ +typedef struct { + LLVMOrcSymbolStringPoolEntryRef Name; + LLVMJITSymbolFlags Flags; +} LLVMOrcCSymbolAliasMapEntry; + +/** + * Represents a pair of a symbol name and SymbolAliasMapEntry. + */ +typedef struct { + LLVMOrcSymbolStringPoolEntryRef Name; + LLVMOrcCSymbolAliasMapEntry Entry; +} LLVMOrcCSymbolAliasMapPair; + +/** + * Represents a list of (SymbolStringPtr, (SymbolStringPtr, JITSymbolFlags)) + * pairs that can be used to construct a SymbolFlagsMap. + */ +typedef LLVMOrcCSymbolAliasMapPair *LLVMOrcCSymbolAliasMapPairs; + +/** + * A reference to an orc::JITDylib instance. + */ +typedef struct LLVMOrcOpaqueJITDylib *LLVMOrcJITDylibRef; + +/** + * Represents a list of LLVMOrcSymbolStringPoolEntryRef and the associated + * length. + */ +typedef struct { + LLVMOrcSymbolStringPoolEntryRef *Symbols; + size_t Length; +} LLVMOrcCSymbolsList; + +/** + * Represents a pair of a JITDylib and LLVMOrcCSymbolsList. + */ +typedef struct { + LLVMOrcJITDylibRef JD; + LLVMOrcCSymbolsList Names; +} LLVMOrcCDependenceMapPair; + +/** + * Represents a list of (JITDylibRef, (LLVMOrcSymbolStringPoolEntryRef*, + * size_t)) pairs that can be used to construct a SymbolDependenceMap. + */ +typedef LLVMOrcCDependenceMapPair *LLVMOrcCDependenceMapPairs; + +/** * Lookup kind. This can be used by definition generators when deciding whether * to produce a definition for a requested symbol. * @@ -155,14 +226,48 @@ typedef struct { typedef LLVMOrcCLookupSetElement *LLVMOrcCLookupSet; /** - * A reference to an orc::MaterializationUnit. + * A reference to a uniquely owned orc::MaterializationUnit instance. */ typedef struct LLVMOrcOpaqueMaterializationUnit *LLVMOrcMaterializationUnitRef; /** - * A reference to an orc::JITDylib instance. + * A reference to a uniquely owned orc::MaterializationResponsibility instance. + * + * Ownership must be passed to a lower-level layer in a JIT stack. */ -typedef struct LLVMOrcOpaqueJITDylib *LLVMOrcJITDylibRef; +typedef struct LLVMOrcOpaqueMaterializationResponsibility + *LLVMOrcMaterializationResponsibilityRef; + +/** + * A MaterializationUnit materialize callback. + * + * Ownership of the Ctx and MR arguments passes to the callback which must + * adhere to the LLVMOrcMaterializationResponsibilityRef contract (see comment + * for that type). + * + * If this callback is called then the LLVMOrcMaterializationUnitDestroy + * callback will NOT be called. + */ +typedef void (*LLVMOrcMaterializationUnitMaterializeFunction)( + void *Ctx, LLVMOrcMaterializationResponsibilityRef MR); + +/** + * A MaterializationUnit discard callback. + * + * Ownership of JD and Symbol remain with the caller: These arguments should + * not be disposed of or released. + */ +typedef void (*LLVMOrcMaterializationUnitDiscardFunction)( + void *Ctx, LLVMOrcJITDylibRef JD, LLVMOrcSymbolStringPoolEntryRef Symbol); + +/** + * A MaterializationUnit destruction callback. + * + * If a custom MaterializationUnit is destroyed before its Materialize + * function is called then this function will be called to provide an + * opportunity for the underlying program representation to be destroyed. + */ +typedef void (*LLVMOrcMaterializationUnitDestroyFunction)(void *Ctx); /** * A reference to an orc::ResourceTracker instance. @@ -207,8 +312,8 @@ typedef struct LLVMOrcOpaqueLookupState *LLVMOrcLookupStateRef; * asynchronous definition process has been completed clients must call * LLVMOrcLookupStateContinueLookup to continue the lookup (this should be * done unconditionally, even if errors have occurred in the mean time, to - * free the lookup state memory and notify the query object of the failures. If - * LookupState is captured this function must return LLVMErrorSuccess. + * free the lookup state memory and notify the query object of the failures). + * If LookupState is captured this function must return LLVMErrorSuccess. * * The Kind argument can be inspected to determine the lookup kind (e.g. * as-if-during-static-link, or as-if-during-dlsym). @@ -245,6 +350,13 @@ typedef struct LLVMOrcOpaqueThreadSafeContext *LLVMOrcThreadSafeContextRef; typedef struct LLVMOrcOpaqueThreadSafeModule *LLVMOrcThreadSafeModuleRef; /** + * A function for inspecting/mutating IR modules, suitable for use with + * LLVMOrcThreadSafeModuleWithModuleDo. + */ +typedef LLVMErrorRef (*LLVMOrcGenericIRModuleOperationFunction)( + void *Ctx, LLVMModuleRef M); + +/** * A reference to an orc::JITTargetMachineBuilder instance. */ typedef struct LLVMOrcOpaqueJITTargetMachineBuilder @@ -256,6 +368,77 @@ typedef struct LLVMOrcOpaqueJITTargetMachineBuilder typedef struct LLVMOrcOpaqueObjectLayer *LLVMOrcObjectLayerRef; /** + * A reference to an orc::ObjectLinkingLayer instance. + */ +typedef struct LLVMOrcOpaqueObjectLinkingLayer *LLVMOrcObjectLinkingLayerRef; + +/** + * A reference to an orc::IRTransformLayer instance. + */ +typedef struct LLVMOrcOpaqueIRTransformLayer *LLVMOrcIRTransformLayerRef; + +/** + * A function for applying transformations as part of an transform layer. + * + * Implementations of this type are responsible for managing the lifetime + * of the Module pointed to by ModInOut: If the LLVMModuleRef value is + * overwritten then the function is responsible for disposing of the incoming + * module. If the module is simply accessed/mutated in-place then ownership + * returns to the caller and the function does not need to do any lifetime + * management. + * + * Clients can call LLVMOrcLLJITGetIRTransformLayer to obtain the transform + * layer of a LLJIT instance, and use LLVMOrcIRTransformLayerSetTransform + * to set the function. This can be used to override the default transform + * layer. + */ +typedef LLVMErrorRef (*LLVMOrcIRTransformLayerTransformFunction)( + void *Ctx, LLVMOrcThreadSafeModuleRef *ModInOut, + LLVMOrcMaterializationResponsibilityRef MR); + +/** + * A reference to an orc::ObjectTransformLayer instance. + */ +typedef struct LLVMOrcOpaqueObjectTransformLayer + *LLVMOrcObjectTransformLayerRef; + +/** + * A function for applying transformations to an object file buffer. + * + * Implementations of this type are responsible for managing the lifetime + * of the memory buffer pointed to by ObjInOut: If the LLVMMemoryBufferRef + * value is overwritten then the function is responsible for disposing of the + * incoming buffer. If the buffer is simply accessed/mutated in-place then + * ownership returns to the caller and the function does not need to do any + * lifetime management. + * + * The transform is allowed to return an error, in which case the ObjInOut + * buffer should be disposed of and set to null. + */ +typedef LLVMErrorRef (*LLVMOrcObjectTransformLayerTransformFunction)( + void *Ctx, LLVMMemoryBufferRef *ObjInOut); + +/** + * A reference to an orc::IndirectStubsManager instance. + */ +typedef struct LLVMOrcOpaqueIndirectStubsManager + *LLVMOrcIndirectStubsManagerRef; + +/** + * A reference to an orc::LazyCallThroughManager instance. + */ +typedef struct LLVMOrcOpaqueLazyCallThroughManager + *LLVMOrcLazyCallThroughManagerRef; + +/** + * A reference to an orc::DumpObjects object. + * + * Can be used to dump object files to disk with unique names. Useful as an + * ObjectTransformLayer transform. + */ +typedef struct LLVMOrcOpaqueDumpObjects *LLVMOrcDumpObjectsRef; + +/** * Attach a custom error reporter function to the ExecutionSession. * * The error reporter will be called to deliver failure notices that can not be @@ -347,13 +530,290 @@ void LLVMOrcDisposeDefinitionGenerator(LLVMOrcDefinitionGeneratorRef DG); void LLVMOrcDisposeMaterializationUnit(LLVMOrcMaterializationUnitRef MU); /** + * Create a custom MaterializationUnit. + * + * Name is a name for this MaterializationUnit to be used for identification + * and logging purposes (e.g. if this MaterializationUnit produces an + * object buffer then the name of that buffer will be derived from this name). + * + * The Syms list contains the names and linkages of the symbols provided by this + * unit. This function takes ownership of the elements of the Syms array. The + * Name fields of the array elements are taken to have been retained for this + * function. The client should *not* release the elements of the array, but is + * still responsible for destroyingthe array itself. + * + * The InitSym argument indicates whether or not this MaterializationUnit + * contains static initializers. If three are no static initializers (the common + * case) then this argument should be null. If there are static initializers + * then InitSym should be set to a unique name that also appears in the Syms + * list with the LLVMJITSymbolGenericFlagsMaterializationSideEffectsOnly flag + * set. This function takes ownership of the InitSym, which should have been + * retained twice on behalf of this function: once for the Syms entry and once + * for InitSym. If clients wish to use the InitSym value after this function + * returns they must retain it once more for themselves. + * + * If any of the symbols in the Syms list is looked up then the Materialize + * function will be called. + * + * If any of the symbols in the Syms list is overridden then the Discard + * function will be called. + * + * The caller owns the underling MaterializationUnit and is responsible for + * either passing it to a JITDylib (via LLVMOrcJITDylibDefine) or disposing + * of it by calling LLVMOrcDisposeMaterializationUnit. + */ +LLVMOrcMaterializationUnitRef LLVMOrcCreateCustomMaterializationUnit( + const char *Name, void *Ctx, LLVMOrcCSymbolFlagsMapPairs Syms, + size_t NumSyms, LLVMOrcSymbolStringPoolEntryRef InitSym, + LLVMOrcMaterializationUnitMaterializeFunction Materialize, + LLVMOrcMaterializationUnitDiscardFunction Discard, + LLVMOrcMaterializationUnitDestroyFunction Destroy); + +/** * Create a MaterializationUnit to define the given symbols as pointing to * the corresponding raw addresses. + * + * This function takes ownership of the elements of the Syms array. The Name + * fields of the array elements are taken to have been retained for this + * function. This allows the following pattern... + * + * size_t NumPairs; + * LLVMOrcCSymbolMapPairs Sym; + * -- Build Syms array -- + * LLVMOrcMaterializationUnitRef MU = + * LLVMOrcAbsoluteSymbols(Syms, NumPairs); + * + * ... without requiring cleanup of the elements of the Sym array afterwards. + * + * The client is still responsible for deleting the Sym array itself. + * + * If a client wishes to reuse elements of the Sym array after this call they + * must explicitly retain each of the elements for themselves. */ LLVMOrcMaterializationUnitRef LLVMOrcAbsoluteSymbols(LLVMOrcCSymbolMapPairs Syms, size_t NumPairs); /** + * Create a MaterializationUnit to define lazy re-expots. These are callable + * entry points that call through to the given symbols. + * + * This function takes ownership of the CallableAliases array. The Name + * fields of the array elements are taken to have been retained for this + * function. This allows the following pattern... + * + * size_t NumPairs; + * LLVMOrcCSymbolAliasMapPairs CallableAliases; + * -- Build CallableAliases array -- + * LLVMOrcMaterializationUnitRef MU = + * LLVMOrcLazyReexports(LCTM, ISM, JD, CallableAliases, NumPairs); + * + * ... without requiring cleanup of the elements of the CallableAliases array afterwards. + * + * The client is still responsible for deleting the CallableAliases array itself. + * + * If a client wishes to reuse elements of the CallableAliases array after this call they + * must explicitly retain each of the elements for themselves. + */ +LLVMOrcMaterializationUnitRef LLVMOrcLazyReexports( + LLVMOrcLazyCallThroughManagerRef LCTM, LLVMOrcIndirectStubsManagerRef ISM, + LLVMOrcJITDylibRef SourceRef, LLVMOrcCSymbolAliasMapPairs CallableAliases, + size_t NumPairs); +// TODO: ImplSymbolMad SrcJDLoc + +/** + * Disposes of the passed MaterializationResponsibility object. + * + * This should only be done after the symbols covered by the object have either + * been resolved and emitted (via + * LLVMOrcMaterializationResponsibilityNotifyResolved and + * LLVMOrcMaterializationResponsibilityNotifyEmitted) or failed (via + * LLVMOrcMaterializationResponsibilityFailMaterialization). + */ +void LLVMOrcDisposeMaterializationResponsibility( + LLVMOrcMaterializationResponsibilityRef MR); + +/** + * Returns the target JITDylib that these symbols are being materialized into. + */ +LLVMOrcJITDylibRef LLVMOrcMaterializationResponsibilityGetTargetDylib( + LLVMOrcMaterializationResponsibilityRef MR); + +/** + * Returns the ExecutionSession for this MaterializationResponsibility. + */ +LLVMOrcExecutionSessionRef +LLVMOrcMaterializationResponsibilityGetExecutionSession( + LLVMOrcMaterializationResponsibilityRef MR); + +/** + * Returns the symbol flags map for this responsibility instance. + * + * The length of the array is returned in NumPairs and the caller is responsible + * for the returned memory and needs to call LLVMOrcDisposeCSymbolFlagsMap. + * + * To use the returned symbols beyond the livetime of the + * MaterializationResponsibility requires the caller to retain the symbols + * explicitly. + */ +LLVMOrcCSymbolFlagsMapPairs LLVMOrcMaterializationResponsibilityGetSymbols( + LLVMOrcMaterializationResponsibilityRef MR, size_t *NumPairs); + +/** + * Disposes of the passed LLVMOrcCSymbolFlagsMap. + * + * Does not release the entries themselves. + */ +void LLVMOrcDisposeCSymbolFlagsMap(LLVMOrcCSymbolFlagsMapPairs Pairs); + +/** + * Returns the initialization pseudo-symbol, if any. This symbol will also + * be present in the SymbolFlagsMap for this MaterializationResponsibility + * object. + * + * The returned symbol is not retained over any mutating operation of the + * MaterializationResponsbility or beyond the lifetime thereof. + */ +LLVMOrcSymbolStringPoolEntryRef +LLVMOrcMaterializationResponsibilityGetInitializerSymbol( + LLVMOrcMaterializationResponsibilityRef MR); + +/** + * Returns the names of any symbols covered by this + * MaterializationResponsibility object that have queries pending. This + * information can be used to return responsibility for unrequested symbols + * back to the JITDylib via the delegate method. + */ +LLVMOrcSymbolStringPoolEntryRef * +LLVMOrcMaterializationResponsibilityGetRequestedSymbols( + LLVMOrcMaterializationResponsibilityRef MR, size_t *NumSymbols); + +/** + * Disposes of the passed LLVMOrcSymbolStringPoolEntryRef* . + * + * Does not release the symbols themselves. + */ +void LLVMOrcDisposeSymbols(LLVMOrcSymbolStringPoolEntryRef *Symbols); + +/* + * Notifies the target JITDylib that the given symbols have been resolved. + * This will update the given symbols' addresses in the JITDylib, and notify + * any pending queries on the given symbols of their resolution. The given + * symbols must be ones covered by this MaterializationResponsibility + * instance. Individual calls to this method may resolve a subset of the + * symbols, but all symbols must have been resolved prior to calling emit. + * + * This method will return an error if any symbols being resolved have been + * moved to the error state due to the failure of a dependency. If this + * method returns an error then clients should log it and call + * LLVMOrcMaterializationResponsibilityFailMaterialization. If no dependencies + * have been registered for the symbols covered by this + * MaterializationResponsibiility then this method is guaranteed to return + * LLVMErrorSuccess. + */ +LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyResolved( + LLVMOrcMaterializationResponsibilityRef MR, LLVMOrcCSymbolMapPairs Symbols, + size_t NumPairs); + +/** + * Notifies the target JITDylib (and any pending queries on that JITDylib) + * that all symbols covered by this MaterializationResponsibility instance + * have been emitted. + * + * This method will return an error if any symbols being resolved have been + * moved to the error state due to the failure of a dependency. If this + * method returns an error then clients should log it and call + * LLVMOrcMaterializationResponsibilityFailMaterialization. + * If no dependencies have been registered for the symbols covered by this + * MaterializationResponsibiility then this method is guaranteed to return + * LLVMErrorSuccess. + */ +LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyEmitted( + LLVMOrcMaterializationResponsibilityRef MR); + +/** + * Attempt to claim responsibility for new definitions. This method can be + * used to claim responsibility for symbols that are added to a + * materialization unit during the compilation process (e.g. literal pool + * symbols). Symbol linkage rules are the same as for symbols that are + * defined up front: duplicate strong definitions will result in errors. + * Duplicate weak definitions will be discarded (in which case they will + * not be added to this responsibility instance). + * + * This method can be used by materialization units that want to add + * additional symbols at materialization time (e.g. stubs, compile + * callbacks, metadata) + */ +LLVMErrorRef LLVMOrcMaterializationResponsibilityDefineMaterializing( + LLVMOrcMaterializationResponsibilityRef MR, + LLVMOrcCSymbolFlagsMapPairs Pairs, size_t NumPairs); + +/** + * Notify all not-yet-emitted covered by this MaterializationResponsibility + * instance that an error has occurred. + * This will remove all symbols covered by this MaterializationResponsibilty + * from the target JITDylib, and send an error to any queries waiting on + * these symbols. + */ +void LLVMOrcMaterializationResponsibilityFailMaterialization( + LLVMOrcMaterializationResponsibilityRef MR); + +/** + * Transfers responsibility to the given MaterializationUnit for all + * symbols defined by that MaterializationUnit. This allows + * materializers to break up work based on run-time information (e.g. + * by introspecting which symbols have actually been looked up and + * materializing only those). + */ +LLVMErrorRef LLVMOrcMaterializationResponsibilityReplace( + LLVMOrcMaterializationResponsibilityRef MR, + LLVMOrcMaterializationUnitRef MU); + +/** + * Delegates responsibility for the given symbols to the returned + * materialization responsibility. Useful for breaking up work between + * threads, or different kinds of materialization processes. + * + * The caller retains responsibility of the the passed + * MaterializationResponsibility. + */ +LLVMErrorRef LLVMOrcMaterializationResponsibilityDelegate( + LLVMOrcMaterializationResponsibilityRef MR, + LLVMOrcSymbolStringPoolEntryRef *Symbols, size_t NumSymbols, + LLVMOrcMaterializationResponsibilityRef *Result); + +/** + * Adds dependencies to a symbol that the MaterializationResponsibility is + * responsible for. + * + * This function takes ownership of Dependencies struct. The Names + * array have been retained for this function. This allows the following + * pattern... + * + * LLVMOrcSymbolStringPoolEntryRef Names[] = {...}; + * LLVMOrcCDependenceMapPair Dependence = {JD, {Names, sizeof(Names)}} + * LLVMOrcMaterializationResponsibilityAddDependencies(JD, Name, &Dependence, + * 1); + * + * ... without requiring cleanup of the elements of the Names array afterwards. + * + * The client is still responsible for deleting the Dependencies.Names array + * itself. + */ +void LLVMOrcMaterializationResponsibilityAddDependencies( + LLVMOrcMaterializationResponsibilityRef MR, + LLVMOrcSymbolStringPoolEntryRef Name, + LLVMOrcCDependenceMapPairs Dependencies, size_t NumPairs); + +/** + * Adds dependencies to all symbols that the MaterializationResponsibility is + * responsible for. See LLVMOrcMaterializationResponsibilityAddDependencies for + * notes about memory responsibility. + */ +void LLVMOrcMaterializationResponsibilityAddDependenciesForAll( + LLVMOrcMaterializationResponsibilityRef MR, + LLVMOrcCDependenceMapPairs Dependencies, size_t NumPairs); + +/** * Create a "bare" JITDylib. * * The client is responsible for ensuring that the JITDylib's name is unique, @@ -503,11 +963,20 @@ LLVMOrcCreateNewThreadSafeModule(LLVMModuleRef M, void LLVMOrcDisposeThreadSafeModule(LLVMOrcThreadSafeModuleRef TSM); /** + * Apply the given function to the module contained in this ThreadSafeModule. + */ +LLVMErrorRef +LLVMOrcThreadSafeModuleWithModuleDo(LLVMOrcThreadSafeModuleRef TSM, + LLVMOrcGenericIRModuleOperationFunction F, + void *Ctx); + +/** * Create a JITTargetMachineBuilder by detecting the host. * * On success the client owns the resulting JITTargetMachineBuilder. It must be - * passed to a consuming operation (e.g. LLVMOrcCreateLLJITBuilder) or disposed - * of by calling LLVMOrcDisposeJITTargetMachineBuilder. + * passed to a consuming operation (e.g. + * LLVMOrcLLJITBuilderSetJITTargetMachineBuilder) or disposed of by calling + * LLVMOrcDisposeJITTargetMachineBuilder. */ LLVMErrorRef LLVMOrcJITTargetMachineBuilderDetectHost( LLVMOrcJITTargetMachineBuilderRef *Result); @@ -517,8 +986,9 @@ LLVMErrorRef LLVMOrcJITTargetMachineBuilderDetectHost( * * This operation takes ownership of the given TargetMachine and destroys it * before returing. The resulting JITTargetMachineBuilder is owned by the client - * and must be passed to a consuming operation (e.g. LLVMOrcCreateLLJITBuilder) - * or disposed of by calling LLVMOrcDisposeJITTargetMachineBuilder. + * and must be passed to a consuming operation (e.g. + * LLVMOrcLLJITBuilderSetJITTargetMachineBuilder) or disposed of by calling + * LLVMOrcDisposeJITTargetMachineBuilder. */ LLVMOrcJITTargetMachineBuilderRef LLVMOrcJITTargetMachineBuilderCreateFromTargetMachine(LLVMTargetMachineRef TM); @@ -530,10 +1000,139 @@ void LLVMOrcDisposeJITTargetMachineBuilder( LLVMOrcJITTargetMachineBuilderRef JTMB); /** + * Returns the target triple for the given JITTargetMachineBuilder as a string. + * + * The caller owns the resulting string as must dispose of it by calling + * LLVMDisposeMessage + */ +char *LLVMOrcJITTargetMachineBuilderGetTargetTriple( + LLVMOrcJITTargetMachineBuilderRef JTMB); + +/** + * Sets the target triple for the given JITTargetMachineBuilder to the given + * string. + */ +void LLVMOrcJITTargetMachineBuilderSetTargetTriple( + LLVMOrcJITTargetMachineBuilderRef JTMB, const char *TargetTriple); + +/** + * Add an object to an ObjectLayer to the given JITDylib. + * + * Adds a buffer representing an object file to the given JITDylib using the + * given ObjectLayer instance. This operation transfers ownership of the buffer + * to the ObjectLayer instance. The buffer should not be disposed of or + * referenced once this function returns. + * + * Resources associated with the given object will be tracked by the given + * JITDylib's default ResourceTracker. + */ +LLVMErrorRef LLVMOrcObjectLayerAddObjectFile(LLVMOrcObjectLayerRef ObjLayer, + LLVMOrcJITDylibRef JD, + LLVMMemoryBufferRef ObjBuffer); + +/** + * Add an object to an ObjectLayer using the given ResourceTracker. + * + * Adds a buffer representing an object file to the given ResourceTracker's + * JITDylib using the given ObjectLayer instance. This operation transfers + * ownership of the buffer to the ObjectLayer instance. The buffer should not + * be disposed of or referenced once this function returns. + * + * Resources associated with the given object will be tracked by + * ResourceTracker RT. + */ +LLVMErrorRef +LLVMOrcObjectLayerAddObjectFileWithRT(LLVMOrcObjectLayerRef ObjLayer, + LLVMOrcResourceTrackerRef RT, + LLVMMemoryBufferRef ObjBuffer); + +/** + * Emit an object buffer to an ObjectLayer. + * + * Ownership of the responsibility object and object buffer pass to this + * function. The client is not responsible for cleanup. + */ +void LLVMOrcObjectLayerEmit(LLVMOrcObjectLayerRef ObjLayer, + LLVMOrcMaterializationResponsibilityRef R, + LLVMMemoryBufferRef ObjBuffer); + +/** * Dispose of an ObjectLayer. */ void LLVMOrcDisposeObjectLayer(LLVMOrcObjectLayerRef ObjLayer); +void LLVMOrcIRTransformLayerEmit(LLVMOrcIRTransformLayerRef IRTransformLayer, + LLVMOrcMaterializationResponsibilityRef MR, + LLVMOrcThreadSafeModuleRef TSM); + +/** + * Set the transform function of the provided transform layer, passing through a + * pointer to user provided context. + */ +void LLVMOrcIRTransformLayerSetTransform( + LLVMOrcIRTransformLayerRef IRTransformLayer, + LLVMOrcIRTransformLayerTransformFunction TransformFunction, void *Ctx); + +/** + * Set the transform function on an LLVMOrcObjectTransformLayer. + */ +void LLVMOrcObjectTransformLayerSetTransform( + LLVMOrcObjectTransformLayerRef ObjTransformLayer, + LLVMOrcObjectTransformLayerTransformFunction TransformFunction, void *Ctx); + +/** + * Create a LocalIndirectStubsManager from the given target triple. + * + * The resulting IndirectStubsManager is owned by the client + * and must be disposed of by calling LLVMOrcDisposeDisposeIndirectStubsManager. + */ +LLVMOrcIndirectStubsManagerRef +LLVMOrcCreateLocalIndirectStubsManager(const char *TargetTriple); + +/** + * Dispose of an IndirectStubsManager. + */ +void LLVMOrcDisposeIndirectStubsManager(LLVMOrcIndirectStubsManagerRef ISM); + +LLVMErrorRef LLVMOrcCreateLocalLazyCallThroughManager( + const char *TargetTriple, LLVMOrcExecutionSessionRef ES, + LLVMOrcJITTargetAddress ErrorHandlerAddr, + LLVMOrcLazyCallThroughManagerRef *LCTM); + +/** + * Dispose of an LazyCallThroughManager. + */ +void LLVMOrcDisposeLazyCallThroughManager( + LLVMOrcLazyCallThroughManagerRef LCTM); + +/** + * Create a DumpObjects instance. + * + * DumpDir specifies the path to write dumped objects to. DumpDir may be empty + * in which case files will be dumped to the working directory. + * + * IdentifierOverride specifies a file name stem to use when dumping objects. + * If empty then each MemoryBuffer's identifier will be used (with a .o suffix + * added if not already present). If an identifier override is supplied it will + * be used instead, along with an incrementing counter (since all buffers will + * use the same identifier, the resulting files will be named <ident>.o, + * <ident>.2.o, <ident>.3.o, and so on). IdentifierOverride should not contain + * an extension, as a .o suffix will be added by DumpObjects. + */ +LLVMOrcDumpObjectsRef LLVMOrcCreateDumpObjects(const char *DumpDir, + const char *IdentifierOverride); + +/** + * Dispose of a DumpObjects instance. + */ +void LLVMOrcDisposeDumpObjects(LLVMOrcDumpObjectsRef DumpObjects); + +/** + * Dump the contents of the given MemoryBuffer. + */ +LLVMErrorRef LLVMOrcDumpObjects_CallOperator(LLVMOrcDumpObjectsRef DumpObjects, + LLVMMemoryBufferRef *ObjBuffer); + LLVM_C_EXTERN_C_END #endif /* LLVM_C_ORC_H */ diff --git a/contrib/llvm-project/llvm/include/llvm-c/Transforms/PassBuilder.h b/contrib/llvm-project/llvm/include/llvm-c/Transforms/PassBuilder.h new file mode 100644 index 000000000000..5635f10d6877 --- /dev/null +++ b/contrib/llvm-project/llvm/include/llvm-c/Transforms/PassBuilder.h @@ -0,0 +1,102 @@ +/*===-- llvm-c/Transform/PassBuilder.h - PassBuilder for LLVM C ---*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header contains the LLVM-C interface into the new pass manager *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_C_TRANSFORMS_PASSBUILDER_H +#define LLVM_C_TRANSFORMS_PASSBUILDER_H + +#include "llvm-c/Error.h" +#include "llvm-c/TargetMachine.h" +#include "llvm-c/Types.h" + +LLVM_C_EXTERN_C_BEGIN + +/** + * A set of options passed which are attached to the Pass Manager upon run. + * + * This corresponds to an llvm::LLVMPassBuilderOptions instance + * + * The details for how the different properties of this structure are used can + * be found in the source for LLVMRunPasses + */ +typedef struct LLVMOpaquePassBuilderOptions *LLVMPassBuilderOptionsRef; + +/** + * Construct and run a set of passes over a module + * + * This function takes a string with the passes that should be used. The format + * of this string is the same as opt's -passes argument for the new pass + * manager. Individual passes may be specified, separated by commas. Full + * pipelines may also be invoked using `default<O3>` and friends. See opt for + * full reference of the Passes format. + */ +LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes, + LLVMTargetMachineRef TM, + LLVMPassBuilderOptionsRef Options); + +/** + * Create a new set of options for a PassBuilder + * + * Ownership of the returned instance is given to the client, and they are + * responsible for it. The client should call LLVMDisposePassBuilderOptions + * to free the pass builder options. + */ +LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions(); + +/** + * Toggle adding the VerifierPass for the PassBuilder, ensuring all functions + * inside the module is valid. + */ +void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options, + LLVMBool VerifyEach); + +/** + * Toggle debug logging when running the PassBuilder + */ +void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options, + LLVMBool DebugLogging); + +void LLVMPassBuilderOptionsSetLoopInterleaving( + LLVMPassBuilderOptionsRef Options, LLVMBool LoopInterleaving); + +void LLVMPassBuilderOptionsSetLoopVectorization( + LLVMPassBuilderOptionsRef Options, LLVMBool LoopVectorization); + +void LLVMPassBuilderOptionsSetSLPVectorization( + LLVMPassBuilderOptionsRef Options, LLVMBool SLPVectorization); + +void LLVMPassBuilderOptionsSetLoopUnrolling(LLVMPassBuilderOptionsRef Options, + LLVMBool LoopUnrolling); + +void LLVMPassBuilderOptionsSetForgetAllSCEVInLoopUnroll( + LLVMPassBuilderOptionsRef Options, LLVMBool ForgetAllSCEVInLoopUnroll); + +void LLVMPassBuilderOptionsSetLicmMssaOptCap(LLVMPassBuilderOptionsRef Options, + unsigned LicmMssaOptCap); + +void LLVMPassBuilderOptionsSetLicmMssaNoAccForPromotionCap( + LLVMPassBuilderOptionsRef Options, unsigned LicmMssaNoAccForPromotionCap); + +void LLVMPassBuilderOptionsSetCallGraphProfile( + LLVMPassBuilderOptionsRef Options, LLVMBool CallGraphProfile); + +void LLVMPassBuilderOptionsSetMergeFunctions(LLVMPassBuilderOptionsRef Options, + LLVMBool MergeFunctions); + +/** + * Dispose of a heap-allocated PassBuilderOptions instance + */ +void LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options); + +LLVM_C_EXTERN_C_END + +#endif // LLVM_C_TRANSFORMS_PASSBUILDER_H diff --git a/contrib/llvm-project/llvm/include/llvm-c/lto.h b/contrib/llvm-project/llvm/include/llvm-c/lto.h index 4dbc77f294c6..f6fc8588f5f7 100644 --- a/contrib/llvm-project/llvm/include/llvm-c/lto.h +++ b/contrib/llvm-project/llvm/include/llvm-c/lto.h @@ -46,7 +46,7 @@ typedef bool lto_bool_t; * @{ */ -#define LTO_API_VERSION 27 +#define LTO_API_VERSION 28 /** * \since prior to LTO_API_VERSION=3 @@ -527,7 +527,23 @@ extern unsigned int lto_api_version(void); /** - * Sets options to help debug codegen bugs. + * Parses options immediately, making them available as early as possible. For + * example during executing codegen::InitTargetOptionsFromCodeGenFlags. Since + * parsing shud only happen once, only one of lto_codegen_debug_options or + * lto_set_debug_options should be called. + * + * This function takes one or more options separated by spaces. + * Warning: passing file paths through this function may confuse the argument + * parser if the paths contain spaces. + * + * \since LTO_API_VERSION=28 + */ +extern void lto_set_debug_options(const char *const *options, int number); + +/** + * Sets options to help debug codegen bugs. Since parsing shud only happen once, + * only one of lto_codegen_debug_options or lto_set_debug_options + * should be called. * * This function takes one or more options separated by spaces. * Warning: passing file paths through this function may confuse the argument |