11using Pkg
2- import BinaryBuilderBase: PkgSpec, Prefix, temp_prefix, setup_dependencies, cleanup_dependencies, destdir
2+ import BinaryBuilderBase:
3+ PkgSpec, Prefix, temp_prefix, setup_dependencies, cleanup_dependencies, destdir
34using Clang. Generators
45
56function mlir_dialects (version:: VersionNumber )
@@ -23,7 +24,11 @@ function mlir_dialects(version::VersionNumber)
2324 # ("dlti", "DLTI.jl", ["DLTI/DLTI.td"]), # TODO crashes
2425 (" emitc" , " EmitC.jl" , [" EmitC/IR/EmitC.td" ]),
2526 (" gpu" , " GPU.jl" , [" GPU/GPUOps.td" ]), # moved to IR subfolder in v15
26- (" linalg" , " Linalg.jl" , [" Linalg/IR/LinalgOps.td" , " Linalg/IR/LinalgStructuredOps.td" ]),
27+ (
28+ " linalg" ,
29+ " Linalg.jl" ,
30+ [" Linalg/IR/LinalgOps.td" , " Linalg/IR/LinalgStructuredOps.td" ],
31+ ),
2732 (" llvm" , " LLVMIR.jl" , [" LLVMIR/LLVMOps.td" ]),
2833 (" math" , " Math.jl" , [" Math/IR/MathOps.td" ]),
2934 (" memref" , " MemRef.jl" , [" MemRef/IR/MemRefOps.td" ]),
@@ -59,7 +64,11 @@ function mlir_dialects(version::VersionNumber)
5964 (" emitc" , " EmitC.jl" , [" EmitC/IR/EmitC.td" ]),
6065 (" func" , " Func.jl" , [" Func/IR/FuncOps.td" ]),
6166 (" gpu" , " GPU.jl" , [" GPU/IR/GPUOps.td" ]),
62- (" linalg" , " Linalg.jl" , [" Linalg/IR/LinalgOps.td" , " Linalg/IR/LinalgStructuredOps.td" ]),
67+ (
68+ " linalg" ,
69+ " Linalg.jl" ,
70+ [" Linalg/IR/LinalgOps.td" , " Linalg/IR/LinalgStructuredOps.td" ],
71+ ),
6372 (" llvm" , " LLVMIR.jl" , [" LLVMIR/LLVMOps.td" ]),
6473 (" math" , " Math.jl" , [" Math/IR/MathOps.td" ]),
6574 (" memref" , " MemRef.jl" , [" MemRef/IR/MemRefOps.td" ]),
@@ -75,12 +84,16 @@ function mlir_dialects(version::VersionNumber)
7584 (" spv" , " SPIRV.jl" , [" SPIRV/IR/SPIRVOps.td" ]), # dialect name renamed to 'spirv' in v16
7685 (" tensor" , " Tensor.jl" , [" Tensor/IR/TensorOps.td" ]),
7786 (" tosa" , " Tosa.jl" , [" Tosa/IR/TosaOps.td" ]),
78- (" transform" , " Transform.jl" , [
79- " Bufferization/TransformOps/BufferizationTransformOps.td" ,
80- " Linalg/TransformOps/LinalgTransformOps.td" ,
81- " SCF/TransformOps/SCFTransformOps.td" ,
82- " Transform/IR/TransformOps.td" ,
83- ]), # more ops files in v16
87+ (
88+ " transform" ,
89+ " Transform.jl" ,
90+ [
91+ " Bufferization/TransformOps/BufferizationTransformOps.td" ,
92+ " Linalg/TransformOps/LinalgTransformOps.td" ,
93+ " SCF/TransformOps/SCFTransformOps.td" ,
94+ " Transform/IR/TransformOps.td" ,
95+ ],
96+ ), # more ops files in v16
8497 (" vector" , " Vector.jl" , [" Vector/IR/VectorOps.td" ]),
8598 (" x86vector" , " X86Vector.jl" , [" X86Vector/X86Vector.td" ]),
8699 ]
@@ -103,7 +116,11 @@ function mlir_dialects(version::VersionNumber)
103116 (" func" , " Func.jl" , [" Func/IR/FuncOps.td" ]),
104117 (" gpu" , " GPU.jl" , [" GPU/IR/GPUOps.td" ]),
105118 (" index" , " Index.jl" , [" Index/IR/IndexOps.td" ]),
106- (" linalg" , " Linalg.jl" , [" Linalg/IR/LinalgOps.td" , " Linalg/IR/LinalgStructuredOps.td" ]),
119+ (
120+ " linalg" ,
121+ " Linalg.jl" ,
122+ [" Linalg/IR/LinalgOps.td" , " Linalg/IR/LinalgStructuredOps.td" ],
123+ ),
107124 (" llvm" , " LLVMIR.jl" , [" LLVMIR/LLVMOps.td" ]),
108125 (" math" , " Math.jl" , [" Math/IR/MathOps.td" ]),
109126 (" memref" , " MemRef.jl" , [" MemRef/IR/MemRefOps.td" ]),
@@ -119,16 +136,20 @@ function mlir_dialects(version::VersionNumber)
119136 (" spirv" , " SPIRV.jl" , [" SPIRV/IR/SPIRVOps.td" ]),
120137 (" tensor" , " Tensor.jl" , [" Tensor/IR/TensorOps.td" ]),
121138 (" tosa" , " Tosa.jl" , [" Tosa/IR/TosaOps.td" ]),
122- (" transform" , " Transform.jl" , [
123- " Affine/TransformOps/AffineTransformOps.td" ,
124- " Bufferization/TransformOps/BufferizationTransformOps.td" ,
125- " GPU/TransformOps/GPUTransformOps.td" ,
126- " Linalg/TransformOps/LinalgTransformOps.td" ,
127- " MemRef/TransformOps/MemRefTransformOps.td" ,
128- " SCF/TransformOps/SCFTransformOps.td" ,
129- " Transform/IR/TransformOps.td" ,
130- " Vector/TransformOps/VectorTransformOps.td" ,
131- ]), # more ops files in v17
139+ (
140+ " transform" ,
141+ " Transform.jl" ,
142+ [
143+ " Affine/TransformOps/AffineTransformOps.td" ,
144+ " Bufferization/TransformOps/BufferizationTransformOps.td" ,
145+ " GPU/TransformOps/GPUTransformOps.td" ,
146+ " Linalg/TransformOps/LinalgTransformOps.td" ,
147+ " MemRef/TransformOps/MemRefTransformOps.td" ,
148+ " SCF/TransformOps/SCFTransformOps.td" ,
149+ " Transform/IR/TransformOps.td" ,
150+ " Vector/TransformOps/VectorTransformOps.td" ,
151+ ],
152+ ), # more ops files in v17
132153 (" vector" , " Vector.jl" , [" Vector/IR/VectorOps.td" ]),
133154 (" x86vector" , " X86Vector.jl" , [" X86Vector/X86Vector.td" ]),
134155 ]
@@ -153,7 +174,11 @@ function mlir_dialects(version::VersionNumber)
153174 (" gpu" , " GPU.jl" , [" GPU/IR/GPUOps.td" ]),
154175 (" index" , " Index.jl" , [" Index/IR/IndexOps.td" ]),
155176 (" irdl" , " IRDL.jl" , [" IRDL/IR/IRDLOps.td" ]),
156- (" linalg" , " Linalg.jl" , [" Linalg/IR/LinalgOps.td" , " Linalg/IR/LinalgStructuredOps.td" ]),
177+ (
178+ " linalg" ,
179+ " Linalg.jl" ,
180+ [" Linalg/IR/LinalgOps.td" , " Linalg/IR/LinalgStructuredOps.td" ],
181+ ),
157182 (" llvm" , " LLVMIR.jl" , [" LLVMIR/LLVMOps.td" ]),
158183 (" math" , " Math.jl" , [" Math/IR/MathOps.td" ]),
159184 (" memref" , " MemRef.jl" , [" MemRef/IR/MemRefOps.td" ]),
@@ -169,19 +194,23 @@ function mlir_dialects(version::VersionNumber)
169194 (" spirv" , " SPIRV.jl" , [" SPIRV/IR/SPIRVOps.td" ]),
170195 (" tensor" , " Tensor.jl" , [" Tensor/IR/TensorOps.td" ]),
171196 (" tosa" , " Tosa.jl" , [" Tosa/IR/TosaOps.td" ]),
172- (" transform" , " Transform.jl" , [
173- " Affine/TransformOps/AffineTransformOps.td" ,
174- " Bufferization/TransformOps/BufferizationTransformOps.td" ,
175- " GPU/TransformOps/GPUTransformOps.td" ,
176- " Linalg/TransformOps/LinalgMatchOps.td" ,
177- " Linalg/TransformOps/LinalgTransformOps.td" ,
178- " MemRef/TransformOps/MemRefTransformOps.td" ,
179- " NVGPU/TransformOps/NVGPUTransformOps.td" ,
180- " SCF/TransformOps/SCFTransformOps.td" ,
181- " Tensor/TransformOps/TensorTransformOps.td" ,
182- " Transform/IR/TransformOps.td" ,
183- " Vector/TransformOps/VectorTransformOps.td" ,
184- ]),
197+ (
198+ " transform" ,
199+ " Transform.jl" ,
200+ [
201+ " Affine/TransformOps/AffineTransformOps.td" ,
202+ " Bufferization/TransformOps/BufferizationTransformOps.td" ,
203+ " GPU/TransformOps/GPUTransformOps.td" ,
204+ " Linalg/TransformOps/LinalgMatchOps.td" ,
205+ " Linalg/TransformOps/LinalgTransformOps.td" ,
206+ " MemRef/TransformOps/MemRefTransformOps.td" ,
207+ " NVGPU/TransformOps/NVGPUTransformOps.td" ,
208+ " SCF/TransformOps/SCFTransformOps.td" ,
209+ " Tensor/TransformOps/TensorTransformOps.td" ,
210+ " Transform/IR/TransformOps.td" ,
211+ " Vector/TransformOps/VectorTransformOps.td" ,
212+ ],
213+ ),
185214 (" ub" , " UB.jl" , [" UB/IR/UBOps.td" ]),
186215 (" vector" , " Vector.jl" , [" Vector/IR/VectorOps.td" ]),
187216 (" x86vector" , " X86Vector.jl" , [" X86Vector/X86Vector.td" ]),
195224
196225function rewrite! (dag:: ExprDAG ) end
197226
198- julia_llvm = Dict ([v " 1.9" => v " 14.0.5+3" , v " 1.10" => v " 15.0.7+10" , v " 1.11" => v " 16.0.6+2" , v " 1.12" => v " 17.0.6+3" ])
227+ julia_llvm = Dict ([
228+ v " 1.9" => v " 14.0.5+3" ,
229+ v " 1.10" => v " 15.0.7+10" ,
230+ v " 1.11" => v " 16.0.6+2" ,
231+ v " 1.12" => v " 17.0.6+3" ,
232+ ])
199233options = load_options (joinpath (@__DIR__ , " wrap.toml" ))
200234
201235@add_def off_t
@@ -212,7 +246,7 @@ for (julia_version, llvm_version) in julia_llvm
212246 # Note: 1.10
213247 dependencies = PkgSpec[
214248 PkgSpec (; name= " LLVM_full_jll" , version= llvm_version),
215- PkgSpec (; name= " mlir_jl_tblgen_jll" )
249+ PkgSpec (; name= " mlir_jl_tblgen_jll" ),
216250 ]
217251
218252 artifact_paths = setup_dependencies (prefix, dependencies, platform; verbose= true )
@@ -224,7 +258,14 @@ for (julia_version, llvm_version) in julia_llvm
224258 mkpath (joinpath (@__DIR__ , " .." , " src" , " API" , string (llvm_version. major)))
225259
226260 let options = deepcopy (options)
227- output_file_path = joinpath (@__DIR__ , " .." , " src" , " API" , string (llvm_version. major), options[" general" ][" output_file_path" ])
261+ output_file_path = joinpath (
262+ @__DIR__ ,
263+ " .." ,
264+ " src" ,
265+ " API" ,
266+ string (llvm_version. major),
267+ options[" general" ][" output_file_path" ],
268+ )
228269 isdir (dirname (output_file_path)) || mkpath (dirname (output_file_path))
229270 options[" general" ][" output_file_path" ] = output_file_path
230271
@@ -233,7 +274,9 @@ for (julia_version, llvm_version) in julia_llvm
233274 push! (args, " -I$include_dir " )
234275 push! (args, " -xc++" )
235276
236- headers = detect_headers (libmlir_header_dir, args, Dict (), endswith (" Python/Interop.h" ))
277+ headers = detect_headers (
278+ libmlir_header_dir, args, Dict (), endswith (" Python/Interop.h" )
279+ )
237280 ctx = create_context (headers, args, options)
238281
239282 # build without printing so we can do custom rewriting
@@ -256,15 +299,20 @@ for (julia_version, llvm_version) in julia_llvm
256299 " --generator=jl-op-defs" ,
257300 " --disable-module-wrap" ,
258301 tdpath,
259- " -I" , dirname (tdpath),
260- " -I" , include_dir,
261- " -o" , tempfile,
302+ " -I" ,
303+ dirname (tdpath),
304+ " -I" ,
305+ include_dir,
306+ " -o" ,
307+ tempfile,
262308 ]
263309 run (` $mlir_jl_tblgen $flags ` )
264310 return tempfile
265311 end
266312
267- output = joinpath (@__DIR__ , " .." , " src" , " Dialects" , string (llvm_version. major), binding)
313+ output = joinpath (
314+ @__DIR__ , " .." , " src" , " Dialects" , string (llvm_version. major), binding
315+ )
268316 open (output, " w" ) do io
269317 println (io, " module $dialect_name \n " )
270318 for tempfile in tempfiles
0 commit comments