1
1
using 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
3
4
using Clang. Generators
4
5
5
6
function mlir_dialects (version:: VersionNumber )
@@ -23,7 +24,11 @@ function mlir_dialects(version::VersionNumber)
23
24
# ("dlti", "DLTI.jl", ["DLTI/DLTI.td"]), # TODO crashes
24
25
(" emitc" , " EmitC.jl" , [" EmitC/IR/EmitC.td" ]),
25
26
(" 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
+ ),
27
32
(" llvm" , " LLVMIR.jl" , [" LLVMIR/LLVMOps.td" ]),
28
33
(" math" , " Math.jl" , [" Math/IR/MathOps.td" ]),
29
34
(" memref" , " MemRef.jl" , [" MemRef/IR/MemRefOps.td" ]),
@@ -59,7 +64,11 @@ function mlir_dialects(version::VersionNumber)
59
64
(" emitc" , " EmitC.jl" , [" EmitC/IR/EmitC.td" ]),
60
65
(" func" , " Func.jl" , [" Func/IR/FuncOps.td" ]),
61
66
(" 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
+ ),
63
72
(" llvm" , " LLVMIR.jl" , [" LLVMIR/LLVMOps.td" ]),
64
73
(" math" , " Math.jl" , [" Math/IR/MathOps.td" ]),
65
74
(" memref" , " MemRef.jl" , [" MemRef/IR/MemRefOps.td" ]),
@@ -75,12 +84,16 @@ function mlir_dialects(version::VersionNumber)
75
84
(" spv" , " SPIRV.jl" , [" SPIRV/IR/SPIRVOps.td" ]), # dialect name renamed to 'spirv' in v16
76
85
(" tensor" , " Tensor.jl" , [" Tensor/IR/TensorOps.td" ]),
77
86
(" 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
84
97
(" vector" , " Vector.jl" , [" Vector/IR/VectorOps.td" ]),
85
98
(" x86vector" , " X86Vector.jl" , [" X86Vector/X86Vector.td" ]),
86
99
]
@@ -103,7 +116,11 @@ function mlir_dialects(version::VersionNumber)
103
116
(" func" , " Func.jl" , [" Func/IR/FuncOps.td" ]),
104
117
(" gpu" , " GPU.jl" , [" GPU/IR/GPUOps.td" ]),
105
118
(" 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
+ ),
107
124
(" llvm" , " LLVMIR.jl" , [" LLVMIR/LLVMOps.td" ]),
108
125
(" math" , " Math.jl" , [" Math/IR/MathOps.td" ]),
109
126
(" memref" , " MemRef.jl" , [" MemRef/IR/MemRefOps.td" ]),
@@ -119,16 +136,20 @@ function mlir_dialects(version::VersionNumber)
119
136
(" spirv" , " SPIRV.jl" , [" SPIRV/IR/SPIRVOps.td" ]),
120
137
(" tensor" , " Tensor.jl" , [" Tensor/IR/TensorOps.td" ]),
121
138
(" 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
132
153
(" vector" , " Vector.jl" , [" Vector/IR/VectorOps.td" ]),
133
154
(" x86vector" , " X86Vector.jl" , [" X86Vector/X86Vector.td" ]),
134
155
]
@@ -153,7 +174,11 @@ function mlir_dialects(version::VersionNumber)
153
174
(" gpu" , " GPU.jl" , [" GPU/IR/GPUOps.td" ]),
154
175
(" index" , " Index.jl" , [" Index/IR/IndexOps.td" ]),
155
176
(" 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
+ ),
157
182
(" llvm" , " LLVMIR.jl" , [" LLVMIR/LLVMOps.td" ]),
158
183
(" math" , " Math.jl" , [" Math/IR/MathOps.td" ]),
159
184
(" memref" , " MemRef.jl" , [" MemRef/IR/MemRefOps.td" ]),
@@ -169,19 +194,23 @@ function mlir_dialects(version::VersionNumber)
169
194
(" spirv" , " SPIRV.jl" , [" SPIRV/IR/SPIRVOps.td" ]),
170
195
(" tensor" , " Tensor.jl" , [" Tensor/IR/TensorOps.td" ]),
171
196
(" 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
+ ),
185
214
(" ub" , " UB.jl" , [" UB/IR/UBOps.td" ]),
186
215
(" vector" , " Vector.jl" , [" Vector/IR/VectorOps.td" ]),
187
216
(" x86vector" , " X86Vector.jl" , [" X86Vector/X86Vector.td" ]),
195
224
196
225
function rewrite! (dag:: ExprDAG ) end
197
226
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
+ ])
199
233
options = load_options (joinpath (@__DIR__ , " wrap.toml" ))
200
234
201
235
@add_def off_t
@@ -212,7 +246,7 @@ for (julia_version, llvm_version) in julia_llvm
212
246
# Note: 1.10
213
247
dependencies = PkgSpec[
214
248
PkgSpec (; name= " LLVM_full_jll" , version= llvm_version),
215
- PkgSpec (; name= " mlir_jl_tblgen_jll" )
249
+ PkgSpec (; name= " mlir_jl_tblgen_jll" ),
216
250
]
217
251
218
252
artifact_paths = setup_dependencies (prefix, dependencies, platform; verbose= true )
@@ -224,7 +258,14 @@ for (julia_version, llvm_version) in julia_llvm
224
258
mkpath (joinpath (@__DIR__ , " .." , " src" , " API" , string (llvm_version. major)))
225
259
226
260
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
+ )
228
269
isdir (dirname (output_file_path)) || mkpath (dirname (output_file_path))
229
270
options[" general" ][" output_file_path" ] = output_file_path
230
271
@@ -233,7 +274,9 @@ for (julia_version, llvm_version) in julia_llvm
233
274
push! (args, " -I$include_dir " )
234
275
push! (args, " -xc++" )
235
276
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
+ )
237
280
ctx = create_context (headers, args, options)
238
281
239
282
# build without printing so we can do custom rewriting
@@ -256,15 +299,20 @@ for (julia_version, llvm_version) in julia_llvm
256
299
" --generator=jl-op-defs" ,
257
300
" --disable-module-wrap" ,
258
301
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,
262
308
]
263
309
run (` $mlir_jl_tblgen $flags ` )
264
310
return tempfile
265
311
end
266
312
267
- output = joinpath (@__DIR__ , " .." , " src" , " Dialects" , string (llvm_version. major), binding)
313
+ output = joinpath (
314
+ @__DIR__ , " .." , " src" , " Dialects" , string (llvm_version. major), binding
315
+ )
268
316
open (output, " w" ) do io
269
317
println (io, " module $dialect_name \n " )
270
318
for tempfile in tempfiles
0 commit comments