Skip to content

Commit bb2e57b

Browse files
committed
Add adjustPassManager for PMB
1 parent 81046c7 commit bb2e57b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

deps/LLVMExtra/include/LLVMExtra.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include "llvm/Config/llvm-config.h"
55
#include <llvm-c/Core.h>
66
#include <llvm-c/Types.h>
7+
typedef struct LLVMOpaqueTargetMachine *LLVMTargetMachineRef;
8+
// Can't include TargetMachine since that would inclue LLVMInitializeNativeTarget
9+
// #include <llvm-c/TargetMachine.h>
10+
#include <llvm-c/Transforms/PassManagerBuilder.h>
711

812
LLVM_C_EXTERN_C_BEGIN
913

@@ -159,6 +163,7 @@ LLVMValueRef LLVMBuildCallWithOpBundle(LLVMBuilderRef B, LLVMValueRef Fn,
159163
LLVMValueRef *Args, unsigned NumArgs,
160164
LLVMOperandBundleDefRef *Bundles, unsigned NumBundles,
161165
const char *Name);
166+
void LLVMAdjustPassManager(LLVMTargetMachineRef TM, LLVMPassManagerBuilderRef PMB);
162167

163168
LLVM_C_EXTERN_C_END
164169
#endif

deps/LLVMExtra/lib/llvm-api.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#endif
2222
#include <llvm/Transforms/Utils/Cloning.h>
2323
#include <llvm/Transforms/Utils/ModuleUtils.h>
24+
#include <llvm/Target/TargetMachine.h>
2425

2526
using namespace llvm;
2627
using namespace llvm::legacy;
@@ -548,3 +549,9 @@ LLVMValueRef LLVMBuildCallWithOpBundle(LLVMBuilderRef B, LLVMValueRef Fn,
548549
return wrap(unwrap(B)->CreateCall(FnT, unwrap(Fn), makeArrayRef(unwrap(Args), NumArgs),
549550
BundleArray, Name));
550551
}
552+
553+
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(TargetMachine, LLVMTargetMachineRef)
554+
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PassManagerBuilder, LLVMPassManagerBuilderRef)
555+
void LLVMAdjustPassManager(LLVMTargetMachineRef TM, LLVMPassManagerBuilderRef PMB) {
556+
unwrap(TM)->adjustPassManager(*unwrap(PMB));
557+
}

lib/libLLVM_extra.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,6 @@ function LLVMBuildCallWithOpBundle(B, Fn, Args, NumArgs, Bundles, NumBundles, Na
419419
ccall((:LLVMBuildCallWithOpBundle, libLLVMExtra), LLVMValueRef, (LLVMBuilderRef, LLVMValueRef, Ptr{LLVMValueRef}, Cuint, Ptr{LLVMOperandBundleDefRef}, Cuint, Cstring), B, Fn, Args, NumArgs, Bundles, NumBundles, Name)
420420
end
421421

422+
function LLVMAdjustPassManager(TM, PMB)
423+
ccall((:LLVMAdjustPassManager, libLLVMExtra), Cvoid, (LLVMTargetMachineRef, LLVMPassManagerBuilderRef), TM, PMB)
424+
end

0 commit comments

Comments
 (0)