Skip to content

Commit e88958a

Browse files
committed
Add high-level wrappers for the Julia passes.
1 parent a2233a8 commit e88958a

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

src/interop.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
module Interop
22

33
using ..LLVM
4+
import ..LLVM: API, ref
45

56

67
const jlctx = Ref{LLVM.Context}()
78

89
include("interop/base.jl")
910
include("interop/asmcall.jl")
11+
include("interop/passes.jl")
1012

1113
end

src/interop/passes.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export alloc_opt!, barrier_noop!, gc_invariant_verifier!, lower_exc_handlers!,
2+
combine_mul_add!, multi_versioning!, propagate_julia_addrsp!, lower_ptls!,
3+
lower_simdloop!, late_lower_gc_frame!
4+
5+
alloc_opt!(pm::PassManager) =
6+
API.LLVMAddAllocOptPass(ref(pm))
7+
8+
barrier_noop!(pm::PassManager) =
9+
API.LLVMAddBarrierNoopPass(ref(pm))
10+
11+
gc_invariant_verifier!(pm::PassManager, strong::Bool=false) =
12+
API.LLVMAddGCInvariantVerifierPass(ref(pm), convert(Bool, strong))
13+
14+
lower_exc_handlers!(pm::PassManager) =
15+
API.LLVMAddLowerExcHandlersPass(ref(pm))
16+
17+
combine_mul_add!(pm::PassManager) =
18+
API.LLVMAddCombineMulAddPass(ref(pm))
19+
20+
multi_versioning!(pm::PassManager) =
21+
API.LLVMAddMultiVersioningPass(ref(pm))
22+
23+
propagate_julia_addrsp!(pm::PassManager) =
24+
API.LLVMAddPropagateJuliaAddrspaces(ref(pm))
25+
26+
lower_ptls!(pm::PassManager, imaging_mode::Bool=false) =
27+
API.LLVMAddLowerPTLSPass(ref(pm), convert(Bool, imaging_mode))
28+
29+
lower_simdloop!(pm::PassManager) =
30+
API.LLVMAddLowerSimdLoopPass(ref(pm))
31+
32+
late_lower_gc_frame!(pm::PassManager) =
33+
API.LLVMAddLateLowerGCFramePass(ref(pm))

test/interop.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,33 @@ d1(a) = @asmcall("bswap \$0", "=r,r", Int32, Tuple{Int32}, a)
8585

8686
end
8787

88+
89+
if VERSION >= v"1.2.0-DEV.531"
90+
@testset "passes" begin
91+
92+
93+
Context() do ctx
94+
LLVM.Module("SomeModule", ctx) do mod
95+
ModulePassManager() do pm
96+
97+
alloc_opt!(pm)
98+
barrier_noop!(pm)
99+
gc_invariant_verifier!(pm)
100+
gc_invariant_verifier!(pm, true)
101+
lower_exc_handlers!(pm)
102+
combine_mul_add!(pm)
103+
multi_versioning!(pm)
104+
propagate_julia_addrsp!(pm)
105+
lower_ptls!(pm)
106+
lower_ptls!(pm, true)
107+
lower_simdloop!(pm)
108+
late_lower_gc_frame!(pm)
109+
110+
end
111+
end
112+
end
113+
114+
end
115+
end
116+
88117
end

0 commit comments

Comments
 (0)