Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MLIR 18 #79

Merged
merged 12 commits into from
Jul 21, 2024
134 changes: 124 additions & 10 deletions bindings/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ function mlir_dialects(version::VersionNumber)
"Linalg.jl",
["Linalg/IR/LinalgOps.td", "Linalg/IR/LinalgStructuredOps.td"],
),
("llvm", "LLVMIR.jl", ["LLVMIR/LLVMOps.td"]),
(
"llvm",
"LLVMIR.jl",
["LLVMIR/LLVMOps.td", "LLVMIR/NVVMOps.td", "LLVMIR/ROCDLOps.td"],
),
("math", "Math.jl", ["Math/IR/MathOps.td"]),
("memref", "MemRef.jl", ["MemRef/IR/MemRefOps.td"]),
("omp", "OpenMP.jl", ["OpenMP/OpenMPOps.td"]),
Expand Down Expand Up @@ -69,7 +73,16 @@ function mlir_dialects(version::VersionNumber)
"Linalg.jl",
["Linalg/IR/LinalgOps.td", "Linalg/IR/LinalgStructuredOps.td"],
),
("llvm", "LLVMIR.jl", ["LLVMIR/LLVMOps.td"]),
(
"llvm",
"LLVMIR.jl",
[
"LLVMIR/LLVMOps.td",
"LLVMIR/LLVMIntrinsicOps.td",
"LLVMIR/NVVMOps.td",
"LLVMIR/ROCDLOps.td",
],
),
("math", "Math.jl", ["Math/IR/MathOps.td"]),
("memref", "MemRef.jl", ["MemRef/IR/MemRefOps.td"]),
("ml_program", "MLProgram.jl", ["MLProgram/IR/MLProgramOps.td"]),
Expand Down Expand Up @@ -121,7 +134,16 @@ function mlir_dialects(version::VersionNumber)
"Linalg.jl",
["Linalg/IR/LinalgOps.td", "Linalg/IR/LinalgStructuredOps.td"],
),
("llvm", "LLVMIR.jl", ["LLVMIR/LLVMOps.td"]),
(
"llvm",
"LLVMIR.jl",
[
"LLVMIR/LLVMOps.td",
"LLVMIR/LLVMIntrinsicOps.td",
"LLVMIR/NVVMOps.td",
"LLVMIR/ROCDLOps.td",
],
),
("math", "Math.jl", ["Math/IR/MathOps.td"]),
("memref", "MemRef.jl", ["MemRef/IR/MemRefOps.td"]),
("ml_program", "MLProgram.jl", ["MLProgram/IR/MLProgramOps.td"]),
Expand Down Expand Up @@ -179,7 +201,16 @@ function mlir_dialects(version::VersionNumber)
"Linalg.jl",
["Linalg/IR/LinalgOps.td", "Linalg/IR/LinalgStructuredOps.td"],
),
("llvm", "LLVMIR.jl", ["LLVMIR/LLVMOps.td"]),
(
"llvm",
"LLVMIR.jl",
[
"LLVMIR/LLVMOps.td",
"LLVMIR/LLVMIntrinsicOps.td",
"LLVMIR/NVVMOps.td",
"LLVMIR/ROCDLOps.td",
],
),
("math", "Math.jl", ["Math/IR/MathOps.td"]),
("memref", "MemRef.jl", ["MemRef/IR/MemRefOps.td"]),
("ml_program", "MLProgram.jl", ["MLProgram/IR/MLProgramOps.td"]),
Expand Down Expand Up @@ -215,6 +246,88 @@ function mlir_dialects(version::VersionNumber)
("vector", "Vector.jl", ["Vector/IR/VectorOps.td"]),
("x86vector", "X86Vector.jl", ["X86Vector/X86Vector.td"]),
]
elseif v"18" <= version < v"19"
[
("acc", "OpenACC.jl", ["OpenACC/OpenACCOps.td"]),
("affine", "Affine.jl", ["Affine/IR/AffineOps.td"]),
("amdgpu", "AMDGPU.jl", ["AMDGPU/IR/AMDGPU.td"]),
("amx", "AMX.jl", ["AMX/AMX.td"]),
("arith", "Arith.jl", ["Arith/IR/ArithOps.td"]),
("arm_neon", "ArmNeon.jl", ["ArmNeon/ArmNeon.td"]),
(
"arm_sme",
"ArmSME.jl",
["ArmSME/IR/ArmSMEOps.td", "ArmSME/IR/ArmSMEIntrinsicOps.td"],
),
("arm_sve", "ArmSVE.jl", ["ArmSVE/IR/ArmSVE.td"]),
("async", "Async.jl", ["Async/IR/AsyncOps.td"]),
("bufferization", "Bufferization.jl", ["Bufferization/IR/BufferizationOps.td"]),
("builtin", "Builtin.jl", ["../IR/BuiltinOps.td"]),
("cf", "ControlFlow.jl", ["ControlFlow/IR/ControlFlowOps.td"]),
("complex", "Complex.jl", ["Complex/IR/ComplexOps.td"]),
# ("dlti", "DLTI.jl", ["DLTI/DLTI.td"]), # TODO crashes
("emitc", "EmitC.jl", ["EmitC/IR/EmitC.td"]),
("func", "Func.jl", ["Func/IR/FuncOps.td"]),
("gpu", "GPU.jl", ["GPU/IR/GPUOps.td"]),
("index", "Index.jl", ["Index/IR/IndexOps.td"]),
("irdl", "IRDL.jl", ["IRDL/IR/IRDLOps.td"]),
(
"linalg",
"Linalg.jl",
["Linalg/IR/LinalgOps.td", "Linalg/IR/LinalgStructuredOps.td"],
),
(
"llvm",
"LLVMIR.jl",
[
"LLVMIR/LLVMOps.td",
"LLVMIR/LLVMIntrinsicOps.td",
"LLVMIR/NVVMOps.td",
"LLVMIR/ROCDLOps.td",
],
),
("math", "Math.jl", ["Math/IR/MathOps.td"]),
("memref", "MemRef.jl", ["MemRef/IR/MemRefOps.td"]),
("mesh", "Mesh.jl", ["Mesh/IR/MeshOps.td"]),
("ml_program", "MLProgram.jl", ["MLProgram/IR/MLProgramOps.td"]),
("nvgpu", "NVGPU.jl", ["NVGPU/IR/NVGPU.td"]),
("omp", "OpenMP.jl", ["OpenMP/OpenMPOps.td"]),
("pdl_interp", "PDLInterp.jl", ["PDLInterp/IR/PDLInterpOps.td"]),
("pdl", "PDL.jl", ["PDL/IR/PDLOps.td"]),
("quant", "Quant.jl", ["Quant/QuantOps.td"]),
("scf", "SCF.jl", ["SCF/IR/SCFOps.td"]),
("shape", "Shape.jl", ["Shape/IR/ShapeOps.td"]),
("sparse_tensor", "SparseTensor.jl", ["SparseTensor/IR/SparseTensorOps.td"]),
("spirv", "SPIRV.jl", ["SPIRV/IR/SPIRVOps.td"]),
("tensor", "Tensor.jl", ["Tensor/IR/TensorOps.td"]),
("tosa", "Tosa.jl", ["Tosa/IR/TosaOps.td"]),
(
"transform",
"Transform.jl",
[
"Affine/TransformOps/AffineTransformOps.td",
"Bufferization/TransformOps/BufferizationTransformOps.td",
"Func/TransformOps/FuncTransformOps.td",
"GPU/TransformOps/GPUTransformOps.td",
"Linalg/TransformOps/LinalgMatchOps.td",
"Linalg/TransformOps/LinalgTransformOps.td",
"MemRef/TransformOps/MemRefTransformOps.td",
"NVGPU/TransformOps/NVGPUTransformOps.td",
"SCF/TransformOps/SCFTransformOps.td",
"SparseTensor/TransformOps/SparseTensorTransformOps.td",
"Tensor/TransformOps/TensorTransformOps.td",
"Transform/IR/TransformOps.td",
"Transform/DebugExtension/DebugExtensionOps.td",
"Transform/LoopExtension/LoopExtensionOps.td",
"Transform/PDLExtension/PDLExtensionOps.td",
"Vector/TransformOps/VectorTransformOps.td",
],
),
("ub", "UB.jl", ["UB/IR/UBOps.td"]),
("vector", "Vector.jl", ["Vector/IR/VectorOps.td"]),
("x86vector", "X86Vector.jl", ["X86Vector/X86Vector.td"]),
]

else
error("Unsupported MLIR version: $version")
end
Expand All @@ -224,12 +337,13 @@ end

function rewrite!(dag::ExprDAG) end

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",
])
julia_llvm = [
(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"),
(v"1.12", v"18.1.7+2"),
]
options = load_options(joinpath(@__DIR__, "wrap.toml"))

@add_def off_t
Expand Down
7 changes: 4 additions & 3 deletions deps/tblgen/jl-generators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <regex>
#include <optional>
#include <iostream>
#include <numeric>

#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Sequence.h"
Expand Down Expand Up @@ -307,7 +308,7 @@ end
for (int i = 0; i < op.getNumOperands(); i++)
{
const auto &named_operand = op.getOperand(i);
std::string operandname = named_operand.name.str();
std::string operandname = sanitizeName(named_operand.name.str());
if (operandname.empty())
{
operandname = "operand_" + std::to_string(i);
Expand All @@ -317,8 +318,8 @@ end
else
opseglist.push_back(named_operand.isVariadic() ? "length(" + operandname + "), " : "1, ");
}
std::string operandsegmentsizes = std::accumulate(std::begin(x), std::end(x), string(),
[](string &ss, string &s)
std::string operandsegmentsizes = std::accumulate(std::begin(opseglist), std::end(opseglist), std::string(),
[](std::string &ss, std::string &s)
{
return ss.empty() ? s : ss + "," + s;
});
Expand Down
Loading
Loading