From 936ca043c0db3fd09fd2c1403ba5779f7f8c6d9c Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Thu, 22 Aug 2024 15:39:36 +0200 Subject: [PATCH] Clean-up LLVMExtra headers. (#450) --- deps/LLVMExtra/include/LLVMExtra.h | 153 +++++++++------------ deps/LLVMExtra/lib/Core.cpp | 205 +++++++++++++++++------------ lib/15/libLLVM_extra.jl | 136 +++++++++---------- lib/16/libLLVM_extra.jl | 136 +++++++++---------- lib/17/libLLVM_extra.jl | 128 +++++++++--------- lib/18/libLLVM_extra.jl | 128 +++++++++--------- 6 files changed, 451 insertions(+), 435 deletions(-) diff --git a/deps/LLVMExtra/include/LLVMExtra.h b/deps/LLVMExtra/include/LLVMExtra.h index 8f2edbc9..b003a7c6 100644 --- a/deps/LLVMExtra/include/LLVMExtra.h +++ b/deps/LLVMExtra/include/LLVMExtra.h @@ -15,6 +15,7 @@ LLVM_C_EXTERN_C_BEGIN // maybe LLVM_C_EXTERN_C_BEGIN somehow eats the function definition? void dummy(); +// Initialization functions LLVMBool LLVMExtraInitializeNativeTarget(void); LLVMBool LLVMExtraInitializeNativeAsmParser(void); LLVMBool LLVMExtraInitializeNativeAsmPrinter(void); @@ -27,7 +28,7 @@ typedef enum { LLVMDebugEmissionKindDebugDirectivesOnly = 3 } LLVMDebugEmissionKind; -// Various missing passes (being upstreamed) +// Missing LegacyPM passes void LLVMAddBarrierNoopPass(LLVMPassManagerRef PM); #if LLVM_VERSION_MAJOR < 17 void LLVMAddDivRemPairsPass(LLVMPassManagerRef PM); @@ -46,36 +47,50 @@ void LLVMAddInductiveRangeCheckEliminationPass(LLVMPassManagerRef PM); #endif void LLVMAddSimpleLoopUnswitchLegacyPass(LLVMPassManagerRef PM); void LLVMAddExpandReductionsPass(LLVMPassManagerRef PM); +#if LLVM_VERSION_MAJOR >= 17 +void LLVMAddCFGSimplificationPass2(LLVMPassManagerRef PM, int BonusInstThreshold, + LLVMBool ForwardSwitchCondToPhi, + LLVMBool ConvertSwitchToLookupTable, + LLVMBool NeedCanonicalLoop, LLVMBool HoistCommonInsts, + LLVMBool SinkCommonInsts, LLVMBool SimplifyCondBranch, + LLVMBool SpeculateBlocks); +#else +void LLVMAddCFGSimplificationPass2(LLVMPassManagerRef PM, int BonusInstThreshold, + LLVMBool ForwardSwitchCondToPhi, + LLVMBool ConvertSwitchToLookupTable, + LLVMBool NeedCanonicalLoop, LLVMBool HoistCommonInsts, + LLVMBool SinkCommonInsts, LLVMBool SimplifyCondBranch, + LLVMBool FoldTwoEntryPHINode); +#endif +#if LLVM_VERSION_MAJOR < 17 +void LLVMAddInternalizePassWithExportList(LLVMPassManagerRef PM, const char **ExportList, + size_t Length); +#endif - -// Infrastructure for writing LLVM passes in Julia +// Custom LegacyPM pass infrastructure typedef struct LLVMOpaquePass *LLVMPassRef; - void LLVMAddPass(LLVMPassManagerRef PM, LLVMPassRef P); typedef LLVMBool (*LLVMPassCallback)(void *Ref, void *Data); - LLVMPassRef LLVMCreateModulePass2(const char *Name, LLVMPassCallback Callback, void *Data); - LLVMPassRef LLVMCreateFunctionPass2(const char *Name, LLVMPassCallback Callback, void *Data); -// Various missing functions - +// Missing functionality void LLVMAddTargetLibraryInfoByTriple(const char *T, LLVMPassManagerRef PM); -#if LLVM_VERSION_MAJOR < 17 -void LLVMAddInternalizePassWithExportList(LLVMPassManagerRef PM, const char **ExportList, - size_t Length); -#endif - void LLVMAppendToUsed(LLVMModuleRef Mod, LLVMValueRef *Values, size_t Count); void LLVMAppendToCompilerUsed(LLVMModuleRef Mod, LLVMValueRef *Values, size_t Count); void LLVMAddGenericAnalysisPasses(LLVMPassManagerRef PM); - void LLVMDumpMetadata(LLVMMetadataRef MD); - char *LLVMPrintMetadataToString(LLVMMetadataRef MD); - const char *LLVMDIScopeGetName(LLVMMetadataRef File, unsigned *Len); +void LLVMFunctionDeleteBody(LLVMValueRef Func); +void LLVMDestroyConstant(LLVMValueRef Const); +LLVMTypeRef LLVMGetFunctionType(LLVMValueRef Fn); +LLVMTypeRef LLVMGetGlobalValueType(LLVMValueRef Fn); + +// Bug fixes +void LLVMSetInitializer2(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal); +void LLVMSetPersonalityFn2(LLVMValueRef Fn, LLVMValueRef PersonalityFn); // APIs without MetadataAsValue const char *LLVMGetMDString2(LLVMMetadataRef MD, unsigned *Length); @@ -86,45 +101,20 @@ void LLVMGetNamedMetadataOperands2(LLVMNamedMDNodeRef NMD, LLVMMetadataRef *Dest void LLVMAddNamedMetadataOperand2(LLVMNamedMDNodeRef NMD, LLVMMetadataRef Val); void LLVMReplaceMDNodeOperandWith2(LLVMMetadataRef MD, unsigned I, LLVMMetadataRef New); +// ORC API extensions typedef struct LLVMOrcOpaqueIRCompileLayer *LLVMOrcIRCompileLayerRef; - void LLVMOrcIRCompileLayerEmit(LLVMOrcIRCompileLayerRef IRLayer, LLVMOrcMaterializationResponsibilityRef MR, LLVMOrcThreadSafeModuleRef TSM); - char *LLVMDumpJitDylibToString(LLVMOrcJITDylibRef JD); -LLVMTypeRef LLVMGetFunctionType(LLVMValueRef Fn); -LLVMTypeRef LLVMGetGlobalValueType(LLVMValueRef Fn); - -#if LLVM_VERSION_MAJOR >= 17 -void LLVMAddCFGSimplificationPass2(LLVMPassManagerRef PM, int BonusInstThreshold, - LLVMBool ForwardSwitchCondToPhi, - LLVMBool ConvertSwitchToLookupTable, - LLVMBool NeedCanonicalLoop, LLVMBool HoistCommonInsts, - LLVMBool SinkCommonInsts, LLVMBool SimplifyCondBranch, - LLVMBool SpeculateBlocks); -#else -void LLVMAddCFGSimplificationPass2(LLVMPassManagerRef PM, int BonusInstThreshold, - LLVMBool ForwardSwitchCondToPhi, - LLVMBool ConvertSwitchToLookupTable, - LLVMBool NeedCanonicalLoop, LLVMBool HoistCommonInsts, - LLVMBool SinkCommonInsts, LLVMBool SimplifyCondBranch, - LLVMBool FoldTwoEntryPHINode); -#endif - - -// Bug fixes -void LLVMSetInitializer2(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal); -void LLVMSetPersonalityFn2(LLVMValueRef Fn, LLVMValueRef PersonalityFn); - +// Cloning functionality typedef enum { LLVMCloneFunctionChangeTypeLocalChangesOnly = 0, LLVMCloneFunctionChangeTypeGlobalChanges = 1, LLVMCloneFunctionChangeTypeDifferentModule = 2, LLVMCloneFunctionChangeTypeClonedModule = 3 } LLVMCloneFunctionChangeType; - void LLVMCloneFunctionInto(LLVMValueRef NewFunc, LLVMValueRef OldFunc, LLVMValueRef *ValueMap, unsigned ValueMapElements, LLVMCloneFunctionChangeType Changes, const char *NameSuffix, @@ -132,18 +122,12 @@ void LLVMCloneFunctionInto(LLVMValueRef NewFunc, LLVMValueRef OldFunc, void *TypeMapperData, LLVMValueRef (*Materializer)(LLVMValueRef, void *), void *MaterializerData); - LLVMBasicBlockRef LLVMCloneBasicBlock(LLVMBasicBlockRef BB, const char *NameSuffix, LLVMValueRef *ValueMap, unsigned ValueMapElements, LLVMValueRef F); -void LLVMFunctionDeleteBody(LLVMValueRef Func); - -void LLVMDestroyConstant(LLVMValueRef Const); - - -// operand bundles (backport of llvm-project/llvm#73914) -#if LLVM_VERSION_MAJOR < 18 +// Operand bundles +#if LLVM_VERSION_MAJOR < 18 // llvm-project/llvm#73914 typedef struct LLVMOpaqueOperandBundle *LLVMOperandBundleRef; LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag, size_t TagLen, LLVMValueRef *Args, @@ -167,42 +151,37 @@ LLVMBuildCallWithOperandBundles(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn, unsigned NumBundles, const char *Name); #endif - -// metadata +// Metadata API extensions LLVMValueRef LLVMMetadataAsValue2(LLVMContextRef C, LLVMMetadataRef Metadata); void LLVMReplaceAllMetadataUsesWith(LLVMValueRef Old, LLVMValueRef New); -#if LLVM_VERSION_MAJOR < 17 +#if LLVM_VERSION_MAJOR < 17 // D136637 void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index, LLVMMetadataRef Replacement); #endif -// constant data +// Constant data LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy, const void *Data, unsigned NumElements); - -// missing opaque pointer APIs +// Missing opaque pointer APIs #if LLVM_VERSION_MAJOR < 17 LLVMBool LLVMContextSupportsTypedPointers(LLVMContextRef C); #endif - // (Post)DominatorTree typedef struct LLVMOpaqueDominatorTree *LLVMDominatorTreeRef; LLVMDominatorTreeRef LLVMCreateDominatorTree(LLVMValueRef Fn); void LLVMDisposeDominatorTree(LLVMDominatorTreeRef Tree); LLVMBool LLVMDominatorTreeInstructionDominates(LLVMDominatorTreeRef Tree, LLVMValueRef InstA, LLVMValueRef InstB); - typedef struct LLVMOpaquePostDominatorTree *LLVMPostDominatorTreeRef; LLVMPostDominatorTreeRef LLVMCreatePostDominatorTree(LLVMValueRef Fn); void LLVMDisposePostDominatorTree(LLVMPostDominatorTreeRef Tree); LLVMBool LLVMPostDominatorTreeInstructionDominates(LLVMPostDominatorTreeRef Tree, LLVMValueRef InstA, LLVMValueRef InstB); - -// fastmath (backport of llvm/llvm-project#75123) -#if LLVM_VERSION_MAJOR < 18 +// fastmath +#if LLVM_VERSION_MAJOR < 18 // llvm/llvm-project#75123 enum { LLVMFastMathAllowReassoc = (1 << 0), LLVMFastMathNoNaNs = (1 << 1), @@ -217,12 +196,34 @@ enum { LLVMFastMathAllowContract | LLVMFastMathApproxFunc, }; typedef unsigned LLVMFastMathFlags; - LLVMFastMathFlags LLVMGetFastMathFlags(LLVMValueRef FPMathInst); void LLVMSetFastMathFlags(LLVMValueRef FPMathInst, LLVMFastMathFlags FMF); LLVMBool LLVMCanValueUseFastMathFlags(LLVMValueRef Inst); #endif +// atomics with syncscope +#if LLVM_VERSION_MAJOR < 20 // llvm/llvm-project#104775 +unsigned LLVMGetSyncScopeID(LLVMContextRef C, const char *Name, size_t SLen); +LLVMValueRef LLVMBuildFenceSyncScope(LLVMBuilderRef B, LLVMAtomicOrdering ordering, + unsigned SSID, const char *Name); +LLVMValueRef LLVMBuildAtomicRMWSyncScope(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, + LLVMValueRef PTR, LLVMValueRef Val, + LLVMAtomicOrdering ordering, unsigned SSID); +LLVMValueRef LLVMBuildAtomicCmpXchgSyncScope(LLVMBuilderRef B, LLVMValueRef Ptr, + LLVMValueRef Cmp, LLVMValueRef New, + LLVMAtomicOrdering SuccessOrdering, + LLVMAtomicOrdering FailureOrdering, + unsigned SSID); +LLVMBool LLVMIsAtomic(LLVMValueRef Inst); +unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst); +void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID); +#endif + +// more LLVMContextRef APIs +#if LLVM_VERSION_MAJOR < 20 // llvm/llvm-project#99087 +LLVMContextRef LLVMGetValueContext(LLVMValueRef Val); +LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder); +#endif // NewPM extensions typedef struct LLVMOpaquePassBuilderExtensions *LLVMPassBuilderExtensionsRef; @@ -240,7 +241,7 @@ void LLVMPassBuilderExtensionsRegisterFunctionPass(LLVMPassBuilderExtensionsRef const char *PassName, LLVMJuliaFunctionPassCallback Callback, void *Thunk); -#if LLVM_VERSION_MAJOR < 20 +#if LLVM_VERSION_MAJOR < 20 // llvm/llvm-project#102482 void LLVMPassBuilderExtensionsSetAAPipeline(LLVMPassBuilderExtensionsRef Extensions, const char *AAPipeline); #endif @@ -252,29 +253,5 @@ LLVMErrorRef LLVMRunJuliaPassesOnFunction(LLVMValueRef F, const char *Passes, LLVMPassBuilderOptionsRef Options, LLVMPassBuilderExtensionsRef Extensions); -// atomics with syncscope (backport of llvm/llvm-project#104775) -#if LLVM_VERSION_MAJOR < 20 -unsigned LLVMGetSyncScopeID(LLVMContextRef C, const char *Name, size_t SLen); -LLVMValueRef LLVMBuildFenceSyncScope(LLVMBuilderRef B, LLVMAtomicOrdering ordering, - unsigned SSID, const char *Name); -LLVMValueRef LLVMBuildAtomicRMWSyncScope(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, - LLVMValueRef PTR, LLVMValueRef Val, - LLVMAtomicOrdering ordering, unsigned SSID); -LLVMValueRef LLVMBuildAtomicCmpXchgSyncScope(LLVMBuilderRef B, LLVMValueRef Ptr, - LLVMValueRef Cmp, LLVMValueRef New, - LLVMAtomicOrdering SuccessOrdering, - LLVMAtomicOrdering FailureOrdering, - unsigned SSID); -LLVMBool LLVMIsAtomic(LLVMValueRef Inst); -unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst); -void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID); -#endif - -// more LLVMContextRef getters (backport of llvm/llvm-project#99087) -#if LLVM_VERSION_MAJOR < 20 -LLVMContextRef LLVMGetValueContext(LLVMValueRef Val); -LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder); -#endif - LLVM_C_EXTERN_C_END #endif diff --git a/deps/LLVMExtra/lib/Core.cpp b/deps/LLVMExtra/lib/Core.cpp index ae7f36cf..7fa8514f 100644 --- a/deps/LLVMExtra/lib/Core.cpp +++ b/deps/LLVMExtra/lib/Core.cpp @@ -35,8 +35,10 @@ using namespace llvm; using namespace llvm::legacy; +// // Initialization functions // + // The LLVMInitialize* functions and friends are defined `static inline` LLVMBool LLVMExtraInitializeNativeTarget() { return InitializeNativeTarget(); } @@ -51,7 +53,10 @@ LLVMBool LLVMExtraInitializeNativeDisassembler() { return InitializeNativeTargetDisassembler(); } -// Various missing passes (being upstreamed) + +// +// Missing LegacyPM passes +// void LLVMAddBarrierNoopPass(LLVMPassManagerRef PM) { unwrap(PM)->add(createBarrierNoopPass()); @@ -106,8 +111,62 @@ void LLVMAddSimpleLoopUnswitchLegacyPass(LLVMPassManagerRef PM) { void LLVMAddExpandReductionsPass(LLVMPassManagerRef PM) { unwrap(PM)->add(createExpandReductionsPass()); } +#if LLVM_VERSION_MAJOR >= 17 +void LLVMAddCFGSimplificationPass2(LLVMPassManagerRef PM, int BonusInstThreshold, + LLVMBool ForwardSwitchCondToPhi, + LLVMBool ConvertSwitchToLookupTable, + LLVMBool NeedCanonicalLoop, LLVMBool HoistCommonInsts, + LLVMBool SinkCommonInsts, LLVMBool SimplifyCondBranch, + LLVMBool SpeculateBlocks) { + auto simplifyCFGOptions = SimplifyCFGOptions() + .bonusInstThreshold(BonusInstThreshold) + .forwardSwitchCondToPhi(ForwardSwitchCondToPhi) + .convertSwitchToLookupTable(ConvertSwitchToLookupTable) + .needCanonicalLoops(NeedCanonicalLoop) + .hoistCommonInsts(HoistCommonInsts) + .sinkCommonInsts(SinkCommonInsts) + .setSimplifyCondBranch(SimplifyCondBranch) + .speculateBlocks(SpeculateBlocks); + unwrap(PM)->add(createCFGSimplificationPass(simplifyCFGOptions)); +} +#else +void LLVMAddCFGSimplificationPass2(LLVMPassManagerRef PM, int BonusInstThreshold, + LLVMBool ForwardSwitchCondToPhi, + LLVMBool ConvertSwitchToLookupTable, + LLVMBool NeedCanonicalLoop, LLVMBool HoistCommonInsts, + LLVMBool SinkCommonInsts, LLVMBool SimplifyCondBranch, + LLVMBool FoldTwoEntryPHINode) { + auto simplifyCFGOptions = SimplifyCFGOptions() + .bonusInstThreshold(BonusInstThreshold) + .forwardSwitchCondToPhi(ForwardSwitchCondToPhi) + .convertSwitchToLookupTable(ConvertSwitchToLookupTable) + .needCanonicalLoops(NeedCanonicalLoop) + .hoistCommonInsts(HoistCommonInsts) + .sinkCommonInsts(SinkCommonInsts) + .setSimplifyCondBranch(SimplifyCondBranch) + .setFoldTwoEntryPHINode(FoldTwoEntryPHINode); + unwrap(PM)->add(createCFGSimplificationPass(simplifyCFGOptions)); +} +#endif -// Infrastructure for writing LLVM passes in Julia +#if LLVM_VERSION_MAJOR < 17 +void LLVMAddInternalizePassWithExportList(LLVMPassManagerRef PM, const char **ExportList, + size_t Length) { + auto PreserveFobj = [=](const GlobalValue &GV) { + for (size_t i = 0; i < Length; i++) { + if (strcmp(ExportList[i], GV.getName().data()) == 0) + return true; + } + return false; + }; + unwrap(PM)->add(createInternalizePass(PreserveFobj)); +} +#endif + + +// +// Custom LegacyPM pass infrastructure +// typedef struct LLVMOpaquePass *LLVMPassRef; DEFINE_STDCXX_CONVERSION_FUNCTIONS(Pass, LLVMPassRef) @@ -169,26 +228,15 @@ LLVMPassRef LLVMCreateFunctionPass2(const char *Name, LLVMPassCallback Callback, return wrap(new JuliaFunctionPass(Name, Callback, Data)); } -// Various missing functions + +// +// Missing functionality +// void LLVMAddTargetLibraryInfoByTriple(const char *T, LLVMPassManagerRef PM) { unwrap(PM)->add(new TargetLibraryInfoWrapperPass(Triple(T))); } -#if LLVM_VERSION_MAJOR < 17 -void LLVMAddInternalizePassWithExportList(LLVMPassManagerRef PM, const char **ExportList, - size_t Length) { - auto PreserveFobj = [=](const GlobalValue &GV) { - for (size_t i = 0; i < Length; i++) { - if (strcmp(ExportList[i], GV.getName().data()) == 0) - return true; - } - return false; - }; - unwrap(PM)->add(createInternalizePass(PreserveFobj)); -} -#endif - void LLVMAppendToUsed(LLVMModuleRef Mod, LLVMValueRef *Values, size_t Count) { SmallVector GlobalValues; for (auto *Value : ArrayRef(Values, Count)) @@ -231,45 +279,39 @@ char *LLVMPrintMetadataToString(LLVMMetadataRef MD) { return strdup(buf.c_str()); } -#if LLVM_VERSION_MAJOR >= 17 -void LLVMAddCFGSimplificationPass2(LLVMPassManagerRef PM, int BonusInstThreshold, - LLVMBool ForwardSwitchCondToPhi, - LLVMBool ConvertSwitchToLookupTable, - LLVMBool NeedCanonicalLoop, LLVMBool HoistCommonInsts, - LLVMBool SinkCommonInsts, LLVMBool SimplifyCondBranch, - LLVMBool SpeculateBlocks) { - auto simplifyCFGOptions = SimplifyCFGOptions() - .bonusInstThreshold(BonusInstThreshold) - .forwardSwitchCondToPhi(ForwardSwitchCondToPhi) - .convertSwitchToLookupTable(ConvertSwitchToLookupTable) - .needCanonicalLoops(NeedCanonicalLoop) - .hoistCommonInsts(HoistCommonInsts) - .sinkCommonInsts(SinkCommonInsts) - .setSimplifyCondBranch(SimplifyCondBranch) - .speculateBlocks(SpeculateBlocks); - unwrap(PM)->add(createCFGSimplificationPass(simplifyCFGOptions)); +void LLVMFunctionDeleteBody(LLVMValueRef Func) { unwrap(Func)->deleteBody(); } + +void LLVMDestroyConstant(LLVMValueRef Const) { unwrap(Const)->destroyConstant(); } + +LLVMTypeRef LLVMGetFunctionType(LLVMValueRef Fn) { + auto Ftype = unwrap(Fn)->getFunctionType(); + return wrap(Ftype); } -#else -void LLVMAddCFGSimplificationPass2(LLVMPassManagerRef PM, int BonusInstThreshold, - LLVMBool ForwardSwitchCondToPhi, - LLVMBool ConvertSwitchToLookupTable, - LLVMBool NeedCanonicalLoop, LLVMBool HoistCommonInsts, - LLVMBool SinkCommonInsts, LLVMBool SimplifyCondBranch, - LLVMBool FoldTwoEntryPHINode) { - auto simplifyCFGOptions = SimplifyCFGOptions() - .bonusInstThreshold(BonusInstThreshold) - .forwardSwitchCondToPhi(ForwardSwitchCondToPhi) - .convertSwitchToLookupTable(ConvertSwitchToLookupTable) - .needCanonicalLoops(NeedCanonicalLoop) - .hoistCommonInsts(HoistCommonInsts) - .sinkCommonInsts(SinkCommonInsts) - .setSimplifyCondBranch(SimplifyCondBranch) - .setFoldTwoEntryPHINode(FoldTwoEntryPHINode); - unwrap(PM)->add(createCFGSimplificationPass(simplifyCFGOptions)); + +LLVMTypeRef LLVMGetGlobalValueType(LLVMValueRef GV) { + auto Ftype = unwrap(GV)->getValueType(); + return wrap(Ftype); } -#endif -// versions of API without MetadataAsValue + +// +// Bug fixes +// + +void LLVMSetInitializer2(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal) { + unwrap(GlobalVar)->setInitializer( + ConstantVal ? unwrap(ConstantVal) : nullptr); +} + +void LLVMSetPersonalityFn2(LLVMValueRef Fn, LLVMValueRef PersonalityFn) { + unwrap(Fn)->setPersonalityFn(PersonalityFn ? unwrap(PersonalityFn) + : nullptr); +} + + +// +// APIs without MetadataAsValue +// const char *LLVMGetMDString2(LLVMMetadataRef MD, unsigned *Length) { const MDString *S = unwrap(MD); @@ -306,17 +348,10 @@ void LLVMReplaceMDNodeOperandWith2(LLVMMetadataRef MD, unsigned I, LLVMMetadataR unwrap(MD)->replaceOperandWith(I, unwrap(New)); } -// Bug fixes (TODO: upstream these) - -void LLVMSetInitializer2(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal) { - unwrap(GlobalVar)->setInitializer( - ConstantVal ? unwrap(ConstantVal) : nullptr); -} -void LLVMSetPersonalityFn2(LLVMValueRef Fn, LLVMValueRef PersonalityFn) { - unwrap(Fn)->setPersonalityFn(PersonalityFn ? unwrap(PersonalityFn) - : nullptr); -} +// +// ORC API extensions +// DEFINE_SIMPLE_CONVERSION_FUNCTIONS(orc::MaterializationResponsibility, LLVMOrcMaterializationResponsibilityRef) @@ -344,6 +379,11 @@ char *LLVMDumpJitDylibToString(LLVMOrcJITDylibRef JD) { return strdup(str.c_str()); } + +// +// Cloning functionality +// + class ExternalTypeRemapper : public ValueMapTypeRemapper { public: ExternalTypeRemapper(LLVMTypeRef (*fptr)(LLVMTypeRef, void *), void *data) @@ -417,12 +457,10 @@ LLVMBasicBlockRef LLVMCloneBasicBlock(LLVMBasicBlockRef BB, const char *NameSuff return wrap(NewBB); } -void LLVMFunctionDeleteBody(LLVMValueRef Func) { unwrap(Func)->deleteBody(); } -void LLVMDestroyConstant(LLVMValueRef Const) { unwrap(Const)->destroyConstant(); } - - -// operand bundles +// +// Operand bundles +// #if LLVM_VERSION_MAJOR < 18 @@ -496,7 +534,9 @@ LLVMBuildCallWithOperandBundles(LLVMBuilderRef B, LLVMTypeRef Ty, #endif -// metadata +// +// Metadata API extensions +// LLVMValueRef LLVMMetadataAsValue2(LLVMContextRef C, LLVMMetadataRef Metadata) { auto *MD = unwrap(Metadata); @@ -510,7 +550,6 @@ void LLVMReplaceAllMetadataUsesWith(LLVMValueRef Old, LLVMValueRef New) { ValueAsMetadata::handleRAUW(unwrap(Old), unwrap(New)); } -// back-port of D136637 #if LLVM_VERSION_MAJOR < 17 void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index, LLVMMetadataRef Replacement) { @@ -521,7 +560,9 @@ void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index, #endif -// constant data +// +// Constant data +// LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy, const void *Data, unsigned NumElements) { @@ -531,7 +572,9 @@ LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy, const void *Data, } -// missing opaque pointer APIs +// +// Missing opaque pointer APIs +// #if LLVM_VERSION_MAJOR < 17 LLVMBool LLVMContextSupportsTypedPointers(LLVMContextRef C) { @@ -539,18 +582,10 @@ LLVMBool LLVMContextSupportsTypedPointers(LLVMContextRef C) { } #endif -LLVMTypeRef LLVMGetFunctionType(LLVMValueRef Fn) { - auto Ftype = unwrap(Fn)->getFunctionType(); - return wrap(Ftype); -} - -LLVMTypeRef LLVMGetGlobalValueType(LLVMValueRef GV) { - auto Ftype = unwrap(GV)->getValueType(); - return wrap(Ftype); -} - +// // DominatorTree and PostDominatorTree +// DEFINE_STDCXX_CONVERSION_FUNCTIONS(DominatorTree, LLVMDominatorTreeRef) @@ -579,7 +614,9 @@ LLVMBool LLVMPostDominatorTreeInstructionDominates(LLVMPostDominatorTreeRef Tree } -// fastmath (backport of llvm/llvm-project#75123) +// +// fastmath +// #if LLVM_VERSION_MAJOR < 18 @@ -735,7 +772,9 @@ void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID) { } +// // more LLVMContextRef getters +// #if LLVM_VERSION_MAJOR < 20 diff --git a/lib/15/libLLVM_extra.jl b/lib/15/libLLVM_extra.jl index 892df38e..2c3565fd 100644 --- a/lib/15/libLLVM_extra.jl +++ b/lib/15/libLLVM_extra.jl @@ -71,6 +71,14 @@ function LLVMAddExpandReductionsPass(PM) ccall((:LLVMAddExpandReductionsPass, libLLVMExtra), Cvoid, (LLVMPassManagerRef,), PM) end +function LLVMAddCFGSimplificationPass2(PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, FoldTwoEntryPHINode) + ccall((:LLVMAddCFGSimplificationPass2, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Cint, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool), PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, FoldTwoEntryPHINode) +end + +function LLVMAddInternalizePassWithExportList(PM, ExportList, Length) + ccall((:LLVMAddInternalizePassWithExportList, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Ptr{Cstring}, Csize_t), PM, ExportList, Length) +end + mutable struct LLVMOpaquePass end const LLVMPassRef = Ptr{LLVMOpaquePass} @@ -94,10 +102,6 @@ function LLVMAddTargetLibraryInfoByTriple(T, PM) ccall((:LLVMAddTargetLibraryInfoByTriple, libLLVMExtra), Cvoid, (Cstring, LLVMPassManagerRef), T, PM) end -function LLVMAddInternalizePassWithExportList(PM, ExportList, Length) - ccall((:LLVMAddInternalizePassWithExportList, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Ptr{Cstring}, Csize_t), PM, ExportList, Length) -end - function LLVMAppendToUsed(Mod, Values, Count) ccall((:LLVMAppendToUsed, libLLVMExtra), Cvoid, (LLVMModuleRef, Ptr{LLVMValueRef}, Csize_t), Mod, Values, Count) end @@ -122,6 +126,30 @@ function LLVMDIScopeGetName(File, Len) ccall((:LLVMDIScopeGetName, libLLVMExtra), Cstring, (LLVMMetadataRef, Ptr{Cuint}), File, Len) end +function LLVMFunctionDeleteBody(Func) + ccall((:LLVMFunctionDeleteBody, libLLVMExtra), Cvoid, (LLVMValueRef,), Func) +end + +function LLVMDestroyConstant(Const) + ccall((:LLVMDestroyConstant, libLLVMExtra), Cvoid, (LLVMValueRef,), Const) +end + +function LLVMGetFunctionType(Fn) + ccall((:LLVMGetFunctionType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) +end + +function LLVMGetGlobalValueType(Fn) + ccall((:LLVMGetGlobalValueType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) +end + +function LLVMSetInitializer2(GlobalVar, ConstantVal) + ccall((:LLVMSetInitializer2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), GlobalVar, ConstantVal) +end + +function LLVMSetPersonalityFn2(Fn, PersonalityFn) + ccall((:LLVMSetPersonalityFn2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), Fn, PersonalityFn) +end + function LLVMGetMDString2(MD, Length) ccall((:LLVMGetMDString2, libLLVMExtra), Cstring, (LLVMMetadataRef, Ptr{Cuint}), MD, Length) end @@ -162,26 +190,6 @@ function LLVMDumpJitDylibToString(JD) ccall((:LLVMDumpJitDylibToString, libLLVMExtra), Cstring, (LLVMOrcJITDylibRef,), JD) end -function LLVMGetFunctionType(Fn) - ccall((:LLVMGetFunctionType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) -end - -function LLVMGetGlobalValueType(Fn) - ccall((:LLVMGetGlobalValueType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) -end - -function LLVMAddCFGSimplificationPass2(PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, FoldTwoEntryPHINode) - ccall((:LLVMAddCFGSimplificationPass2, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Cint, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool), PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, FoldTwoEntryPHINode) -end - -function LLVMSetInitializer2(GlobalVar, ConstantVal) - ccall((:LLVMSetInitializer2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), GlobalVar, ConstantVal) -end - -function LLVMSetPersonalityFn2(Fn, PersonalityFn) - ccall((:LLVMSetPersonalityFn2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), Fn, PersonalityFn) -end - @cenum LLVMCloneFunctionChangeType::UInt32 begin LLVMCloneFunctionChangeTypeLocalChangesOnly = 0 LLVMCloneFunctionChangeTypeGlobalChanges = 1 @@ -197,14 +205,6 @@ function LLVMCloneBasicBlock(BB, NameSuffix, ValueMap, ValueMapElements, F) ccall((:LLVMCloneBasicBlock, libLLVMExtra), LLVMBasicBlockRef, (LLVMBasicBlockRef, Cstring, Ptr{LLVMValueRef}, Cuint, LLVMValueRef), BB, NameSuffix, ValueMap, ValueMapElements, F) end -function LLVMFunctionDeleteBody(Func) - ccall((:LLVMFunctionDeleteBody, libLLVMExtra), Cvoid, (LLVMValueRef,), Func) -end - -function LLVMDestroyConstant(Const) - ccall((:LLVMDestroyConstant, libLLVMExtra), Cvoid, (LLVMValueRef,), Const) -end - mutable struct LLVMOpaqueOperandBundle end const LLVMOperandBundleRef = Ptr{LLVMOpaqueOperandBundle} @@ -323,6 +323,42 @@ function LLVMCanValueUseFastMathFlags(Inst) ccall((:LLVMCanValueUseFastMathFlags, libLLVMExtra), LLVMBool, (LLVMValueRef,), Inst) end +function LLVMGetSyncScopeID(C, Name, SLen) + ccall((:LLVMGetSyncScopeID, libLLVMExtra), Cuint, (LLVMContextRef, Cstring, Csize_t), C, Name, SLen) +end + +function LLVMBuildFenceSyncScope(B, ordering, SSID, Name) + ccall((:LLVMBuildFenceSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicOrdering, Cuint, Cstring), B, ordering, SSID, Name) +end + +function LLVMBuildAtomicRMWSyncScope(B, op, PTR, Val, ordering, SSID) + ccall((:LLVMBuildAtomicRMWSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicRMWBinOp, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, Cuint), B, op, PTR, Val, ordering, SSID) +end + +function LLVMBuildAtomicCmpXchgSyncScope(B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) + ccall((:LLVMBuildAtomicCmpXchgSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMValueRef, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, LLVMAtomicOrdering, Cuint), B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) +end + +function LLVMIsAtomic(Inst) + ccall((:LLVMIsAtomic, libLLVMExtra), LLVMBool, (LLVMValueRef,), Inst) +end + +function LLVMGetAtomicSyncScopeID(AtomicInst) + ccall((:LLVMGetAtomicSyncScopeID, libLLVMExtra), Cuint, (LLVMValueRef,), AtomicInst) +end + +function LLVMSetAtomicSyncScopeID(AtomicInst, SSID) + ccall((:LLVMSetAtomicSyncScopeID, libLLVMExtra), Cvoid, (LLVMValueRef, Cuint), AtomicInst, SSID) +end + +function LLVMGetValueContext(Val) + ccall((:LLVMGetValueContext, libLLVMExtra), LLVMContextRef, (LLVMValueRef,), Val) +end + +function LLVMGetBuilderContext(Builder) + ccall((:LLVMGetBuilderContext, libLLVMExtra), LLVMContextRef, (LLVMBuilderRef,), Builder) +end + mutable struct LLVMOpaquePassBuilderExtensions end const LLVMPassBuilderExtensionsRef = Ptr{LLVMOpaquePassBuilderExtensions} @@ -365,39 +401,3 @@ function LLVMRunJuliaPassesOnFunction(F, Passes, TM, Options, Extensions) ccall((:LLVMRunJuliaPassesOnFunction, libLLVMExtra), LLVMErrorRef, (LLVMValueRef, Cstring, LLVMTargetMachineRef, LLVMPassBuilderOptionsRef, LLVMPassBuilderExtensionsRef), F, Passes, TM, Options, Extensions) end -function LLVMGetSyncScopeID(C, Name, SLen) - ccall((:LLVMGetSyncScopeID, libLLVMExtra), Cuint, (LLVMContextRef, Cstring, Csize_t), C, Name, SLen) -end - -function LLVMBuildFenceSyncScope(B, ordering, SSID, Name) - ccall((:LLVMBuildFenceSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicOrdering, Cuint, Cstring), B, ordering, SSID, Name) -end - -function LLVMBuildAtomicRMWSyncScope(B, op, PTR, Val, ordering, SSID) - ccall((:LLVMBuildAtomicRMWSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicRMWBinOp, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, Cuint), B, op, PTR, Val, ordering, SSID) -end - -function LLVMBuildAtomicCmpXchgSyncScope(B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) - ccall((:LLVMBuildAtomicCmpXchgSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMValueRef, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, LLVMAtomicOrdering, Cuint), B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) -end - -function LLVMIsAtomic(Inst) - ccall((:LLVMIsAtomic, libLLVMExtra), LLVMBool, (LLVMValueRef,), Inst) -end - -function LLVMGetAtomicSyncScopeID(AtomicInst) - ccall((:LLVMGetAtomicSyncScopeID, libLLVMExtra), Cuint, (LLVMValueRef,), AtomicInst) -end - -function LLVMSetAtomicSyncScopeID(AtomicInst, SSID) - ccall((:LLVMSetAtomicSyncScopeID, libLLVMExtra), Cvoid, (LLVMValueRef, Cuint), AtomicInst, SSID) -end - -function LLVMGetValueContext(Val) - ccall((:LLVMGetValueContext, libLLVMExtra), LLVMContextRef, (LLVMValueRef,), Val) -end - -function LLVMGetBuilderContext(Builder) - ccall((:LLVMGetBuilderContext, libLLVMExtra), LLVMContextRef, (LLVMBuilderRef,), Builder) -end - diff --git a/lib/16/libLLVM_extra.jl b/lib/16/libLLVM_extra.jl index 892df38e..2c3565fd 100644 --- a/lib/16/libLLVM_extra.jl +++ b/lib/16/libLLVM_extra.jl @@ -71,6 +71,14 @@ function LLVMAddExpandReductionsPass(PM) ccall((:LLVMAddExpandReductionsPass, libLLVMExtra), Cvoid, (LLVMPassManagerRef,), PM) end +function LLVMAddCFGSimplificationPass2(PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, FoldTwoEntryPHINode) + ccall((:LLVMAddCFGSimplificationPass2, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Cint, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool), PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, FoldTwoEntryPHINode) +end + +function LLVMAddInternalizePassWithExportList(PM, ExportList, Length) + ccall((:LLVMAddInternalizePassWithExportList, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Ptr{Cstring}, Csize_t), PM, ExportList, Length) +end + mutable struct LLVMOpaquePass end const LLVMPassRef = Ptr{LLVMOpaquePass} @@ -94,10 +102,6 @@ function LLVMAddTargetLibraryInfoByTriple(T, PM) ccall((:LLVMAddTargetLibraryInfoByTriple, libLLVMExtra), Cvoid, (Cstring, LLVMPassManagerRef), T, PM) end -function LLVMAddInternalizePassWithExportList(PM, ExportList, Length) - ccall((:LLVMAddInternalizePassWithExportList, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Ptr{Cstring}, Csize_t), PM, ExportList, Length) -end - function LLVMAppendToUsed(Mod, Values, Count) ccall((:LLVMAppendToUsed, libLLVMExtra), Cvoid, (LLVMModuleRef, Ptr{LLVMValueRef}, Csize_t), Mod, Values, Count) end @@ -122,6 +126,30 @@ function LLVMDIScopeGetName(File, Len) ccall((:LLVMDIScopeGetName, libLLVMExtra), Cstring, (LLVMMetadataRef, Ptr{Cuint}), File, Len) end +function LLVMFunctionDeleteBody(Func) + ccall((:LLVMFunctionDeleteBody, libLLVMExtra), Cvoid, (LLVMValueRef,), Func) +end + +function LLVMDestroyConstant(Const) + ccall((:LLVMDestroyConstant, libLLVMExtra), Cvoid, (LLVMValueRef,), Const) +end + +function LLVMGetFunctionType(Fn) + ccall((:LLVMGetFunctionType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) +end + +function LLVMGetGlobalValueType(Fn) + ccall((:LLVMGetGlobalValueType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) +end + +function LLVMSetInitializer2(GlobalVar, ConstantVal) + ccall((:LLVMSetInitializer2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), GlobalVar, ConstantVal) +end + +function LLVMSetPersonalityFn2(Fn, PersonalityFn) + ccall((:LLVMSetPersonalityFn2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), Fn, PersonalityFn) +end + function LLVMGetMDString2(MD, Length) ccall((:LLVMGetMDString2, libLLVMExtra), Cstring, (LLVMMetadataRef, Ptr{Cuint}), MD, Length) end @@ -162,26 +190,6 @@ function LLVMDumpJitDylibToString(JD) ccall((:LLVMDumpJitDylibToString, libLLVMExtra), Cstring, (LLVMOrcJITDylibRef,), JD) end -function LLVMGetFunctionType(Fn) - ccall((:LLVMGetFunctionType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) -end - -function LLVMGetGlobalValueType(Fn) - ccall((:LLVMGetGlobalValueType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) -end - -function LLVMAddCFGSimplificationPass2(PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, FoldTwoEntryPHINode) - ccall((:LLVMAddCFGSimplificationPass2, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Cint, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool), PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, FoldTwoEntryPHINode) -end - -function LLVMSetInitializer2(GlobalVar, ConstantVal) - ccall((:LLVMSetInitializer2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), GlobalVar, ConstantVal) -end - -function LLVMSetPersonalityFn2(Fn, PersonalityFn) - ccall((:LLVMSetPersonalityFn2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), Fn, PersonalityFn) -end - @cenum LLVMCloneFunctionChangeType::UInt32 begin LLVMCloneFunctionChangeTypeLocalChangesOnly = 0 LLVMCloneFunctionChangeTypeGlobalChanges = 1 @@ -197,14 +205,6 @@ function LLVMCloneBasicBlock(BB, NameSuffix, ValueMap, ValueMapElements, F) ccall((:LLVMCloneBasicBlock, libLLVMExtra), LLVMBasicBlockRef, (LLVMBasicBlockRef, Cstring, Ptr{LLVMValueRef}, Cuint, LLVMValueRef), BB, NameSuffix, ValueMap, ValueMapElements, F) end -function LLVMFunctionDeleteBody(Func) - ccall((:LLVMFunctionDeleteBody, libLLVMExtra), Cvoid, (LLVMValueRef,), Func) -end - -function LLVMDestroyConstant(Const) - ccall((:LLVMDestroyConstant, libLLVMExtra), Cvoid, (LLVMValueRef,), Const) -end - mutable struct LLVMOpaqueOperandBundle end const LLVMOperandBundleRef = Ptr{LLVMOpaqueOperandBundle} @@ -323,6 +323,42 @@ function LLVMCanValueUseFastMathFlags(Inst) ccall((:LLVMCanValueUseFastMathFlags, libLLVMExtra), LLVMBool, (LLVMValueRef,), Inst) end +function LLVMGetSyncScopeID(C, Name, SLen) + ccall((:LLVMGetSyncScopeID, libLLVMExtra), Cuint, (LLVMContextRef, Cstring, Csize_t), C, Name, SLen) +end + +function LLVMBuildFenceSyncScope(B, ordering, SSID, Name) + ccall((:LLVMBuildFenceSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicOrdering, Cuint, Cstring), B, ordering, SSID, Name) +end + +function LLVMBuildAtomicRMWSyncScope(B, op, PTR, Val, ordering, SSID) + ccall((:LLVMBuildAtomicRMWSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicRMWBinOp, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, Cuint), B, op, PTR, Val, ordering, SSID) +end + +function LLVMBuildAtomicCmpXchgSyncScope(B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) + ccall((:LLVMBuildAtomicCmpXchgSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMValueRef, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, LLVMAtomicOrdering, Cuint), B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) +end + +function LLVMIsAtomic(Inst) + ccall((:LLVMIsAtomic, libLLVMExtra), LLVMBool, (LLVMValueRef,), Inst) +end + +function LLVMGetAtomicSyncScopeID(AtomicInst) + ccall((:LLVMGetAtomicSyncScopeID, libLLVMExtra), Cuint, (LLVMValueRef,), AtomicInst) +end + +function LLVMSetAtomicSyncScopeID(AtomicInst, SSID) + ccall((:LLVMSetAtomicSyncScopeID, libLLVMExtra), Cvoid, (LLVMValueRef, Cuint), AtomicInst, SSID) +end + +function LLVMGetValueContext(Val) + ccall((:LLVMGetValueContext, libLLVMExtra), LLVMContextRef, (LLVMValueRef,), Val) +end + +function LLVMGetBuilderContext(Builder) + ccall((:LLVMGetBuilderContext, libLLVMExtra), LLVMContextRef, (LLVMBuilderRef,), Builder) +end + mutable struct LLVMOpaquePassBuilderExtensions end const LLVMPassBuilderExtensionsRef = Ptr{LLVMOpaquePassBuilderExtensions} @@ -365,39 +401,3 @@ function LLVMRunJuliaPassesOnFunction(F, Passes, TM, Options, Extensions) ccall((:LLVMRunJuliaPassesOnFunction, libLLVMExtra), LLVMErrorRef, (LLVMValueRef, Cstring, LLVMTargetMachineRef, LLVMPassBuilderOptionsRef, LLVMPassBuilderExtensionsRef), F, Passes, TM, Options, Extensions) end -function LLVMGetSyncScopeID(C, Name, SLen) - ccall((:LLVMGetSyncScopeID, libLLVMExtra), Cuint, (LLVMContextRef, Cstring, Csize_t), C, Name, SLen) -end - -function LLVMBuildFenceSyncScope(B, ordering, SSID, Name) - ccall((:LLVMBuildFenceSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicOrdering, Cuint, Cstring), B, ordering, SSID, Name) -end - -function LLVMBuildAtomicRMWSyncScope(B, op, PTR, Val, ordering, SSID) - ccall((:LLVMBuildAtomicRMWSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicRMWBinOp, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, Cuint), B, op, PTR, Val, ordering, SSID) -end - -function LLVMBuildAtomicCmpXchgSyncScope(B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) - ccall((:LLVMBuildAtomicCmpXchgSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMValueRef, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, LLVMAtomicOrdering, Cuint), B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) -end - -function LLVMIsAtomic(Inst) - ccall((:LLVMIsAtomic, libLLVMExtra), LLVMBool, (LLVMValueRef,), Inst) -end - -function LLVMGetAtomicSyncScopeID(AtomicInst) - ccall((:LLVMGetAtomicSyncScopeID, libLLVMExtra), Cuint, (LLVMValueRef,), AtomicInst) -end - -function LLVMSetAtomicSyncScopeID(AtomicInst, SSID) - ccall((:LLVMSetAtomicSyncScopeID, libLLVMExtra), Cvoid, (LLVMValueRef, Cuint), AtomicInst, SSID) -end - -function LLVMGetValueContext(Val) - ccall((:LLVMGetValueContext, libLLVMExtra), LLVMContextRef, (LLVMValueRef,), Val) -end - -function LLVMGetBuilderContext(Builder) - ccall((:LLVMGetBuilderContext, libLLVMExtra), LLVMContextRef, (LLVMBuilderRef,), Builder) -end - diff --git a/lib/17/libLLVM_extra.jl b/lib/17/libLLVM_extra.jl index 9d770feb..a12c752e 100644 --- a/lib/17/libLLVM_extra.jl +++ b/lib/17/libLLVM_extra.jl @@ -43,6 +43,10 @@ function LLVMAddExpandReductionsPass(PM) ccall((:LLVMAddExpandReductionsPass, libLLVMExtra), Cvoid, (LLVMPassManagerRef,), PM) end +function LLVMAddCFGSimplificationPass2(PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, SpeculateBlocks) + ccall((:LLVMAddCFGSimplificationPass2, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Cint, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool), PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, SpeculateBlocks) +end + mutable struct LLVMOpaquePass end const LLVMPassRef = Ptr{LLVMOpaquePass} @@ -90,6 +94,30 @@ function LLVMDIScopeGetName(File, Len) ccall((:LLVMDIScopeGetName, libLLVMExtra), Cstring, (LLVMMetadataRef, Ptr{Cuint}), File, Len) end +function LLVMFunctionDeleteBody(Func) + ccall((:LLVMFunctionDeleteBody, libLLVMExtra), Cvoid, (LLVMValueRef,), Func) +end + +function LLVMDestroyConstant(Const) + ccall((:LLVMDestroyConstant, libLLVMExtra), Cvoid, (LLVMValueRef,), Const) +end + +function LLVMGetFunctionType(Fn) + ccall((:LLVMGetFunctionType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) +end + +function LLVMGetGlobalValueType(Fn) + ccall((:LLVMGetGlobalValueType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) +end + +function LLVMSetInitializer2(GlobalVar, ConstantVal) + ccall((:LLVMSetInitializer2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), GlobalVar, ConstantVal) +end + +function LLVMSetPersonalityFn2(Fn, PersonalityFn) + ccall((:LLVMSetPersonalityFn2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), Fn, PersonalityFn) +end + function LLVMGetMDString2(MD, Length) ccall((:LLVMGetMDString2, libLLVMExtra), Cstring, (LLVMMetadataRef, Ptr{Cuint}), MD, Length) end @@ -130,26 +158,6 @@ function LLVMDumpJitDylibToString(JD) ccall((:LLVMDumpJitDylibToString, libLLVMExtra), Cstring, (LLVMOrcJITDylibRef,), JD) end -function LLVMGetFunctionType(Fn) - ccall((:LLVMGetFunctionType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) -end - -function LLVMGetGlobalValueType(Fn) - ccall((:LLVMGetGlobalValueType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) -end - -function LLVMAddCFGSimplificationPass2(PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, SpeculateBlocks) - ccall((:LLVMAddCFGSimplificationPass2, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Cint, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool), PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, SpeculateBlocks) -end - -function LLVMSetInitializer2(GlobalVar, ConstantVal) - ccall((:LLVMSetInitializer2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), GlobalVar, ConstantVal) -end - -function LLVMSetPersonalityFn2(Fn, PersonalityFn) - ccall((:LLVMSetPersonalityFn2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), Fn, PersonalityFn) -end - @cenum LLVMCloneFunctionChangeType::UInt32 begin LLVMCloneFunctionChangeTypeLocalChangesOnly = 0 LLVMCloneFunctionChangeTypeGlobalChanges = 1 @@ -165,14 +173,6 @@ function LLVMCloneBasicBlock(BB, NameSuffix, ValueMap, ValueMapElements, F) ccall((:LLVMCloneBasicBlock, libLLVMExtra), LLVMBasicBlockRef, (LLVMBasicBlockRef, Cstring, Ptr{LLVMValueRef}, Cuint, LLVMValueRef), BB, NameSuffix, ValueMap, ValueMapElements, F) end -function LLVMFunctionDeleteBody(Func) - ccall((:LLVMFunctionDeleteBody, libLLVMExtra), Cvoid, (LLVMValueRef,), Func) -end - -function LLVMDestroyConstant(Const) - ccall((:LLVMDestroyConstant, libLLVMExtra), Cvoid, (LLVMValueRef,), Const) -end - mutable struct LLVMOpaqueOperandBundle end const LLVMOperandBundleRef = Ptr{LLVMOpaqueOperandBundle} @@ -283,6 +283,42 @@ function LLVMCanValueUseFastMathFlags(Inst) ccall((:LLVMCanValueUseFastMathFlags, libLLVMExtra), LLVMBool, (LLVMValueRef,), Inst) end +function LLVMGetSyncScopeID(C, Name, SLen) + ccall((:LLVMGetSyncScopeID, libLLVMExtra), Cuint, (LLVMContextRef, Cstring, Csize_t), C, Name, SLen) +end + +function LLVMBuildFenceSyncScope(B, ordering, SSID, Name) + ccall((:LLVMBuildFenceSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicOrdering, Cuint, Cstring), B, ordering, SSID, Name) +end + +function LLVMBuildAtomicRMWSyncScope(B, op, PTR, Val, ordering, SSID) + ccall((:LLVMBuildAtomicRMWSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicRMWBinOp, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, Cuint), B, op, PTR, Val, ordering, SSID) +end + +function LLVMBuildAtomicCmpXchgSyncScope(B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) + ccall((:LLVMBuildAtomicCmpXchgSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMValueRef, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, LLVMAtomicOrdering, Cuint), B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) +end + +function LLVMIsAtomic(Inst) + ccall((:LLVMIsAtomic, libLLVMExtra), LLVMBool, (LLVMValueRef,), Inst) +end + +function LLVMGetAtomicSyncScopeID(AtomicInst) + ccall((:LLVMGetAtomicSyncScopeID, libLLVMExtra), Cuint, (LLVMValueRef,), AtomicInst) +end + +function LLVMSetAtomicSyncScopeID(AtomicInst, SSID) + ccall((:LLVMSetAtomicSyncScopeID, libLLVMExtra), Cvoid, (LLVMValueRef, Cuint), AtomicInst, SSID) +end + +function LLVMGetValueContext(Val) + ccall((:LLVMGetValueContext, libLLVMExtra), LLVMContextRef, (LLVMValueRef,), Val) +end + +function LLVMGetBuilderContext(Builder) + ccall((:LLVMGetBuilderContext, libLLVMExtra), LLVMContextRef, (LLVMBuilderRef,), Builder) +end + mutable struct LLVMOpaquePassBuilderExtensions end const LLVMPassBuilderExtensionsRef = Ptr{LLVMOpaquePassBuilderExtensions} @@ -325,39 +361,3 @@ function LLVMRunJuliaPassesOnFunction(F, Passes, TM, Options, Extensions) ccall((:LLVMRunJuliaPassesOnFunction, libLLVMExtra), LLVMErrorRef, (LLVMValueRef, Cstring, LLVMTargetMachineRef, LLVMPassBuilderOptionsRef, LLVMPassBuilderExtensionsRef), F, Passes, TM, Options, Extensions) end -function LLVMGetSyncScopeID(C, Name, SLen) - ccall((:LLVMGetSyncScopeID, libLLVMExtra), Cuint, (LLVMContextRef, Cstring, Csize_t), C, Name, SLen) -end - -function LLVMBuildFenceSyncScope(B, ordering, SSID, Name) - ccall((:LLVMBuildFenceSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicOrdering, Cuint, Cstring), B, ordering, SSID, Name) -end - -function LLVMBuildAtomicRMWSyncScope(B, op, PTR, Val, ordering, SSID) - ccall((:LLVMBuildAtomicRMWSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicRMWBinOp, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, Cuint), B, op, PTR, Val, ordering, SSID) -end - -function LLVMBuildAtomicCmpXchgSyncScope(B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) - ccall((:LLVMBuildAtomicCmpXchgSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMValueRef, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, LLVMAtomicOrdering, Cuint), B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) -end - -function LLVMIsAtomic(Inst) - ccall((:LLVMIsAtomic, libLLVMExtra), LLVMBool, (LLVMValueRef,), Inst) -end - -function LLVMGetAtomicSyncScopeID(AtomicInst) - ccall((:LLVMGetAtomicSyncScopeID, libLLVMExtra), Cuint, (LLVMValueRef,), AtomicInst) -end - -function LLVMSetAtomicSyncScopeID(AtomicInst, SSID) - ccall((:LLVMSetAtomicSyncScopeID, libLLVMExtra), Cvoid, (LLVMValueRef, Cuint), AtomicInst, SSID) -end - -function LLVMGetValueContext(Val) - ccall((:LLVMGetValueContext, libLLVMExtra), LLVMContextRef, (LLVMValueRef,), Val) -end - -function LLVMGetBuilderContext(Builder) - ccall((:LLVMGetBuilderContext, libLLVMExtra), LLVMContextRef, (LLVMBuilderRef,), Builder) -end - diff --git a/lib/18/libLLVM_extra.jl b/lib/18/libLLVM_extra.jl index 344c6968..95298f76 100644 --- a/lib/18/libLLVM_extra.jl +++ b/lib/18/libLLVM_extra.jl @@ -43,6 +43,10 @@ function LLVMAddExpandReductionsPass(PM) ccall((:LLVMAddExpandReductionsPass, libLLVMExtra), Cvoid, (LLVMPassManagerRef,), PM) end +function LLVMAddCFGSimplificationPass2(PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, SpeculateBlocks) + ccall((:LLVMAddCFGSimplificationPass2, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Cint, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool), PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, SpeculateBlocks) +end + mutable struct LLVMOpaquePass end const LLVMPassRef = Ptr{LLVMOpaquePass} @@ -90,6 +94,30 @@ function LLVMDIScopeGetName(File, Len) ccall((:LLVMDIScopeGetName, libLLVMExtra), Cstring, (LLVMMetadataRef, Ptr{Cuint}), File, Len) end +function LLVMFunctionDeleteBody(Func) + ccall((:LLVMFunctionDeleteBody, libLLVMExtra), Cvoid, (LLVMValueRef,), Func) +end + +function LLVMDestroyConstant(Const) + ccall((:LLVMDestroyConstant, libLLVMExtra), Cvoid, (LLVMValueRef,), Const) +end + +function LLVMGetFunctionType(Fn) + ccall((:LLVMGetFunctionType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) +end + +function LLVMGetGlobalValueType(Fn) + ccall((:LLVMGetGlobalValueType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) +end + +function LLVMSetInitializer2(GlobalVar, ConstantVal) + ccall((:LLVMSetInitializer2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), GlobalVar, ConstantVal) +end + +function LLVMSetPersonalityFn2(Fn, PersonalityFn) + ccall((:LLVMSetPersonalityFn2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), Fn, PersonalityFn) +end + function LLVMGetMDString2(MD, Length) ccall((:LLVMGetMDString2, libLLVMExtra), Cstring, (LLVMMetadataRef, Ptr{Cuint}), MD, Length) end @@ -130,26 +158,6 @@ function LLVMDumpJitDylibToString(JD) ccall((:LLVMDumpJitDylibToString, libLLVMExtra), Cstring, (LLVMOrcJITDylibRef,), JD) end -function LLVMGetFunctionType(Fn) - ccall((:LLVMGetFunctionType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) -end - -function LLVMGetGlobalValueType(Fn) - ccall((:LLVMGetGlobalValueType, libLLVMExtra), LLVMTypeRef, (LLVMValueRef,), Fn) -end - -function LLVMAddCFGSimplificationPass2(PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, SpeculateBlocks) - ccall((:LLVMAddCFGSimplificationPass2, libLLVMExtra), Cvoid, (LLVMPassManagerRef, Cint, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool, LLVMBool), PM, BonusInstThreshold, ForwardSwitchCondToPhi, ConvertSwitchToLookupTable, NeedCanonicalLoop, HoistCommonInsts, SinkCommonInsts, SimplifyCondBranch, SpeculateBlocks) -end - -function LLVMSetInitializer2(GlobalVar, ConstantVal) - ccall((:LLVMSetInitializer2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), GlobalVar, ConstantVal) -end - -function LLVMSetPersonalityFn2(Fn, PersonalityFn) - ccall((:LLVMSetPersonalityFn2, libLLVMExtra), Cvoid, (LLVMValueRef, LLVMValueRef), Fn, PersonalityFn) -end - @cenum LLVMCloneFunctionChangeType::UInt32 begin LLVMCloneFunctionChangeTypeLocalChangesOnly = 0 LLVMCloneFunctionChangeTypeGlobalChanges = 1 @@ -165,14 +173,6 @@ function LLVMCloneBasicBlock(BB, NameSuffix, ValueMap, ValueMapElements, F) ccall((:LLVMCloneBasicBlock, libLLVMExtra), LLVMBasicBlockRef, (LLVMBasicBlockRef, Cstring, Ptr{LLVMValueRef}, Cuint, LLVMValueRef), BB, NameSuffix, ValueMap, ValueMapElements, F) end -function LLVMFunctionDeleteBody(Func) - ccall((:LLVMFunctionDeleteBody, libLLVMExtra), Cvoid, (LLVMValueRef,), Func) -end - -function LLVMDestroyConstant(Const) - ccall((:LLVMDestroyConstant, libLLVMExtra), Cvoid, (LLVMValueRef,), Const) -end - function LLVMMetadataAsValue2(C, Metadata) ccall((:LLVMMetadataAsValue2, libLLVMExtra), LLVMValueRef, (LLVMContextRef, LLVMMetadataRef), C, Metadata) end @@ -217,6 +217,42 @@ function LLVMPostDominatorTreeInstructionDominates(Tree, InstA, InstB) ccall((:LLVMPostDominatorTreeInstructionDominates, libLLVMExtra), LLVMBool, (LLVMPostDominatorTreeRef, LLVMValueRef, LLVMValueRef), Tree, InstA, InstB) end +function LLVMGetSyncScopeID(C, Name, SLen) + ccall((:LLVMGetSyncScopeID, libLLVMExtra), Cuint, (LLVMContextRef, Cstring, Csize_t), C, Name, SLen) +end + +function LLVMBuildFenceSyncScope(B, ordering, SSID, Name) + ccall((:LLVMBuildFenceSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicOrdering, Cuint, Cstring), B, ordering, SSID, Name) +end + +function LLVMBuildAtomicRMWSyncScope(B, op, PTR, Val, ordering, SSID) + ccall((:LLVMBuildAtomicRMWSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicRMWBinOp, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, Cuint), B, op, PTR, Val, ordering, SSID) +end + +function LLVMBuildAtomicCmpXchgSyncScope(B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) + ccall((:LLVMBuildAtomicCmpXchgSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMValueRef, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, LLVMAtomicOrdering, Cuint), B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) +end + +function LLVMIsAtomic(Inst) + ccall((:LLVMIsAtomic, libLLVMExtra), LLVMBool, (LLVMValueRef,), Inst) +end + +function LLVMGetAtomicSyncScopeID(AtomicInst) + ccall((:LLVMGetAtomicSyncScopeID, libLLVMExtra), Cuint, (LLVMValueRef,), AtomicInst) +end + +function LLVMSetAtomicSyncScopeID(AtomicInst, SSID) + ccall((:LLVMSetAtomicSyncScopeID, libLLVMExtra), Cvoid, (LLVMValueRef, Cuint), AtomicInst, SSID) +end + +function LLVMGetValueContext(Val) + ccall((:LLVMGetValueContext, libLLVMExtra), LLVMContextRef, (LLVMValueRef,), Val) +end + +function LLVMGetBuilderContext(Builder) + ccall((:LLVMGetBuilderContext, libLLVMExtra), LLVMContextRef, (LLVMBuilderRef,), Builder) +end + mutable struct LLVMOpaquePassBuilderExtensions end const LLVMPassBuilderExtensionsRef = Ptr{LLVMOpaquePassBuilderExtensions} @@ -259,39 +295,3 @@ function LLVMRunJuliaPassesOnFunction(F, Passes, TM, Options, Extensions) ccall((:LLVMRunJuliaPassesOnFunction, libLLVMExtra), LLVMErrorRef, (LLVMValueRef, Cstring, LLVMTargetMachineRef, LLVMPassBuilderOptionsRef, LLVMPassBuilderExtensionsRef), F, Passes, TM, Options, Extensions) end -function LLVMGetSyncScopeID(C, Name, SLen) - ccall((:LLVMGetSyncScopeID, libLLVMExtra), Cuint, (LLVMContextRef, Cstring, Csize_t), C, Name, SLen) -end - -function LLVMBuildFenceSyncScope(B, ordering, SSID, Name) - ccall((:LLVMBuildFenceSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicOrdering, Cuint, Cstring), B, ordering, SSID, Name) -end - -function LLVMBuildAtomicRMWSyncScope(B, op, PTR, Val, ordering, SSID) - ccall((:LLVMBuildAtomicRMWSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMAtomicRMWBinOp, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, Cuint), B, op, PTR, Val, ordering, SSID) -end - -function LLVMBuildAtomicCmpXchgSyncScope(B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) - ccall((:LLVMBuildAtomicCmpXchgSyncScope, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMValueRef, LLVMValueRef, LLVMValueRef, LLVMAtomicOrdering, LLVMAtomicOrdering, Cuint), B, Ptr, Cmp, New, SuccessOrdering, FailureOrdering, SSID) -end - -function LLVMIsAtomic(Inst) - ccall((:LLVMIsAtomic, libLLVMExtra), LLVMBool, (LLVMValueRef,), Inst) -end - -function LLVMGetAtomicSyncScopeID(AtomicInst) - ccall((:LLVMGetAtomicSyncScopeID, libLLVMExtra), Cuint, (LLVMValueRef,), AtomicInst) -end - -function LLVMSetAtomicSyncScopeID(AtomicInst, SSID) - ccall((:LLVMSetAtomicSyncScopeID, libLLVMExtra), Cvoid, (LLVMValueRef, Cuint), AtomicInst, SSID) -end - -function LLVMGetValueContext(Val) - ccall((:LLVMGetValueContext, libLLVMExtra), LLVMContextRef, (LLVMValueRef,), Val) -end - -function LLVMGetBuilderContext(Builder) - ccall((:LLVMGetBuilderContext, libLLVMExtra), LLVMContextRef, (LLVMBuilderRef,), Builder) -end -