1- struct PipelineConfig
2- Speedup:: Cint
3- Size:: Cint
4- lower_intrinsics:: Cint
5- dump_native:: Cint
6- external_use:: Cint
7- llvm_only:: Cint
8- always_inline:: Cint
9- enable_early_simplifications:: Cint
10- enable_early_optimizations:: Cint
11- enable_scalar_optimizations:: Cint
12- enable_loop_optimizations:: Cint
13- enable_vector_pipeline:: Cint
14- remove_ni:: Cint
15- cleanup:: Cint
1+ function registerEnzymeAndPassPipeline! (pb:: NewPMPassBuilder )
2+ enzyme_callback = cglobal ((:registerEnzymeAndPassPipeline , API. libEnzyme))
3+ LLVM. API. LLVMPassBuilderExtensionsPushRegistrationCallbacks (pb. exts, enzyme_callback)
164end
175
18- const RunAttributor = Ref (true )
19-
20- function pipeline_options (;
21- lower_intrinsics:: Bool = true ,
22- dump_native:: Bool = false ,
23- external_use:: Bool = false ,
24- llvm_only:: Bool = false ,
25- always_inline:: Bool = true ,
26- enable_early_simplifications:: Bool = true ,
27- enable_early_optimizations:: Bool = true ,
28- enable_scalar_optimizations:: Bool = true ,
29- enable_loop_optimizations:: Bool = true ,
30- enable_vector_pipeline:: Bool = true ,
31- remove_ni:: Bool = true ,
32- cleanup:: Bool = true ,
33- Size:: Cint = 0 ,
34- Speedup:: Cint = 3 ,
35- )
36- return PipelineConfig (
37- Speedup,
38- Size,
39- lower_intrinsics,
40- dump_native,
41- external_use,
42- llvm_only,
43- always_inline,
44- enable_early_simplifications,
45- enable_early_optimizations,
46- enable_scalar_optimizations,
47- enable_loop_optimizations,
48- enable_vector_pipeline,
49- remove_ni,
50- cleanup,
51- )
52- end
6+ LLVM. @function_pass " jl-inst-simplify" JLInstSimplifyPass
7+ LLVM. @module_pass " preserve-nvvm" PreserveNVVMPass
8+ LLVM. @module_pass " preserve-nvvm-end" PreserveNVVMEndPass
539
54- function run_jl_pipeline (pm:: ModulePassManager , tm:: LLVM.TargetMachine ; kwargs... )
55- config = Ref (pipeline_options (; kwargs... ))
56- function jl_pipeline (m)
57- @dispose pb = NewPMPassBuilder () begin
58- add! (pb, NewPMModulePassManager ()) do mpm
59- @ccall jl_build_newpm_pipeline (
60- mpm. ref:: Ptr{Cvoid} ,
61- pb. ref:: Ptr{Cvoid} ,
62- config:: Ptr{PipelineConfig} ,
63- ):: Cvoid
64- end
65- LLVM. run! (mpm, m, tm)
66- end
67- return true
68- end
69- add! (pm, ModulePass (" JLPipeline" , jl_pipeline))
70- end
10+ const RunAttributor = Ref (true )
7111
7212@static if VERSION < v " 1.11.0-DEV.428"
7313else
@@ -215,22 +155,7 @@ function loop_optimizations_tm!(pm::LLVM.ModulePassManager, tm::LLVM.TargetMachi
215155 loop_unswitch! (pm)
216156 end
217157 else
218- run_jl_pipeline (
219- pm,
220- tm;
221- lower_intrinsics = false ,
222- dump_native = false ,
223- external_use = false ,
224- llvm_only = false ,
225- always_inline = false ,
226- enable_early_simplifications = false ,
227- enable_early_optimizations = false ,
228- enable_scalar_optimizations = false ,
229- enable_loop_optimizations = true ,
230- enable_vector_pipeline = false ,
231- remove_ni = false ,
232- cleanup = false ,
233- )
158+ @assert false
234159 end
235160end
236161
@@ -253,36 +178,7 @@ function more_loop_optimizations_tm!(pm::LLVM.ModulePassManager, tm::LLVM.Target
253178 loop_deletion! (pm)
254179 loop_unroll! (pm) # TODO : in Julia createSimpleLoopUnroll
255180 else
256- # LowerSIMDLoopPass
257- # LoopRotatePass [opt >= 2]
258- # LICMPass
259- # JuliaLICMPass
260- # SimpleLoopUnswitchPass
261- # LICMPass
262- # JuliaLICMPass
263- # IRCEPass
264- # LoopInstSimplifyPass
265- # - in ours this is instcombine with jlinstsimplify
266- # LoopIdiomRecognizePass
267- # IndVarSimplifyPass
268- # LoopDeletionPass
269- # LoopFullUnrollPass
270- run_jl_pipeline (
271- pm,
272- tm;
273- lower_intrinsics = false ,
274- dump_native = false ,
275- external_use = false ,
276- llvm_only = false ,
277- always_inline = false ,
278- enable_early_simplifications = false ,
279- enable_early_optimizations = false ,
280- enable_scalar_optimizations = false ,
281- enable_loop_optimizations = true ,
282- enable_vector_pipeline = false ,
283- remove_ni = false ,
284- cleanup = false ,
285- )
181+ @assert false
286182 end
287183end
288184
0 commit comments