diff --git a/src/Dialects/14/AMX.jl b/src/Dialects/14/AMX.jl index ef35e3f3..c7d28870 100644 --- a/src/Dialects/14/AMX.jl +++ b/src/Dialects/14/AMX.jl @@ -240,8 +240,8 @@ function tile_muli(lhs::Value, rhs::Value, acc::Value; res::MLIRType, isZextLhs= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (isZextLhs != nothing) && push!(attributes, namedattribute("isZextLhs", isZextLhs)) - (isZextRhs != nothing) && push!(attributes, namedattribute("isZextRhs", isZextRhs)) + !isnothing(isZextLhs) && push!(attributes, namedattribute("isZextLhs", isZextLhs)) + !isnothing(isZextRhs) && push!(attributes, namedattribute("isZextRhs", isZextRhs)) create_operation( "amx.tile_muli", location; diff --git a/src/Dialects/14/Arithmetic.jl b/src/Dialects/14/Arithmetic.jl index 400b1837..95b0c7cc 100644 --- a/src/Dialects/14/Arithmetic.jl +++ b/src/Dialects/14/Arithmetic.jl @@ -35,7 +35,7 @@ function addf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.addf", location; @@ -72,7 +72,7 @@ function addi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.addi", location; @@ -109,7 +109,7 @@ function andi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.andi", location; @@ -173,7 +173,7 @@ function ceildivsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.ceildivsi", location; @@ -206,7 +206,7 @@ function ceildivui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.ceildivui", location; @@ -380,7 +380,7 @@ function divf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.divf", location; @@ -418,7 +418,7 @@ function divsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.divsi", location; @@ -457,7 +457,7 @@ function divui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.divui", location; @@ -624,7 +624,7 @@ function floordivsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.floordivsi", location; @@ -682,7 +682,7 @@ function maxf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.maxf", location; @@ -702,7 +702,7 @@ function maxsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.maxsi", location; @@ -722,7 +722,7 @@ function maxui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.maxui", location; @@ -757,7 +757,7 @@ function minf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.minf", location; @@ -777,7 +777,7 @@ function minsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.minsi", location; @@ -797,7 +797,7 @@ function minui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.minui", location; @@ -837,7 +837,7 @@ function mulf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.mulf", location; @@ -857,7 +857,7 @@ function muli(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.muli", location; @@ -894,7 +894,7 @@ function negf(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.negf", location; @@ -931,7 +931,7 @@ function ori(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.ori", location; @@ -951,7 +951,7 @@ function remf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.remf", location; @@ -989,7 +989,7 @@ function remsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.remsi", location; @@ -1027,7 +1027,7 @@ function remui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.remui", location; @@ -1080,7 +1080,7 @@ function shli(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.shli", location; @@ -1114,7 +1114,7 @@ function shrsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.shrsi", location; @@ -1145,7 +1145,7 @@ function shrui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.shrui", location; @@ -1185,7 +1185,7 @@ function subf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.subf", location; @@ -1205,7 +1205,7 @@ function subi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.subi", location; @@ -1321,7 +1321,7 @@ function xori(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.xori", location; diff --git a/src/Dialects/14/ArmNeon.jl b/src/Dialects/14/ArmNeon.jl index 7fafa0f7..d6d30af9 100644 --- a/src/Dialects/14/ArmNeon.jl +++ b/src/Dialects/14/ArmNeon.jl @@ -32,7 +32,7 @@ function intr_smull(a::Value, b::Value; res::MLIRType, location=Location()) end """ -`2d_sdot` +`_2d_sdot` The two input vectors `b` and `c` have a 2D shape, consisting of either 2 or 4 rows, each row having length 4. This operation computes the pair-wise @@ -43,20 +43,20 @@ corresponding entry of `a`: res[i] := a[i] + dot_product(b[i, ...], c[i, ...]) ``` """ -# function 2d_sdot(a::Value, b::Value, c::Value; res::MLIRType, location=Location()) -# results = MLIRType[res, ] -# operands = Value[a, b, c, ] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[] +function _2d_sdot(a::Value, b::Value, c::Value; res::MLIRType, location=Location()) + results = MLIRType[res, ] + operands = Value[a, b, c, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] -# create_operation( -# "arm_neon.2d.sdot", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "arm_neon.2d.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `intr_sdot` diff --git a/src/Dialects/14/Async.jl b/src/Dialects/14/Async.jl index b4919e20..0518e27a 100644 --- a/src/Dialects/14/Async.jl +++ b/src/Dialects/14/Async.jl @@ -26,7 +26,7 @@ function add_to_group(operand::Value, group::Value; rank=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (rank != nothing) && push!(results, rank) + !isnothing(rank) && push!(results, rank) create_operation( "async.add_to_group", location; @@ -93,7 +93,7 @@ function await(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.await", location; @@ -115,7 +115,7 @@ function coro_begin(id::Value; handle=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (handle != nothing) && push!(results, handle) + !isnothing(handle) && push!(results, handle) create_operation( "async.coro.begin", location; @@ -179,7 +179,7 @@ function coro_id(; id=nothing::Union{Nothing, MLIRType}, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (id != nothing) && push!(results, id) + !isnothing(id) && push!(results, id) create_operation( "async.coro.id", location; @@ -200,7 +200,7 @@ function coro_save(handle::Value; state=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (state != nothing) && push!(results, state) + !isnothing(state) && push!(results, state) create_operation( "async.coro.save", location; @@ -260,7 +260,7 @@ function create_group(size::Value; result=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.create_group", location; @@ -360,7 +360,7 @@ function runtime_add_to_group(operand::Value, group::Value; rank=nothing::Union{ owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (rank != nothing) && push!(results, rank) + !isnothing(rank) && push!(results, rank) create_operation( "async.runtime.add_to_group", location; @@ -425,7 +425,7 @@ function runtime_create_group(size::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.runtime.create_group", location; @@ -491,7 +491,7 @@ function runtime_is_error(operand::Value; is_error=nothing::Union{Nothing, MLIRT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (is_error != nothing) && push!(results, is_error) + !isnothing(is_error) && push!(results, is_error) create_operation( "async.runtime.is_error", location; @@ -534,7 +534,7 @@ function runtime_num_worker_threads(; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.runtime.num_worker_threads", location; diff --git a/src/Dialects/14/Builtin.jl b/src/Dialects/14/Builtin.jl index abb2ad3e..f9341e1f 100644 --- a/src/Dialects/14/Builtin.jl +++ b/src/Dialects/14/Builtin.jl @@ -50,7 +50,7 @@ function func(; sym_name, type, sym_visibility=nothing, body::Region, location=L owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("type", type), ] - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "builtin.func", location; @@ -85,8 +85,8 @@ function module_(; sym_name=nothing, sym_visibility=nothing, body::Region, locat owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (sym_name != nothing) && push!(attributes, namedattribute("sym_name", sym_name)) - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "builtin.module", location; diff --git a/src/Dialects/14/Complex.jl b/src/Dialects/14/Complex.jl index 3e523d4e..862293dd 100644 --- a/src/Dialects/14/Complex.jl +++ b/src/Dialects/14/Complex.jl @@ -48,7 +48,7 @@ function add(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.add", location; @@ -128,7 +128,7 @@ function div(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.div", location; @@ -155,7 +155,7 @@ function eq(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.eq", location; @@ -184,7 +184,7 @@ function exp(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.exp", location; @@ -240,7 +240,7 @@ function log1p(complex::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.log1p", location; @@ -269,7 +269,7 @@ function log(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.log", location; @@ -294,7 +294,7 @@ function mul(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.mul", location; @@ -321,7 +321,7 @@ function neg(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.neg", location; @@ -349,7 +349,7 @@ function neq(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.neq", location; @@ -403,7 +403,7 @@ function sign(complex::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.sign", location; @@ -430,7 +430,7 @@ function sub(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.sub", location; diff --git a/src/Dialects/14/EmitC.jl b/src/Dialects/14/EmitC.jl index b92895db..d6acf630 100644 --- a/src/Dialects/14/EmitC.jl +++ b/src/Dialects/14/EmitC.jl @@ -63,8 +63,8 @@ function call(operands::Vector{Value}; result_0::Vector{MLIRType}, callee, args= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("callee", callee), ] - (args != nothing) && push!(attributes, namedattribute("args", args)) - (template_args != nothing) && push!(attributes, namedattribute("template_args", template_args)) + !isnothing(args) && push!(attributes, namedattribute("args", args)) + !isnothing(template_args) && push!(attributes, namedattribute("template_args", template_args)) create_operation( "emitc.call", location; @@ -138,7 +138,7 @@ function include(; include, is_standard_include=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("include", include), ] - (is_standard_include != nothing) && push!(attributes, namedattribute("is_standard_include", is_standard_include)) + !isnothing(is_standard_include) && push!(attributes, namedattribute("is_standard_include", is_standard_include)) create_operation( "emitc.include", location; diff --git a/src/Dialects/14/GPU.jl b/src/Dialects/14/GPU.jl index 0cc84420..c2a455f4 100644 --- a/src/Dialects/14/GPU.jl +++ b/src/Dialects/14/GPU.jl @@ -36,8 +36,8 @@ function all_reduce(value::Value; result_0=nothing::Union{Nothing, MLIRType}, op owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (result_0 != nothing) && push!(results, result_0) - (op != nothing) && push!(attributes, namedattribute("op", op)) + !isnothing(result_0) && push!(results, result_0) + !isnothing(op) && push!(attributes, namedattribute("op", op)) create_operation( "gpu.all_reduce", location; @@ -73,7 +73,7 @@ function alloc(asyncDependencies::Vector{Value}, dynamicSizes::Vector{Value}, sy successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(asyncDependencies), length(dynamicSizes), length(symbolOperands), ])) - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.alloc", location; @@ -135,7 +135,7 @@ function block_dim(; result_0=nothing::Union{Nothing, MLIRType}, dimension, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.block_dim", location; @@ -163,7 +163,7 @@ function block_id(; result_0=nothing::Union{Nothing, MLIRType}, dimension, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.block_id", location; @@ -199,7 +199,7 @@ function dealloc(asyncDependencies::Vector{Value}, memref::Value; asyncToken=not owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.dealloc", location; @@ -342,7 +342,7 @@ function grid_dim(; result_0=nothing::Union{Nothing, MLIRType}, dimension, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.grid_dim", location; @@ -466,9 +466,9 @@ function launch_func(asyncDependencies::Vector{Value}, gridSizeX::Value, gridSiz owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kernel", kernel), ] - (dynamicSharedMemorySize != nothing) && push!(operands, dynamicSharedMemorySize) + !isnothing(dynamicSharedMemorySize) && push!(operands, dynamicSharedMemorySize) push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1length(operands), ])) - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.launch_func", location; @@ -552,7 +552,7 @@ function launch(gridSizeX::Value, gridSizeY::Value, gridSizeZ::Value, blockSizeX owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (dynamicSharedMemorySize != nothing) && push!(operands, dynamicSharedMemorySize) + !isnothing(dynamicSharedMemorySize) && push!(operands, dynamicSharedMemorySize) create_operation( "gpu.launch", location; @@ -586,7 +586,7 @@ function memcpy(asyncDependencies::Vector{Value}, dst::Value, src::Value; asyncT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.memcpy", location; @@ -620,7 +620,7 @@ function memset(asyncDependencies::Vector{Value}, dst::Value, value::Value; asyn owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.memset", location; @@ -667,7 +667,7 @@ function num_subgroups(; result=nothing::Union{Nothing, MLIRType}, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "gpu.num_subgroups", location; @@ -750,8 +750,8 @@ function shuffle(value::Value, offset::Value, width::Value; result=nothing::Unio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("mode", mode), ] - (result != nothing) && push!(results, result) - (valid != nothing) && push!(results, valid) + !isnothing(result) && push!(results, result) + !isnothing(valid) && push!(results, valid) create_operation( "gpu.shuffle", location; @@ -779,7 +779,7 @@ function subgroup_id(; result=nothing::Union{Nothing, MLIRType}, location=Locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "gpu.subgroup_id", location; @@ -817,7 +817,7 @@ function subgroup_mma_compute(opA::Value, opB::Value, opC::Value; res=nothing::U owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "gpu.subgroup_mma_compute", location; @@ -993,7 +993,7 @@ function subgroup_size(; result=nothing::Union{Nothing, MLIRType}, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "gpu.subgroup_size", location; @@ -1043,7 +1043,7 @@ function thread_id(; result_0=nothing::Union{Nothing, MLIRType}, dimension, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.thread_id", location; @@ -1092,7 +1092,7 @@ function wait(asyncDependencies::Vector{Value}; asyncToken=nothing::Union{Nothin owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.wait", location; diff --git a/src/Dialects/14/LLVMIR.jl b/src/Dialects/14/LLVMIR.jl index dfae218a..db672730 100644 --- a/src/Dialects/14/LLVMIR.jl +++ b/src/Dialects/14/LLVMIR.jl @@ -15,7 +15,7 @@ function ashr(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.ashr", location; @@ -62,7 +62,7 @@ function add(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.add", location; @@ -149,7 +149,7 @@ function alias_scope_domain(; sym_name, description=nothing, location=Location() owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), ] - (description != nothing) && push!(attributes, namedattribute("description", description)) + !isnothing(description) && push!(attributes, namedattribute("description", description)) create_operation( "llvm.alias_scope_domain", location; @@ -198,7 +198,7 @@ function alias_scope(; sym_name, domain, description=nothing, location=Location( owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("domain", domain), ] - (description != nothing) && push!(attributes, namedattribute("description", description)) + !isnothing(description) && push!(attributes, namedattribute("description", description)) create_operation( "llvm.alias_scope", location; @@ -218,7 +218,7 @@ function alloca(arraySize::Value; res::MLIRType, alignment=nothing, location=Loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "llvm.alloca", location; @@ -238,7 +238,7 @@ function and(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.and", location; @@ -315,7 +315,7 @@ function intr_bitreverse(in::Value; res=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.bitreverse", location; @@ -399,8 +399,8 @@ function call(operand_0::Vector{Value}; result_0::Vector{MLIRType}, callee=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (callee != nothing) && push!(attributes, namedattribute("callee", callee)) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.call", location; @@ -421,7 +421,7 @@ function cond_br(condition::Value, trueDestOperands::Vector{Value}, falseDestOpe successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands), ])) - (branch_weights != nothing) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) create_operation( "llvm.cond_br", location; @@ -486,7 +486,7 @@ function intr_copysign(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.copysign", location; @@ -677,7 +677,7 @@ function intr_cos(in::Value; res=nothing::Union{Nothing, MLIRType}, location=Loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.cos", location; @@ -735,7 +735,7 @@ function intr_ctpop(in::Value; res=nothing::Union{Nothing, MLIRType}, location=L owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.ctpop", location; @@ -774,7 +774,7 @@ function intr_exp2(in::Value; res=nothing::Union{Nothing, MLIRType}, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.exp2", location; @@ -794,7 +794,7 @@ function intr_exp(in::Value; res=nothing::Union{Nothing, MLIRType}, location=Loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.exp", location; @@ -852,7 +852,7 @@ function intr_fabs(in::Value; res=nothing::Union{Nothing, MLIRType}, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.fabs", location; @@ -872,8 +872,8 @@ function fadd(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fadd", location; @@ -893,7 +893,7 @@ function intr_ceil(in::Value; res=nothing::Union{Nothing, MLIRType}, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.ceil", location; @@ -913,7 +913,7 @@ function fcmp(lhs::Value, rhs::Value; res::MLIRType, predicate, fastmathFlags=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("predicate", predicate), ] - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fcmp", location; @@ -933,8 +933,8 @@ function fdiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fdiv", location; @@ -954,7 +954,7 @@ function intr_floor(in::Value; res=nothing::Union{Nothing, MLIRType}, location=L owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.floor", location; @@ -974,7 +974,7 @@ function intr_fma(a::Value, b::Value, c::Value; res=nothing::Union{Nothing, MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.fma", location; @@ -994,7 +994,7 @@ function intr_fmuladd(a::Value, b::Value, c::Value; res=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.fmuladd", location; @@ -1014,8 +1014,8 @@ function fmul(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fmul", location; @@ -1035,8 +1035,8 @@ function fneg(operand::Value; res=nothing::Union{Nothing, MLIRType}, fastmathFla owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fneg", location; @@ -1132,8 +1132,8 @@ function frem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.frem", location; @@ -1153,8 +1153,8 @@ function fsub(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fsub", location; @@ -1193,7 +1193,7 @@ function freeze(val::Value; res=nothing::Union{Nothing, MLIRType}, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.freeze", location; @@ -1415,13 +1415,13 @@ function mlir_global(; global_type, constant=nothing, sym_name, linkage, dso_loc owned_regions = Region[initializer, ] successors = Block[] attributes = NamedAttribute[namedattribute("global_type", global_type), namedattribute("sym_name", sym_name), namedattribute("linkage", linkage), ] - (constant != nothing) && push!(attributes, namedattribute("constant", constant)) - (dso_local != nothing) && push!(attributes, namedattribute("dso_local", dso_local)) - (value != nothing) && push!(attributes, namedattribute("value", value)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (addr_space != nothing) && push!(attributes, namedattribute("addr_space", addr_space)) - (unnamed_addr != nothing) && push!(attributes, namedattribute("unnamed_addr", unnamed_addr)) - (section != nothing) && push!(attributes, namedattribute("section", section)) + !isnothing(constant) && push!(attributes, namedattribute("constant", constant)) + !isnothing(dso_local) && push!(attributes, namedattribute("dso_local", dso_local)) + !isnothing(value) && push!(attributes, namedattribute("value", value)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(addr_space) && push!(attributes, namedattribute("addr_space", addr_space)) + !isnothing(unnamed_addr) && push!(attributes, namedattribute("unnamed_addr", unnamed_addr)) + !isnothing(section) && push!(attributes, namedattribute("section", section)) create_operation( "llvm.mlir.global", location; @@ -1466,11 +1466,11 @@ function inline_asm(operands::Vector{Value}; res=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("asm_string", asm_string), namedattribute("constraints", constraints), ] - (res != nothing) && push!(results, res) - (has_side_effects != nothing) && push!(attributes, namedattribute("has_side_effects", has_side_effects)) - (is_align_stack != nothing) && push!(attributes, namedattribute("is_align_stack", is_align_stack)) - (asm_dialect != nothing) && push!(attributes, namedattribute("asm_dialect", asm_dialect)) - (operand_attrs != nothing) && push!(attributes, namedattribute("operand_attrs", operand_attrs)) + !isnothing(res) && push!(results, res) + !isnothing(has_side_effects) && push!(attributes, namedattribute("has_side_effects", has_side_effects)) + !isnothing(is_align_stack) && push!(attributes, namedattribute("is_align_stack", is_align_stack)) + !isnothing(asm_dialect) && push!(attributes, namedattribute("asm_dialect", asm_dialect)) + !isnothing(operand_attrs) && push!(attributes, namedattribute("operand_attrs", operand_attrs)) create_operation( "llvm.inline_asm", location; @@ -1548,7 +1548,7 @@ function invoke(callee_operands::Vector{Value}, normalDestOperands::Vector{Value successors = Block[normalDest, unwindDest, ] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(callee_operands), length(normalDestOperands), length(unwindDestOperands), ])) - (callee != nothing) && push!(attributes, namedattribute("callee", callee)) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) create_operation( "llvm.invoke", location; @@ -1593,10 +1593,10 @@ function func(; linkage=nothing, dso_local=nothing, personality=nothing, passthr owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (linkage != nothing) && push!(attributes, namedattribute("linkage", linkage)) - (dso_local != nothing) && push!(attributes, namedattribute("dso_local", dso_local)) - (personality != nothing) && push!(attributes, namedattribute("personality", personality)) - (passthrough != nothing) && push!(attributes, namedattribute("passthrough", passthrough)) + !isnothing(linkage) && push!(attributes, namedattribute("linkage", linkage)) + !isnothing(dso_local) && push!(attributes, namedattribute("dso_local", dso_local)) + !isnothing(personality) && push!(attributes, namedattribute("personality", personality)) + !isnothing(passthrough) && push!(attributes, namedattribute("passthrough", passthrough)) create_operation( "llvm.func", location; @@ -1616,7 +1616,7 @@ function lshr(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.lshr", location; @@ -1636,7 +1636,7 @@ function landingpad(operand_0::Vector{Value}; res::MLIRType, cleanup=nothing, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (cleanup != nothing) && push!(attributes, namedattribute("cleanup", cleanup)) + !isnothing(cleanup) && push!(attributes, namedattribute("cleanup", cleanup)) create_operation( "llvm.landingpad", location; @@ -1656,12 +1656,12 @@ function load(addr::Value; res::MLIRType, access_groups=nothing, alias_scopes=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (access_groups != nothing) && push!(attributes, namedattribute("access_groups", access_groups)) - (alias_scopes != nothing) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) - (noalias_scopes != nothing) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (volatile_ != nothing) && push!(attributes, namedattribute("volatile_", volatile_)) - (nontemporal != nothing) && push!(attributes, namedattribute("nontemporal", nontemporal)) + !isnothing(access_groups) && push!(attributes, namedattribute("access_groups", access_groups)) + !isnothing(alias_scopes) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) + !isnothing(noalias_scopes) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) create_operation( "llvm.load", location; @@ -1681,7 +1681,7 @@ function intr_log10(in::Value; res=nothing::Union{Nothing, MLIRType}, location=L owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.log10", location; @@ -1701,7 +1701,7 @@ function intr_log2(in::Value; res=nothing::Union{Nothing, MLIRType}, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.log2", location; @@ -1721,7 +1721,7 @@ function intr_log(in::Value; res=nothing::Union{Nothing, MLIRType}, location=Loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.log", location; @@ -1855,7 +1855,7 @@ function intr_maxnum(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.maxnum", location; @@ -1875,7 +1875,7 @@ function intr_maximum(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.maximum", location; @@ -1998,7 +1998,7 @@ function intr_minnum(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.minnum", location; @@ -2018,7 +2018,7 @@ function intr_minimum(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.minimum", location; @@ -2038,7 +2038,7 @@ function mul(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.mul", location; @@ -2091,7 +2091,7 @@ function or(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.or", location; @@ -2130,7 +2130,7 @@ function intr_pow(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.pow", location; @@ -2245,7 +2245,7 @@ function sdiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.sdiv", location; @@ -2303,7 +2303,7 @@ function intr_smax(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.smax", location; @@ -2323,7 +2323,7 @@ function intr_smin(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.smin", location; @@ -2362,7 +2362,7 @@ function srem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.srem", location; @@ -2401,7 +2401,7 @@ function select(condition::Value, trueValue::Value, falseValue::Value; res=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.select", location; @@ -2421,7 +2421,7 @@ function shl(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.shl", location; @@ -2460,7 +2460,7 @@ function intr_sin(in::Value; res=nothing::Union{Nothing, MLIRType}, location=Loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.sin", location; @@ -2480,7 +2480,7 @@ function intr_sqrt(in::Value; res=nothing::Union{Nothing, MLIRType}, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.sqrt", location; @@ -2538,12 +2538,12 @@ function store(value::Value, addr::Value; access_groups=nothing, alias_scopes=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (access_groups != nothing) && push!(attributes, namedattribute("access_groups", access_groups)) - (alias_scopes != nothing) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) - (noalias_scopes != nothing) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (volatile_ != nothing) && push!(attributes, namedattribute("volatile_", volatile_)) - (nontemporal != nothing) && push!(attributes, namedattribute("nontemporal", nontemporal)) + !isnothing(access_groups) && push!(attributes, namedattribute("access_groups", access_groups)) + !isnothing(alias_scopes) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) + !isnothing(noalias_scopes) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) create_operation( "llvm.store", location; @@ -2563,7 +2563,7 @@ function sub(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.sub", location; @@ -2584,8 +2584,8 @@ function switch(value::Value, defaultOperands::Vector{Value}, caseOperands::Vect successors = Block[defaultDestination, caseDestinations..., ] attributes = NamedAttribute[namedattribute("case_operand_segments", case_operand_segments), ] push!(attributes, operandsegmentsizes([1, length(defaultOperands), length(caseOperands), ])) - (case_values != nothing) && push!(attributes, namedattribute("case_values", case_values)) - (branch_weights != nothing) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) create_operation( "llvm.switch", location; @@ -2643,7 +2643,7 @@ function udiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.udiv", location; @@ -2682,7 +2682,7 @@ function intr_umax(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.umax", location; @@ -2702,7 +2702,7 @@ function intr_umin(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.intr.umin", location; @@ -2741,7 +2741,7 @@ function urem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.urem", location; @@ -2829,7 +2829,7 @@ function xor(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.xor", location; @@ -2982,7 +2982,7 @@ function intr_vector_reduce_fadd(operand_0::Value, operand_1::Value; res::MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (reassoc != nothing) && push!(attributes, namedattribute("reassoc", reassoc)) + !isnothing(reassoc) && push!(attributes, namedattribute("reassoc", reassoc)) create_operation( "llvm.intr.vector.reduce.fadd", location; @@ -3040,7 +3040,7 @@ function intr_vector_reduce_fmul(operand_0::Value, operand_1::Value; res::MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (reassoc != nothing) && push!(attributes, namedattribute("reassoc", reassoc)) + !isnothing(reassoc) && push!(attributes, namedattribute("reassoc", reassoc)) create_operation( "llvm.intr.vector.reduce.fmul", location; diff --git a/src/Dialects/14/Linalg.jl b/src/Dialects/14/Linalg.jl index 797abbc2..3f35a011 100644 --- a/src/Dialects/14/Linalg.jl +++ b/src/Dialects/14/Linalg.jl @@ -48,7 +48,7 @@ function index(; result=nothing::Union{Nothing, MLIRType}, dim, location=Locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dim", dim), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "linalg.index", location; @@ -155,7 +155,7 @@ function tiled_loop(lowerBound::Vector{Value}, upperBound::Vector{Value}, step:: successors = Block[] attributes = NamedAttribute[namedattribute("iterator_types", iterator_types), ] push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(inputs), length(outputs), ])) - (distribution_types != nothing) && push!(attributes, namedattribute("distribution_types", distribution_types)) + !isnothing(distribution_types) && push!(attributes, namedattribute("distribution_types", distribution_types)) create_operation( "linalg.tiled_loop", location; @@ -193,4 +193,923 @@ function yield(values::Vector{Value}; location=Location()) ) end +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`batch_matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function batch_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.batch_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`batch_matvec` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function batch_matvec(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.batch_matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_1d_nwc_wcf` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_1d_nwc_wcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_1d_nwc_wcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_1d` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_1d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_1d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_nchw_fchw` + +Layout: + * Input: NCHW. + * Kernel: FCHW. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d_nchw_fchw(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_2d_nchw_fchw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_nhwc_hwcf` + +Layout: + * Input: NHWC. + * Kernel: HWCF. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d_nhwc_hwcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_2d_nhwc_hwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_nhwc_hwcf_q` + +Layout: + * Input: NHWC. + * Kernel: HWCF. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. This includes the zero +point offsets common to quantized operations. +""" +function conv_2d_nhwc_hwcf_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_2d_nhwc_hwcf_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_3d_ndhwc_dhwcf` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_3d_ndhwc_dhwcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_3d_ndhwc_dhwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_3d` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_3d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_3d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_1d_nwc_wc` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. Multiplier is set to 1 +which is a special case for most depthwise convolutions. +""" +function depthwise_conv_1d_nwc_wc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.depthwise_conv_1d_nwc_wc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwc` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. Multiplier is set to 1 +which is a special case for most depthwise convolutions. +""" +function depthwise_conv_2d_nhwc_hwc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwc_q` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_2d_nhwc_hwc_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwcm` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_2d_nhwc_hwcm(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwcm_q` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_2d_nhwc_hwcm_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`dot` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function dot(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.dot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`fill` + +""" +function fill(value::Value, output::Value; result=nothing::Union{Nothing, MLIRType}, region::Region, location=Location()) + results = MLIRType[] + operands = Value[value, output, ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + create_operation( + "linalg.fill", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`fill_rng_2d` + +The operation generations pseudo random numbers using a linear congruential +generator. It provides no guarantees regarding the distribution of the +generated random numbers. Instead of generating the random numbers +sequentially, it instantiates one random number generator per data element +and runs them in parallel. The seed operand and the indices of the data +element seed the random number generation. The min and max operands limit +the range of the generated random numbers. +""" +function fill_rng_2d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.fill_rng_2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`generic` + +Generic Linalg op form where the key properties of the computation are +specified as attributes. In pretty form, a `linalg.generic` op is written +as: + + ```mlir + linalg.generic #trait_attribute + ins(%A, %B : memref, + memref) + outs(%C : memref) + attrs = {other-optional-attributes} + {region} + ``` + +Where #trait_attributes is an alias of a dictionary attribute containing: + - doc [optional]: a documentation string + - indexing_maps: a list of AffineMapAttr, one AffineMapAttr per each input + and output view. Such AffineMapAttr specifies the mapping between the + loops and the indexing within each view. + - library_call [optional]: a StringAttr containing the name of an + external library function that the linalg.generic operation maps to. + The external library is assumed to be dynamically linked and no strong + compile-time guarantees are provided. In the absence of such a library + call, linalg.generic will always lower to loops. + - iterator_types: an ArrayAttr specifying the type of the enclosing loops. + Each element of the list represents and iterator of one of the following + types: + parallel, reduction, window + +# Example +Defining a #matmul_trait attribute in MLIR can be done as follows: + ```mlir + #matmul_accesses = [ + (m, n, k) -> (m, k), + (m, n, k) -> (k, n), + (m, n, k) -> (m, n) + ] + #matmul_trait = { + doc = \"C(m, n) += A(m, k) * B(k, n)\", + indexing_maps = #matmul_accesses, + library_call = \"linalg_matmul\", + iterator_types = [\"parallel\", \"parallel\", \"reduction\"] + } + ``` + +And can be reused in multiple places as: + ```mlir + linalg.generic #matmul_trait + ins(%A, %B : memref, + memref) + outs(%C : memref) + {other-optional-attributes} { + ^bb0(%a: f32, %b: f32, %c: f32) : + %d = arith.mulf %a, %b: f32 + %e = arith.addf %c, %d: f32 + linalg.yield %e : f32 + } + ``` + +This may lower to either: + ```mlir + call @linalg_matmul(%A, %B, %C) : + (memref, + memref, + memref) + -> () + ``` + +or IR resembling: +```mlir +scf.for %m = %c0 to %M step %c1 { + scf.for %n = %c0 to %N step %c1 { + scf.for %k = %c0 to %K step %c1 { + %a = load %A[%m, %k] : memref + %b = load %B[%k, %n] : memref + %c = load %C[%m, %n] : memref + %d = arith.mulf %a, %b: f32 + %e = arith.addf %c, %d: f32 + store %e, %C[%m, %n] : memref + } + } +} +``` + +To allow progressive lowering from the value world (a.k.a tensor values) to +the buffer world (a.k.a memref values), a `linalg.generic` op allows mixing +tensors and buffers operands and tensor results. + +```mlir +%C = linalg.generic #trait_attribute + ins(%A, %B : tensor, memref) + outs(%C : tensor) + {other-optional-attributes} + {region} + -> (tensor) +``` +""" +function generic(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, indexing_maps, iterator_types, doc=nothing, library_call=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(doc) && push!(attributes, namedattribute("doc", doc)) + !isnothing(library_call) && push!(attributes, namedattribute("library_call", library_call)) + + create_operation( + "linalg.generic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`matmul_unsigned` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function matmul_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.matmul_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`matvec` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function matvec(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`mmt4d` + +Differences from linalg.matmul: +* The right hand side is transposed, whence the \'t\' in \'mmt\'. +* The input and output tensors have a 4D shape instead of a 2D shape. They + are interpreted as 2D matrices with one level of 2D tile subdivision, + whence the 2+2=4 dimensions. The inner tile dimensions are identified with + \'0\' suffixes below, for instance the LHS matrix shape (M, K, M0, K0) reads + as: MxK tiles, each of shape M0xK0. +""" +function mmt4d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.mmt4d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nchw_max` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nchw_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.pooling_nchw_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_ndhwc_max` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_ndhwc_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.pooling_ndhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_ndhwc_min` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_ndhwc_min(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.pooling_ndhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_ndhwc_sum` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_ndhwc_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.pooling_ndhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_max` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.pooling_nhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_max_unsigned` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_max_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.pooling_nhwc_max_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_min` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_min(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.pooling_nhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_min_unsigned` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_min_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.pooling_nhwc_min_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_sum` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides, dilations, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.pooling_nhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`quantized_batch_matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. The quantized variant +includes zero-point adjustments for the left and right operands of the +matmul. +""" +function quantized_batch_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.quantized_batch_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`quantized_matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. The quantized variant +includes zero-point adjustments for the left and right operands of the +matmul. +""" +function quantized_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.quantized_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`soft_plus_2d` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function soft_plus_2d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.soft_plus_2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`vecmat` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function vecmat(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.vecmat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + end # linalg diff --git a/src/Dialects/14/Math.jl b/src/Dialects/14/Math.jl index c7f15b14..5df088eb 100644 --- a/src/Dialects/14/Math.jl +++ b/src/Dialects/14/Math.jl @@ -31,7 +31,7 @@ function abs(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.abs", location; @@ -81,7 +81,7 @@ function atan2(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.atan2", location; @@ -124,7 +124,7 @@ function atan(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.atan", location; @@ -167,7 +167,7 @@ function ceil(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.ceil", location; @@ -211,7 +211,7 @@ function copysign(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.copysign", location; @@ -254,7 +254,7 @@ function cos(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.cos", location; @@ -288,7 +288,7 @@ function ctlz(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.ctlz", location; @@ -322,7 +322,7 @@ function cttz(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.cttz", location; @@ -356,7 +356,7 @@ function ctpop(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.ctpop", location; @@ -399,7 +399,7 @@ function erf(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.erf", location; @@ -441,7 +441,7 @@ function exp2(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.exp2", location; @@ -485,7 +485,7 @@ function expm1(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.expm1", location; @@ -527,7 +527,7 @@ function exp(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.exp", location; @@ -570,7 +570,7 @@ function floor(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.floor", location; @@ -618,7 +618,7 @@ function fma(a::Value, b::Value, c::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.fma", location; @@ -646,7 +646,7 @@ function log10(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.log10", location; @@ -676,7 +676,7 @@ function log1p(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.log1p", location; @@ -704,7 +704,7 @@ function log2(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.log2", location; @@ -732,7 +732,7 @@ function log(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.log", location; @@ -775,7 +775,7 @@ function powf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.powf", location; @@ -799,7 +799,7 @@ function rsqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.rsqrt", location; @@ -842,7 +842,7 @@ function sin(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.sin", location; @@ -877,7 +877,7 @@ function sqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.sqrt", location; @@ -920,7 +920,7 @@ function tanh(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.tanh", location; diff --git a/src/Dialects/14/MemRef.jl b/src/Dialects/14/MemRef.jl index f43d4fc5..df87912d 100644 --- a/src/Dialects/14/MemRef.jl +++ b/src/Dialects/14/MemRef.jl @@ -252,7 +252,7 @@ function alloc(dynamicSizes::Vector{Value}, symbolOperands::Vector{Value}; memre successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "memref.alloc", location; @@ -306,7 +306,7 @@ function alloca(dynamicSizes::Vector{Value}, symbolOperands::Vector{Value}; memr successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "memref.alloca", location; @@ -801,10 +801,10 @@ function global_(; sym_name, sym_visibility=nothing, type, initial_value=nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("type", type), ] - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) - (initial_value != nothing) && push!(attributes, namedattribute("initial_value", initial_value)) - (constant != nothing) && push!(attributes, namedattribute("constant", constant)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(initial_value) && push!(attributes, namedattribute("initial_value", initial_value)) + !isnothing(constant) && push!(attributes, namedattribute("constant", constant)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "memref.global", location; diff --git a/src/Dialects/14/OpenACC.jl b/src/Dialects/14/OpenACC.jl index 099a545a..6df1d71b 100644 --- a/src/Dialects/14/OpenACC.jl +++ b/src/Dialects/14/OpenACC.jl @@ -29,9 +29,9 @@ function data(ifCond=nothing::Union{Nothing, Value}; copyOperands::Vector{Value} owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1length(copyOperands), length(copyinOperands), length(copyinReadonlyOperands), length(copyoutOperands), length(copyoutZeroOperands), length(createOperands), length(createZeroOperands), length(noCreateOperands), length(presentOperands), length(deviceptrOperands), length(attachOperands), ])) - (defaultAttr != nothing) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) create_operation( "acc.data", location; @@ -58,12 +58,12 @@ function enter_data(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(copyinOperands), length(createOperands), length(createZeroOperands), length(attachOperands), ])) - (async != nothing) && push!(attributes, namedattribute("async", async)) - (wait != nothing) && push!(attributes, namedattribute("wait", wait)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) create_operation( "acc.enter_data", location; @@ -90,13 +90,13 @@ function exit_data(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(copyoutOperands), length(deleteOperands), length(detachOperands), ])) - (async != nothing) && push!(attributes, namedattribute("async", async)) - (wait != nothing) && push!(attributes, namedattribute("wait", wait)) - (finalize != nothing) && push!(attributes, namedattribute("finalize", finalize)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + !isnothing(finalize) && push!(attributes, namedattribute("finalize", finalize)) create_operation( "acc.exit_data", location; @@ -125,8 +125,8 @@ function init(deviceTypeOperands::Vector{Value}, deviceNumOperand=nothing::Union owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (deviceNumOperand != nothing) && push!(operands, deviceNumOperand) - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(deviceNumOperand) && push!(operands, deviceNumOperand) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([length(deviceTypeOperands), (deviceNumOperand==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) create_operation( @@ -163,17 +163,17 @@ function loop(gangNum=nothing::Union{Nothing, Value}; gangStatic=nothing::Union{ owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (gangNum != nothing) && push!(operands, gangNum) - (gangStatic != nothing) && push!(operands, gangStatic) - (workerNum != nothing) && push!(operands, workerNum) - (vectorLength != nothing) && push!(operands, vectorLength) + !isnothing(gangNum) && push!(operands, gangNum) + !isnothing(gangStatic) && push!(operands, gangStatic) + !isnothing(workerNum) && push!(operands, workerNum) + !isnothing(vectorLength) && push!(operands, vectorLength) push!(attributes, operandsegmentsizes([(gangNum==nothing) ? 0 : 1(gangStatic==nothing) ? 0 : 1(workerNum==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1length(tileOperands), length(privateOperands), length(reductionOperands), ])) - (collapse != nothing) && push!(attributes, namedattribute("collapse", collapse)) - (seq != nothing) && push!(attributes, namedattribute("seq", seq)) - (independent != nothing) && push!(attributes, namedattribute("independent", independent)) - (auto_ != nothing) && push!(attributes, namedattribute("auto_", auto_)) - (reductionOp != nothing) && push!(attributes, namedattribute("reductionOp", reductionOp)) - (exec_mapping != nothing) && push!(attributes, namedattribute("exec_mapping", exec_mapping)) + !isnothing(collapse) && push!(attributes, namedattribute("collapse", collapse)) + !isnothing(seq) && push!(attributes, namedattribute("seq", seq)) + !isnothing(independent) && push!(attributes, namedattribute("independent", independent)) + !isnothing(auto_) && push!(attributes, namedattribute("auto_", auto_)) + !isnothing(reductionOp) && push!(attributes, namedattribute("reductionOp", reductionOp)) + !isnothing(exec_mapping) && push!(attributes, namedattribute("exec_mapping", exec_mapping)) create_operation( "acc.loop", location; @@ -204,18 +204,18 @@ function parallel(async=nothing::Union{Nothing, Value}; waitOperands::Vector{Val owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (async != nothing) && push!(operands, async) - (numGangs != nothing) && push!(operands, numGangs) - (numWorkers != nothing) && push!(operands, numWorkers) - (vectorLength != nothing) && push!(operands, vectorLength) - (ifCond != nothing) && push!(operands, ifCond) - (selfCond != nothing) && push!(operands, selfCond) + !isnothing(async) && push!(operands, async) + !isnothing(numGangs) && push!(operands, numGangs) + !isnothing(numWorkers) && push!(operands, numWorkers) + !isnothing(vectorLength) && push!(operands, vectorLength) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(selfCond) && push!(operands, selfCond) push!(attributes, operandsegmentsizes([(async==nothing) ? 0 : 1length(waitOperands), (numGangs==nothing) ? 0 : 1(numWorkers==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1(selfCond==nothing) ? 0 : 1length(reductionOperands), length(copyOperands), length(copyinOperands), length(copyinReadonlyOperands), length(copyoutOperands), length(copyoutZeroOperands), length(createOperands), length(createZeroOperands), length(noCreateOperands), length(presentOperands), length(devicePtrOperands), length(attachOperands), length(gangPrivateOperands), length(gangFirstPrivateOperands), ])) - (asyncAttr != nothing) && push!(attributes, namedattribute("asyncAttr", asyncAttr)) - (waitAttr != nothing) && push!(attributes, namedattribute("waitAttr", waitAttr)) - (selfAttr != nothing) && push!(attributes, namedattribute("selfAttr", selfAttr)) - (reductionOp != nothing) && push!(attributes, namedattribute("reductionOp", reductionOp)) - (defaultAttr != nothing) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + !isnothing(asyncAttr) && push!(attributes, namedattribute("asyncAttr", asyncAttr)) + !isnothing(waitAttr) && push!(attributes, namedattribute("waitAttr", waitAttr)) + !isnothing(selfAttr) && push!(attributes, namedattribute("selfAttr", selfAttr)) + !isnothing(reductionOp) && push!(attributes, namedattribute("reductionOp", reductionOp)) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) create_operation( "acc.parallel", location; @@ -244,8 +244,8 @@ function shutdown(deviceTypeOperands::Vector{Value}, deviceNumOperand=nothing::U owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (deviceNumOperand != nothing) && push!(operands, deviceNumOperand) - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(deviceNumOperand) && push!(operands, deviceNumOperand) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([length(deviceTypeOperands), (deviceNumOperand==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) create_operation( @@ -299,13 +299,13 @@ function update(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing::Uni owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(deviceTypeOperands), length(hostOperands), length(deviceOperands), ])) - (async != nothing) && push!(attributes, namedattribute("async", async)) - (wait != nothing) && push!(attributes, namedattribute("wait", wait)) - (ifPresent != nothing) && push!(attributes, namedattribute("ifPresent", ifPresent)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + !isnothing(ifPresent) && push!(attributes, namedattribute("ifPresent", ifPresent)) create_operation( "acc.update", location; @@ -334,11 +334,11 @@ function wait(waitOperands::Vector{Value}, asyncOperand=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([length(waitOperands), (asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) - (async != nothing) && push!(attributes, namedattribute("async", async)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) create_operation( "acc.wait", location; diff --git a/src/Dialects/14/OpenMP.jl b/src/Dialects/14/OpenMP.jl index a419db61..72115735 100644 --- a/src/Dialects/14/OpenMP.jl +++ b/src/Dialects/14/OpenMP.jl @@ -44,8 +44,8 @@ function atomic_capture(; hint=nothing, memory_order=nothing, region::Region, lo owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (hint != nothing) && push!(attributes, namedattribute("hint", hint)) - (memory_order != nothing) && push!(attributes, namedattribute("memory_order", memory_order)) + !isnothing(hint) && push!(attributes, namedattribute("hint", hint)) + !isnothing(memory_order) && push!(attributes, namedattribute("memory_order", memory_order)) create_operation( "omp.atomic.capture", location; @@ -76,8 +76,8 @@ function atomic_read(x::Value, v::Value; hint=nothing, memory_order=nothing, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (hint != nothing) && push!(attributes, namedattribute("hint", hint)) - (memory_order != nothing) && push!(attributes, namedattribute("memory_order", memory_order)) + !isnothing(hint) && push!(attributes, namedattribute("hint", hint)) + !isnothing(memory_order) && push!(attributes, namedattribute("memory_order", memory_order)) create_operation( "omp.atomic.read", location; @@ -117,9 +117,9 @@ function atomic_update(x::Value, expr::Value; isXBinopExpr=nothing, binop, hint= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("binop", binop), ] - (isXBinopExpr != nothing) && push!(attributes, namedattribute("isXBinopExpr", isXBinopExpr)) - (hint != nothing) && push!(attributes, namedattribute("hint", hint)) - (memory_order != nothing) && push!(attributes, namedattribute("memory_order", memory_order)) + !isnothing(isXBinopExpr) && push!(attributes, namedattribute("isXBinopExpr", isXBinopExpr)) + !isnothing(hint) && push!(attributes, namedattribute("hint", hint)) + !isnothing(memory_order) && push!(attributes, namedattribute("memory_order", memory_order)) create_operation( "omp.atomic.update", location; @@ -152,8 +152,8 @@ function atomic_write(address::Value, value::Value; hint=nothing, memory_order=n owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (hint != nothing) && push!(attributes, namedattribute("hint", hint)) - (memory_order != nothing) && push!(attributes, namedattribute("memory_order", memory_order)) + !isnothing(hint) && push!(attributes, namedattribute("hint", hint)) + !isnothing(memory_order) && push!(attributes, namedattribute("memory_order", memory_order)) create_operation( "omp.atomic.write", location; @@ -197,7 +197,7 @@ function critical_declare(; sym_name, hint=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), ] - (hint != nothing) && push!(attributes, namedattribute("hint", hint)) + !isnothing(hint) && push!(attributes, namedattribute("hint", hint)) create_operation( "omp.critical.declare", location; @@ -219,7 +219,7 @@ function critical(; name=nothing, region::Region, location=Location()) owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (name != nothing) && push!(attributes, namedattribute("name", name)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) create_operation( "omp.critical", location; @@ -297,8 +297,8 @@ function ordered(depend_vec_vars::Vector{Value}; depend_type_val=nothing, num_lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (depend_type_val != nothing) && push!(attributes, namedattribute("depend_type_val", depend_type_val)) - (num_loops_val != nothing) && push!(attributes, namedattribute("num_loops_val", num_loops_val)) + !isnothing(depend_type_val) && push!(attributes, namedattribute("depend_type_val", depend_type_val)) + !isnothing(num_loops_val) && push!(attributes, namedattribute("num_loops_val", num_loops_val)) create_operation( "omp.ordered", location; @@ -325,7 +325,7 @@ function ordered_region(; simd=nothing, region::Region, location=Location()) owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (simd != nothing) && push!(attributes, namedattribute("simd", simd)) + !isnothing(simd) && push!(attributes, namedattribute("simd", simd)) create_operation( "omp.ordered_region", location; @@ -369,11 +369,11 @@ function parallel(if_expr_var=nothing::Union{Nothing, Value}; num_threads_var=no owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr_var != nothing) && push!(operands, if_expr_var) - (num_threads_var != nothing) && push!(operands, num_threads_var) + !isnothing(if_expr_var) && push!(operands, if_expr_var) + !isnothing(num_threads_var) && push!(operands, num_threads_var) push!(attributes, operandsegmentsizes([(if_expr_var==nothing) ? 0 : 1(num_threads_var==nothing) ? 0 : 1length(private_vars), length(firstprivate_vars), length(shared_vars), length(copyin_vars), length(allocate_vars), length(allocators_vars), ])) - (default_val != nothing) && push!(attributes, namedattribute("default_val", default_val)) - (proc_bind_val != nothing) && push!(attributes, namedattribute("proc_bind_val", proc_bind_val)) + !isnothing(default_val) && push!(attributes, namedattribute("default_val", default_val)) + !isnothing(proc_bind_val) && push!(attributes, namedattribute("proc_bind_val", proc_bind_val)) create_operation( "omp.parallel", location; @@ -503,8 +503,8 @@ function sections(private_vars::Vector{Value}, firstprivate_vars::Vector{Value}, successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(private_vars), length(firstprivate_vars), length(lastprivate_vars), length(reduction_vars), length(allocate_vars), length(allocators_vars), ])) - (reductions != nothing) && push!(attributes, namedattribute("reductions", reductions)) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) create_operation( "omp.sections", location; @@ -540,11 +540,11 @@ function target(if_expr=nothing::Union{Nothing, Value}; device=nothing::Union{No owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr != nothing) && push!(operands, if_expr) - (device != nothing) && push!(operands, device) - (thread_limit != nothing) && push!(operands, thread_limit) + !isnothing(if_expr) && push!(operands, if_expr) + !isnothing(device) && push!(operands, device) + !isnothing(thread_limit) && push!(operands, thread_limit) push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1(thread_limit==nothing) ? 0 : 1])) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) create_operation( "omp.target", location; @@ -685,17 +685,17 @@ function wsloop(lowerBound::Vector{Value}, upperBound::Vector{Value}, step::Vect owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (schedule_chunk_var != nothing) && push!(operands, schedule_chunk_var) + !isnothing(schedule_chunk_var) && push!(operands, schedule_chunk_var) push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(private_vars), length(firstprivate_vars), length(lastprivate_vars), length(linear_vars), length(linear_step_vars), length(reduction_vars), (schedule_chunk_var==nothing) ? 0 : 1])) - (reductions != nothing) && push!(attributes, namedattribute("reductions", reductions)) - (schedule_val != nothing) && push!(attributes, namedattribute("schedule_val", schedule_val)) - (schedule_modifier != nothing) && push!(attributes, namedattribute("schedule_modifier", schedule_modifier)) - (simd_modifier != nothing) && push!(attributes, namedattribute("simd_modifier", simd_modifier)) - (collapse_val != nothing) && push!(attributes, namedattribute("collapse_val", collapse_val)) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) - (ordered_val != nothing) && push!(attributes, namedattribute("ordered_val", ordered_val)) - (order_val != nothing) && push!(attributes, namedattribute("order_val", order_val)) - (inclusive != nothing) && push!(attributes, namedattribute("inclusive", inclusive)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(schedule_val) && push!(attributes, namedattribute("schedule_val", schedule_val)) + !isnothing(schedule_modifier) && push!(attributes, namedattribute("schedule_modifier", schedule_modifier)) + !isnothing(simd_modifier) && push!(attributes, namedattribute("simd_modifier", simd_modifier)) + !isnothing(collapse_val) && push!(attributes, namedattribute("collapse_val", collapse_val)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(ordered_val) && push!(attributes, namedattribute("ordered_val", ordered_val)) + !isnothing(order_val) && push!(attributes, namedattribute("order_val", order_val)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) create_operation( "omp.wsloop", location; diff --git a/src/Dialects/14/PDL.jl b/src/Dialects/14/PDL.jl index 71e56649..91e10db3 100644 --- a/src/Dialects/14/PDL.jl +++ b/src/Dialects/14/PDL.jl @@ -28,7 +28,7 @@ function apply_native_constraint(args::Vector{Value}; name, constParams=nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("name", name), ] - (constParams != nothing) && push!(attributes, namedattribute("constParams", constParams)) + !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) create_operation( "pdl.apply_native_constraint", location; @@ -80,7 +80,7 @@ function apply_native_rewrite(args::Vector{Value}; results::Vector{MLIRType}, na owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("name", name), ] - (constParams != nothing) && push!(attributes, namedattribute("constParams", constParams)) + !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) create_operation( "pdl.apply_native_rewrite", location; @@ -121,8 +121,8 @@ function attribute(type=nothing::Union{Nothing, Value}; attr::MLIRType, value=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (type != nothing) && push!(operands, type) - (value != nothing) && push!(attributes, namedattribute("value", value)) + !isnothing(type) && push!(operands, type) + !isnothing(value) && push!(attributes, namedattribute("value", value)) create_operation( "pdl.attribute", location; @@ -187,7 +187,7 @@ function operand(type=nothing::Union{Nothing, Value}; val::MLIRType, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (type != nothing) && push!(operands, type) + !isnothing(type) && push!(operands, type) create_operation( "pdl.operand", location; @@ -224,7 +224,7 @@ function operands(type=nothing::Union{Nothing, Value}; val::MLIRType, location=L owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (type != nothing) && push!(operands, type) + !isnothing(type) && push!(operands, type) create_operation( "pdl.operands", location; @@ -338,7 +338,7 @@ function operation(operands::Vector{Value}, attributes::Vector{Value}, types::Ve successors = Block[] attributes = NamedAttribute[namedattribute("attributeNames", attributeNames), ] push!(attributes, operandsegmentsizes([length(operands), length(attributes), length(types), ])) - (name != nothing) && push!(attributes, namedattribute("name", name)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) create_operation( "pdl.operation", location; @@ -378,7 +378,7 @@ function pattern(; benefit, sym_name=nothing, body::Region, location=Location()) owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("benefit", benefit), ] - (sym_name != nothing) && push!(attributes, namedattribute("sym_name", sym_name)) + !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) create_operation( "pdl.pattern", location; @@ -419,7 +419,7 @@ function replace(operation::Value, replOperation=nothing::Union{Nothing, Value}; owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (replOperation != nothing) && push!(operands, replOperation) + !isnothing(replOperation) && push!(operands, replOperation) push!(attributes, operandsegmentsizes([1, (replOperation==nothing) ? 0 : 1length(replValues), ])) create_operation( @@ -502,7 +502,7 @@ function results(parent::Value; val::MLIRType, index=nothing, location=Location( owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (index != nothing) && push!(attributes, namedattribute("index", index)) + !isnothing(index) && push!(attributes, namedattribute("index", index)) create_operation( "pdl.results", location; @@ -558,10 +558,10 @@ function rewrite(root=nothing::Union{Nothing, Value}; externalArgs::Vector{Value owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (root != nothing) && push!(operands, root) + !isnothing(root) && push!(operands, root) push!(attributes, operandsegmentsizes([(root==nothing) ? 0 : 1length(externalArgs), ])) - (name != nothing) && push!(attributes, namedattribute("name", name)) - (externalConstParams != nothing) && push!(attributes, namedattribute("externalConstParams", externalConstParams)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + !isnothing(externalConstParams) && push!(attributes, namedattribute("externalConstParams", externalConstParams)) create_operation( "pdl.rewrite", location; @@ -595,7 +595,7 @@ function type(; result::MLIRType, type=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (type != nothing) && push!(attributes, namedattribute("type", type)) + !isnothing(type) && push!(attributes, namedattribute("type", type)) create_operation( "pdl.type", location; @@ -629,7 +629,7 @@ function types(; result::MLIRType, types=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (types != nothing) && push!(attributes, namedattribute("types", types)) + !isnothing(types) && push!(attributes, namedattribute("types", types)) create_operation( "pdl.types", location; diff --git a/src/Dialects/14/PDLInterp.jl b/src/Dialects/14/PDLInterp.jl index f4526001..1434f7b1 100644 --- a/src/Dialects/14/PDLInterp.jl +++ b/src/Dialects/14/PDLInterp.jl @@ -28,7 +28,7 @@ function apply_constraint(args::Vector{Value}; name, constParams=nothing, trueDe owned_regions = Region[] successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[namedattribute("name", name), ] - (constParams != nothing) && push!(attributes, namedattribute("constParams", constParams)) + !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) create_operation( "pdl_interp.apply_constraint", location; @@ -71,7 +71,7 @@ function apply_rewrite(args::Vector{Value}; results::Vector{MLIRType}, name, con owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("name", name), ] - (constParams != nothing) && push!(attributes, namedattribute("constParams", constParams)) + !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) create_operation( "pdl_interp.apply_rewrite", location; @@ -190,7 +190,7 @@ function check_operand_count(operation::Value; count, compareAtLeast=nothing, tr owned_regions = Region[] successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[namedattribute("count", count), ] - (compareAtLeast != nothing) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) + !isnothing(compareAtLeast) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) create_operation( "pdl_interp.check_operand_count", location; @@ -253,7 +253,7 @@ function check_result_count(operation::Value; count, compareAtLeast=nothing, tru owned_regions = Region[] successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[namedattribute("count", count), ] - (compareAtLeast != nothing) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) + !isnothing(compareAtLeast) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) create_operation( "pdl_interp.check_result_count", location; @@ -717,7 +717,7 @@ function get_operands(operation::Value; value::MLIRType, index=nothing, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (index != nothing) && push!(attributes, namedattribute("index", index)) + !isnothing(index) && push!(attributes, namedattribute("index", index)) create_operation( "pdl_interp.get_operands", location; @@ -784,7 +784,7 @@ function get_results(operation::Value; value::MLIRType, index=nothing, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (index != nothing) && push!(attributes, namedattribute("index", index)) + !isnothing(index) && push!(attributes, namedattribute("index", index)) create_operation( "pdl_interp.get_results", location; @@ -936,8 +936,8 @@ function record_match(inputs::Vector{Value}, matchedOps::Vector{Value}; rewriter successors = Block[dest, ] attributes = NamedAttribute[namedattribute("rewriter", rewriter), namedattribute("benefit", benefit), ] push!(attributes, operandsegmentsizes([length(inputs), length(matchedOps), ])) - (rootKind != nothing) && push!(attributes, namedattribute("rootKind", rootKind)) - (generatedOps != nothing) && push!(attributes, namedattribute("generatedOps", generatedOps)) + !isnothing(rootKind) && push!(attributes, namedattribute("rootKind", rootKind)) + !isnothing(generatedOps) && push!(attributes, namedattribute("generatedOps", generatedOps)) create_operation( "pdl_interp.record_match", location; diff --git a/src/Dialects/14/Quant.jl b/src/Dialects/14/Quant.jl index 56dc7666..28c09a39 100644 --- a/src/Dialects/14/Quant.jl +++ b/src/Dialects/14/Quant.jl @@ -19,9 +19,9 @@ function const_fake_quant(inputs::Value; outputs=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("min", min), namedattribute("max", max), namedattribute("num_bits", num_bits), ] - (outputs != nothing) && push!(results, outputs) - (narrow_range != nothing) && push!(attributes, namedattribute("narrow_range", narrow_range)) - (is_signed != nothing) && push!(attributes, namedattribute("is_signed", is_signed)) + !isnothing(outputs) && push!(results, outputs) + !isnothing(narrow_range) && push!(attributes, namedattribute("narrow_range", narrow_range)) + !isnothing(is_signed) && push!(attributes, namedattribute("is_signed", is_signed)) create_operation( "quant.const_fake_quant", location; @@ -46,9 +46,9 @@ function const_fake_quant_per_axis(inputs::Value; outputs=nothing::Union{Nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("min", min), namedattribute("max", max), namedattribute("axis", axis), namedattribute("num_bits", num_bits), ] - (outputs != nothing) && push!(results, outputs) - (narrow_range != nothing) && push!(attributes, namedattribute("narrow_range", narrow_range)) - (is_signed != nothing) && push!(attributes, namedattribute("is_signed", is_signed)) + !isnothing(outputs) && push!(results, outputs) + !isnothing(narrow_range) && push!(attributes, namedattribute("narrow_range", narrow_range)) + !isnothing(is_signed) && push!(attributes, namedattribute("is_signed", is_signed)) create_operation( "quant.const_fake_quant_per_axis", location; @@ -74,7 +74,7 @@ function coupled_ref(arg::Value; result_0=nothing::Union{Nothing, MLIRType}, cou owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("coupledKey", coupledKey), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "quant.coupled_ref", location; @@ -186,9 +186,9 @@ function stats(arg::Value; result_0=nothing::Union{Nothing, MLIRType}, layerStat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("layerStats", layerStats), ] - (result_0 != nothing) && push!(results, result_0) - (axisStats != nothing) && push!(attributes, namedattribute("axisStats", axisStats)) - (axis != nothing) && push!(attributes, namedattribute("axis", axis)) + !isnothing(result_0) && push!(results, result_0) + !isnothing(axisStats) && push!(attributes, namedattribute("axisStats", axisStats)) + !isnothing(axis) && push!(attributes, namedattribute("axis", axis)) create_operation( "quant.stats", location; @@ -213,7 +213,7 @@ function stats_ref(arg::Value; result_0=nothing::Union{Nothing, MLIRType}, stats owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("statsKey", statsKey), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "quant.stats_ref", location; diff --git a/src/Dialects/14/SPIRV.jl b/src/Dialects/14/SPIRV.jl index c980f7dc..2f92cc0a 100644 --- a/src/Dialects/14/SPIRV.jl +++ b/src/Dialects/14/SPIRV.jl @@ -875,7 +875,7 @@ function BitCount(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitCount", location; @@ -933,7 +933,7 @@ function BitFieldInsert(base::Value, insert::Value, offset::Value, count::Value; owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitFieldInsert", location; @@ -991,7 +991,7 @@ function BitFieldSExtract(base::Value, offset::Value, count::Value; result=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitFieldSExtract", location; @@ -1031,7 +1031,7 @@ function BitFieldUExtract(base::Value, offset::Value, count::Value; result=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitFieldUExtract", location; @@ -1075,7 +1075,7 @@ function BitReverse(operand::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitReverse", location; @@ -1171,7 +1171,7 @@ function BitwiseAnd(operand1::Value, operand2::Value; result=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitwiseAnd", location; @@ -1213,7 +1213,7 @@ function BitwiseOr(operand1::Value, operand2::Value; result=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitwiseOr", location; @@ -1255,7 +1255,7 @@ function BitwiseXor(operand1::Value, operand2::Value; result=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitwiseXor", location; @@ -1306,7 +1306,7 @@ function BranchConditional(condition::Value, trueTargetOperands::Vector{Value}, successors = Block[trueTarget, falseTarget, ] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([1, length(trueTargetOperands), length(falseTargetOperands), ])) - (branch_weights != nothing) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) create_operation( "spv.BranchConditional", location; @@ -1783,7 +1783,7 @@ function CooperativeMatrixLengthNV(; result=nothing::Union{Nothing, MLIRType}, t owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("type", type), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CooperativeMatrixLengthNV", location; @@ -1852,7 +1852,7 @@ function CooperativeMatrixLoadNV(pointer::Value, stride::Value, columnmajor::Val owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) create_operation( "spv.CooperativeMatrixLoadNV", location; @@ -1915,7 +1915,7 @@ function CooperativeMatrixMulAddNV(a::Value, b::Value, c::Value; result=nothing: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CooperativeMatrixMulAddNV", location; @@ -1970,7 +1970,7 @@ function CooperativeMatrixStoreNV(pointer::Value, object::Value, stride::Value, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) create_operation( "spv.CooperativeMatrixStoreNV", location; @@ -2015,10 +2015,10 @@ function CopyMemory(target::Value, source::Value; memory_access=nothing, alignme owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (source_memory_access != nothing) && push!(attributes, namedattribute("source_memory_access", source_memory_access)) - (source_alignment != nothing) && push!(attributes, namedattribute("source_alignment", source_alignment)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(source_memory_access) && push!(attributes, namedattribute("source_memory_access", source_memory_access)) + !isnothing(source_alignment) && push!(attributes, namedattribute("source_alignment", source_alignment)) create_operation( "spv.CopyMemory", location; @@ -2158,7 +2158,7 @@ function FAdd(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FAdd", location; @@ -2240,7 +2240,7 @@ function FDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FDiv", location; @@ -2283,7 +2283,7 @@ function FMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FMod", location; @@ -2325,7 +2325,7 @@ function FMul(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FMul", location; @@ -2365,7 +2365,7 @@ function FNegate(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FNegate", location; @@ -2655,7 +2655,7 @@ function FRem(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FRem", location; @@ -2696,7 +2696,7 @@ function FSub(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FSub", location; @@ -3032,7 +3032,7 @@ function FunctionCall(arguments::Vector{Value}; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("callee", callee), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FunctionCall", location; @@ -3527,7 +3527,7 @@ function GLSL_FMix(x::Value, y::Value, a::Value; result=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GLSL.FMix", location; @@ -3801,7 +3801,7 @@ function GLSL_Ldexp(x::Value, exp::Value; y=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (y != nothing) && push!(results, y) + !isnothing(y) && push!(results, y) create_operation( "spv.GLSL.Ldexp", location; @@ -4502,17 +4502,17 @@ spv.GlobalVariable @var2 bind(1, 2) : !spv.ptr spv.GlobalVariable @var3 built_in(\"GlobalInvocationId\") : !spv.ptr, Input> ``` """ -function GlobalVariable(; type, sym_name, initializer=nothing, binding=nothing, descriptorSet=nothing, builtin=nothing, location=Location()) +function GlobalVariable(; type, sym_name, initializer=nothing, location_=nothing, binding=nothing, descriptorSet=nothing, builtin=nothing, location=Location()) results = MLIRType[] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("type", type), namedattribute("sym_name", sym_name), ] - (initializer != nothing) && push!(attributes, namedattribute("initializer", initializer)) - (location != nothing) && push!(attributes, namedattribute("location", location)) - (binding != nothing) && push!(attributes, namedattribute("binding", binding)) - (descriptorSet != nothing) && push!(attributes, namedattribute("descriptorSet", descriptorSet)) - (builtin != nothing) && push!(attributes, namedattribute("builtin", builtin)) + !isnothing(initializer) && push!(attributes, namedattribute("initializer", initializer)) + !isnothing(location) && push!(attributes, namedattribute("location", location_)) + !isnothing(binding) && push!(attributes, namedattribute("binding", binding)) + !isnothing(descriptorSet) && push!(attributes, namedattribute("descriptorSet", descriptorSet)) + !isnothing(builtin) && push!(attributes, namedattribute("builtin", builtin)) create_operation( "spv.GlobalVariable", location; @@ -4573,7 +4573,7 @@ function GroupBroadcast(value::Value, localid::Value; result=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GroupBroadcast", location; @@ -4674,7 +4674,7 @@ function GroupNonUniformBroadcast(value::Value, id::Value; result=nothing::Union owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GroupNonUniformBroadcast", location; @@ -4711,7 +4711,7 @@ function GroupNonUniformElect(; result=nothing::Union{Nothing, MLIRType}, execut owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GroupNonUniformElect", location; @@ -4769,7 +4769,7 @@ function GroupNonUniformFAdd(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformFAdd", location; @@ -4830,7 +4830,7 @@ function GroupNonUniformFMax(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformFMax", location; @@ -4891,7 +4891,7 @@ function GroupNonUniformFMin(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformFMin", location; @@ -4949,7 +4949,7 @@ function GroupNonUniformFMul(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformFMul", location; @@ -5005,7 +5005,7 @@ function GroupNonUniformIAdd(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformIAdd", location; @@ -5061,7 +5061,7 @@ function GroupNonUniformIMul(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformIMul", location; @@ -5117,7 +5117,7 @@ function GroupNonUniformSMax(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformSMax", location; @@ -5173,7 +5173,7 @@ function GroupNonUniformSMin(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformSMin", location; @@ -5230,7 +5230,7 @@ function GroupNonUniformUMax(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformUMax", location; @@ -5287,7 +5287,7 @@ function GroupNonUniformUMin(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformUMin", location; @@ -5334,7 +5334,7 @@ function IAdd(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.IAdd", location; @@ -5422,7 +5422,7 @@ function IMul(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.IMul", location; @@ -5510,7 +5510,7 @@ function ISub(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.ISub", location; @@ -5562,7 +5562,7 @@ function ImageDrefGather(sampledimage::Value, coordinate::Value, dref::Value, op owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (imageoperands != nothing) && push!(attributes, namedattribute("imageoperands", imageoperands)) + !isnothing(imageoperands) && push!(attributes, namedattribute("imageoperands", imageoperands)) create_operation( "spv.ImageDrefGather", location; @@ -5810,8 +5810,8 @@ function Load(ptr::Value; value::MLIRType, memory_access=nothing, alignment=noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "spv.Load", location; @@ -6269,8 +6269,8 @@ function module_(; addressing_model, memory_model, vce_triple=nothing, sym_name= owned_regions = Region[region_0, ] successors = Block[] attributes = NamedAttribute[namedattribute("addressing_model", addressing_model), namedattribute("memory_model", memory_model), ] - (vce_triple != nothing) && push!(attributes, namedattribute("vce_triple", vce_triple)) - (sym_name != nothing) && push!(attributes, namedattribute("sym_name", sym_name)) + !isnothing(vce_triple) && push!(attributes, namedattribute("vce_triple", vce_triple)) + !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) create_operation( "spv.module", location; @@ -6312,7 +6312,7 @@ function Not(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.Not", location; @@ -7121,7 +7121,7 @@ function SDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.SDiv", location; @@ -7330,7 +7330,7 @@ function SMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.SMod", location; @@ -7366,7 +7366,7 @@ function SNegate(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.SNegate", location; @@ -7411,7 +7411,7 @@ function SRem(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.SRem", location; @@ -7466,7 +7466,7 @@ function Select(condition::Value, true_value::Value, false_value::Value; result= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.Select", location; @@ -7876,8 +7876,8 @@ function Store(ptr::Value, value::Value; memory_access=nothing, alignment=nothin owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "spv.Store", location; @@ -8140,7 +8140,7 @@ function UDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.UDiv", location; @@ -8347,7 +8347,7 @@ function UMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.UMod", location; @@ -8502,7 +8502,7 @@ function Variable(initializer=nothing::Union{Nothing, Value}; pointer::MLIRType, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("storage_class", storage_class), ] - (initializer != nothing) && push!(operands, initializer) + !isnothing(initializer) && push!(operands, initializer) create_operation( "spv.Variable", location; @@ -8589,7 +8589,7 @@ function VectorInsertDynamic(vector::Value, component::Value, index::Value; resu owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.VectorInsertDynamic", location; diff --git a/src/Dialects/14/Shape.jl b/src/Dialects/14/Shape.jl index e9879594..353756bc 100644 --- a/src/Dialects/14/Shape.jl +++ b/src/Dialects/14/Shape.jl @@ -21,7 +21,7 @@ function add(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.add", location; @@ -174,7 +174,7 @@ function broadcast(shapes::Vector{Value}; result::MLIRType, error=nothing, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (error != nothing) && push!(attributes, namedattribute("error", error)) + !isnothing(error) && push!(attributes, namedattribute("error", error)) create_operation( "shape.broadcast", location; @@ -201,7 +201,7 @@ function concat(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.concat", location; @@ -230,7 +230,7 @@ function const_shape(; result=nothing::Union{Nothing, MLIRType}, shape, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("shape", shape), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.const_shape", location; @@ -255,7 +255,7 @@ function const_size(; result=nothing::Union{Nothing, MLIRType}, value, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("value", value), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.const_size", location; @@ -286,7 +286,7 @@ function const_witness(; result=nothing::Union{Nothing, MLIRType}, passing, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("passing", passing), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.const_witness", location; @@ -317,7 +317,7 @@ function cstr_broadcastable(shapes::Vector{Value}; result=nothing::Union{Nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.cstr_broadcastable", location; @@ -346,7 +346,7 @@ function cstr_eq(shapes::Vector{Value}; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.cstr_eq", location; @@ -381,7 +381,7 @@ function cstr_require(pred::Value; result=nothing::Union{Nothing, MLIRType}, msg owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("msg", msg), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.cstr_require", location; @@ -436,7 +436,7 @@ function div(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.div", location; @@ -459,7 +459,7 @@ function from_extent_tensor(input::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.from_extent_tensor", location; @@ -543,7 +543,7 @@ function get_extent(shape::Value, dim::Value; extent=nothing::Union{Nothing, MLI owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (extent != nothing) && push!(results, extent) + !isnothing(extent) && push!(results, extent) create_operation( "shape.get_extent", location; @@ -568,7 +568,7 @@ function index_to_size(arg::Value; result=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.index_to_size", location; @@ -602,7 +602,7 @@ function is_broadcastable(shapes::Vector{Value}; result=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.is_broadcastable", location; @@ -626,7 +626,7 @@ function max(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.max", location; @@ -669,8 +669,8 @@ function meet(arg0::Value, arg1::Value; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (error != nothing) && push!(attributes, namedattribute("error", error)) + !isnothing(result) && push!(results, result) + !isnothing(error) && push!(attributes, namedattribute("error", error)) create_operation( "shape.meet", location; @@ -694,7 +694,7 @@ function min(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.min", location; @@ -720,7 +720,7 @@ function mul(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.mul", location; @@ -745,7 +745,7 @@ function num_elements(shape::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.num_elements", location; @@ -766,7 +766,7 @@ function rank(shape::Value; rank=nothing::Union{Nothing, MLIRType}, location=Loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (rank != nothing) && push!(results, rank) + !isnothing(rank) && push!(results, rank) create_operation( "shape.rank", location; @@ -839,7 +839,7 @@ function shape_eq(shapes::Vector{Value}; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.shape_eq", location; @@ -861,7 +861,7 @@ function shape_of(arg::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.shape_of", location; @@ -885,7 +885,7 @@ function size_to_index(arg::Value; result=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.size_to_index", location; @@ -1031,7 +1031,7 @@ function with_shape(operand::Value, shape::Value; result=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.with_shape", location; diff --git a/src/Dialects/14/SparseTensor.jl b/src/Dialects/14/SparseTensor.jl index 1622b73b..666dc2c5 100644 --- a/src/Dialects/14/SparseTensor.jl +++ b/src/Dialects/14/SparseTensor.jl @@ -235,8 +235,8 @@ function load(tensor::Value; result=nothing::Union{Nothing, MLIRType}, hasInsert owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (hasInserts != nothing) && push!(attributes, namedattribute("hasInserts", hasInserts)) + !isnothing(result) && push!(results, result) + !isnothing(hasInserts) && push!(attributes, namedattribute("hasInserts", hasInserts)) create_operation( "sparse_tensor.load", location; diff --git a/src/Dialects/14/StandardOps.jl b/src/Dialects/14/StandardOps.jl index 56f267c3..97deaccd 100644 --- a/src/Dialects/14/StandardOps.jl +++ b/src/Dialects/14/StandardOps.jl @@ -293,7 +293,7 @@ function select(condition::Value, true_value::Value, false_value::Value; result= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "std.select", location; @@ -370,7 +370,7 @@ function switch(flag::Value, defaultOperands::Vector{Value}, caseOperands::Vecto successors = Block[defaultDestination, caseDestinations..., ] attributes = NamedAttribute[namedattribute("case_operand_segments", case_operand_segments), ] push!(attributes, operandsegmentsizes([1, length(defaultOperands), length(caseOperands), ])) - (case_values != nothing) && push!(attributes, namedattribute("case_values", case_values)) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) create_operation( "std.switch", location; diff --git a/src/Dialects/14/Tensor.jl b/src/Dialects/14/Tensor.jl index 984ba86b..0bc0cec8 100644 --- a/src/Dialects/14/Tensor.jl +++ b/src/Dialects/14/Tensor.jl @@ -114,7 +114,7 @@ function dim(source::Value, index::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "tensor.dim", location; @@ -506,7 +506,7 @@ function pad(source::Value, low::Vector{Value}, high::Vector{Value}; result::MLI successors = Block[] attributes = NamedAttribute[namedattribute("static_low", static_low), namedattribute("static_high", static_high), ] push!(attributes, operandsegmentsizes([1, length(low), length(high), ])) - (nofold != nothing) && push!(attributes, namedattribute("nofold", nofold)) + !isnothing(nofold) && push!(attributes, namedattribute("nofold", nofold)) create_operation( "tensor.pad", location; @@ -534,7 +534,7 @@ function rank(tensor::Value; result_0=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "tensor.rank", location; diff --git a/src/Dialects/14/Tosa.jl b/src/Dialects/14/Tosa.jl index 4c56f8ce..6c9046d6 100644 --- a/src/Dialects/14/Tosa.jl +++ b/src/Dialects/14/Tosa.jl @@ -126,7 +126,7 @@ function avg_pool2d(input::Value; output::MLIRType, kernel, stride, pad, quantiz owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kernel", kernel), namedattribute("stride", stride), namedattribute("pad", pad), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.avg_pool2d", location; @@ -354,7 +354,7 @@ function const_(; output=nothing::Union{Nothing, MLIRType}, value, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("value", value), ] - (output != nothing) && push!(results, output) + !isnothing(output) && push!(results, output) create_operation( "tosa.const", location; @@ -376,7 +376,7 @@ function conv2d(input::Value, weight::Value, bias::Value; output::MLIRType, pad, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.conv2d", location; @@ -397,7 +397,7 @@ function conv3d(input::Value, weight::Value, bias::Value; output::MLIRType, pad, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.conv3d", location; @@ -442,7 +442,7 @@ function depthwise_conv2d(input::Value, weight::Value, bias::Value; output::MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.depthwise_conv2d", location; @@ -544,7 +544,7 @@ function fully_connected(input::Value, weight::Value, bias::Value; output::MLIRT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.fully_connected", location; @@ -815,7 +815,7 @@ function matmul(a::Value, b::Value; c::MLIRType, quantization_info=nothing, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.matmul", location; @@ -922,7 +922,7 @@ function negate(input1::Value; output::MLIRType, quantization_info=nothing, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.negate", location; @@ -943,8 +943,8 @@ function pad(input1::Value, padding::Value, pad_const=nothing::Union{Nothing, Va owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (pad_const != nothing) && push!(operands, pad_const) - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(pad_const) && push!(operands, pad_const) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.pad", location; @@ -1455,7 +1455,7 @@ function transpose_conv2d(input::Value, filter::Value, bias::Value; output::MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("out_pad", out_pad), namedattribute("stride", stride), namedattribute("dilation", dilation), namedattribute("out_shape", out_shape), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.transpose_conv2d", location; diff --git a/src/Dialects/14/Vector.jl b/src/Dialects/14/Vector.jl index a82681a9..13fae03a 100644 --- a/src/Dialects/14/Vector.jl +++ b/src/Dialects/14/Vector.jl @@ -334,7 +334,7 @@ function contract(lhs::Value, rhs::Value, acc::Value, masks::Vector{Value}; resu owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] - (kind != nothing) && push!(attributes, namedattribute("kind", kind)) + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) create_operation( "vector.contract", location; @@ -463,7 +463,7 @@ function extractelement(vector::Value, position=nothing::Union{Nothing, Value}; owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (position != nothing) && push!(operands, position) + !isnothing(position) && push!(operands, position) create_operation( "vector.extractelement", location; @@ -746,7 +746,7 @@ function insertelement(source::Value, dest::Value, position=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (position != nothing) && push!(operands, position) + !isnothing(position) && push!(operands, position) create_operation( "vector.insertelement", location; @@ -1169,7 +1169,7 @@ function outerproduct(lhs::Value, rhs::Value, acc::Vector{Value}; result_0::MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (kind != nothing) && push!(attributes, namedattribute("kind", kind)) + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) create_operation( "vector.outerproduct", location; @@ -1767,9 +1767,9 @@ function transfer_read(source::Value, indices::Vector{Value}, padding::Value, ma owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] - (mask != nothing) && push!(operands, mask) + !isnothing(mask) && push!(operands, mask) push!(attributes, operandsegmentsizes([1, length(indices), 1, (mask==nothing) ? 0 : 1])) - (in_bounds != nothing) && push!(attributes, namedattribute("in_bounds", in_bounds)) + !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) create_operation( "vector.transfer_read", location; @@ -1875,10 +1875,10 @@ function transfer_write(vector::Value, source::Value, indices::Vector{Value}, ma owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] - (mask != nothing) && push!(operands, mask) + !isnothing(mask) && push!(operands, mask) push!(attributes, operandsegmentsizes([1, 1, length(indices), (mask==nothing) ? 0 : 1])) - (result != nothing) && push!(results, result) - (in_bounds != nothing) && push!(attributes, namedattribute("in_bounds", in_bounds)) + !isnothing(result) && push!(results, result) + !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) create_operation( "vector.transfer_write", location; diff --git a/src/Dialects/14/X86Vector.jl b/src/Dialects/14/X86Vector.jl index 4f7e8fee..ea19a6f9 100644 --- a/src/Dialects/14/X86Vector.jl +++ b/src/Dialects/14/X86Vector.jl @@ -15,7 +15,7 @@ function avx_intr_dp_ps_256(a::Value, b::Value, c::Value; res=nothing::Union{Not owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx.intr.dp.ps.256", location; @@ -49,7 +49,7 @@ function avx_intr_dot(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx.intr.dot", location; @@ -69,7 +69,7 @@ function avx512_intr_mask_compress(a::Value, src::Value, k::Value; res=nothing:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.compress", location; @@ -100,9 +100,9 @@ function avx512_mask_compress(k::Value, a::Value, src=nothing::Union{Nothing, Va owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (src != nothing) && push!(operands, src) - (dst != nothing) && push!(results, dst) - (constant_src != nothing) && push!(attributes, namedattribute("constant_src", constant_src)) + !isnothing(src) && push!(operands, src) + !isnothing(dst) && push!(results, dst) + !isnothing(constant_src) && push!(attributes, namedattribute("constant_src", constant_src)) create_operation( "x86vector.avx512.mask.compress", location; @@ -132,7 +132,7 @@ function avx512_mask_rndscale(src::Value, k::Value, a::Value, imm::Value, roundi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (dst != nothing) && push!(results, dst) + !isnothing(dst) && push!(results, dst) create_operation( "x86vector.avx512.mask.rndscale", location; @@ -152,7 +152,7 @@ function avx512_intr_mask_rndscale_pd_512(src::Value, k::Value, a::Value, imm::V owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.rndscale.pd.512", location; @@ -172,7 +172,7 @@ function avx512_intr_mask_rndscale_ps_512(src::Value, k::Value, a::Value, imm::V owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.rndscale.ps.512", location; @@ -202,7 +202,7 @@ function avx512_mask_scalef(src::Value, a::Value, b::Value, k::Value, rounding:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (dst != nothing) && push!(results, dst) + !isnothing(dst) && push!(results, dst) create_operation( "x86vector.avx512.mask.scalef", location; @@ -222,7 +222,7 @@ function avx512_intr_mask_scalef_pd_512(src::Value, a::Value, b::Value, k::Value owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.scalef.pd.512", location; @@ -242,7 +242,7 @@ function avx512_intr_mask_scalef_ps_512(src::Value, a::Value, b::Value, k::Value owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.scalef.ps.512", location; @@ -262,7 +262,7 @@ function avx_intr_rsqrt_ps_256(a::Value; res=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx.intr.rsqrt.ps.256", location; @@ -282,7 +282,7 @@ function avx_rsqrt(a::Value; b=nothing::Union{Nothing, MLIRType}, location=Locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (b != nothing) && push!(results, b) + !isnothing(b) && push!(results, b) create_operation( "x86vector.avx.rsqrt", location; diff --git a/src/Dialects/15/AMDGPU.jl b/src/Dialects/15/AMDGPU.jl index 3ad03eb2..8ba85074 100644 --- a/src/Dialects/15/AMDGPU.jl +++ b/src/Dialects/15/AMDGPU.jl @@ -61,10 +61,10 @@ function raw_buffer_atomic_fadd(value::Value, memref::Value, indices::Vector{Val owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (sgprOffset != nothing) && push!(operands, sgprOffset) + !isnothing(sgprOffset) && push!(operands, sgprOffset) push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) - (boundsCheck != nothing) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) - (indexOffset != nothing) && push!(attributes, namedattribute("indexOffset", indexOffset)) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) create_operation( "amdgpu.raw_buffer_atomic_fadd", location; @@ -112,10 +112,10 @@ function raw_buffer_load(memref::Value, indices::Vector{Value}, sgprOffset=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (sgprOffset != nothing) && push!(operands, sgprOffset) + !isnothing(sgprOffset) && push!(operands, sgprOffset) push!(attributes, operandsegmentsizes([1, length(indices), (sgprOffset==nothing) ? 0 : 1])) - (boundsCheck != nothing) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) - (indexOffset != nothing) && push!(attributes, namedattribute("indexOffset", indexOffset)) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) create_operation( "amdgpu.raw_buffer_load", location; @@ -151,10 +151,10 @@ function raw_buffer_store(value::Value, memref::Value, indices::Vector{Value}, s owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (sgprOffset != nothing) && push!(operands, sgprOffset) + !isnothing(sgprOffset) && push!(operands, sgprOffset) push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) - (boundsCheck != nothing) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) - (indexOffset != nothing) && push!(attributes, namedattribute("indexOffset", indexOffset)) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) create_operation( "amdgpu.raw_buffer_store", location; diff --git a/src/Dialects/15/AMX.jl b/src/Dialects/15/AMX.jl index ef35e3f3..c7d28870 100644 --- a/src/Dialects/15/AMX.jl +++ b/src/Dialects/15/AMX.jl @@ -240,8 +240,8 @@ function tile_muli(lhs::Value, rhs::Value, acc::Value; res::MLIRType, isZextLhs= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (isZextLhs != nothing) && push!(attributes, namedattribute("isZextLhs", isZextLhs)) - (isZextRhs != nothing) && push!(attributes, namedattribute("isZextRhs", isZextRhs)) + !isnothing(isZextLhs) && push!(attributes, namedattribute("isZextLhs", isZextLhs)) + !isnothing(isZextRhs) && push!(attributes, namedattribute("isZextRhs", isZextRhs)) create_operation( "amx.tile_muli", location; diff --git a/src/Dialects/15/Arithmetic.jl b/src/Dialects/15/Arithmetic.jl index e9fe0d46..0a66d05a 100644 --- a/src/Dialects/15/Arithmetic.jl +++ b/src/Dialects/15/Arithmetic.jl @@ -35,7 +35,7 @@ function addf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.addf", location; @@ -72,7 +72,7 @@ function addi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.addi", location; @@ -109,7 +109,7 @@ function andi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.andi", location; @@ -173,7 +173,7 @@ function ceildivsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.ceildivsi", location; @@ -206,7 +206,7 @@ function ceildivui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.ceildivui", location; @@ -361,7 +361,7 @@ function constant(; result=nothing::Union{Nothing, MLIRType}, value, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("value", value), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.constant", location; @@ -381,7 +381,7 @@ function divf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.divf", location; @@ -419,7 +419,7 @@ function divsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.divsi", location; @@ -458,7 +458,7 @@ function divui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.divui", location; @@ -625,7 +625,7 @@ function floordivsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.floordivsi", location; @@ -683,7 +683,7 @@ function maxf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.maxf", location; @@ -703,7 +703,7 @@ function maxsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.maxsi", location; @@ -723,7 +723,7 @@ function maxui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.maxui", location; @@ -758,7 +758,7 @@ function minf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.minf", location; @@ -778,7 +778,7 @@ function minsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.minsi", location; @@ -798,7 +798,7 @@ function minui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.minui", location; @@ -838,7 +838,7 @@ function mulf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.mulf", location; @@ -858,7 +858,7 @@ function muli(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.muli", location; @@ -895,7 +895,7 @@ function negf(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.negf", location; @@ -932,7 +932,7 @@ function ori(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.ori", location; @@ -952,7 +952,7 @@ function remf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.remf", location; @@ -990,7 +990,7 @@ function remsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.remsi", location; @@ -1028,7 +1028,7 @@ function remui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.remui", location; @@ -1081,7 +1081,7 @@ function shli(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.shli", location; @@ -1115,7 +1115,7 @@ function shrsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.shrsi", location; @@ -1146,7 +1146,7 @@ function shrui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.shrui", location; @@ -1186,7 +1186,7 @@ function subf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.subf", location; @@ -1206,7 +1206,7 @@ function subi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.subi", location; @@ -1322,7 +1322,7 @@ function xori(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.xori", location; @@ -1368,7 +1368,7 @@ function select(condition::Value, true_value::Value, false_value::Value; result= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.select", location; diff --git a/src/Dialects/15/ArmNeon.jl b/src/Dialects/15/ArmNeon.jl index 7fafa0f7..d6d30af9 100644 --- a/src/Dialects/15/ArmNeon.jl +++ b/src/Dialects/15/ArmNeon.jl @@ -32,7 +32,7 @@ function intr_smull(a::Value, b::Value; res::MLIRType, location=Location()) end """ -`2d_sdot` +`_2d_sdot` The two input vectors `b` and `c` have a 2D shape, consisting of either 2 or 4 rows, each row having length 4. This operation computes the pair-wise @@ -43,20 +43,20 @@ corresponding entry of `a`: res[i] := a[i] + dot_product(b[i, ...], c[i, ...]) ``` """ -# function 2d_sdot(a::Value, b::Value, c::Value; res::MLIRType, location=Location()) -# results = MLIRType[res, ] -# operands = Value[a, b, c, ] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[] +function _2d_sdot(a::Value, b::Value, c::Value; res::MLIRType, location=Location()) + results = MLIRType[res, ] + operands = Value[a, b, c, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] -# create_operation( -# "arm_neon.2d.sdot", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "arm_neon.2d.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `intr_sdot` diff --git a/src/Dialects/15/Async.jl b/src/Dialects/15/Async.jl index b4919e20..0518e27a 100644 --- a/src/Dialects/15/Async.jl +++ b/src/Dialects/15/Async.jl @@ -26,7 +26,7 @@ function add_to_group(operand::Value, group::Value; rank=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (rank != nothing) && push!(results, rank) + !isnothing(rank) && push!(results, rank) create_operation( "async.add_to_group", location; @@ -93,7 +93,7 @@ function await(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.await", location; @@ -115,7 +115,7 @@ function coro_begin(id::Value; handle=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (handle != nothing) && push!(results, handle) + !isnothing(handle) && push!(results, handle) create_operation( "async.coro.begin", location; @@ -179,7 +179,7 @@ function coro_id(; id=nothing::Union{Nothing, MLIRType}, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (id != nothing) && push!(results, id) + !isnothing(id) && push!(results, id) create_operation( "async.coro.id", location; @@ -200,7 +200,7 @@ function coro_save(handle::Value; state=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (state != nothing) && push!(results, state) + !isnothing(state) && push!(results, state) create_operation( "async.coro.save", location; @@ -260,7 +260,7 @@ function create_group(size::Value; result=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.create_group", location; @@ -360,7 +360,7 @@ function runtime_add_to_group(operand::Value, group::Value; rank=nothing::Union{ owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (rank != nothing) && push!(results, rank) + !isnothing(rank) && push!(results, rank) create_operation( "async.runtime.add_to_group", location; @@ -425,7 +425,7 @@ function runtime_create_group(size::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.runtime.create_group", location; @@ -491,7 +491,7 @@ function runtime_is_error(operand::Value; is_error=nothing::Union{Nothing, MLIRT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (is_error != nothing) && push!(results, is_error) + !isnothing(is_error) && push!(results, is_error) create_operation( "async.runtime.is_error", location; @@ -534,7 +534,7 @@ function runtime_num_worker_threads(; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.runtime.num_worker_threads", location; diff --git a/src/Dialects/15/Bufferization.jl b/src/Dialects/15/Bufferization.jl index 4275e9b0..81e0994a 100644 --- a/src/Dialects/15/Bufferization.jl +++ b/src/Dialects/15/Bufferization.jl @@ -52,9 +52,9 @@ function alloc_tensor(dynamic_sizes::Vector{Value}, copy=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (copy != nothing) && push!(operands, copy) + !isnothing(copy) && push!(operands, copy) push!(attributes, operandsegmentsizes([length(dynamic_sizes), (copy==nothing) ? 0 : 1])) - (memory_space != nothing) && push!(attributes, namedattribute("memory_space", memory_space)) + !isnothing(memory_space) && push!(attributes, namedattribute("memory_space", memory_space)) create_operation( "bufferization.alloc_tensor", location; diff --git a/src/Dialects/15/Builtin.jl b/src/Dialects/15/Builtin.jl index 6560185b..ef7076e0 100644 --- a/src/Dialects/15/Builtin.jl +++ b/src/Dialects/15/Builtin.jl @@ -30,8 +30,8 @@ function module_(; sym_name=nothing, sym_visibility=nothing, bodyRegion::Region, owned_regions = Region[bodyRegion, ] successors = Block[] attributes = NamedAttribute[] - (sym_name != nothing) && push!(attributes, namedattribute("sym_name", sym_name)) - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "builtin.module", location; diff --git a/src/Dialects/15/Complex.jl b/src/Dialects/15/Complex.jl index ebf8b2ef..4979b6d0 100644 --- a/src/Dialects/15/Complex.jl +++ b/src/Dialects/15/Complex.jl @@ -48,7 +48,7 @@ function add(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.add", location; @@ -102,7 +102,7 @@ function atan2(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.atan2", location; @@ -130,7 +130,7 @@ function conj(complex::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.conj", location; @@ -185,7 +185,7 @@ function cos(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.cos", location; @@ -238,7 +238,7 @@ function div(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.div", location; @@ -265,7 +265,7 @@ function eq(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.eq", location; @@ -294,7 +294,7 @@ function exp(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.exp", location; @@ -327,7 +327,7 @@ function expm1(complex::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.expm1", location; @@ -383,7 +383,7 @@ function log1p(complex::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.log1p", location; @@ -412,7 +412,7 @@ function log(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.log", location; @@ -437,7 +437,7 @@ function mul(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.mul", location; @@ -464,7 +464,7 @@ function neg(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.neg", location; @@ -492,7 +492,7 @@ function neq(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.neq", location; @@ -520,7 +520,7 @@ function pow(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.pow", location; @@ -573,7 +573,7 @@ function rsqrt(complex::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.rsqrt", location; @@ -601,7 +601,7 @@ function sign(complex::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.sign", location; @@ -629,7 +629,7 @@ function sin(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.sin", location; @@ -656,7 +656,7 @@ function sqrt(complex::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.sqrt", location; @@ -683,7 +683,7 @@ function sub(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.sub", location; @@ -711,7 +711,7 @@ function tan(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.tan", location; @@ -739,7 +739,7 @@ function tanh(complex::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.tanh", location; diff --git a/src/Dialects/15/ControlFlow.jl b/src/Dialects/15/ControlFlow.jl index 183ffebd..3b3cc9a2 100644 --- a/src/Dialects/15/ControlFlow.jl +++ b/src/Dialects/15/ControlFlow.jl @@ -136,7 +136,7 @@ function switch(flag::Value, defaultOperands::Vector{Value}, caseOperands::Vecto successors = Block[defaultDestination, caseDestinations..., ] attributes = NamedAttribute[namedattribute("case_operand_segments", case_operand_segments), ] push!(attributes, operandsegmentsizes([1, length(defaultOperands), length(caseOperands), ])) - (case_values != nothing) && push!(attributes, namedattribute("case_values", case_values)) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) create_operation( "cf.switch", location; diff --git a/src/Dialects/15/EmitC.jl b/src/Dialects/15/EmitC.jl index 4a4d2ee5..1aca33da 100644 --- a/src/Dialects/15/EmitC.jl +++ b/src/Dialects/15/EmitC.jl @@ -63,8 +63,8 @@ function call(operands::Vector{Value}; result_0::Vector{MLIRType}, callee, args= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("callee", callee), ] - (args != nothing) && push!(attributes, namedattribute("args", args)) - (template_args != nothing) && push!(attributes, namedattribute("template_args", template_args)) + !isnothing(args) && push!(attributes, namedattribute("args", args)) + !isnothing(template_args) && push!(attributes, namedattribute("template_args", template_args)) create_operation( "emitc.call", location; @@ -172,7 +172,7 @@ function include(; include, is_standard_include=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("include", include), ] - (is_standard_include != nothing) && push!(attributes, namedattribute("is_standard_include", is_standard_include)) + !isnothing(is_standard_include) && push!(attributes, namedattribute("is_standard_include", is_standard_include)) create_operation( "emitc.include", location; diff --git a/src/Dialects/15/Func.jl b/src/Dialects/15/Func.jl index b500c189..72a4139b 100644 --- a/src/Dialects/15/Func.jl +++ b/src/Dialects/15/Func.jl @@ -147,7 +147,7 @@ function func_(; sym_name, function_type, sym_visibility=nothing, body::Region, owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("function_type", function_type), ] - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "func.func", location; diff --git a/src/Dialects/15/GPU.jl b/src/Dialects/15/GPU.jl index ba13de41..df36aa0d 100644 --- a/src/Dialects/15/GPU.jl +++ b/src/Dialects/15/GPU.jl @@ -36,8 +36,8 @@ function all_reduce(value::Value; result_0=nothing::Union{Nothing, MLIRType}, op owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (result_0 != nothing) && push!(results, result_0) - (op != nothing) && push!(attributes, namedattribute("op", op)) + !isnothing(result_0) && push!(results, result_0) + !isnothing(op) && push!(attributes, namedattribute("op", op)) create_operation( "gpu.all_reduce", location; @@ -73,7 +73,7 @@ function alloc(asyncDependencies::Vector{Value}, dynamicSizes::Vector{Value}, sy successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(asyncDependencies), length(dynamicSizes), length(symbolOperands), ])) - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.alloc", location; @@ -135,7 +135,7 @@ function block_dim(; result_0=nothing::Union{Nothing, MLIRType}, dimension, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.block_dim", location; @@ -163,7 +163,7 @@ function block_id(; result_0=nothing::Union{Nothing, MLIRType}, dimension, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.block_id", location; @@ -199,7 +199,7 @@ function dealloc(asyncDependencies::Vector{Value}, memref::Value; asyncToken=not owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.dealloc", location; @@ -343,7 +343,7 @@ function global_id(; result_0=nothing::Union{Nothing, MLIRType}, dimension, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.global_id", location; @@ -371,7 +371,7 @@ function grid_dim(; result_0=nothing::Union{Nothing, MLIRType}, dimension, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.grid_dim", location; @@ -424,7 +424,7 @@ function lane_id(; result=nothing::Union{Nothing, MLIRType}, location=Location() owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "gpu.lane_id", location; @@ -521,9 +521,9 @@ function launch_func(asyncDependencies::Vector{Value}, gridSizeX::Value, gridSiz owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kernel", kernel), ] - (dynamicSharedMemorySize != nothing) && push!(operands, dynamicSharedMemorySize) + !isnothing(dynamicSharedMemorySize) && push!(operands, dynamicSharedMemorySize) push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1length(operands), ])) - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.launch_func", location; @@ -613,9 +613,9 @@ function launch(asyncDependencies::Vector{Value}, gridSizeX::Value, gridSizeY::V owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (dynamicSharedMemorySize != nothing) && push!(operands, dynamicSharedMemorySize) + !isnothing(dynamicSharedMemorySize) && push!(operands, dynamicSharedMemorySize) push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1])) - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.launch", location; @@ -649,7 +649,7 @@ function memcpy(asyncDependencies::Vector{Value}, dst::Value, src::Value; asyncT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.memcpy", location; @@ -683,7 +683,7 @@ function memset(asyncDependencies::Vector{Value}, dst::Value, value::Value; asyn owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.memset", location; @@ -730,7 +730,7 @@ function num_subgroups(; result=nothing::Union{Nothing, MLIRType}, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "gpu.num_subgroups", location; @@ -835,8 +835,8 @@ function shuffle(value::Value, offset::Value, width::Value; result=nothing::Unio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("mode", mode), ] - (result != nothing) && push!(results, result) - (valid != nothing) && push!(results, valid) + !isnothing(result) && push!(results, result) + !isnothing(valid) && push!(results, valid) create_operation( "gpu.shuffle", location; @@ -864,7 +864,7 @@ function subgroup_id(; result=nothing::Union{Nothing, MLIRType}, location=Locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "gpu.subgroup_id", location; @@ -902,7 +902,7 @@ function subgroup_mma_compute(opA::Value, opB::Value, opC::Value; res=nothing::U owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "gpu.subgroup_mma_compute", location; @@ -1078,7 +1078,7 @@ function subgroup_size(; result=nothing::Union{Nothing, MLIRType}, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "gpu.subgroup_size", location; @@ -1128,7 +1128,7 @@ function thread_id(; result_0=nothing::Union{Nothing, MLIRType}, dimension, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.thread_id", location; @@ -1177,7 +1177,7 @@ function wait(asyncDependencies::Vector{Value}; asyncToken=nothing::Union{Nothin owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.wait", location; diff --git a/src/Dialects/15/LLVMIR.jl b/src/Dialects/15/LLVMIR.jl index 1f353f23..c4b0196b 100644 --- a/src/Dialects/15/LLVMIR.jl +++ b/src/Dialects/15/LLVMIR.jl @@ -15,7 +15,7 @@ function ashr(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.ashr", location; @@ -62,7 +62,7 @@ function add(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.add", location; @@ -149,7 +149,7 @@ function alias_scope_domain(; sym_name, description=nothing, location=Location() owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), ] - (description != nothing) && push!(attributes, namedattribute("description", description)) + !isnothing(description) && push!(attributes, namedattribute("description", description)) create_operation( "llvm.alias_scope_domain", location; @@ -198,7 +198,7 @@ function alias_scope(; sym_name, domain, description=nothing, location=Location( owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("domain", domain), ] - (description != nothing) && push!(attributes, namedattribute("description", description)) + !isnothing(description) && push!(attributes, namedattribute("description", description)) create_operation( "llvm.alias_scope", location; @@ -218,8 +218,8 @@ function alloca(arraySize::Value; res::MLIRType, alignment=nothing, elem_type=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (elem_type != nothing) && push!(attributes, namedattribute("elem_type", elem_type)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(elem_type) && push!(attributes, namedattribute("elem_type", elem_type)) create_operation( "llvm.alloca", location; @@ -239,7 +239,7 @@ function and(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.and", location; @@ -361,8 +361,8 @@ function call(operand_0::Vector{Value}; result_0::Vector{MLIRType}, callee=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (callee != nothing) && push!(attributes, namedattribute("callee", callee)) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.call", location; @@ -383,7 +383,7 @@ function cond_br(condition::Value, trueDestOperands::Vector{Value}, falseDestOpe successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands), ])) - (branch_weights != nothing) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) create_operation( "llvm.cond_br", location; @@ -486,8 +486,8 @@ function fadd(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fadd", location; @@ -507,7 +507,7 @@ function fcmp(lhs::Value, rhs::Value; res::MLIRType, predicate, fastmathFlags=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("predicate", predicate), ] - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fcmp", location; @@ -527,8 +527,8 @@ function fdiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fdiv", location; @@ -548,8 +548,8 @@ function fmul(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fmul", location; @@ -569,8 +569,8 @@ function fneg(operand::Value; res=nothing::Union{Nothing, MLIRType}, fastmathFla owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fneg", location; @@ -666,8 +666,8 @@ function frem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.frem", location; @@ -687,8 +687,8 @@ function fsub(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fsub", location; @@ -727,7 +727,7 @@ function freeze(val::Value; res=nothing::Union{Nothing, MLIRType}, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.freeze", location; @@ -747,7 +747,7 @@ function getelementptr(base::Value, indices::Vector{Value}; res::MLIRType, struc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("structIndices", structIndices), ] - (elem_type != nothing) && push!(attributes, namedattribute("elem_type", elem_type)) + !isnothing(elem_type) && push!(attributes, namedattribute("elem_type", elem_type)) create_operation( "llvm.getelementptr", location; @@ -931,14 +931,14 @@ function mlir_global(; global_type, constant=nothing, sym_name, linkage, dso_loc owned_regions = Region[initializer, ] successors = Block[] attributes = NamedAttribute[namedattribute("global_type", global_type), namedattribute("sym_name", sym_name), namedattribute("linkage", linkage), ] - (constant != nothing) && push!(attributes, namedattribute("constant", constant)) - (dso_local != nothing) && push!(attributes, namedattribute("dso_local", dso_local)) - (thread_local_ != nothing) && push!(attributes, namedattribute("thread_local_", thread_local_)) - (value != nothing) && push!(attributes, namedattribute("value", value)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (addr_space != nothing) && push!(attributes, namedattribute("addr_space", addr_space)) - (unnamed_addr != nothing) && push!(attributes, namedattribute("unnamed_addr", unnamed_addr)) - (section != nothing) && push!(attributes, namedattribute("section", section)) + !isnothing(constant) && push!(attributes, namedattribute("constant", constant)) + !isnothing(dso_local) && push!(attributes, namedattribute("dso_local", dso_local)) + !isnothing(thread_local_) && push!(attributes, namedattribute("thread_local_", thread_local_)) + !isnothing(value) && push!(attributes, namedattribute("value", value)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(addr_space) && push!(attributes, namedattribute("addr_space", addr_space)) + !isnothing(unnamed_addr) && push!(attributes, namedattribute("unnamed_addr", unnamed_addr)) + !isnothing(section) && push!(attributes, namedattribute("section", section)) create_operation( "llvm.mlir.global", location; @@ -983,11 +983,11 @@ function inline_asm(operands::Vector{Value}; res=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("asm_string", asm_string), namedattribute("constraints", constraints), ] - (res != nothing) && push!(results, res) - (has_side_effects != nothing) && push!(attributes, namedattribute("has_side_effects", has_side_effects)) - (is_align_stack != nothing) && push!(attributes, namedattribute("is_align_stack", is_align_stack)) - (asm_dialect != nothing) && push!(attributes, namedattribute("asm_dialect", asm_dialect)) - (operand_attrs != nothing) && push!(attributes, namedattribute("operand_attrs", operand_attrs)) + !isnothing(res) && push!(results, res) + !isnothing(has_side_effects) && push!(attributes, namedattribute("has_side_effects", has_side_effects)) + !isnothing(is_align_stack) && push!(attributes, namedattribute("is_align_stack", is_align_stack)) + !isnothing(asm_dialect) && push!(attributes, namedattribute("asm_dialect", asm_dialect)) + !isnothing(operand_attrs) && push!(attributes, namedattribute("operand_attrs", operand_attrs)) create_operation( "llvm.inline_asm", location; @@ -1065,7 +1065,7 @@ function invoke(callee_operands::Vector{Value}, normalDestOperands::Vector{Value successors = Block[normalDest, unwindDest, ] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(callee_operands), length(normalDestOperands), length(unwindDestOperands), ])) - (callee != nothing) && push!(attributes, namedattribute("callee", callee)) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) create_operation( "llvm.invoke", location; @@ -1110,12 +1110,12 @@ function func(; function_type, linkage=nothing, dso_local=nothing, CConv=nothing owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("function_type", function_type), ] - (linkage != nothing) && push!(attributes, namedattribute("linkage", linkage)) - (dso_local != nothing) && push!(attributes, namedattribute("dso_local", dso_local)) - (CConv != nothing) && push!(attributes, namedattribute("CConv", CConv)) - (personality != nothing) && push!(attributes, namedattribute("personality", personality)) - (garbageCollector != nothing) && push!(attributes, namedattribute("garbageCollector", garbageCollector)) - (passthrough != nothing) && push!(attributes, namedattribute("passthrough", passthrough)) + !isnothing(linkage) && push!(attributes, namedattribute("linkage", linkage)) + !isnothing(dso_local) && push!(attributes, namedattribute("dso_local", dso_local)) + !isnothing(CConv) && push!(attributes, namedattribute("CConv", CConv)) + !isnothing(personality) && push!(attributes, namedattribute("personality", personality)) + !isnothing(garbageCollector) && push!(attributes, namedattribute("garbageCollector", garbageCollector)) + !isnothing(passthrough) && push!(attributes, namedattribute("passthrough", passthrough)) create_operation( "llvm.func", location; @@ -1135,7 +1135,7 @@ function lshr(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.lshr", location; @@ -1155,7 +1155,7 @@ function landingpad(operand_0::Vector{Value}; res::MLIRType, cleanup=nothing, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (cleanup != nothing) && push!(attributes, namedattribute("cleanup", cleanup)) + !isnothing(cleanup) && push!(attributes, namedattribute("cleanup", cleanup)) create_operation( "llvm.landingpad", location; @@ -1175,12 +1175,12 @@ function load(addr::Value; res::MLIRType, access_groups=nothing, alias_scopes=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (access_groups != nothing) && push!(attributes, namedattribute("access_groups", access_groups)) - (alias_scopes != nothing) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) - (noalias_scopes != nothing) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (volatile_ != nothing) && push!(attributes, namedattribute("volatile_", volatile_)) - (nontemporal != nothing) && push!(attributes, namedattribute("nontemporal", nontemporal)) + !isnothing(access_groups) && push!(attributes, namedattribute("access_groups", access_groups)) + !isnothing(alias_scopes) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) + !isnothing(noalias_scopes) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) create_operation( "llvm.load", location; @@ -1227,7 +1227,7 @@ function mul(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.mul", location; @@ -1280,7 +1280,7 @@ function or(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.or", location; @@ -1357,7 +1357,7 @@ function sdiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.sdiv", location; @@ -1415,7 +1415,7 @@ function srem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.srem", location; @@ -1435,7 +1435,7 @@ function select(condition::Value, trueValue::Value, falseValue::Value; res=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.select", location; @@ -1455,7 +1455,7 @@ function shl(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.shl", location; @@ -1494,12 +1494,12 @@ function store(value::Value, addr::Value; access_groups=nothing, alias_scopes=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (access_groups != nothing) && push!(attributes, namedattribute("access_groups", access_groups)) - (alias_scopes != nothing) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) - (noalias_scopes != nothing) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (volatile_ != nothing) && push!(attributes, namedattribute("volatile_", volatile_)) - (nontemporal != nothing) && push!(attributes, namedattribute("nontemporal", nontemporal)) + !isnothing(access_groups) && push!(attributes, namedattribute("access_groups", access_groups)) + !isnothing(alias_scopes) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) + !isnothing(noalias_scopes) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) create_operation( "llvm.store", location; @@ -1519,7 +1519,7 @@ function sub(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.sub", location; @@ -1540,8 +1540,8 @@ function switch(value::Value, defaultOperands::Vector{Value}, caseOperands::Vect successors = Block[defaultDestination, caseDestinations..., ] attributes = NamedAttribute[namedattribute("case_operand_segments", case_operand_segments), ] push!(attributes, operandsegmentsizes([1, length(defaultOperands), length(caseOperands), ])) - (case_values != nothing) && push!(attributes, namedattribute("case_values", case_values)) - (branch_weights != nothing) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) create_operation( "llvm.switch", location; @@ -1580,7 +1580,7 @@ function udiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.udiv", location; @@ -1619,7 +1619,7 @@ function urem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.urem", location; @@ -1688,7 +1688,7 @@ function xor(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.xor", location; diff --git a/src/Dialects/15/Linalg.jl b/src/Dialects/15/Linalg.jl index befbd7e3..e393f3ee 100644 --- a/src/Dialects/15/Linalg.jl +++ b/src/Dialects/15/Linalg.jl @@ -48,7 +48,7 @@ function index(; result=nothing::Union{Nothing, MLIRType}, dim, location=Locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dim", dim), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "linalg.index", location; @@ -112,4 +112,1200 @@ function yield(values::Vector{Value}; location=Location()) ) end +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`batch_matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function batch_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.batch_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`batch_matvec` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function batch_matvec(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.batch_matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_1d_nwc_wcf` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_1d_nwc_wcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_1d_nwc_wcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_1d` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_1d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_1d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_nchw_fchw` + +Layout: + * Input: NCHW. + * Kernel: FCHW. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d_nchw_fchw(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_2d_nchw_fchw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_ngchw_fgchw` + +Layout: + * Input: NGCHW. + * Kernel: FGCHW. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d_ngchw_fgchw(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_2d_ngchw_fgchw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_nhwc_fhwc` + +Layout: + * Input: NHWC. + * Kernel: FHWC. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d_nhwc_fhwc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_2d_nhwc_fhwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_nhwc_hwcf` + +Layout: + * Input: NHWC. + * Kernel: HWCF. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d_nhwc_hwcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_2d_nhwc_hwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_nhwc_hwcf_q` + +Layout: + * Input: NHWC. + * Kernel: HWCF. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. This includes the zero +point offsets common to quantized operations. +""" +function conv_2d_nhwc_hwcf_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_2d_nhwc_hwcf_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_3d_ndhwc_dhwcf` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_3d_ndhwc_dhwcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_3d_ndhwc_dhwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_3d` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_3d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_3d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`copy` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function copy(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, cast=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + create_operation( + "linalg.copy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_1d_nwc_wc` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. Multiplier is set to 1 +which is a special case for most depthwise convolutions. +""" +function depthwise_conv_1d_nwc_wc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_1d_nwc_wc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_1d_nwc_wcm` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_1d_nwc_wcm(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_1d_nwc_wcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nchw_chw` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. Multiplier is set to 1 +which is a special case for most depthwise convolutions. +""" +function depthwise_conv_2d_nchw_chw(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_2d_nchw_chw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwc` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. Multiplier is set to 1 +which is a special case for most depthwise convolutions. +""" +function depthwise_conv_2d_nhwc_hwc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwc_q` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_2d_nhwc_hwc_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwcm` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_2d_nhwc_hwcm(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwcm_q` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_2d_nhwc_hwcm_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_3d_ndhwc_dhwc` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. Multiplier is set to 1 +which is a special case for most depthwise convolutions. +""" +function depthwise_conv_3d_ndhwc_dhwc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_3d_ndhwc_dhwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_3d_ndhwc_dhwcm` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_3d_ndhwc_dhwcm(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_3d_ndhwc_dhwcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`dot` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function dot(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.dot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`elemwise_binary` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function elemwise_binary(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, fun=nothing, cast=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(fun) && push!(attributes, namedattribute("fun", fun)) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + create_operation( + "linalg.elemwise_binary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`elemwise_unary` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function elemwise_unary(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, fun=nothing, cast=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(fun) && push!(attributes, namedattribute("fun", fun)) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + create_operation( + "linalg.elemwise_unary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`fill` + +Works for arbitrary ranked output tensors since the operation performs scalar +accesses only and is thus rank polymorphic. Numeric casting is performed on +the value operand, promoting it to the same data type as the output. +""" +function fill(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.fill", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`fill_rng_2d` + +The operation generations pseudo random numbers using a linear congruential +generator. It provides no guarantees regarding the distribution of the +generated random numbers. Instead of generating the random numbers +sequentially, it instantiates one random number generator per data element +and runs them in parallel. The seed operand and the indices of the data +element seed the random number generation. The min and max operands limit +the range of the generated random numbers. +""" +function fill_rng_2d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.fill_rng_2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`generic` + +Generic Linalg op form where the key properties of the computation are +specified as attributes. In pretty form, a `linalg.generic` op is written +as: + + ```mlir + linalg.generic #trait_attribute + ins(%A, %B : memref, + memref) + outs(%C : memref) + attrs = {other-optional-attributes} + {region} + ``` + +Where #trait_attributes is an alias of a dictionary attribute containing: + - doc [optional]: a documentation string + - indexing_maps: a list of AffineMapAttr, one AffineMapAttr per each input + and output view. Such AffineMapAttr specifies the mapping between the + loops and the indexing within each view. + - library_call [optional]: a StringAttr containing the name of an + external library function that the linalg.generic operation maps to. + The external library is assumed to be dynamically linked and no strong + compile-time guarantees are provided. In the absence of such a library + call, linalg.generic will always lower to loops. + - iterator_types: an ArrayAttr specifying the type of the enclosing loops. + Each element of the list represents and iterator of one of the following + types: + parallel, reduction, window + +# Example +Defining a #matmul_trait attribute in MLIR can be done as follows: + ```mlir + #matmul_accesses = [ + (m, n, k) -> (m, k), + (m, n, k) -> (k, n), + (m, n, k) -> (m, n) + ] + #matmul_trait = { + doc = \"C(m, n) += A(m, k) * B(k, n)\", + indexing_maps = #matmul_accesses, + library_call = \"linalg_matmul\", + iterator_types = [\"parallel\", \"parallel\", \"reduction\"] + } + ``` + +And can be reused in multiple places as: + ```mlir + linalg.generic #matmul_trait + ins(%A, %B : memref, + memref) + outs(%C : memref) + {other-optional-attributes} { + ^bb0(%a: f32, %b: f32, %c: f32) : + %d = arith.mulf %a, %b: f32 + %e = arith.addf %c, %d: f32 + linalg.yield %e : f32 + } + ``` + +This may lower to either: + ```mlir + call @linalg_matmul(%A, %B, %C) : + (memref, + memref, + memref) + -> () + ``` + +or IR resembling: +```mlir +scf.for %m = %c0 to %M step %c1 { + scf.for %n = %c0 to %N step %c1 { + scf.for %k = %c0 to %K step %c1 { + %a = load %A[%m, %k] : memref + %b = load %B[%k, %n] : memref + %c = load %C[%m, %n] : memref + %d = arith.mulf %a, %b: f32 + %e = arith.addf %c, %d: f32 + store %e, %C[%m, %n] : memref + } + } +} +``` + +To allow progressive lowering from the value world (a.k.a tensor values) to +the buffer world (a.k.a memref values), a `linalg.generic` op allows mixing +tensors and buffers operands and tensor results. + +```mlir +%C = linalg.generic #trait_attribute + ins(%A, %B : tensor, memref) + outs(%C : tensor) + {other-optional-attributes} + {region} + -> (tensor) +``` +""" +function generic(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, indexing_maps, iterator_types, doc=nothing, library_call=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(doc) && push!(attributes, namedattribute("doc", doc)) + !isnothing(library_call) && push!(attributes, namedattribute("library_call", library_call)) + + create_operation( + "linalg.generic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, cast=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + create_operation( + "linalg.matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`matmul_unsigned` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function matmul_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.matmul_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`matvec` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function matvec(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`mmt4d` + +Differences from linalg.matmul: +* The right hand side is transposed, whence the \'t\' in \'mmt\'. +* The input and output tensors have a 4D shape instead of a 2D shape. They + are interpreted as 2D matrices with one level of 2D tile subdivision, + whence the 2+2=4 dimensions. The inner tile dimensions are identified with + \'0\' suffixes below, for instance the LHS matrix shape (M, K, M0, K0) reads + as: MxK tiles, each of shape M0xK0. +""" +function mmt4d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.mmt4d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nchw_max` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nchw_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nchw_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nchw_sum` + +Layout: + * Input: NCHW. + * Kernel: HW. + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nchw_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nchw_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_ndhwc_max` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_ndhwc_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_ndhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_ndhwc_min` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_ndhwc_min(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_ndhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_ndhwc_sum` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_ndhwc_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_ndhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_max` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_max_unsigned` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_max_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nhwc_max_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_min` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_min(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_min_unsigned` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_min_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nhwc_min_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_sum` + +Layout: + * Input: NHWC. + * Kernel: HW. + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`quantized_batch_matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. The quantized variant +includes zero-point adjustments for the left and right operands of the +matmul. +""" +function quantized_batch_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.quantized_batch_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`quantized_matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. The quantized variant +includes zero-point adjustments for the left and right operands of the +matmul. +""" +function quantized_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.quantized_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`vecmat` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function vecmat(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.vecmat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + end # linalg diff --git a/src/Dialects/15/MLProgram.jl b/src/Dialects/15/MLProgram.jl index 59f540e2..afd87715 100644 --- a/src/Dialects/15/MLProgram.jl +++ b/src/Dialects/15/MLProgram.jl @@ -31,7 +31,7 @@ function func(; sym_name, function_type, sym_visibility=nothing, body::Region, l owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("function_type", function_type), ] - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "ml_program.func", location; @@ -55,20 +55,20 @@ such a load can be considered to have no side effects. %0 = ml_program.global_load_const @foobar : tensor ``` """ -# function global_load_const(; result::MLIRType, global, location=Location()) -# results = MLIRType[result, ] -# operands = Value[] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[namedattribute("global", global), ] +function global_load_const(; result::MLIRType, global_, location=Location()) + results = MLIRType[result, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] -# create_operation( -# "ml_program.global_load_const", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "ml_program.global_load_const", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `global_load_graph` @@ -90,20 +90,20 @@ without additional consideration to evaluation order constraints. ordering (%token -> !ml_program.token) : tensor ``` """ -# function global_load_graph(consumeTokens::Vector{Value}; result::MLIRType, produceToken::MLIRType, global, location=Location()) -# results = MLIRType[result, produceToken, ] -# operands = Value[consumeTokens..., ] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[namedattribute("global", global), ] +function global_load_graph(consumeTokens::Vector{Value}; result::MLIRType, produceToken::MLIRType, global_, location=Location()) + results = MLIRType[result, produceToken, ] + operands = Value[consumeTokens..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] -# create_operation( -# "ml_program.global_load_graph", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "ml_program.global_load_graph", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `global_load` @@ -125,20 +125,20 @@ without additional consideration to evaluation order constraints. See %0 = ml_program.global_load @foobar : tensor ``` """ -# function global_load(; result::MLIRType, global, location=Location()) -# results = MLIRType[result, ] -# operands = Value[] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[namedattribute("global", global), ] +function global_load(; result::MLIRType, global_, location=Location()) + results = MLIRType[result, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] -# create_operation( -# "ml_program.global_load", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "ml_program.global_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `global_` @@ -176,9 +176,9 @@ function global_(; sym_name, type, is_mutable=nothing, value=nothing, sym_visibi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("type", type), ] - (is_mutable != nothing) && push!(attributes, namedattribute("is_mutable", is_mutable)) - (value != nothing) && push!(attributes, namedattribute("value", value)) - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(is_mutable) && push!(attributes, namedattribute("is_mutable", is_mutable)) + !isnothing(value) && push!(attributes, namedattribute("value", value)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "ml_program.global", location; @@ -208,20 +208,20 @@ without additional consideration to evaluation order constraints. ordering (%in_token -> !ml_program.token) : tensor ``` """ -# function global_store_graph(value::Value, consumeTokens::Vector{Value}; produceToken::MLIRType, global, location=Location()) -# results = MLIRType[produceToken, ] -# operands = Value[value, consumeTokens..., ] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[namedattribute("global", global), ] +function global_store_graph(value::Value, consumeTokens::Vector{Value}; produceToken::MLIRType, global_, location=Location()) + results = MLIRType[produceToken, ] + operands = Value[value, consumeTokens..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] -# create_operation( -# "ml_program.global_store_graph", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "ml_program.global_store_graph", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `global_store` @@ -243,20 +243,20 @@ without additional consideration to evaluation order constraints. See ml_program.global_store @foobar = %0 : tensor ``` """ -# function global_store(value::Value; global, location=Location()) -# results = MLIRType[] -# operands = Value[value, ] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[namedattribute("global", global), ] +function global_store(value::Value; global_, location=Location()) + results = MLIRType[] + operands = Value[value, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] -# create_operation( -# "ml_program.global_store", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "ml_program.global_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `output` @@ -332,7 +332,7 @@ function subgraph(; sym_name, function_type, sym_visibility=nothing, body::Regio owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("function_type", function_type), ] - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "ml_program.subgraph", location; diff --git a/src/Dialects/15/Math.jl b/src/Dialects/15/Math.jl index 78484781..f780b69a 100644 --- a/src/Dialects/15/Math.jl +++ b/src/Dialects/15/Math.jl @@ -25,7 +25,7 @@ function abs(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.abs", location; @@ -68,7 +68,7 @@ function atan2(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.atan2", location; @@ -104,7 +104,7 @@ function atan(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.atan", location; @@ -140,7 +140,7 @@ function ceil(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.ceil", location; @@ -177,7 +177,7 @@ function copysign(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.copysign", location; @@ -213,7 +213,7 @@ function cos(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.cos", location; @@ -242,7 +242,7 @@ function ctlz(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.ctlz", location; @@ -271,7 +271,7 @@ function cttz(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.cttz", location; @@ -300,7 +300,7 @@ function ctpop(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.ctpop", location; @@ -336,7 +336,7 @@ function erf(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.erf", location; @@ -372,7 +372,7 @@ function exp2(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.exp2", location; @@ -410,7 +410,7 @@ function expm1(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.expm1", location; @@ -446,7 +446,7 @@ function exp(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.exp", location; @@ -482,7 +482,7 @@ function floor(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.floor", location; @@ -523,7 +523,7 @@ function fma(a::Value, b::Value, c::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.fma", location; @@ -553,7 +553,7 @@ function log10(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.log10", location; @@ -585,7 +585,7 @@ function log1p(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.log1p", location; @@ -615,7 +615,7 @@ function log2(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.log2", location; @@ -645,7 +645,7 @@ function log(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.log", location; @@ -681,7 +681,7 @@ function powf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.powf", location; @@ -720,7 +720,7 @@ function round(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.round", location; @@ -750,7 +750,7 @@ function rsqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.rsqrt", location; @@ -786,7 +786,7 @@ function sin(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.sin", location; @@ -816,7 +816,7 @@ function sqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.sqrt", location; @@ -846,7 +846,7 @@ function tan(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.tan", location; @@ -876,7 +876,7 @@ function tanh(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.tanh", location; diff --git a/src/Dialects/15/MemRef.jl b/src/Dialects/15/MemRef.jl index 613666f1..9e200eca 100644 --- a/src/Dialects/15/MemRef.jl +++ b/src/Dialects/15/MemRef.jl @@ -252,7 +252,7 @@ function alloc(dynamicSizes::Vector{Value}, symbolOperands::Vector{Value}; memre successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "memref.alloc", location; @@ -306,7 +306,7 @@ function alloca(dynamicSizes::Vector{Value}, symbolOperands::Vector{Value}; memr successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "memref.alloca", location; @@ -818,10 +818,10 @@ function global_(; sym_name, sym_visibility=nothing, type, initial_value=nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("type", type), ] - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) - (initial_value != nothing) && push!(attributes, namedattribute("initial_value", initial_value)) - (constant != nothing) && push!(attributes, namedattribute("constant", constant)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(initial_value) && push!(attributes, namedattribute("initial_value", initial_value)) + !isnothing(constant) && push!(attributes, namedattribute("constant", constant)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "memref.global", location; diff --git a/src/Dialects/15/NVGPU.jl b/src/Dialects/15/NVGPU.jl index 796a01db..f6f8d853 100644 --- a/src/Dialects/15/NVGPU.jl +++ b/src/Dialects/15/NVGPU.jl @@ -54,7 +54,7 @@ function device_async_copy(dst::Value, dstIndices::Vector{Value}, src::Value, sr successors = Block[] attributes = NamedAttribute[namedattribute("numElements", numElements), ] push!(attributes, operandsegmentsizes([1, length(dstIndices), 1, length(srcIndices), ])) - (bypassL1 != nothing) && push!(attributes, namedattribute("bypassL1", bypassL1)) + !isnothing(bypassL1) && push!(attributes, namedattribute("bypassL1", bypassL1)) create_operation( "nvgpu.device_async_copy", location; @@ -119,7 +119,7 @@ function device_async_wait(asyncDependencies::Value; numGroups=nothing, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (numGroups != nothing) && push!(attributes, namedattribute("numGroups", numGroups)) + !isnothing(numGroups) && push!(attributes, namedattribute("numGroups", numGroups)) create_operation( "nvgpu.device_async_wait", location; diff --git a/src/Dialects/15/OpenACC.jl b/src/Dialects/15/OpenACC.jl index 099a545a..6df1d71b 100644 --- a/src/Dialects/15/OpenACC.jl +++ b/src/Dialects/15/OpenACC.jl @@ -29,9 +29,9 @@ function data(ifCond=nothing::Union{Nothing, Value}; copyOperands::Vector{Value} owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1length(copyOperands), length(copyinOperands), length(copyinReadonlyOperands), length(copyoutOperands), length(copyoutZeroOperands), length(createOperands), length(createZeroOperands), length(noCreateOperands), length(presentOperands), length(deviceptrOperands), length(attachOperands), ])) - (defaultAttr != nothing) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) create_operation( "acc.data", location; @@ -58,12 +58,12 @@ function enter_data(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(copyinOperands), length(createOperands), length(createZeroOperands), length(attachOperands), ])) - (async != nothing) && push!(attributes, namedattribute("async", async)) - (wait != nothing) && push!(attributes, namedattribute("wait", wait)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) create_operation( "acc.enter_data", location; @@ -90,13 +90,13 @@ function exit_data(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(copyoutOperands), length(deleteOperands), length(detachOperands), ])) - (async != nothing) && push!(attributes, namedattribute("async", async)) - (wait != nothing) && push!(attributes, namedattribute("wait", wait)) - (finalize != nothing) && push!(attributes, namedattribute("finalize", finalize)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + !isnothing(finalize) && push!(attributes, namedattribute("finalize", finalize)) create_operation( "acc.exit_data", location; @@ -125,8 +125,8 @@ function init(deviceTypeOperands::Vector{Value}, deviceNumOperand=nothing::Union owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (deviceNumOperand != nothing) && push!(operands, deviceNumOperand) - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(deviceNumOperand) && push!(operands, deviceNumOperand) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([length(deviceTypeOperands), (deviceNumOperand==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) create_operation( @@ -163,17 +163,17 @@ function loop(gangNum=nothing::Union{Nothing, Value}; gangStatic=nothing::Union{ owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (gangNum != nothing) && push!(operands, gangNum) - (gangStatic != nothing) && push!(operands, gangStatic) - (workerNum != nothing) && push!(operands, workerNum) - (vectorLength != nothing) && push!(operands, vectorLength) + !isnothing(gangNum) && push!(operands, gangNum) + !isnothing(gangStatic) && push!(operands, gangStatic) + !isnothing(workerNum) && push!(operands, workerNum) + !isnothing(vectorLength) && push!(operands, vectorLength) push!(attributes, operandsegmentsizes([(gangNum==nothing) ? 0 : 1(gangStatic==nothing) ? 0 : 1(workerNum==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1length(tileOperands), length(privateOperands), length(reductionOperands), ])) - (collapse != nothing) && push!(attributes, namedattribute("collapse", collapse)) - (seq != nothing) && push!(attributes, namedattribute("seq", seq)) - (independent != nothing) && push!(attributes, namedattribute("independent", independent)) - (auto_ != nothing) && push!(attributes, namedattribute("auto_", auto_)) - (reductionOp != nothing) && push!(attributes, namedattribute("reductionOp", reductionOp)) - (exec_mapping != nothing) && push!(attributes, namedattribute("exec_mapping", exec_mapping)) + !isnothing(collapse) && push!(attributes, namedattribute("collapse", collapse)) + !isnothing(seq) && push!(attributes, namedattribute("seq", seq)) + !isnothing(independent) && push!(attributes, namedattribute("independent", independent)) + !isnothing(auto_) && push!(attributes, namedattribute("auto_", auto_)) + !isnothing(reductionOp) && push!(attributes, namedattribute("reductionOp", reductionOp)) + !isnothing(exec_mapping) && push!(attributes, namedattribute("exec_mapping", exec_mapping)) create_operation( "acc.loop", location; @@ -204,18 +204,18 @@ function parallel(async=nothing::Union{Nothing, Value}; waitOperands::Vector{Val owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (async != nothing) && push!(operands, async) - (numGangs != nothing) && push!(operands, numGangs) - (numWorkers != nothing) && push!(operands, numWorkers) - (vectorLength != nothing) && push!(operands, vectorLength) - (ifCond != nothing) && push!(operands, ifCond) - (selfCond != nothing) && push!(operands, selfCond) + !isnothing(async) && push!(operands, async) + !isnothing(numGangs) && push!(operands, numGangs) + !isnothing(numWorkers) && push!(operands, numWorkers) + !isnothing(vectorLength) && push!(operands, vectorLength) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(selfCond) && push!(operands, selfCond) push!(attributes, operandsegmentsizes([(async==nothing) ? 0 : 1length(waitOperands), (numGangs==nothing) ? 0 : 1(numWorkers==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1(selfCond==nothing) ? 0 : 1length(reductionOperands), length(copyOperands), length(copyinOperands), length(copyinReadonlyOperands), length(copyoutOperands), length(copyoutZeroOperands), length(createOperands), length(createZeroOperands), length(noCreateOperands), length(presentOperands), length(devicePtrOperands), length(attachOperands), length(gangPrivateOperands), length(gangFirstPrivateOperands), ])) - (asyncAttr != nothing) && push!(attributes, namedattribute("asyncAttr", asyncAttr)) - (waitAttr != nothing) && push!(attributes, namedattribute("waitAttr", waitAttr)) - (selfAttr != nothing) && push!(attributes, namedattribute("selfAttr", selfAttr)) - (reductionOp != nothing) && push!(attributes, namedattribute("reductionOp", reductionOp)) - (defaultAttr != nothing) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + !isnothing(asyncAttr) && push!(attributes, namedattribute("asyncAttr", asyncAttr)) + !isnothing(waitAttr) && push!(attributes, namedattribute("waitAttr", waitAttr)) + !isnothing(selfAttr) && push!(attributes, namedattribute("selfAttr", selfAttr)) + !isnothing(reductionOp) && push!(attributes, namedattribute("reductionOp", reductionOp)) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) create_operation( "acc.parallel", location; @@ -244,8 +244,8 @@ function shutdown(deviceTypeOperands::Vector{Value}, deviceNumOperand=nothing::U owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (deviceNumOperand != nothing) && push!(operands, deviceNumOperand) - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(deviceNumOperand) && push!(operands, deviceNumOperand) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([length(deviceTypeOperands), (deviceNumOperand==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) create_operation( @@ -299,13 +299,13 @@ function update(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing::Uni owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(deviceTypeOperands), length(hostOperands), length(deviceOperands), ])) - (async != nothing) && push!(attributes, namedattribute("async", async)) - (wait != nothing) && push!(attributes, namedattribute("wait", wait)) - (ifPresent != nothing) && push!(attributes, namedattribute("ifPresent", ifPresent)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + !isnothing(ifPresent) && push!(attributes, namedattribute("ifPresent", ifPresent)) create_operation( "acc.update", location; @@ -334,11 +334,11 @@ function wait(waitOperands::Vector{Value}, asyncOperand=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([length(waitOperands), (asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) - (async != nothing) && push!(attributes, namedattribute("async", async)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) create_operation( "acc.wait", location; diff --git a/src/Dialects/15/OpenMP.jl b/src/Dialects/15/OpenMP.jl index 4a6e3b04..bcd92120 100644 --- a/src/Dialects/15/OpenMP.jl +++ b/src/Dialects/15/OpenMP.jl @@ -44,8 +44,8 @@ function atomic_capture(; hint_val=nothing, memory_order_val=nothing, region::Re owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (hint_val != nothing) && push!(attributes, namedattribute("hint_val", hint_val)) - (memory_order_val != nothing) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) create_operation( "omp.atomic.capture", location; @@ -76,8 +76,8 @@ function atomic_read(x::Value, v::Value; hint_val=nothing, memory_order_val=noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (hint_val != nothing) && push!(attributes, namedattribute("hint_val", hint_val)) - (memory_order_val != nothing) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) create_operation( "omp.atomic.read", location; @@ -123,8 +123,8 @@ function atomic_update(x::Value; hint_val=nothing, memory_order_val=nothing, reg owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (hint_val != nothing) && push!(attributes, namedattribute("hint_val", hint_val)) - (memory_order_val != nothing) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) create_operation( "omp.atomic.update", location; @@ -157,8 +157,8 @@ function atomic_write(address::Value, value::Value; hint_val=nothing, memory_ord owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (hint_val != nothing) && push!(attributes, namedattribute("hint_val", hint_val)) - (memory_order_val != nothing) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) create_operation( "omp.atomic.write", location; @@ -201,7 +201,7 @@ function cancel(if_expr=nothing::Union{Nothing, Value}; cancellation_construct_t owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("cancellation_construct_type_val", cancellation_construct_type_val), ] - (if_expr != nothing) && push!(operands, if_expr) + !isnothing(if_expr) && push!(operands, if_expr) create_operation( "omp.cancel", location; @@ -246,7 +246,7 @@ function critical_declare(; sym_name, hint_val=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), ] - (hint_val != nothing) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) create_operation( "omp.critical.declare", location; @@ -268,7 +268,7 @@ function critical(; name=nothing, region::Region, location=Location()) owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (name != nothing) && push!(attributes, namedattribute("name", name)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) create_operation( "omp.critical", location; @@ -346,8 +346,8 @@ function ordered(depend_vec_vars::Vector{Value}; depend_type_val=nothing, num_lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (depend_type_val != nothing) && push!(attributes, namedattribute("depend_type_val", depend_type_val)) - (num_loops_val != nothing) && push!(attributes, namedattribute("num_loops_val", num_loops_val)) + !isnothing(depend_type_val) && push!(attributes, namedattribute("depend_type_val", depend_type_val)) + !isnothing(num_loops_val) && push!(attributes, namedattribute("num_loops_val", num_loops_val)) create_operation( "omp.ordered", location; @@ -374,7 +374,7 @@ function ordered_region(; simd=nothing, region::Region, location=Location()) owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (simd != nothing) && push!(attributes, namedattribute("simd", simd)) + !isnothing(simd) && push!(attributes, namedattribute("simd", simd)) create_operation( "omp.ordered_region", location; @@ -422,11 +422,11 @@ function parallel(if_expr_var=nothing::Union{Nothing, Value}; num_threads_var=no owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr_var != nothing) && push!(operands, if_expr_var) - (num_threads_var != nothing) && push!(operands, num_threads_var) + !isnothing(if_expr_var) && push!(operands, if_expr_var) + !isnothing(num_threads_var) && push!(operands, num_threads_var) push!(attributes, operandsegmentsizes([(if_expr_var==nothing) ? 0 : 1(num_threads_var==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), length(reduction_vars), ])) - (reductions != nothing) && push!(attributes, namedattribute("reductions", reductions)) - (proc_bind_val != nothing) && push!(attributes, namedattribute("proc_bind_val", proc_bind_val)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(proc_bind_val) && push!(attributes, namedattribute("proc_bind_val", proc_bind_val)) create_operation( "omp.parallel", location; @@ -555,8 +555,8 @@ function sections(reduction_vars::Vector{Value}, allocate_vars::Vector{Value}, a successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(reduction_vars), length(allocate_vars), length(allocators_vars), ])) - (reductions != nothing) && push!(attributes, namedattribute("reductions", reductions)) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) create_operation( "omp.sections", location; @@ -596,9 +596,9 @@ function simdloop(lowerBound::Vector{Value}, upperBound::Vector{Value}, step::Ve owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr != nothing) && push!(operands, if_expr) + !isnothing(if_expr) && push!(operands, if_expr) push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), (if_expr==nothing) ? 0 : 1])) - (inclusive != nothing) && push!(attributes, namedattribute("inclusive", inclusive)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) create_operation( "omp.simdloop", location; @@ -624,7 +624,7 @@ function single(allocate_vars::Vector{Value}, allocators_vars::Vector{Value}; no successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(allocate_vars), length(allocators_vars), ])) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) create_operation( "omp.single", location; @@ -660,11 +660,11 @@ function target(if_expr=nothing::Union{Nothing, Value}; device=nothing::Union{No owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr != nothing) && push!(operands, if_expr) - (device != nothing) && push!(operands, device) - (thread_limit != nothing) && push!(operands, thread_limit) + !isnothing(if_expr) && push!(operands, if_expr) + !isnothing(device) && push!(operands, device) + !isnothing(thread_limit) && push!(operands, thread_limit) push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1(thread_limit==nothing) ? 0 : 1])) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) create_operation( "omp.target", location; @@ -705,7 +705,7 @@ function taskgroup(task_reduction_vars::Vector{Value}, allocate_vars::Vector{Val successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(task_reduction_vars), length(allocate_vars), length(allocators_vars), ])) - (task_reductions != nothing) && push!(attributes, namedattribute("task_reductions", task_reductions)) + !isnothing(task_reductions) && push!(attributes, namedattribute("task_reductions", task_reductions)) create_operation( "omp.taskgroup", location; @@ -819,18 +819,18 @@ function taskloop(lowerBound::Vector{Value}, upperBound::Vector{Value}, step::Ve owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr != nothing) && push!(operands, if_expr) - (final_expr != nothing) && push!(operands, final_expr) - (priority != nothing) && push!(operands, priority) - (grain_size != nothing) && push!(operands, grain_size) - (num_tasks != nothing) && push!(operands, num_tasks) + !isnothing(if_expr) && push!(operands, if_expr) + !isnothing(final_expr) && push!(operands, final_expr) + !isnothing(priority) && push!(operands, priority) + !isnothing(grain_size) && push!(operands, grain_size) + !isnothing(num_tasks) && push!(operands, num_tasks) push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), (if_expr==nothing) ? 0 : 1(final_expr==nothing) ? 0 : 1length(in_reduction_vars), length(reduction_vars), (priority==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), (grain_size==nothing) ? 0 : 1(num_tasks==nothing) ? 0 : 1])) - (inclusive != nothing) && push!(attributes, namedattribute("inclusive", inclusive)) - (untied != nothing) && push!(attributes, namedattribute("untied", untied)) - (mergeable != nothing) && push!(attributes, namedattribute("mergeable", mergeable)) - (in_reductions != nothing) && push!(attributes, namedattribute("in_reductions", in_reductions)) - (reductions != nothing) && push!(attributes, namedattribute("reductions", reductions)) - (nogroup != nothing) && push!(attributes, namedattribute("nogroup", nogroup)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + !isnothing(untied) && push!(attributes, namedattribute("untied", untied)) + !isnothing(mergeable) && push!(attributes, namedattribute("mergeable", mergeable)) + !isnothing(in_reductions) && push!(attributes, namedattribute("in_reductions", in_reductions)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nogroup) && push!(attributes, namedattribute("nogroup", nogroup)) create_operation( "omp.taskloop", location; @@ -888,13 +888,13 @@ function task(if_expr=nothing::Union{Nothing, Value}; final_expr=nothing::Union{ owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr != nothing) && push!(operands, if_expr) - (final_expr != nothing) && push!(operands, final_expr) - (priority != nothing) && push!(operands, priority) + !isnothing(if_expr) && push!(operands, if_expr) + !isnothing(final_expr) && push!(operands, final_expr) + !isnothing(priority) && push!(operands, priority) push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(final_expr==nothing) ? 0 : 1length(in_reduction_vars), (priority==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), ])) - (untied != nothing) && push!(attributes, namedattribute("untied", untied)) - (mergeable != nothing) && push!(attributes, namedattribute("mergeable", mergeable)) - (in_reductions != nothing) && push!(attributes, namedattribute("in_reductions", in_reductions)) + !isnothing(untied) && push!(attributes, namedattribute("untied", untied)) + !isnothing(mergeable) && push!(attributes, namedattribute("mergeable", mergeable)) + !isnothing(in_reductions) && push!(attributes, namedattribute("in_reductions", in_reductions)) create_operation( "omp.task", location; @@ -1069,16 +1069,16 @@ function wsloop(lowerBound::Vector{Value}, upperBound::Vector{Value}, step::Vect owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (schedule_chunk_var != nothing) && push!(operands, schedule_chunk_var) + !isnothing(schedule_chunk_var) && push!(operands, schedule_chunk_var) push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(linear_vars), length(linear_step_vars), length(reduction_vars), (schedule_chunk_var==nothing) ? 0 : 1])) - (reductions != nothing) && push!(attributes, namedattribute("reductions", reductions)) - (schedule_val != nothing) && push!(attributes, namedattribute("schedule_val", schedule_val)) - (schedule_modifier != nothing) && push!(attributes, namedattribute("schedule_modifier", schedule_modifier)) - (simd_modifier != nothing) && push!(attributes, namedattribute("simd_modifier", simd_modifier)) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) - (ordered_val != nothing) && push!(attributes, namedattribute("ordered_val", ordered_val)) - (order_val != nothing) && push!(attributes, namedattribute("order_val", order_val)) - (inclusive != nothing) && push!(attributes, namedattribute("inclusive", inclusive)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(schedule_val) && push!(attributes, namedattribute("schedule_val", schedule_val)) + !isnothing(schedule_modifier) && push!(attributes, namedattribute("schedule_modifier", schedule_modifier)) + !isnothing(simd_modifier) && push!(attributes, namedattribute("simd_modifier", simd_modifier)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(ordered_val) && push!(attributes, namedattribute("ordered_val", ordered_val)) + !isnothing(order_val) && push!(attributes, namedattribute("order_val", order_val)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) create_operation( "omp.wsloop", location; diff --git a/src/Dialects/15/PDL.jl b/src/Dialects/15/PDL.jl index 51471728..b8ff40e0 100644 --- a/src/Dialects/15/PDL.jl +++ b/src/Dialects/15/PDL.jl @@ -108,8 +108,8 @@ function attribute(type=nothing::Union{Nothing, Value}; attr::MLIRType, value=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (type != nothing) && push!(operands, type) - (value != nothing) && push!(attributes, namedattribute("value", value)) + !isnothing(type) && push!(operands, type) + !isnothing(value) && push!(attributes, namedattribute("value", value)) create_operation( "pdl.attribute", location; @@ -174,7 +174,7 @@ function operand(type=nothing::Union{Nothing, Value}; val::MLIRType, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (type != nothing) && push!(operands, type) + !isnothing(type) && push!(operands, type) create_operation( "pdl.operand", location; @@ -211,7 +211,7 @@ function operands(type=nothing::Union{Nothing, Value}; val::MLIRType, location=L owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (type != nothing) && push!(operands, type) + !isnothing(type) && push!(operands, type) create_operation( "pdl.operands", location; @@ -325,7 +325,7 @@ function operation(operands::Vector{Value}, attributes::Vector{Value}, types::Ve successors = Block[] attributes = NamedAttribute[namedattribute("attributeNames", attributeNames), ] push!(attributes, operandsegmentsizes([length(operands), length(attributes), length(types), ])) - (name != nothing) && push!(attributes, namedattribute("name", name)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) create_operation( "pdl.operation", location; @@ -365,7 +365,7 @@ function pattern(; benefit, sym_name=nothing, body::Region, location=Location()) owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("benefit", benefit), ] - (sym_name != nothing) && push!(attributes, namedattribute("sym_name", sym_name)) + !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) create_operation( "pdl.pattern", location; @@ -406,7 +406,7 @@ function replace(operation::Value, replOperation=nothing::Union{Nothing, Value}; owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (replOperation != nothing) && push!(operands, replOperation) + !isnothing(replOperation) && push!(operands, replOperation) push!(attributes, operandsegmentsizes([1, (replOperation==nothing) ? 0 : 1length(replValues), ])) create_operation( @@ -489,7 +489,7 @@ function results(parent::Value; val::MLIRType, index=nothing, location=Location( owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (index != nothing) && push!(attributes, namedattribute("index", index)) + !isnothing(index) && push!(attributes, namedattribute("index", index)) create_operation( "pdl.results", location; @@ -544,9 +544,9 @@ function rewrite(root=nothing::Union{Nothing, Value}; externalArgs::Vector{Value owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (root != nothing) && push!(operands, root) + !isnothing(root) && push!(operands, root) push!(attributes, operandsegmentsizes([(root==nothing) ? 0 : 1length(externalArgs), ])) - (name != nothing) && push!(attributes, namedattribute("name", name)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) create_operation( "pdl.rewrite", location; @@ -580,7 +580,7 @@ function type(; result::MLIRType, type=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (type != nothing) && push!(attributes, namedattribute("type", type)) + !isnothing(type) && push!(attributes, namedattribute("type", type)) create_operation( "pdl.type", location; @@ -614,7 +614,7 @@ function types(; result::MLIRType, types=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (types != nothing) && push!(attributes, namedattribute("types", types)) + !isnothing(types) && push!(attributes, namedattribute("types", types)) create_operation( "pdl.types", location; diff --git a/src/Dialects/15/PDLInterp.jl b/src/Dialects/15/PDLInterp.jl index 276898f6..7ac3ed80 100644 --- a/src/Dialects/15/PDLInterp.jl +++ b/src/Dialects/15/PDLInterp.jl @@ -182,7 +182,7 @@ function check_operand_count(inputOp::Value; count, compareAtLeast=nothing, true owned_regions = Region[] successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[namedattribute("count", count), ] - (compareAtLeast != nothing) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) + !isnothing(compareAtLeast) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) create_operation( "pdl_interp.check_operand_count", location; @@ -245,7 +245,7 @@ function check_result_count(inputOp::Value; count, compareAtLeast=nothing, trueD owned_regions = Region[] successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[namedattribute("count", count), ] - (compareAtLeast != nothing) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) + !isnothing(compareAtLeast) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) create_operation( "pdl_interp.check_result_count", location; @@ -392,7 +392,7 @@ function create_operation(inputOperands::Vector{Value}, inputAttributes::Vector{ successors = Block[] attributes = NamedAttribute[namedattribute("name", name), namedattribute("inputAttributeNames", inputAttributeNames), ] push!(attributes, operandsegmentsizes([length(inputOperands), length(inputAttributes), length(inputResultTypes), ])) - (inferredResultTypes != nothing) && push!(attributes, namedattribute("inferredResultTypes", inferredResultTypes)) + !isnothing(inferredResultTypes) && push!(attributes, namedattribute("inferredResultTypes", inferredResultTypes)) create_operation( "pdl_interp.create_operation", location; @@ -747,7 +747,7 @@ function get_operands(inputOp::Value; value::MLIRType, index=nothing, location=L owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (index != nothing) && push!(attributes, namedattribute("index", index)) + !isnothing(index) && push!(attributes, namedattribute("index", index)) create_operation( "pdl_interp.get_operands", location; @@ -814,7 +814,7 @@ function get_results(inputOp::Value; value::MLIRType, index=nothing, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (index != nothing) && push!(attributes, namedattribute("index", index)) + !isnothing(index) && push!(attributes, namedattribute("index", index)) create_operation( "pdl_interp.get_results", location; @@ -938,8 +938,8 @@ function record_match(inputs::Vector{Value}, matchedOps::Vector{Value}; rewriter successors = Block[dest, ] attributes = NamedAttribute[namedattribute("rewriter", rewriter), namedattribute("benefit", benefit), ] push!(attributes, operandsegmentsizes([length(inputs), length(matchedOps), ])) - (rootKind != nothing) && push!(attributes, namedattribute("rootKind", rootKind)) - (generatedOps != nothing) && push!(attributes, namedattribute("generatedOps", generatedOps)) + !isnothing(rootKind) && push!(attributes, namedattribute("rootKind", rootKind)) + !isnothing(generatedOps) && push!(attributes, namedattribute("generatedOps", generatedOps)) create_operation( "pdl_interp.record_match", location; diff --git a/src/Dialects/15/Quant.jl b/src/Dialects/15/Quant.jl index 56dc7666..28c09a39 100644 --- a/src/Dialects/15/Quant.jl +++ b/src/Dialects/15/Quant.jl @@ -19,9 +19,9 @@ function const_fake_quant(inputs::Value; outputs=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("min", min), namedattribute("max", max), namedattribute("num_bits", num_bits), ] - (outputs != nothing) && push!(results, outputs) - (narrow_range != nothing) && push!(attributes, namedattribute("narrow_range", narrow_range)) - (is_signed != nothing) && push!(attributes, namedattribute("is_signed", is_signed)) + !isnothing(outputs) && push!(results, outputs) + !isnothing(narrow_range) && push!(attributes, namedattribute("narrow_range", narrow_range)) + !isnothing(is_signed) && push!(attributes, namedattribute("is_signed", is_signed)) create_operation( "quant.const_fake_quant", location; @@ -46,9 +46,9 @@ function const_fake_quant_per_axis(inputs::Value; outputs=nothing::Union{Nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("min", min), namedattribute("max", max), namedattribute("axis", axis), namedattribute("num_bits", num_bits), ] - (outputs != nothing) && push!(results, outputs) - (narrow_range != nothing) && push!(attributes, namedattribute("narrow_range", narrow_range)) - (is_signed != nothing) && push!(attributes, namedattribute("is_signed", is_signed)) + !isnothing(outputs) && push!(results, outputs) + !isnothing(narrow_range) && push!(attributes, namedattribute("narrow_range", narrow_range)) + !isnothing(is_signed) && push!(attributes, namedattribute("is_signed", is_signed)) create_operation( "quant.const_fake_quant_per_axis", location; @@ -74,7 +74,7 @@ function coupled_ref(arg::Value; result_0=nothing::Union{Nothing, MLIRType}, cou owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("coupledKey", coupledKey), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "quant.coupled_ref", location; @@ -186,9 +186,9 @@ function stats(arg::Value; result_0=nothing::Union{Nothing, MLIRType}, layerStat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("layerStats", layerStats), ] - (result_0 != nothing) && push!(results, result_0) - (axisStats != nothing) && push!(attributes, namedattribute("axisStats", axisStats)) - (axis != nothing) && push!(attributes, namedattribute("axis", axis)) + !isnothing(result_0) && push!(results, result_0) + !isnothing(axisStats) && push!(attributes, namedattribute("axisStats", axisStats)) + !isnothing(axis) && push!(attributes, namedattribute("axis", axis)) create_operation( "quant.stats", location; @@ -213,7 +213,7 @@ function stats_ref(arg::Value; result_0=nothing::Union{Nothing, MLIRType}, stats owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("statsKey", statsKey), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "quant.stats_ref", location; diff --git a/src/Dialects/15/SCF.jl b/src/Dialects/15/SCF.jl index ad9be3ec..a329a35b 100644 --- a/src/Dialects/15/SCF.jl +++ b/src/Dialects/15/SCF.jl @@ -294,7 +294,7 @@ function foreach_thread(num_threads::Vector{Value}; results::Vector{MLIRType}, t owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (thread_dim_mapping != nothing) && push!(attributes, namedattribute("thread_dim_mapping", thread_dim_mapping)) + !isnothing(thread_dim_mapping) && push!(attributes, namedattribute("thread_dim_mapping", thread_dim_mapping)) create_operation( "scf.foreach_thread", location; diff --git a/src/Dialects/15/SPIRV.jl b/src/Dialects/15/SPIRV.jl index eec360dc..7ca3aed5 100644 --- a/src/Dialects/15/SPIRV.jl +++ b/src/Dialects/15/SPIRV.jl @@ -907,7 +907,7 @@ function BitCount(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitCount", location; @@ -965,7 +965,7 @@ function BitFieldInsert(base::Value, insert::Value, offset::Value, count::Value; owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitFieldInsert", location; @@ -1023,7 +1023,7 @@ function BitFieldSExtract(base::Value, offset::Value, count::Value; result=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitFieldSExtract", location; @@ -1063,7 +1063,7 @@ function BitFieldUExtract(base::Value, offset::Value, count::Value; result=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitFieldUExtract", location; @@ -1107,7 +1107,7 @@ function BitReverse(operand::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitReverse", location; @@ -1203,7 +1203,7 @@ function BitwiseAnd(operand1::Value, operand2::Value; result=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitwiseAnd", location; @@ -1245,7 +1245,7 @@ function BitwiseOr(operand1::Value, operand2::Value; result=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitwiseOr", location; @@ -1287,7 +1287,7 @@ function BitwiseXor(operand1::Value, operand2::Value; result=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.BitwiseXor", location; @@ -1338,7 +1338,7 @@ function BranchConditional(condition::Value, trueTargetOperands::Vector{Value}, successors = Block[trueTarget, falseTarget, ] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([1, length(trueTargetOperands), length(falseTargetOperands), ])) - (branch_weights != nothing) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) create_operation( "spv.BranchConditional", location; @@ -1414,7 +1414,7 @@ function CL_ceil(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.ceil", location; @@ -1455,7 +1455,7 @@ function CL_cos(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.cos", location; @@ -1496,7 +1496,7 @@ function CL_erf(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.erf", location; @@ -1537,7 +1537,7 @@ function CL_exp(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.exp", location; @@ -1578,7 +1578,7 @@ function CL_fabs(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.fabs", location; @@ -1619,7 +1619,7 @@ function CL_floor(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.floor", location; @@ -1656,7 +1656,7 @@ function CL_fma(x::Value, y::Value, z::Value; result=nothing::Union{Nothing, MLI owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.fma", location; @@ -1697,7 +1697,7 @@ function CL_log(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.log", location; @@ -1739,7 +1739,7 @@ function CL_pow(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.pow", location; @@ -1779,7 +1779,7 @@ function CL_round(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.round", location; @@ -1820,7 +1820,7 @@ function CL_rsqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.rsqrt", location; @@ -1861,7 +1861,7 @@ function CL_s_abs(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.s_abs", location; @@ -1902,7 +1902,7 @@ function CL_sin(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.sin", location; @@ -1943,7 +1943,7 @@ function CL_sqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.sqrt", location; @@ -1984,7 +1984,7 @@ function CL_tanh(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CL.tanh", location; @@ -2426,7 +2426,7 @@ function CooperativeMatrixLengthNV(; result=nothing::Union{Nothing, MLIRType}, t owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("type", type), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CooperativeMatrixLengthNV", location; @@ -2495,7 +2495,7 @@ function CooperativeMatrixLoadNV(pointer::Value, stride::Value, columnmajor::Val owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) create_operation( "spv.CooperativeMatrixLoadNV", location; @@ -2558,7 +2558,7 @@ function CooperativeMatrixMulAddNV(a::Value, b::Value, c::Value; result=nothing: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.CooperativeMatrixMulAddNV", location; @@ -2613,7 +2613,7 @@ function CooperativeMatrixStoreNV(pointer::Value, object::Value, stride::Value, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) create_operation( "spv.CooperativeMatrixStoreNV", location; @@ -2658,10 +2658,10 @@ function CopyMemory(target::Value, source::Value; memory_access=nothing, alignme owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (source_memory_access != nothing) && push!(attributes, namedattribute("source_memory_access", source_memory_access)) - (source_alignment != nothing) && push!(attributes, namedattribute("source_alignment", source_alignment)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(source_memory_access) && push!(attributes, namedattribute("source_memory_access", source_memory_access)) + !isnothing(source_alignment) && push!(attributes, namedattribute("source_alignment", source_alignment)) create_operation( "spv.CopyMemory", location; @@ -2801,7 +2801,7 @@ function FAdd(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FAdd", location; @@ -2883,7 +2883,7 @@ function FDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FDiv", location; @@ -2926,7 +2926,7 @@ function FMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FMod", location; @@ -2968,7 +2968,7 @@ function FMul(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FMul", location; @@ -3008,7 +3008,7 @@ function FNegate(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FNegate", location; @@ -3298,7 +3298,7 @@ function FRem(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FRem", location; @@ -3339,7 +3339,7 @@ function FSub(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FSub", location; @@ -3675,7 +3675,7 @@ function FunctionCall(arguments::Vector{Value}; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("callee", callee), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.FunctionCall", location; @@ -3720,7 +3720,7 @@ function GL_Acos(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Acos", location; @@ -3765,7 +3765,7 @@ function GL_Asin(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Asin", location; @@ -3810,7 +3810,7 @@ function GL_Atan(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Atan", location; @@ -3852,7 +3852,7 @@ function GL_Ceil(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Ceil", location; @@ -3895,7 +3895,7 @@ function GL_Cos(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Cos", location; @@ -3938,7 +3938,7 @@ function GL_Cosh(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Cosh", location; @@ -3981,7 +3981,7 @@ function GL_Exp(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Exp", location; @@ -4022,7 +4022,7 @@ function GL_FAbs(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.FAbs", location; @@ -4104,7 +4104,7 @@ function GL_FMax(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.FMax", location; @@ -4146,7 +4146,7 @@ function GL_FMin(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.FMin", location; @@ -4180,7 +4180,7 @@ function GL_FMix(x::Value, y::Value, a::Value; result=nothing::Union{Nothing, ML owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.FMix", location; @@ -4221,7 +4221,7 @@ function GL_FSign(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.FSign", location; @@ -4250,7 +4250,7 @@ function GL_FindUMsb(operand::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.FindUMsb", location; @@ -4292,7 +4292,7 @@ function GL_Floor(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Floor", location; @@ -4436,7 +4436,7 @@ function GL_InverseSqrt(operand::Value; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.InverseSqrt", location; @@ -4486,7 +4486,7 @@ function GL_Ldexp(x::Value, exp::Value; y=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (y != nothing) && push!(results, y) + !isnothing(y) && push!(results, y) create_operation( "spv.GL.Ldexp", location; @@ -4530,7 +4530,7 @@ function GL_Log(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Log", location; @@ -4575,7 +4575,7 @@ function GL_Pow(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Pow", location; @@ -4616,7 +4616,7 @@ function GL_Round(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Round", location; @@ -4656,7 +4656,7 @@ function GL_SAbs(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.SAbs", location; @@ -4736,7 +4736,7 @@ function GL_SMax(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.SMax", location; @@ -4777,7 +4777,7 @@ function GL_SMin(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.SMin", location; @@ -4817,7 +4817,7 @@ function GL_SSign(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.SSign", location; @@ -4860,7 +4860,7 @@ function GL_Sin(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Sin", location; @@ -4903,7 +4903,7 @@ function GL_Sinh(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Sinh", location; @@ -4944,7 +4944,7 @@ function GL_Sqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Sqrt", location; @@ -4987,7 +4987,7 @@ function GL_Tan(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Tan", location; @@ -5030,7 +5030,7 @@ function GL_Tanh(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.Tanh", location; @@ -5110,7 +5110,7 @@ function GL_UMax(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.UMax", location; @@ -5151,7 +5151,7 @@ function GL_UMin(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GL.UMin", location; @@ -5201,17 +5201,17 @@ spv.GlobalVariable @var2 bind(1, 2) : !spv.ptr spv.GlobalVariable @var3 built_in(\"GlobalInvocationId\") : !spv.ptr, Input> ``` """ -function GlobalVariable(; type, sym_name, initializer=nothing, binding=nothing, descriptor_set=nothing, builtin=nothing, location=Location()) +function GlobalVariable(; type, sym_name, initializer=nothing, location_=nothing, binding=nothing, descriptor_set=nothing, builtin=nothing, location=Location()) results = MLIRType[] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("type", type), namedattribute("sym_name", sym_name), ] - (initializer != nothing) && push!(attributes, namedattribute("initializer", initializer)) - (location != nothing) && push!(attributes, namedattribute("location", location)) - (binding != nothing) && push!(attributes, namedattribute("binding", binding)) - (descriptor_set != nothing) && push!(attributes, namedattribute("descriptor_set", descriptor_set)) - (builtin != nothing) && push!(attributes, namedattribute("builtin", builtin)) + !isnothing(initializer) && push!(attributes, namedattribute("initializer", initializer)) + !isnothing(location) && push!(attributes, namedattribute("location", location_)) + !isnothing(binding) && push!(attributes, namedattribute("binding", binding)) + !isnothing(descriptor_set) && push!(attributes, namedattribute("descriptor_set", descriptor_set)) + !isnothing(builtin) && push!(attributes, namedattribute("builtin", builtin)) create_operation( "spv.GlobalVariable", location; @@ -5272,7 +5272,7 @@ function GroupBroadcast(value::Value, localid::Value; result=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GroupBroadcast", location; @@ -5373,7 +5373,7 @@ function GroupNonUniformBroadcast(value::Value, id::Value; result=nothing::Union owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GroupNonUniformBroadcast", location; @@ -5410,7 +5410,7 @@ function GroupNonUniformElect(; result=nothing::Union{Nothing, MLIRType}, execut owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.GroupNonUniformElect", location; @@ -5468,7 +5468,7 @@ function GroupNonUniformFAdd(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformFAdd", location; @@ -5529,7 +5529,7 @@ function GroupNonUniformFMax(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformFMax", location; @@ -5590,7 +5590,7 @@ function GroupNonUniformFMin(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformFMin", location; @@ -5648,7 +5648,7 @@ function GroupNonUniformFMul(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformFMul", location; @@ -5704,7 +5704,7 @@ function GroupNonUniformIAdd(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformIAdd", location; @@ -5760,7 +5760,7 @@ function GroupNonUniformIMul(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformIMul", location; @@ -5816,7 +5816,7 @@ function GroupNonUniformSMax(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformSMax", location; @@ -5872,7 +5872,7 @@ function GroupNonUniformSMin(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformSMin", location; @@ -5929,7 +5929,7 @@ function GroupNonUniformUMax(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformUMax", location; @@ -5986,7 +5986,7 @@ function GroupNonUniformUMin(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spv.GroupNonUniformUMin", location; @@ -6033,7 +6033,7 @@ function IAdd(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.IAdd", location; @@ -6121,7 +6121,7 @@ function IMul(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.IMul", location; @@ -6255,7 +6255,7 @@ function ISub(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.ISub", location; @@ -6307,7 +6307,7 @@ function ImageDrefGather(sampledimage::Value, coordinate::Value, dref::Value, op owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (imageoperands != nothing) && push!(attributes, namedattribute("imageoperands", imageoperands)) + !isnothing(imageoperands) && push!(attributes, namedattribute("imageoperands", imageoperands)) create_operation( "spv.ImageDrefGather", location; @@ -6555,8 +6555,8 @@ function Load(ptr::Value; value::MLIRType, memory_access=nothing, alignment=noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "spv.Load", location; @@ -7014,8 +7014,8 @@ function module_(; addressing_model, memory_model, vce_triple=nothing, sym_name= owned_regions = Region[region_0, ] successors = Block[] attributes = NamedAttribute[namedattribute("addressing_model", addressing_model), namedattribute("memory_model", memory_model), ] - (vce_triple != nothing) && push!(attributes, namedattribute("vce_triple", vce_triple)) - (sym_name != nothing) && push!(attributes, namedattribute("sym_name", sym_name)) + !isnothing(vce_triple) && push!(attributes, namedattribute("vce_triple", vce_triple)) + !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) create_operation( "spv.module", location; @@ -7057,7 +7057,7 @@ function Not(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.Not", location; @@ -7345,7 +7345,7 @@ function SDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.SDiv", location; @@ -7554,7 +7554,7 @@ function SMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.SMod", location; @@ -7590,7 +7590,7 @@ function SNegate(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.SNegate", location; @@ -7635,7 +7635,7 @@ function SRem(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.SRem", location; @@ -7690,7 +7690,7 @@ function Select(condition::Value, true_value::Value, false_value::Value; result= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.Select", location; @@ -7778,7 +7778,7 @@ function ShiftLeftLogical(operand1::Value, operand2::Value; result=nothing::Unio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.ShiftLeftLogical", location; @@ -7827,7 +7827,7 @@ function ShiftRightArithmetic(operand1::Value, operand2::Value; result=nothing:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.ShiftRightArithmetic", location; @@ -7877,7 +7877,7 @@ function ShiftRightLogical(operand1::Value, operand2::Value; result=nothing::Uni owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.ShiftRightLogical", location; @@ -8103,8 +8103,8 @@ function Store(ptr::Value, value::Value; memory_access=nothing, alignment=nothin owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "spv.Store", location; @@ -8367,7 +8367,7 @@ function UDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.UDiv", location; @@ -8574,7 +8574,7 @@ function UMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.UMod", location; @@ -8729,7 +8729,7 @@ function Variable(initializer=nothing::Union{Nothing, Value}; pointer::MLIRType, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("storage_class", storage_class), ] - (initializer != nothing) && push!(operands, initializer) + !isnothing(initializer) && push!(operands, initializer) create_operation( "spv.Variable", location; @@ -8816,7 +8816,7 @@ function VectorInsertDynamic(vector::Value, component::Value, index::Value; resu owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spv.VectorInsertDynamic", location; diff --git a/src/Dialects/15/Shape.jl b/src/Dialects/15/Shape.jl index 26dc2dc8..e59a32cb 100644 --- a/src/Dialects/15/Shape.jl +++ b/src/Dialects/15/Shape.jl @@ -21,7 +21,7 @@ function add(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.add", location; @@ -88,7 +88,7 @@ function assuming_all(inputs::Vector{Value}; result=nothing::Union{Nothing, MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.assuming_all", location; @@ -175,7 +175,7 @@ function broadcast(shapes::Vector{Value}; result::MLIRType, error=nothing, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (error != nothing) && push!(attributes, namedattribute("error", error)) + !isnothing(error) && push!(attributes, namedattribute("error", error)) create_operation( "shape.broadcast", location; @@ -230,7 +230,7 @@ function const_shape(; result=nothing::Union{Nothing, MLIRType}, shape, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("shape", shape), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.const_shape", location; @@ -255,7 +255,7 @@ function const_size(; result=nothing::Union{Nothing, MLIRType}, value, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("value", value), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.const_size", location; @@ -286,7 +286,7 @@ function const_witness(; result=nothing::Union{Nothing, MLIRType}, passing, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("passing", passing), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.const_witness", location; @@ -317,7 +317,7 @@ function cstr_broadcastable(shapes::Vector{Value}; result=nothing::Union{Nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.cstr_broadcastable", location; @@ -346,7 +346,7 @@ function cstr_eq(shapes::Vector{Value}; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.cstr_eq", location; @@ -381,7 +381,7 @@ function cstr_require(pred::Value; result=nothing::Union{Nothing, MLIRType}, msg owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("msg", msg), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.cstr_require", location; @@ -436,7 +436,7 @@ function div(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.div", location; @@ -459,7 +459,7 @@ function from_extent_tensor(input::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.from_extent_tensor", location; @@ -488,7 +488,7 @@ function from_extents(extents::Vector{Value}; shape=nothing::Union{Nothing, MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (shape != nothing) && push!(results, shape) + !isnothing(shape) && push!(results, shape) create_operation( "shape.from_extents", location; @@ -511,7 +511,7 @@ function func(; sym_name, function_type, sym_visibility=nothing, body::Region, l owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("function_type", function_type), ] - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "shape.func", location; @@ -567,7 +567,7 @@ function get_extent(shape::Value, dim::Value; extent=nothing::Union{Nothing, MLI owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (extent != nothing) && push!(results, extent) + !isnothing(extent) && push!(results, extent) create_operation( "shape.get_extent", location; @@ -592,7 +592,7 @@ function index_to_size(arg::Value; result=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.index_to_size", location; @@ -626,7 +626,7 @@ function is_broadcastable(shapes::Vector{Value}; result=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.is_broadcastable", location; @@ -650,7 +650,7 @@ function max(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.max", location; @@ -693,8 +693,8 @@ function meet(arg0::Value, arg1::Value; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (error != nothing) && push!(attributes, namedattribute("error", error)) + !isnothing(result) && push!(results, result) + !isnothing(error) && push!(attributes, namedattribute("error", error)) create_operation( "shape.meet", location; @@ -718,7 +718,7 @@ function min(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.min", location; @@ -744,7 +744,7 @@ function mul(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.mul", location; @@ -769,7 +769,7 @@ function num_elements(shape::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.num_elements", location; @@ -790,7 +790,7 @@ function rank(shape::Value; rank=nothing::Union{Nothing, MLIRType}, location=Loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (rank != nothing) && push!(results, rank) + !isnothing(rank) && push!(results, rank) create_operation( "shape.rank", location; @@ -884,7 +884,7 @@ function shape_eq(shapes::Vector{Value}; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.shape_eq", location; @@ -906,7 +906,7 @@ function shape_of(arg::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.shape_of", location; @@ -930,7 +930,7 @@ function size_to_index(arg::Value; result=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.size_to_index", location; @@ -1076,7 +1076,7 @@ function with_shape(operand::Value, shape::Value; result=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.with_shape", location; diff --git a/src/Dialects/15/SparseTensor.jl b/src/Dialects/15/SparseTensor.jl index 2436a388..30fb6687 100644 --- a/src/Dialects/15/SparseTensor.jl +++ b/src/Dialects/15/SparseTensor.jl @@ -111,8 +111,8 @@ function binary(x::Value, y::Value; output::MLIRType, left_identity=nothing, rig owned_regions = Region[overlapRegion, leftRegion, rightRegion, ] successors = Block[] attributes = NamedAttribute[] - (left_identity != nothing) && push!(attributes, namedattribute("left_identity", left_identity)) - (right_identity != nothing) && push!(attributes, namedattribute("right_identity", right_identity)) + !isnothing(left_identity) && push!(attributes, namedattribute("left_identity", left_identity)) + !isnothing(right_identity) && push!(attributes, namedattribute("right_identity", right_identity)) create_operation( "sparse_tensor.binary", location; @@ -322,8 +322,8 @@ function load(tensor::Value; result=nothing::Union{Nothing, MLIRType}, hasInsert owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (hasInserts != nothing) && push!(attributes, namedattribute("hasInserts", hasInserts)) + !isnothing(result) && push!(results, result) + !isnothing(hasInserts) && push!(attributes, namedattribute("hasInserts", hasInserts)) create_operation( "sparse_tensor.load", location; @@ -442,7 +442,7 @@ function reduce(x::Value, y::Value, identity::Value; output=nothing::Union{Nothi owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (output != nothing) && push!(results, output) + !isnothing(output) && push!(results, output) create_operation( "sparse_tensor.reduce", location; diff --git a/src/Dialects/15/Tensor.jl b/src/Dialects/15/Tensor.jl index 31cbb12b..03e4019c 100644 --- a/src/Dialects/15/Tensor.jl +++ b/src/Dialects/15/Tensor.jl @@ -114,7 +114,7 @@ function dim(source::Value, index::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "tensor.dim", location; @@ -530,7 +530,7 @@ function pad(source::Value, low::Vector{Value}, high::Vector{Value}; result::MLI successors = Block[] attributes = NamedAttribute[namedattribute("static_low", static_low), namedattribute("static_high", static_high), ] push!(attributes, operandsegmentsizes([1, length(low), length(high), ])) - (nofold != nothing) && push!(attributes, namedattribute("nofold", nofold)) + !isnothing(nofold) && push!(attributes, namedattribute("nofold", nofold)) create_operation( "tensor.pad", location; @@ -635,7 +635,7 @@ function rank(tensor::Value; result_0=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "tensor.rank", location; diff --git a/src/Dialects/15/Tosa.jl b/src/Dialects/15/Tosa.jl index 87f3774c..04db92ac 100644 --- a/src/Dialects/15/Tosa.jl +++ b/src/Dialects/15/Tosa.jl @@ -126,7 +126,7 @@ function avg_pool2d(input::Value; output::MLIRType, kernel, stride, pad, quantiz owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kernel", kernel), namedattribute("stride", stride), namedattribute("pad", pad), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.avg_pool2d", location; @@ -354,7 +354,7 @@ function const_(; output=nothing::Union{Nothing, MLIRType}, value, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("value", value), ] - (output != nothing) && push!(results, output) + !isnothing(output) && push!(results, output) create_operation( "tosa.const", location; @@ -376,7 +376,7 @@ function conv2d(input::Value, weight::Value, bias::Value; output::MLIRType, pad, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.conv2d", location; @@ -397,7 +397,7 @@ function conv3d(input::Value, weight::Value, bias::Value; output::MLIRType, pad, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.conv3d", location; @@ -442,7 +442,7 @@ function depthwise_conv2d(input::Value, weight::Value, bias::Value; output::MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.depthwise_conv2d", location; @@ -544,7 +544,7 @@ function fully_connected(input::Value, weight::Value, bias::Value; output::MLIRT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.fully_connected", location; @@ -815,7 +815,7 @@ function matmul(a::Value, b::Value; c::MLIRType, quantization_info=nothing, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.matmul", location; @@ -922,7 +922,7 @@ function negate(input1::Value; output::MLIRType, quantization_info=nothing, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.negate", location; @@ -943,8 +943,8 @@ function pad(input1::Value, padding::Value, pad_const=nothing::Union{Nothing, Va owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (pad_const != nothing) && push!(operands, pad_const) - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(pad_const) && push!(operands, pad_const) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.pad", location; @@ -1455,7 +1455,7 @@ function transpose_conv2d(input::Value, filter::Value, bias::Value; output::MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("out_pad", out_pad), namedattribute("stride", stride), namedattribute("out_shape", out_shape), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.transpose_conv2d", location; diff --git a/src/Dialects/15/Transform.jl b/src/Dialects/15/Transform.jl index 846b7e2e..10d2e5bd 100644 --- a/src/Dialects/15/Transform.jl +++ b/src/Dialects/15/Transform.jl @@ -72,7 +72,7 @@ function alternatives(scope=nothing::Union{Nothing, Value}; results::Vector{MLIR owned_regions = Region[alternatives..., ] successors = Block[] attributes = NamedAttribute[] - (scope != nothing) && push!(operands, scope) + !isnothing(scope) && push!(operands, scope) create_operation( "transform.alternatives", location; @@ -166,7 +166,7 @@ function merge_handles(handles::Vector{Value}; result::MLIRType, deduplicate=not owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (deduplicate != nothing) && push!(attributes, namedattribute("deduplicate", deduplicate)) + !isnothing(deduplicate) && push!(attributes, namedattribute("deduplicate", deduplicate)) create_operation( "transform.merge_handles", location; @@ -271,7 +271,7 @@ function sequence(root=nothing::Union{Nothing, Value}; results::Vector{MLIRType} owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (root != nothing) && push!(operands, root) + !isnothing(root) && push!(operands, root) create_operation( "transform.sequence", location; @@ -323,7 +323,7 @@ function with_pdl_patterns(root=nothing::Union{Nothing, Value}; body::Region, lo owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (root != nothing) && push!(operands, root) + !isnothing(root) && push!(operands, root) create_operation( "transform.with_pdl_patterns", location; @@ -355,4 +355,934 @@ function yield(operands::Vector{Value}; location=Location()) ) end +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`bufferization_one_shot_bufferize` + +Indicates that the given `target` op should be bufferized with One-Shot +Bufferize. The bufferization can be configured with various attributes that +corresponding to options in `BufferizationOptions` and the +`one-shot-bufferize` pass. More information can be found in the pass +documentation. + +If `target_is_module` is set, `target` must be a module. In that case the +`target` handle can be reused by other transform ops. When bufferizing other +ops, the `target` handled is freed after bufferization and can no longer be +used. + +Note: Only ops that implement `BufferizableOpInterface` are bufferized. All +other ops are ignored if `allow_unknown_ops`. If `allow_unknown_ops` is +unset, this transform fails when an unknown/non-bufferizable op is found. +Many ops implement `BufferizableOpInterface` via an external model. These +external models must be registered when applying this transform op; +otherwise, said ops would be considered non-bufferizable. +""" +function bufferization_one_shot_bufferize(target::Value; allow_return_allocs=nothing, allow_unknown_ops=nothing, bufferize_function_boundaries=nothing, create_deallocs=nothing, target_is_module=nothing, test_analysis_only=nothing, print_conflicts=nothing, location=Location()) + results = MLIRType[] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(allow_return_allocs) && push!(attributes, namedattribute("allow_return_allocs", allow_return_allocs)) + !isnothing(allow_unknown_ops) && push!(attributes, namedattribute("allow_unknown_ops", allow_unknown_ops)) + !isnothing(bufferize_function_boundaries) && push!(attributes, namedattribute("bufferize_function_boundaries", bufferize_function_boundaries)) + !isnothing(create_deallocs) && push!(attributes, namedattribute("create_deallocs", create_deallocs)) + !isnothing(target_is_module) && push!(attributes, namedattribute("target_is_module", target_is_module)) + !isnothing(test_analysis_only) && push!(attributes, namedattribute("test_analysis_only", test_analysis_only)) + !isnothing(print_conflicts) && push!(attributes, namedattribute("print_conflicts", print_conflicts)) + + create_operation( + "transform.bufferization.one_shot_bufferize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`structured_decompose` + +Decomposes named complex operations, such as higher-dimensional +(depthwise) convolutions, into combinations of lower-dimensional equivalents +when possible. + +#### Return modes + +This operation ignores non-Linalg ops and drops them in the return. +If all the operations referred to by the `target` PDLOperation decompose +properly, the transform succeeds. Otherwise the transform silently fails. +The return handle points to only the subset of successfully produced +computational operations, which can be empty. +""" +function structured_decompose(target::Value; transformed::MLIRType, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "transform.structured.decompose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_fuse_into_containing_op` +Fuse a producer into a containing operation. +""" +function structured_fuse_into_containing_op(producer_op::Value, containing_op::Value; fused_op::MLIRType, location=Location()) + results = MLIRType[fused_op, ] + operands = Value[producer_op, containing_op, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "transform.structured.fuse_into_containing_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_fuse` + +Tiles the operations pointed to by the target handle and fuses their +producers greedily using the options provided as attributes. +""" +function structured_fuse(target::Value; transformed::MLIRType, loops::Vector{MLIRType}, tile_sizes=nothing, tile_interchange=nothing, location=Location()) + results = MLIRType[transformed, loops..., ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + !isnothing(tile_interchange) && push!(attributes, namedattribute("tile_interchange", tile_interchange)) + + create_operation( + "transform.structured.fuse", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_generalize` + +Transforms a named structured operation into the generic form with the +explicit attached region. + +#### Return modes + +This operation ignores non-Linalg ops and drops them in the return. +If all the operations referred to by the `target` PDLOperation generalize +properly, the transform succeeds. Otherwise the transform silently fails. +The return handle points to only the subset of successfully produced +equivalent generic operations, which can be empty or contain the original +ops if they were already in generic form. +""" +function structured_generalize(target::Value; transformed::MLIRType, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "transform.structured.generalize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_interchange` + +Interchanges the iterators of the operations pointed to by the target handle +using the iterator interchange attribute. + +#### Return modes + +This operation ignores non-linalg::Generic ops and drops them in the return. +This operation fails if the interchange attribute is invalid. +If all the operations referred to by the `target` PDLOperation interchange +properly, the transform succeeds. +If any interchange fails, the transform definitely fails. +The return handle points to only the subset of successfully produced +interchanged operations, which can be empty. +""" +function structured_interchange(target::Value; transformed::MLIRType, iterator_interchange=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(iterator_interchange) && push!(attributes, namedattribute("iterator_interchange", iterator_interchange)) + + create_operation( + "transform.structured.interchange", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_match` + +Match op with the specified constraints, within the target op. + +The following constraints are supported: + - interface: an optional MatchInterfaceEnum specifying an enum + representation for an interface to target. + - ops: an optional StrArrayAttr specifying the concrete name of an op. + Multiple names can be specified. Matched ops must have one of specified + names. + - attribute: an optional Str specifying the name of an attribute that + matched ops must have. + +Note: Only ops that satisfy all specified constraints are matched. + +TODO: Extend with regions to allow a limited form of constraints. + +#### Return modes + +This op traverses the ops nested under `target` and returns the handles to +all the operations that match the requirements. + +This op fails if the target is not a handle to exactly one operation. +Otherwise it succeeds. + +This operation does not consume the target handle and produces new handles: +it is a navigation op. +""" +function structured_match(target::Value; results::MLIRType, ops=nothing, interface=nothing, attribute=nothing, location=Location()) + results = MLIRType[results, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ops) && push!(attributes, namedattribute("ops", ops)) + !isnothing(interface) && push!(attributes, namedattribute("interface", interface)) + !isnothing(attribute) && push!(attributes, namedattribute("attribute", attribute)) + + create_operation( + "transform.structured.match", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_multitile_sizes` + +Emits the IR computing the tile sizes `s1` and `s2` such that: + + - there exists a combination of `n` tiles of size `s1` and `m` tiles of + size `s2` that covers the entirety of the iteration space `dimension` of + the target structured op; + - `s1`, `s2` is less than or equal to `target_size`; + - `s1` and `s2` are divisible by `divisor. + +For example, for a dimension of size 54 with target size 12 and divisor 2, +this can emit the IR computing the tile size 10, used for 3 tiles, and 12, +used for 2 tiles, totally 10*3 + 12*2 = 54. Note that when the divisor does +not divide the original dimension size, it is impossible to compute such +tile sizes. An assertion is emitted to guard against this in the dynamic +case. + +Expects the target size and the divisor to be strictly positive. Folds the +IR as much as possible, normally obtaining constant sizes and numbers of +tiles for a statically known dimension. + +This does *not* consume the target handle and produces three handles each +pointing to single-result index-typed operations (which may be arithmetic +constant operations) defining the two respective tile sizes and the product +of the first tile size with the number of tiles of that size (useful for +splitting the iteration space). + +This operation composes with the regular tiling when applied per-dimension: + +```mlir +%sz1, %sz2, %split = structured.multitile_sizes %target + { target_size = 10, dimension = 1 } +%low, %high = structured.split %target after %split { dimension = 1 } +%tiled_low = structured.tile %low [0, %sz1] +%tiled_high = structured.tile %high [0, %sz2] +%common = merge_handles %tiled_low, %tiled_high + +%sz3, %sz4, %split = structured.multitile_size %target + { target_size = 42, dimension = 0 } +%sz3r, %sz4r, %splitr = replicate num(%common) %sz3, %sz4, %splitr +structured.split %common after %splitr { dimension = 0 } +// ... +``` +""" +function structured_multitile_sizes(target::Value; low_size::MLIRType, high_size::MLIRType, split_point::MLIRType, dimension, target_size, divisor=nothing, location=Location()) + results = MLIRType[low_size, high_size, split_point, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), namedattribute("target_size", target_size), ] + !isnothing(divisor) && push!(attributes, namedattribute("divisor", divisor)) + + create_operation( + "transform.structured.multitile_sizes", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_pad` + +Pads the operations pointed to by the target handle using the options +provides as operation attributes. + +#### Return modes + +This operation ignores non-Linalg ops and drops them in the return. +This operation may produce a definiteFailure if the padding fails for any +reason. +If all the operations referred to by the `target` PDLOperation pad +properly, the transform succeeds. Otherwise the transform silently fails. +The return handle points to only the subset of successfully produced +padded operations, which can be empty. +""" +function structured_pad(target::Value; transformed::MLIRType, padding_values=nothing, padding_dimensions=nothing, pack_paddings=nothing, hoist_paddings=nothing, transpose_paddings=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(padding_values) && push!(attributes, namedattribute("padding_values", padding_values)) + !isnothing(padding_dimensions) && push!(attributes, namedattribute("padding_dimensions", padding_dimensions)) + !isnothing(pack_paddings) && push!(attributes, namedattribute("pack_paddings", pack_paddings)) + !isnothing(hoist_paddings) && push!(attributes, namedattribute("hoist_paddings", hoist_paddings)) + !isnothing(transpose_paddings) && push!(attributes, namedattribute("transpose_paddings", transpose_paddings)) + + create_operation( + "transform.structured.pad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_promote` + +Promotes the specified operands of the target into a separate memory buffer. + +At this point, this transform does not allow customizing alloc/dealloc +functions nor the behavior on copy in/out operations. + +#### Return modes + +This operation applies to a single Linalg op that satisfies the +`promoteSubviewsPrecondition`, otherwise it fails. + +If the operations referred to by the `target` PDLOperation promote +properly, the transform succeeds. + +When successful, the return handle points to the \$target operation that +was modified inplace. +""" +function structured_promote(target::Value; transformed::MLIRType, operands_to_promote=nothing, use_full_tile_buffers=nothing, use_full_tiles_by_default=nothing, use_alloca=nothing, alignment=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(operands_to_promote) && push!(attributes, namedattribute("operands_to_promote", operands_to_promote)) + !isnothing(use_full_tile_buffers) && push!(attributes, namedattribute("use_full_tile_buffers", use_full_tile_buffers)) + !isnothing(use_full_tiles_by_default) && push!(attributes, namedattribute("use_full_tiles_by_default", use_full_tiles_by_default)) + !isnothing(use_alloca) && push!(attributes, namedattribute("use_alloca", use_alloca)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + create_operation( + "transform.structured.promote", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_scalarize` + +Indicates that ops of a specific kind in the given function should be +scalarized (i.e. their dynamic dimensions tiled by 1). + +#### Return modes: + +This operation ignores non-Linalg ops and drops them in the return. +This operation produces `definiteFailure` if the scalarization fails for any +reason. +If all the operations referred to by the `target` PDLOperation scalarize +properly, the transform succeeds. Otherwise the transform silently fails. + +The return handle points to only the subset of successfully produced +tiled-by-1 operations, which can be empty. + +This operation does not return handles to the tiled loop. +We make this design choice because it is hard to know ahead of time the +number of loops that will be produced (it depends on the number of dynamic +dimensions after multiple transformations have been applied). +Loops can always be recovered by navigating from the tiled operations if +needed. +""" +function structured_scalarize(target::Value; result::MLIRType, location=Location()) + results = MLIRType[result, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "transform.structured.scalarize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_split` + +Indicates that the given `target` op should be split into two complementary +parts, which combined cover the entire iteration domain of the original op. +The split is performed along the iteration space dimension provided as +attribute. In case of dimension overflow, the transformation fails. The +split is performed at the dimension iterator value specified as either the +static split point attribute when it is known at transform IR construction +time or as the handle to an operation producing a single index-typed value +when it is computed by payload IR. In the latter case, the static split +point must be set to `ShapedType::kDynamicSize` and the dynamic size handle +must point to as many value-producing operations as there are structured +operations pointed to by the target handle. + +The operation consumes the target handle, but preserves the split point +handle if provided. It produces two new handles pointing to the two parts +of the structured op after splitting, in the same order as the target +operand, with the first handle corresponding to the part with lower +iteration space indices. +""" +function structured_split(target::Value, dynamic_split_point=nothing::Union{Nothing, Value}; first::MLIRType, second::MLIRType, dimension, static_split_point, location=Location()) + results = MLIRType[first, second, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), namedattribute("static_split_point", static_split_point), ] + !isnothing(dynamic_split_point) && push!(operands, dynamic_split_point) + + create_operation( + "transform.structured.split", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_split_reduction` + +Indicates that the given `target` op should be transformed with the +`splitReduction` transformation and split factor provided as attribute. + +The `splitReduction` transformation splits the first single linalg op +reduction into a parallel and reduction dimension. +A new `linalg.generic` op is created to perform the rest of the reduction. + +The transformation supports different configurations attributes: + - split_factor: the factor by which to split (i.e. the size of the + remaining reduction after splitting). + - insert_split_dimension: the dimension in the temporary tensor into + which the new parallel dimension is inserted. + - use_scaling_algorithm: whether to use a scaling based formulation that + does not create an ExpandShapeOp (default: do not use scaling) + - use_alloc: whether to use an alloc op to allocate the temporary + tensor (default: do not use alloc op) + +#### Return modes + +This operation ignores non-Linalg ops and drops them in the return. +This operation produces `definiteFailure` if the splitting fails for any +reason. + +If all the operations referred to by the `target` PDLOperation split +properly, the transform succeeds. Otherwise the transform silently fails. +The 4 returned handles points to only the subset of successfully produced +computational operations, which can all be empty. +This 4 returned handles point to: + - the init op (or tensor_alloc op if use_alloc = true), + - the fill op used to initialize the neutral element, + - the split op and + - the result-combining op. + +#### Example (default: `use_scaling_algorithm = false, use_alloc = false`): + +``` + %r = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, + affine_map<(d0) -> ()>], + iterator_types = [\"reduction\"]} + ins(%in : tensor<32xf32>) + outs(%out : tensor) { + ^bb0(%arg1: f32, %arg2: f32): + %y = arith.addf %arg1, %arg2 : f32 + linalg.yield %y : f32 + } -> tensor +``` + +is split into: + +``` + %cst = arith.constant 0.000000e+00 : f32 + %0 = tensor.expand_shape %in [[0, 1]] : tensor<32xf32> into tensor<4x8xf32> + %1 = linalg.init_tensor [4] : tensor<4xf32> + %2 = linalg.fill ins(%cst : f32) outs(%1 : tensor<4xf32>) -> tensor<4xf32> + %3 = linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, + affine_map<(d0, d1) -> (d0)>], + iterator_types = [\"parallel\", \"reduction\"]} + ins(%0 : tensor<4x8xf32>) outs(%2 : tensor<4xf32>) { + ^bb0(%arg3: f32, %arg5: f32): + %5 = arith.addf %arg3, %arg4 : f32 + linalg.yield %5 : f32 + } -> tensor<4xf32> + %r = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, + affine_map<(d0) -> ()>], + iterator_types = [\"reduction\"]} + ins(%3 : tensor<4xf32>) outs(%out : tensor) { + ^bb0(%arg3: f32, %arg4: f32): + %5 = arith.addf %arg3, %arg4 : f32 + linalg.yield %5 : f32 + } -> tensor +``` + +#### Example (`use_scaling_algorithm = true, use_alloc = true`): + +Instead of introducing an ExpandShapeOp, this scaling-based implementation +rewrites a reduction dimension `k` into `k * split_factor + kk`. +The dimension `kk` is added as an extra parallel dimension to the +intermediate output tensor at position `insert_split_dimension`. + +Consider a minimal example where `k` is reduced: + O(i, j) += I(i, j, k) +Assume i=3, j=5, k=128, split_factor=16 and insert_split_dimension=0. +The compute is rewritten as: + a. O_i(kk, i, j) += I(i, j, 16 * k + kk) + b. O(i, j) += O_i(kk, i, j) +The intermediate tensor O_i is of shape (128/16)x3x5 == 8x3x5. + +#### Example: + +``` + %0 = linalg.matmul ins(%A, %B: tensor<16x256xf32>, tensor<256x32xf32>) + outs(%C: tensor<16x32xf32>) -> tensor<16x32xf32> +``` + +Is transformed to: + +``` + #map0 = affine_map<(d0, d1, d2, d3) -> (d0, d2 * 4 + d3)> + #map1 = affine_map<(d0, d1, d2, d3) -> (d2 * 4 + d3, d1)> + #map2 = affine_map<(d0, d1, d2, d3) -> (d2, d3)> + #map3 = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)> + #map4 = affine_map<(d0, d1, d2) -> (d0, d1, d2)> + #map5 = affine_map<(d0, d1, d2) -> (d0, d1)> + %0 = linalg.init_tensor [16, 32, 64] : tensor<16x32x64xf32> + %cst = arith.constant 0.000000e+00 : f32 + %1 = linalg.fill ins(%cst : f32) outs(%0 : tensor<16x32x64xf32>) -> + tensor<16x32x64xf32> + %2 = linalg.init_tensor [64, 4] : tensor<64x4xi1> + + %3 = linalg.generic {indexing_maps = [#map0, #map1, #map2, #map3], + iterator_types = [\"parallel\", \"parallel\", \"parallel\", \"reduction\"]} + ins(%A, %B, %2 : tensor<16x256xf32>, tensor<256x32xf32>, tensor<64x4xi1>) + outs(%1 : tensor<16x32x64xf32>) { + ^bb0(%arg3: f32, %arg4: f32, %arg5: i1, %arg6: f32): + %5 = arith.mulf %arg3, %arg4 : f32 + %6 = arith.addf %arg6, %5 : f32 + linalg.yield %6 : f32 + } -> tensor<16x32x64xf32> + + %4 = linalg.generic {indexing_maps = [#map4, #map5], + iterator_types = [\"parallel\", \"parallel\", \"reduction\"]} + ins(%3 : tensor<16x32x64xf32>) + outs(%C : tensor<16x32xf32>) { + ^bb0(%arg3: f32, %arg4: f32): + %5 = arith.addf %arg3, %arg4 : f32 + linalg.yield %5 : f32 + } -> tensor<16x32xf32> + + return %4 : tensor<16x32xf32> +``` +""" +function structured_split_reduction(target::Value; init_or_alloc_op::MLIRType, fill_op::MLIRType, split_linalg_op::MLIRType, combining_linalg_op::MLIRType, split_factor=nothing, insert_split_dimension=nothing, use_scaling_algorithm=nothing, use_alloc=nothing, location=Location()) + results = MLIRType[init_or_alloc_op, fill_op, split_linalg_op, combining_linalg_op, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(split_factor) && push!(attributes, namedattribute("split_factor", split_factor)) + !isnothing(insert_split_dimension) && push!(attributes, namedattribute("insert_split_dimension", insert_split_dimension)) + !isnothing(use_scaling_algorithm) && push!(attributes, namedattribute("use_scaling_algorithm", use_scaling_algorithm)) + !isnothing(use_alloc) && push!(attributes, namedattribute("use_alloc", use_alloc)) + + create_operation( + "transform.structured.split_reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_tile` + +Indicates that the given `target` op should be tiled with the given sizes. +This transform generates a loop nest with a smaller (\"tiled\") target +operation in its body. Currently limited to LinalgOps. + +Tile sizes may be known at transformation time, in which case they are +expected to be provided in the `static_size` attribute, or not, in which +case the tile value must be computed by the payload IR and the handle to the +operation computing it must be provided through `dynamic_sizes`. When the +sizes are not known statically, the corresponding entry in the +`static_sizes` attribute must be set to `ShapedType::kDynamicSize`. Only +the dynamic sizes must be provided in `dynamic_sizes`, i.e., there should +be as many handles as `ShapedType::kDynamicSize` values in the +`static_sizes` attribute. A static size of `0` indicates that the dimension +should not be tiled. No loop will be generated for such dimensions. If all +tile sizes are `0`, this transform is effectively a no-op. + +This op returns handles to the tiled op (in the generated loop nest) and the +generated loops. The number of loops is the number of tile sizes that are +statically known to be non-zero. + +#### Return modes + +On success, the resulting handles are associated with co-indexed lists of +tiled operations and loops around them. + +This operation only supports Linalg ops and produces a silenceable failure +if the input contains any non-Linalg ops. The ops preceding it in the list +associated with the `target` handle will have been tiled. + +This operation produces a silenceable failure if the `dynamic_sizes` handles +are associated with lists of payload operations of a size different than +that of the list associated with the `target` handle. + +If the internal implementation of tiling for any of the operations fails, +produces a definite failure. +""" +function structured_tile(target::Value, dynamic_sizes::Vector{Value}; tiled_linalg_op::MLIRType, loops::Vector{MLIRType}, static_sizes=nothing, interchange=nothing, location=Location()) + results = MLIRType[tiled_linalg_op, loops..., ] + operands = Value[target, dynamic_sizes..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_sizes) && push!(attributes, namedattribute("static_sizes", static_sizes)) + !isnothing(interchange) && push!(attributes, namedattribute("interchange", interchange)) + + create_operation( + "transform.structured.tile", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_tile_to_foreach_thread_op` + +Tile a TilingInterface op to a tiled `scf.foreach_thread`. Tiling is +applied by either specifying `num_threads` or `tile_size`. If `num_threads` +is specified, then the tile size for each dimension `i` is calculated +dynamically via `ceilDiv(dimSize[i], num_threads[i])`. +If non-empty, the `thread_dim_mapping` is added as an attribute to the +resulting `scf.foreach_thread`. +Zero tile sizes indicate that the dimension is not tiled and can be +thought of as tiling by the full size of data. +It is the user\'s responsibility to ensure that `num_threads/tile_sizes` is +a valid tiling specification (i.e. that only tiles parallel dimensions, +e.g. in the Linalg case). + +#### Return modes + +This operation ignores ops that do not implement the TilingInterface and +drops them in the return. + +If all the operations referred to by the `target` PDLOperation tile +successfully, the transform succeeds. +Otherwise the transform silently fails. + +The two returned handles point to only the subset of successfully produced +tiled operations, which can all be empty. + +These two returned handles point to: + - the new scf.foreach_thread op, + - the tiled op that implements TilingInterface. + +### Example using `num_threads` + +``` +%0 = pdl_match @match_matmul in %arg1 +%3:2 = transform.structured.tile_to_foreach_thread_op %0 num_threads [10, 20] +``` + +### Example using `tile_sizes` + +``` +%0 = pdl_match @match_matmul in %arg1 +%3:2 = transform.structured.tile_to_foreach_thread_op %0 tile_sizes [10, 20, 0] +``` +""" +function structured_tile_to_foreach_thread_op(target::Value; foreach_thread_op::MLIRType, tiled_op::MLIRType, num_threads=nothing, tile_sizes=nothing, thread_dim_mapping=nothing, location=Location()) + results = MLIRType[foreach_thread_op, tiled_op, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(num_threads) && push!(attributes, namedattribute("num_threads", num_threads)) + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + !isnothing(thread_dim_mapping) && push!(attributes, namedattribute("thread_dim_mapping", thread_dim_mapping)) + + create_operation( + "transform.structured.tile_to_foreach_thread_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_vectorize` + +Indicates that the given `target` op all the ops it contains should be +vectorized with the configuration specified by the attributes of this op. +This vectorization only handles structured ops that operate on shaped types +and does not vectorize loops or straight-line. Internally, it applies a +set of rewrite patterns, some of which enable vectorization and some of +which clean up the results. Therefore, it can only be applied to an op with +the \"isolated from above property\". If finer granularity is required, it can +be achieved by outlining the target part of the payload IR into, e.g., a +function, performing the transformation, and inlining it back. This +transformation only fails if the entire pattern rewriting failed, i.e., it +does **not** fail when no ops were vectorized. + +Note that this transformation is invalidating the handles to any payload IR +operation that is contained inside the vectorization target. + +#### Return modes: + +This operation produces `definiteFailure` if vectorization fails for any +reason. +The operation always returns the handle to the target op that is expected +to be isolated from above. +""" +function structured_vectorize(target::Value; transformed::MLIRType, vectorize_padding=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(vectorize_padding) && push!(attributes, namedattribute("vectorize_padding", vectorize_padding)) + + create_operation( + "transform.structured.vectorize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`loop_get_parent_for` + +Produces a handle to the n-th (default 1) parent `scf.for` loop for each +Payload IR operation associated with the operand. Fails if such a loop +cannot be found. The list of operations associated with the handle contains +parent operations in the same order as the list associated with the operand, +except for operations that are parents to more than one input which are only +present once. +""" +function loop_get_parent_for(target::Value; parent::MLIRType, num_loops=nothing, location=Location()) + results = MLIRType[parent, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(num_loops) && push!(attributes, namedattribute("num_loops", num_loops)) + + create_operation( + "transform.loop.get_parent_for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`loop_outline` + +Moves the loop into a separate function with the specified name and +replaces the loop in the Payload IR with a call to that function. Takes +care of forwarding values that are used in the loop as function arguments. +If the operand is associated with more than one loop, each loop will be +outlined into a separate function. The provided name is used as a _base_ +for forming actual function names following SymbolTable auto-renaming +scheme to avoid duplicate symbols. Expects that all ops in the Payload IR +have a SymbolTable ancestor (typically true because of the top-level +module). Returns the handle to the list of outlined functions in the same +order as the operand handle. +""" +function loop_outline(target::Value; transformed::MLIRType, func_name, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("func_name", func_name), ] + + create_operation( + "transform.loop.outline", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`loop_peel` + +Updates the given loop so that its step evenly divides its range and puts +the remaining iteration into a separate loop or a conditional. + +In the absence of sufficient static information, this op may peel a loop, +even if the step always divides the range evenly at runtime. + +#### Return modes + +This operation ignores non-scf::ForOp ops and drops them in the return. + +This operation always succeeds and returns the scf::ForOp with the +postcondition: \"the loop trip count is divisible by the step\". +This operation may return the same unmodified loop handle when peeling did +not modify the IR (i.e. the loop trip count was already divisible). + +Note that even though the Payload IR modification may be performed +in-place, this operation consumes the operand handle and produces a new +one. + +TODO: Return both the peeled loop and the remainder loop. +""" +function loop_peel(target::Value; transformed::MLIRType, fail_if_already_divisible=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(fail_if_already_divisible) && push!(attributes, namedattribute("fail_if_already_divisible", fail_if_already_divisible)) + + create_operation( + "transform.loop.peel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`loop_pipeline` + +Transforms the given loops one by one to achieve software pipelining for +each of them. That is, performs some amount of reads from memory before the +loop rather than inside the loop, the same amount of writes into memory +after the loop, and updates each iteration to read the data for a following +iteration rather than the current one. + +The amount is specified by the attributes. + +The values read and about to be stored are transferred as loop iteration +arguments. Currently supports memref and vector transfer operations as +memory reads/writes. + +#### Return modes + +This operation ignores non-scf::For ops and drops them in the return. +If all the operations referred to by the `target` PDLOperation pipeline +properly, the transform succeeds. Otherwise the transform silently fails. +The return handle points to only the subset of successfully produced +pipelined loops, which can be empty. +""" +function loop_pipeline(target::Value; transformed::MLIRType, iteration_interval=nothing, read_latency=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(iteration_interval) && push!(attributes, namedattribute("iteration_interval", iteration_interval)) + !isnothing(read_latency) && push!(attributes, namedattribute("read_latency", read_latency)) + + create_operation( + "transform.loop.pipeline", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`loop_unroll` + +Unrolls each loop associated with the given handle to have up to the given +number of loop body copies per iteration. If the unroll factor is larger +than the loop trip count, the latter is used as the unroll factor instead. + +#### Return modes + +This operation ignores non-scf::For ops and drops them in the return. +If all the operations referred to by the `target` PDLOperation unroll +properly, the transform succeeds. Otherwise the transform silently fails. + +Does not return handles as the operation may result in the loop being +removed after a full unrolling. +""" +function loop_unroll(target::Value; factor, location=Location()) + results = MLIRType[] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("factor", factor), ] + + create_operation( + "transform.loop.unroll", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + end # transform diff --git a/src/Dialects/15/Vector.jl b/src/Dialects/15/Vector.jl index 98a84c87..b7541a26 100644 --- a/src/Dialects/15/Vector.jl +++ b/src/Dialects/15/Vector.jl @@ -25,7 +25,7 @@ function vscale(; res=nothing::Union{Nothing, MLIRType}, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "vector.vscale", location; @@ -335,7 +335,7 @@ function contract(lhs::Value, rhs::Value, acc::Value, masks::Vector{Value}; resu owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] - (kind != nothing) && push!(attributes, namedattribute("kind", kind)) + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) create_operation( "vector.contract", location; @@ -464,7 +464,7 @@ function extractelement(vector::Value, position=nothing::Union{Nothing, Value}; owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (position != nothing) && push!(operands, position) + !isnothing(position) && push!(operands, position) create_operation( "vector.extractelement", location; @@ -552,7 +552,7 @@ function extract(vector::Value; result_0=nothing::Union{Nothing, MLIRType}, posi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("position", position), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "vector.extract", location; @@ -626,7 +626,7 @@ function fma(lhs::Value, rhs::Value, acc::Value; result=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "vector.fma", location; @@ -749,8 +749,8 @@ function insertelement(source::Value, dest::Value, position=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (position != nothing) && push!(operands, position) - (result != nothing) && push!(results, result) + !isnothing(position) && push!(operands, position) + !isnothing(result) && push!(results, result) create_operation( "vector.insertelement", location; @@ -812,7 +812,7 @@ function insert_map(vector::Value, dest::Value, ids::Vector{Value}; result=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "vector.insert_map", location; @@ -842,7 +842,7 @@ function insert(source::Value, dest::Value; res=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("position", position), ] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "vector.insert", location; @@ -880,7 +880,7 @@ function insert_strided_slice(source::Value, dest::Value; res=nothing::Union{Not owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("offsets", offsets), namedattribute("strides", strides), ] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "vector.insert_strided_slice", location; @@ -1112,7 +1112,7 @@ function multi_reduction(source::Value, acc::Value; dest=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dims", reduction_dims), ] - (dest != nothing) && push!(results, dest) + !isnothing(dest) && push!(results, dest) create_operation( "vector.multi_reduction", location; @@ -1178,7 +1178,7 @@ function outerproduct(lhs::Value, rhs::Value, acc::Vector{Value}; result_0::MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (kind != nothing) && push!(attributes, namedattribute("kind", kind)) + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) create_operation( "vector.outerproduct", location; @@ -1255,7 +1255,7 @@ function reduction(vector::Value, acc=nothing::Union{Nothing, Value}; dest::MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kind", kind), ] - (acc != nothing) && push!(operands, acc) + !isnothing(acc) && push!(operands, acc) create_operation( "vector.reduction", location; @@ -1388,8 +1388,8 @@ function scan(source::Value, initial_value::Value; dest=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dim", reduction_dim), namedattribute("inclusive", inclusive), ] - (dest != nothing) && push!(results, dest) - (accumulated_value != nothing) && push!(results, accumulated_value) + !isnothing(dest) && push!(results, dest) + !isnothing(accumulated_value) && push!(results, accumulated_value) create_operation( "vector.scan", location; @@ -1534,7 +1534,7 @@ function shuffle(v1::Value, v2::Value; vector=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("mask", mask), ] - (vector != nothing) && push!(results, vector) + !isnothing(vector) && push!(results, vector) create_operation( "vector.shuffle", location; @@ -1805,9 +1805,9 @@ function transfer_read(source::Value, indices::Vector{Value}, padding::Value, ma owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] - (mask != nothing) && push!(operands, mask) + !isnothing(mask) && push!(operands, mask) push!(attributes, operandsegmentsizes([1, length(indices), 1, (mask==nothing) ? 0 : 1])) - (in_bounds != nothing) && push!(attributes, namedattribute("in_bounds", in_bounds)) + !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) create_operation( "vector.transfer_read", location; @@ -1903,10 +1903,10 @@ function transfer_write(vector::Value, source::Value, indices::Vector{Value}, ma owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] - (mask != nothing) && push!(operands, mask) + !isnothing(mask) && push!(operands, mask) push!(attributes, operandsegmentsizes([1, 1, length(indices), (mask==nothing) ? 0 : 1])) - (result != nothing) && push!(results, result) - (in_bounds != nothing) && push!(attributes, namedattribute("in_bounds", in_bounds)) + !isnothing(result) && push!(results, result) + !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) create_operation( "vector.transfer_write", location; diff --git a/src/Dialects/15/X86Vector.jl b/src/Dialects/15/X86Vector.jl index 4f7e8fee..ea19a6f9 100644 --- a/src/Dialects/15/X86Vector.jl +++ b/src/Dialects/15/X86Vector.jl @@ -15,7 +15,7 @@ function avx_intr_dp_ps_256(a::Value, b::Value, c::Value; res=nothing::Union{Not owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx.intr.dp.ps.256", location; @@ -49,7 +49,7 @@ function avx_intr_dot(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx.intr.dot", location; @@ -69,7 +69,7 @@ function avx512_intr_mask_compress(a::Value, src::Value, k::Value; res=nothing:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.compress", location; @@ -100,9 +100,9 @@ function avx512_mask_compress(k::Value, a::Value, src=nothing::Union{Nothing, Va owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (src != nothing) && push!(operands, src) - (dst != nothing) && push!(results, dst) - (constant_src != nothing) && push!(attributes, namedattribute("constant_src", constant_src)) + !isnothing(src) && push!(operands, src) + !isnothing(dst) && push!(results, dst) + !isnothing(constant_src) && push!(attributes, namedattribute("constant_src", constant_src)) create_operation( "x86vector.avx512.mask.compress", location; @@ -132,7 +132,7 @@ function avx512_mask_rndscale(src::Value, k::Value, a::Value, imm::Value, roundi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (dst != nothing) && push!(results, dst) + !isnothing(dst) && push!(results, dst) create_operation( "x86vector.avx512.mask.rndscale", location; @@ -152,7 +152,7 @@ function avx512_intr_mask_rndscale_pd_512(src::Value, k::Value, a::Value, imm::V owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.rndscale.pd.512", location; @@ -172,7 +172,7 @@ function avx512_intr_mask_rndscale_ps_512(src::Value, k::Value, a::Value, imm::V owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.rndscale.ps.512", location; @@ -202,7 +202,7 @@ function avx512_mask_scalef(src::Value, a::Value, b::Value, k::Value, rounding:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (dst != nothing) && push!(results, dst) + !isnothing(dst) && push!(results, dst) create_operation( "x86vector.avx512.mask.scalef", location; @@ -222,7 +222,7 @@ function avx512_intr_mask_scalef_pd_512(src::Value, a::Value, b::Value, k::Value owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.scalef.pd.512", location; @@ -242,7 +242,7 @@ function avx512_intr_mask_scalef_ps_512(src::Value, a::Value, b::Value, k::Value owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.scalef.ps.512", location; @@ -262,7 +262,7 @@ function avx_intr_rsqrt_ps_256(a::Value; res=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx.intr.rsqrt.ps.256", location; @@ -282,7 +282,7 @@ function avx_rsqrt(a::Value; b=nothing::Union{Nothing, MLIRType}, location=Locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (b != nothing) && push!(results, b) + !isnothing(b) && push!(results, b) create_operation( "x86vector.avx.rsqrt", location; diff --git a/src/Dialects/16/AMDGPU.jl b/src/Dialects/16/AMDGPU.jl index f33316f4..4e3afa7f 100644 --- a/src/Dialects/16/AMDGPU.jl +++ b/src/Dialects/16/AMDGPU.jl @@ -70,13 +70,13 @@ function mfma(sourceA::Value, sourceB::Value, destC::Value; destD::MLIRType, m, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("m", m), namedattribute("n", n), namedattribute("k", k), namedattribute("blocks", blocks), ] - (cbsz != nothing) && push!(attributes, namedattribute("cbsz", cbsz)) - (abid != nothing) && push!(attributes, namedattribute("abid", abid)) - (blgp != nothing) && push!(attributes, namedattribute("blgp", blgp)) - (reducePrecision != nothing) && push!(attributes, namedattribute("reducePrecision", reducePrecision)) - (negateA != nothing) && push!(attributes, namedattribute("negateA", negateA)) - (negateB != nothing) && push!(attributes, namedattribute("negateB", negateB)) - (negateC != nothing) && push!(attributes, namedattribute("negateC", negateC)) + !isnothing(cbsz) && push!(attributes, namedattribute("cbsz", cbsz)) + !isnothing(abid) && push!(attributes, namedattribute("abid", abid)) + !isnothing(blgp) && push!(attributes, namedattribute("blgp", blgp)) + !isnothing(reducePrecision) && push!(attributes, namedattribute("reducePrecision", reducePrecision)) + !isnothing(negateA) && push!(attributes, namedattribute("negateA", negateA)) + !isnothing(negateB) && push!(attributes, namedattribute("negateB", negateB)) + !isnothing(negateC) && push!(attributes, namedattribute("negateC", negateC)) create_operation( "amdgpu.mfma", location; @@ -112,10 +112,10 @@ function raw_buffer_atomic_fadd(value::Value, memref::Value, indices::Vector{Val owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (sgprOffset != nothing) && push!(operands, sgprOffset) + !isnothing(sgprOffset) && push!(operands, sgprOffset) push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) - (boundsCheck != nothing) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) - (indexOffset != nothing) && push!(attributes, namedattribute("indexOffset", indexOffset)) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) create_operation( "amdgpu.raw_buffer_atomic_fadd", location; @@ -163,10 +163,10 @@ function raw_buffer_load(memref::Value, indices::Vector{Value}, sgprOffset=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (sgprOffset != nothing) && push!(operands, sgprOffset) + !isnothing(sgprOffset) && push!(operands, sgprOffset) push!(attributes, operandsegmentsizes([1, length(indices), (sgprOffset==nothing) ? 0 : 1])) - (boundsCheck != nothing) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) - (indexOffset != nothing) && push!(attributes, namedattribute("indexOffset", indexOffset)) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) create_operation( "amdgpu.raw_buffer_load", location; @@ -202,10 +202,10 @@ function raw_buffer_store(value::Value, memref::Value, indices::Vector{Value}, s owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (sgprOffset != nothing) && push!(operands, sgprOffset) + !isnothing(sgprOffset) && push!(operands, sgprOffset) push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) - (boundsCheck != nothing) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) - (indexOffset != nothing) && push!(attributes, namedattribute("indexOffset", indexOffset)) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) create_operation( "amdgpu.raw_buffer_store", location; diff --git a/src/Dialects/16/AMX.jl b/src/Dialects/16/AMX.jl index ef35e3f3..c7d28870 100644 --- a/src/Dialects/16/AMX.jl +++ b/src/Dialects/16/AMX.jl @@ -240,8 +240,8 @@ function tile_muli(lhs::Value, rhs::Value, acc::Value; res::MLIRType, isZextLhs= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (isZextLhs != nothing) && push!(attributes, namedattribute("isZextLhs", isZextLhs)) - (isZextRhs != nothing) && push!(attributes, namedattribute("isZextRhs", isZextRhs)) + !isnothing(isZextLhs) && push!(attributes, namedattribute("isZextLhs", isZextLhs)) + !isnothing(isZextRhs) && push!(attributes, namedattribute("isZextRhs", isZextRhs)) create_operation( "amx.tile_muli", location; diff --git a/src/Dialects/16/Arith.jl b/src/Dialects/16/Arith.jl index 24a1354f..e14e8e58 100644 --- a/src/Dialects/16/Arith.jl +++ b/src/Dialects/16/Arith.jl @@ -35,8 +35,8 @@ function addf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "arith.addf", location; @@ -73,7 +73,7 @@ function addi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.addi", location; @@ -146,7 +146,7 @@ function andi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.andi", location; @@ -210,7 +210,7 @@ function ceildivsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.ceildivsi", location; @@ -243,7 +243,7 @@ function ceildivui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.ceildivui", location; @@ -286,7 +286,7 @@ function cmpf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("predicate", predicate), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.cmpf", location; @@ -367,7 +367,7 @@ function cmpi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("predicate", predicate), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.cmpi", location; @@ -400,7 +400,7 @@ function constant(; result=nothing::Union{Nothing, MLIRType}, value, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("value", value), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.constant", location; @@ -420,8 +420,8 @@ function divf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "arith.divf", location; @@ -459,7 +459,7 @@ function divsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.divsi", location; @@ -498,7 +498,7 @@ function divui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.divui", location; @@ -665,7 +665,7 @@ function floordivsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.floordivsi", location; @@ -746,8 +746,8 @@ function maxf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "arith.maxf", location; @@ -767,7 +767,7 @@ function maxsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.maxsi", location; @@ -787,7 +787,7 @@ function maxui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.maxui", location; @@ -822,8 +822,8 @@ function minf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "arith.minf", location; @@ -843,7 +843,7 @@ function minsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.minsi", location; @@ -863,7 +863,7 @@ function minui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.minui", location; @@ -903,8 +903,8 @@ function mulf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "arith.mulf", location; @@ -924,7 +924,7 @@ function muli(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.muli", location; @@ -961,8 +961,8 @@ function mulsi_extended(lhs::Value, rhs::Value; low=nothing::Union{Nothing, MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (low != nothing) && push!(results, low) - (high != nothing) && push!(results, high) + !isnothing(low) && push!(results, low) + !isnothing(high) && push!(results, high) create_operation( "arith.mulsi_extended", location; @@ -999,8 +999,8 @@ function mului_extended(lhs::Value, rhs::Value; low=nothing::Union{Nothing, MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (low != nothing) && push!(results, low) - (high != nothing) && push!(results, high) + !isnothing(low) && push!(results, low) + !isnothing(high) && push!(results, high) create_operation( "arith.mului_extended", location; @@ -1037,8 +1037,8 @@ function negf(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "arith.negf", location; @@ -1075,7 +1075,7 @@ function ori(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.ori", location; @@ -1095,8 +1095,8 @@ function remf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "arith.remf", location; @@ -1134,7 +1134,7 @@ function remsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.remsi", location; @@ -1172,7 +1172,7 @@ function remui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.remui", location; @@ -1225,7 +1225,7 @@ function shli(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.shli", location; @@ -1259,7 +1259,7 @@ function shrsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.shrsi", location; @@ -1290,7 +1290,7 @@ function shrui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.shrui", location; @@ -1330,8 +1330,8 @@ function subf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "arith.subf", location; @@ -1351,7 +1351,7 @@ function subi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.subi", location; @@ -1467,7 +1467,7 @@ function xori(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.xori", location; @@ -1513,7 +1513,7 @@ function select(condition::Value, true_value::Value, false_value::Value; result= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "arith.select", location; diff --git a/src/Dialects/16/ArmNeon.jl b/src/Dialects/16/ArmNeon.jl index 7fafa0f7..d6d30af9 100644 --- a/src/Dialects/16/ArmNeon.jl +++ b/src/Dialects/16/ArmNeon.jl @@ -32,7 +32,7 @@ function intr_smull(a::Value, b::Value; res::MLIRType, location=Location()) end """ -`2d_sdot` +`_2d_sdot` The two input vectors `b` and `c` have a 2D shape, consisting of either 2 or 4 rows, each row having length 4. This operation computes the pair-wise @@ -43,20 +43,20 @@ corresponding entry of `a`: res[i] := a[i] + dot_product(b[i, ...], c[i, ...]) ``` """ -# function 2d_sdot(a::Value, b::Value, c::Value; res::MLIRType, location=Location()) -# results = MLIRType[res, ] -# operands = Value[a, b, c, ] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[] +function _2d_sdot(a::Value, b::Value, c::Value; res::MLIRType, location=Location()) + results = MLIRType[res, ] + operands = Value[a, b, c, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] -# create_operation( -# "arm_neon.2d.sdot", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "arm_neon.2d.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `intr_sdot` diff --git a/src/Dialects/16/Async.jl b/src/Dialects/16/Async.jl index f04ac719..6930ec5a 100644 --- a/src/Dialects/16/Async.jl +++ b/src/Dialects/16/Async.jl @@ -26,7 +26,7 @@ function add_to_group(operand::Value, group::Value; rank=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (rank != nothing) && push!(results, rank) + !isnothing(rank) && push!(results, rank) create_operation( "async.add_to_group", location; @@ -93,7 +93,7 @@ function await(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.await", location; @@ -144,7 +144,7 @@ function coro_begin(id::Value; handle=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (handle != nothing) && push!(results, handle) + !isnothing(handle) && push!(results, handle) create_operation( "async.coro.begin", location; @@ -208,7 +208,7 @@ function coro_id(; id=nothing::Union{Nothing, MLIRType}, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (id != nothing) && push!(results, id) + !isnothing(id) && push!(results, id) create_operation( "async.coro.id", location; @@ -229,7 +229,7 @@ function coro_save(handle::Value; state=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (state != nothing) && push!(results, state) + !isnothing(state) && push!(results, state) create_operation( "async.coro.save", location; @@ -289,7 +289,7 @@ function create_group(size::Value; result=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.create_group", location; @@ -393,9 +393,9 @@ function func(; sym_name, function_type, sym_visibility=nothing, arg_attrs=nothi owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("function_type", function_type), ] - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) - (arg_attrs != nothing) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) - (res_attrs != nothing) && push!(attributes, namedattribute("res_attrs", res_attrs)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(arg_attrs) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) + !isnothing(res_attrs) && push!(attributes, namedattribute("res_attrs", res_attrs)) create_operation( "async.func", location; @@ -466,7 +466,7 @@ function runtime_add_to_group(operand::Value, group::Value; rank=nothing::Union{ owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (rank != nothing) && push!(results, rank) + !isnothing(rank) && push!(results, rank) create_operation( "async.runtime.add_to_group", location; @@ -531,7 +531,7 @@ function runtime_create_group(size::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.runtime.create_group", location; @@ -597,7 +597,7 @@ function runtime_is_error(operand::Value; is_error=nothing::Union{Nothing, MLIRT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (is_error != nothing) && push!(results, is_error) + !isnothing(is_error) && push!(results, is_error) create_operation( "async.runtime.is_error", location; @@ -619,7 +619,7 @@ function runtime_load(storage::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.runtime.load", location; @@ -641,7 +641,7 @@ function runtime_num_worker_threads(; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "async.runtime.num_worker_threads", location; diff --git a/src/Dialects/16/Bufferization.jl b/src/Dialects/16/Bufferization.jl index 61236116..a28c12e5 100644 --- a/src/Dialects/16/Bufferization.jl +++ b/src/Dialects/16/Bufferization.jl @@ -62,10 +62,10 @@ function alloc_tensor(dynamic_sizes::Vector{Value}, copy=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (copy != nothing) && push!(operands, copy) - (size_hint != nothing) && push!(operands, size_hint) + !isnothing(copy) && push!(operands, copy) + !isnothing(size_hint) && push!(operands, size_hint) push!(attributes, operandsegmentsizes([length(dynamic_sizes), (copy==nothing) ? 0 : 1(size_hint==nothing) ? 0 : 1])) - (memory_space != nothing) && push!(attributes, namedattribute("memory_space", memory_space)) + !isnothing(memory_space) && push!(attributes, namedattribute("memory_space", memory_space)) create_operation( "bufferization.alloc_tensor", location; @@ -206,7 +206,7 @@ function to_tensor(memref::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "bufferization.to_tensor", location; diff --git a/src/Dialects/16/Builtin.jl b/src/Dialects/16/Builtin.jl index 6560185b..ef7076e0 100644 --- a/src/Dialects/16/Builtin.jl +++ b/src/Dialects/16/Builtin.jl @@ -30,8 +30,8 @@ function module_(; sym_name=nothing, sym_visibility=nothing, bodyRegion::Region, owned_regions = Region[bodyRegion, ] successors = Block[] attributes = NamedAttribute[] - (sym_name != nothing) && push!(attributes, namedattribute("sym_name", sym_name)) - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "builtin.module", location; diff --git a/src/Dialects/16/Complex.jl b/src/Dialects/16/Complex.jl index dbeecd9e..ec9ddac1 100644 --- a/src/Dialects/16/Complex.jl +++ b/src/Dialects/16/Complex.jl @@ -22,7 +22,7 @@ function abs(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.abs", location; @@ -49,7 +49,7 @@ function add(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.add", location; @@ -76,7 +76,7 @@ function angle(complex::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.angle", location; @@ -104,7 +104,7 @@ function atan2(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.atan2", location; @@ -132,7 +132,7 @@ function conj(complex::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.conj", location; @@ -187,7 +187,7 @@ function cos(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.cos", location; @@ -240,7 +240,7 @@ function div(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.div", location; @@ -267,7 +267,7 @@ function eq(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.eq", location; @@ -296,7 +296,7 @@ function exp(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.exp", location; @@ -329,7 +329,7 @@ function expm1(complex::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.expm1", location; @@ -356,7 +356,7 @@ function im(complex::Value; imaginary=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (imaginary != nothing) && push!(results, imaginary) + !isnothing(imaginary) && push!(results, imaginary) create_operation( "complex.im", location; @@ -386,7 +386,7 @@ function log1p(complex::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.log1p", location; @@ -415,7 +415,7 @@ function log(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.log", location; @@ -440,7 +440,7 @@ function mul(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.mul", location; @@ -467,7 +467,7 @@ function neg(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.neg", location; @@ -495,7 +495,7 @@ function neq(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.neq", location; @@ -523,7 +523,7 @@ function pow(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.pow", location; @@ -550,7 +550,7 @@ function re(complex::Value; real=nothing::Union{Nothing, MLIRType}, location=Loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (real != nothing) && push!(results, real) + !isnothing(real) && push!(results, real) create_operation( "complex.re", location; @@ -577,7 +577,7 @@ function rsqrt(complex::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.rsqrt", location; @@ -605,7 +605,7 @@ function sign(complex::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.sign", location; @@ -633,7 +633,7 @@ function sin(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.sin", location; @@ -660,7 +660,7 @@ function sqrt(complex::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.sqrt", location; @@ -687,7 +687,7 @@ function sub(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.sub", location; @@ -715,7 +715,7 @@ function tan(complex::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.tan", location; @@ -743,7 +743,7 @@ function tanh(complex::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "complex.tanh", location; diff --git a/src/Dialects/16/ControlFlow.jl b/src/Dialects/16/ControlFlow.jl index 183ffebd..3b3cc9a2 100644 --- a/src/Dialects/16/ControlFlow.jl +++ b/src/Dialects/16/ControlFlow.jl @@ -136,7 +136,7 @@ function switch(flag::Value, defaultOperands::Vector{Value}, caseOperands::Vecto successors = Block[defaultDestination, caseDestinations..., ] attributes = NamedAttribute[namedattribute("case_operand_segments", case_operand_segments), ] push!(attributes, operandsegmentsizes([1, length(defaultOperands), length(caseOperands), ])) - (case_values != nothing) && push!(attributes, namedattribute("case_values", case_values)) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) create_operation( "cf.switch", location; diff --git a/src/Dialects/16/EmitC.jl b/src/Dialects/16/EmitC.jl index 4a4d2ee5..1aca33da 100644 --- a/src/Dialects/16/EmitC.jl +++ b/src/Dialects/16/EmitC.jl @@ -63,8 +63,8 @@ function call(operands::Vector{Value}; result_0::Vector{MLIRType}, callee, args= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("callee", callee), ] - (args != nothing) && push!(attributes, namedattribute("args", args)) - (template_args != nothing) && push!(attributes, namedattribute("template_args", template_args)) + !isnothing(args) && push!(attributes, namedattribute("args", args)) + !isnothing(template_args) && push!(attributes, namedattribute("template_args", template_args)) create_operation( "emitc.call", location; @@ -172,7 +172,7 @@ function include(; include, is_standard_include=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("include", include), ] - (is_standard_include != nothing) && push!(attributes, namedattribute("is_standard_include", is_standard_include)) + !isnothing(is_standard_include) && push!(attributes, namedattribute("is_standard_include", is_standard_include)) create_operation( "emitc.include", location; diff --git a/src/Dialects/16/Func.jl b/src/Dialects/16/Func.jl index 26a2c59a..76eb68c6 100644 --- a/src/Dialects/16/Func.jl +++ b/src/Dialects/16/Func.jl @@ -147,9 +147,9 @@ function func_(; sym_name, function_type, sym_visibility=nothing, arg_attrs=noth owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("function_type", function_type), ] - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) - (arg_attrs != nothing) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) - (res_attrs != nothing) && push!(attributes, namedattribute("res_attrs", res_attrs)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(arg_attrs) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) + !isnothing(res_attrs) && push!(attributes, namedattribute("res_attrs", res_attrs)) create_operation( "func.func", location; diff --git a/src/Dialects/16/GPU.jl b/src/Dialects/16/GPU.jl index 87719577..a9d2b8be 100644 --- a/src/Dialects/16/GPU.jl +++ b/src/Dialects/16/GPU.jl @@ -36,9 +36,9 @@ function all_reduce(value::Value; result_0=nothing::Union{Nothing, MLIRType}, op owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (result_0 != nothing) && push!(results, result_0) - (op != nothing) && push!(attributes, namedattribute("op", op)) - (uniform != nothing) && push!(attributes, namedattribute("uniform", uniform)) + !isnothing(result_0) && push!(results, result_0) + !isnothing(op) && push!(attributes, namedattribute("op", op)) + !isnothing(uniform) && push!(attributes, namedattribute("uniform", uniform)) create_operation( "gpu.all_reduce", location; @@ -77,8 +77,8 @@ function alloc(asyncDependencies::Vector{Value}, dynamicSizes::Vector{Value}, sy successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(asyncDependencies), length(dynamicSizes), length(symbolOperands), ])) - (asyncToken != nothing) && push!(results, asyncToken) - (hostShared != nothing) && push!(attributes, namedattribute("hostShared", hostShared)) + !isnothing(asyncToken) && push!(results, asyncToken) + !isnothing(hostShared) && push!(attributes, namedattribute("hostShared", hostShared)) create_operation( "gpu.alloc", location; @@ -140,7 +140,7 @@ function block_dim(; result_0=nothing::Union{Nothing, MLIRType}, dimension, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.block_dim", location; @@ -168,7 +168,7 @@ function block_id(; result_0=nothing::Union{Nothing, MLIRType}, dimension, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.block_id", location; @@ -204,7 +204,7 @@ function dealloc(asyncDependencies::Vector{Value}, memref::Value; asyncToken=not owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.dealloc", location; @@ -287,8 +287,8 @@ function func(; function_type, arg_attrs=nothing, res_attrs=nothing, body::Regio owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("function_type", function_type), ] - (arg_attrs != nothing) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) - (res_attrs != nothing) && push!(attributes, namedattribute("res_attrs", res_attrs)) + !isnothing(arg_attrs) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) + !isnothing(res_attrs) && push!(attributes, namedattribute("res_attrs", res_attrs)) create_operation( "gpu.func", location; @@ -358,7 +358,7 @@ function global_id(; result_0=nothing::Union{Nothing, MLIRType}, dimension, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.global_id", location; @@ -386,7 +386,7 @@ function grid_dim(; result_0=nothing::Union{Nothing, MLIRType}, dimension, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.grid_dim", location; @@ -439,7 +439,7 @@ function lane_id(; result=nothing::Union{Nothing, MLIRType}, location=Location() owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "gpu.lane_id", location; @@ -536,9 +536,9 @@ function launch_func(asyncDependencies::Vector{Value}, gridSizeX::Value, gridSiz owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kernel", kernel), ] - (dynamicSharedMemorySize != nothing) && push!(operands, dynamicSharedMemorySize) + !isnothing(dynamicSharedMemorySize) && push!(operands, dynamicSharedMemorySize) push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1length(kernelOperands), ])) - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.launch_func", location; @@ -628,9 +628,9 @@ function launch(asyncDependencies::Vector{Value}, gridSizeX::Value, gridSizeY::V owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (dynamicSharedMemorySize != nothing) && push!(operands, dynamicSharedMemorySize) + !isnothing(dynamicSharedMemorySize) && push!(operands, dynamicSharedMemorySize) push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1])) - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.launch", location; @@ -664,7 +664,7 @@ function memcpy(asyncDependencies::Vector{Value}, dst::Value, src::Value; asyncT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.memcpy", location; @@ -698,7 +698,7 @@ function memset(asyncDependencies::Vector{Value}, dst::Value, value::Value; asyn owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.memset", location; @@ -745,7 +745,7 @@ function num_subgroups(; result=nothing::Union{Nothing, MLIRType}, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "gpu.num_subgroups", location; @@ -850,8 +850,8 @@ function shuffle(value::Value, offset::Value, width::Value; shuffleResult=nothin owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("mode", mode), ] - (shuffleResult != nothing) && push!(results, shuffleResult) - (valid != nothing) && push!(results, valid) + !isnothing(shuffleResult) && push!(results, shuffleResult) + !isnothing(valid) && push!(results, valid) create_operation( "gpu.shuffle", location; @@ -879,7 +879,7 @@ function subgroup_id(; result=nothing::Union{Nothing, MLIRType}, location=Locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "gpu.subgroup_id", location; @@ -922,9 +922,9 @@ function subgroup_mma_compute(opA::Value, opB::Value, opC::Value; res=nothing::U owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (a_transpose != nothing) && push!(attributes, namedattribute("a_transpose", a_transpose)) - (b_transpose != nothing) && push!(attributes, namedattribute("b_transpose", b_transpose)) + !isnothing(res) && push!(results, res) + !isnothing(a_transpose) && push!(attributes, namedattribute("a_transpose", a_transpose)) + !isnothing(b_transpose) && push!(attributes, namedattribute("b_transpose", b_transpose)) create_operation( "gpu.subgroup_mma_compute", location; @@ -1037,7 +1037,7 @@ function subgroup_mma_load_matrix(srcMemref::Value, indices::Vector{Value}; res: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] - (transpose != nothing) && push!(attributes, namedattribute("transpose", transpose)) + !isnothing(transpose) && push!(attributes, namedattribute("transpose", transpose)) create_operation( "gpu.subgroup_mma_load_matrix", location; @@ -1076,7 +1076,7 @@ function subgroup_mma_store_matrix(src::Value, dstMemref::Value, indices::Vector owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] - (transpose != nothing) && push!(attributes, namedattribute("transpose", transpose)) + !isnothing(transpose) && push!(attributes, namedattribute("transpose", transpose)) create_operation( "gpu.subgroup_mma_store_matrix", location; @@ -1107,8 +1107,8 @@ function subgroup_reduce(value::Value; result_0=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("op", op), ] - (result_0 != nothing) && push!(results, result_0) - (uniform != nothing) && push!(attributes, namedattribute("uniform", uniform)) + !isnothing(result_0) && push!(results, result_0) + !isnothing(uniform) && push!(attributes, namedattribute("uniform", uniform)) create_operation( "gpu.subgroup_reduce", location; @@ -1135,7 +1135,7 @@ function subgroup_size(; result=nothing::Union{Nothing, MLIRType}, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "gpu.subgroup_size", location; @@ -1185,7 +1185,7 @@ function thread_id(; result_0=nothing::Union{Nothing, MLIRType}, dimension, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dimension", dimension), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "gpu.thread_id", location; @@ -1234,7 +1234,7 @@ function wait(asyncDependencies::Vector{Value}; asyncToken=nothing::Union{Nothin owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncToken != nothing) && push!(results, asyncToken) + !isnothing(asyncToken) && push!(results, asyncToken) create_operation( "gpu.wait", location; diff --git a/src/Dialects/16/Index.jl b/src/Dialects/16/Index.jl index 62e28202..e27aeb60 100644 --- a/src/Dialects/16/Index.jl +++ b/src/Dialects/16/Index.jl @@ -23,7 +23,7 @@ function add(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.add", location; @@ -52,7 +52,7 @@ function and(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.and", location; @@ -83,7 +83,7 @@ function bool_constant(; result=nothing::Union{Nothing, MLIRType}, value, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("value", value), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.bool.constant", location; @@ -181,7 +181,7 @@ function ceildivs(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.ceildivs", location; @@ -213,7 +213,7 @@ function ceildivu(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.ceildivu", location; @@ -262,7 +262,7 @@ function cmp(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, p owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("pred", pred), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.cmp", location; @@ -290,7 +290,7 @@ function constant(; result=nothing::Union{Nothing, MLIRType}, value, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("value", value), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.constant", location; @@ -322,7 +322,7 @@ function divs(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.divs", location; @@ -354,7 +354,7 @@ function divu(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.divu", location; @@ -386,7 +386,7 @@ function floordivs(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.floordivs", location; @@ -415,7 +415,7 @@ function maxs(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.maxs", location; @@ -445,7 +445,7 @@ function maxu(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.maxu", location; @@ -474,7 +474,7 @@ function mins(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.mins", location; @@ -504,7 +504,7 @@ function minu(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.minu", location; @@ -532,7 +532,7 @@ function mul(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.mul", location; @@ -561,7 +561,7 @@ function or(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.or", location; @@ -590,7 +590,7 @@ function rems(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.rems", location; @@ -620,7 +620,7 @@ function remu(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.remu", location; @@ -651,7 +651,7 @@ function shl(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.shl", location; @@ -682,7 +682,7 @@ function shrs(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.shrs", location; @@ -713,7 +713,7 @@ function shru(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.shru", location; @@ -742,7 +742,7 @@ function sizeof(; result=nothing::Union{Nothing, MLIRType}, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.sizeof", location; @@ -771,7 +771,7 @@ function sub(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.sub", location; @@ -800,7 +800,7 @@ function xor(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "index.xor", location; diff --git a/src/Dialects/16/LLVMIR.jl b/src/Dialects/16/LLVMIR.jl index 03752cdb..121ecfe3 100644 --- a/src/Dialects/16/LLVMIR.jl +++ b/src/Dialects/16/LLVMIR.jl @@ -15,7 +15,7 @@ function ashr(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.ashr", location; @@ -62,7 +62,7 @@ function add(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.add", location; @@ -149,7 +149,7 @@ function alias_scope_domain(; sym_name, description=nothing, location=Location() owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), ] - (description != nothing) && push!(attributes, namedattribute("description", description)) + !isnothing(description) && push!(attributes, namedattribute("description", description)) create_operation( "llvm.alias_scope_domain", location; @@ -197,7 +197,7 @@ function alias_scope(; sym_name, domain, description=nothing, location=Location( owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("domain", domain), ] - (description != nothing) && push!(attributes, namedattribute("description", description)) + !isnothing(description) && push!(attributes, namedattribute("description", description)) create_operation( "llvm.alias_scope", location; @@ -217,8 +217,8 @@ function alloca(arraySize::Value; res::MLIRType, alignment=nothing, elem_type=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (elem_type != nothing) && push!(attributes, namedattribute("elem_type", elem_type)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(elem_type) && push!(attributes, namedattribute("elem_type", elem_type)) create_operation( "llvm.alloca", location; @@ -238,7 +238,7 @@ function and(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.and", location; @@ -358,10 +358,10 @@ function call(operand_0::Vector{Value}; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (callee != nothing) && push!(attributes, namedattribute("callee", callee)) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) - (branch_weights != nothing) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(result) && push!(results, result) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) create_operation( "llvm.call", location; @@ -382,7 +382,7 @@ function cond_br(condition::Value, trueDestOperands::Vector{Value}, falseDestOpe successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands), ])) - (branch_weights != nothing) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) create_operation( "llvm.cond_br", location; @@ -447,7 +447,7 @@ function extractelement(vector::Value, position::Value; res=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.extractelement", location; @@ -486,8 +486,8 @@ function fadd(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fadd", location; @@ -507,8 +507,8 @@ function fcmp(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, pre owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("predicate", predicate), ] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fcmp", location; @@ -528,8 +528,8 @@ function fdiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fdiv", location; @@ -549,8 +549,8 @@ function fmul(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fmul", location; @@ -570,8 +570,8 @@ function fneg(operand::Value; res=nothing::Union{Nothing, MLIRType}, fastmathFla owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fneg", location; @@ -667,8 +667,8 @@ function frem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.frem", location; @@ -688,8 +688,8 @@ function fsub(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) - (fastmathFlags != nothing) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) create_operation( "llvm.fsub", location; @@ -728,7 +728,7 @@ function freeze(val::Value; res=nothing::Union{Nothing, MLIRType}, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.freeze", location; @@ -771,8 +771,8 @@ function getelementptr(base::Value, dynamicIndices::Vector{Value}; res::MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("rawConstantIndices", rawConstantIndices), ] - (elem_type != nothing) && push!(attributes, namedattribute("elem_type", elem_type)) - (inbounds != nothing) && push!(attributes, namedattribute("inbounds", inbounds)) + !isnothing(elem_type) && push!(attributes, namedattribute("elem_type", elem_type)) + !isnothing(inbounds) && push!(attributes, namedattribute("inbounds", inbounds)) create_operation( "llvm.getelementptr", location; @@ -956,14 +956,14 @@ function mlir_global(; global_type, constant=nothing, sym_name, linkage, dso_loc owned_regions = Region[initializer, ] successors = Block[] attributes = NamedAttribute[namedattribute("global_type", global_type), namedattribute("sym_name", sym_name), namedattribute("linkage", linkage), ] - (constant != nothing) && push!(attributes, namedattribute("constant", constant)) - (dso_local != nothing) && push!(attributes, namedattribute("dso_local", dso_local)) - (thread_local_ != nothing) && push!(attributes, namedattribute("thread_local_", thread_local_)) - (value != nothing) && push!(attributes, namedattribute("value", value)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (addr_space != nothing) && push!(attributes, namedattribute("addr_space", addr_space)) - (unnamed_addr != nothing) && push!(attributes, namedattribute("unnamed_addr", unnamed_addr)) - (section != nothing) && push!(attributes, namedattribute("section", section)) + !isnothing(constant) && push!(attributes, namedattribute("constant", constant)) + !isnothing(dso_local) && push!(attributes, namedattribute("dso_local", dso_local)) + !isnothing(thread_local_) && push!(attributes, namedattribute("thread_local_", thread_local_)) + !isnothing(value) && push!(attributes, namedattribute("value", value)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(addr_space) && push!(attributes, namedattribute("addr_space", addr_space)) + !isnothing(unnamed_addr) && push!(attributes, namedattribute("unnamed_addr", unnamed_addr)) + !isnothing(section) && push!(attributes, namedattribute("section", section)) create_operation( "llvm.mlir.global", location; @@ -983,7 +983,7 @@ function icmp(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, pre owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("predicate", predicate), ] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.icmp", location; @@ -1009,11 +1009,11 @@ function inline_asm(operands::Vector{Value}; res=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("asm_string", asm_string), namedattribute("constraints", constraints), ] - (res != nothing) && push!(results, res) - (has_side_effects != nothing) && push!(attributes, namedattribute("has_side_effects", has_side_effects)) - (is_align_stack != nothing) && push!(attributes, namedattribute("is_align_stack", is_align_stack)) - (asm_dialect != nothing) && push!(attributes, namedattribute("asm_dialect", asm_dialect)) - (operand_attrs != nothing) && push!(attributes, namedattribute("operand_attrs", operand_attrs)) + !isnothing(res) && push!(results, res) + !isnothing(has_side_effects) && push!(attributes, namedattribute("has_side_effects", has_side_effects)) + !isnothing(is_align_stack) && push!(attributes, namedattribute("is_align_stack", is_align_stack)) + !isnothing(asm_dialect) && push!(attributes, namedattribute("asm_dialect", asm_dialect)) + !isnothing(operand_attrs) && push!(attributes, namedattribute("operand_attrs", operand_attrs)) create_operation( "llvm.inline_asm", location; @@ -1033,7 +1033,7 @@ function insertelement(vector::Value, value::Value, position::Value; res=nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.insertelement", location; @@ -1053,7 +1053,7 @@ function insertvalue(container::Value, value::Value; res=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("position", position), ] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.insertvalue", location; @@ -1093,8 +1093,8 @@ function invoke(callee_operands::Vector{Value}, normalDestOperands::Vector{Value successors = Block[normalDest, unwindDest, ] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(callee_operands), length(normalDestOperands), length(unwindDestOperands), ])) - (callee != nothing) && push!(attributes, namedattribute("callee", callee)) - (branch_weights != nothing) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) create_operation( "llvm.invoke", location; @@ -1139,16 +1139,16 @@ function func(; sym_name, function_type, linkage=nothing, dso_local=nothing, CCo owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("function_type", function_type), ] - (linkage != nothing) && push!(attributes, namedattribute("linkage", linkage)) - (dso_local != nothing) && push!(attributes, namedattribute("dso_local", dso_local)) - (CConv != nothing) && push!(attributes, namedattribute("CConv", CConv)) - (personality != nothing) && push!(attributes, namedattribute("personality", personality)) - (garbageCollector != nothing) && push!(attributes, namedattribute("garbageCollector", garbageCollector)) - (passthrough != nothing) && push!(attributes, namedattribute("passthrough", passthrough)) - (arg_attrs != nothing) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) - (res_attrs != nothing) && push!(attributes, namedattribute("res_attrs", res_attrs)) - (function_entry_count != nothing) && push!(attributes, namedattribute("function_entry_count", function_entry_count)) - (memory != nothing) && push!(attributes, namedattribute("memory", memory)) + !isnothing(linkage) && push!(attributes, namedattribute("linkage", linkage)) + !isnothing(dso_local) && push!(attributes, namedattribute("dso_local", dso_local)) + !isnothing(CConv) && push!(attributes, namedattribute("CConv", CConv)) + !isnothing(personality) && push!(attributes, namedattribute("personality", personality)) + !isnothing(garbageCollector) && push!(attributes, namedattribute("garbageCollector", garbageCollector)) + !isnothing(passthrough) && push!(attributes, namedattribute("passthrough", passthrough)) + !isnothing(arg_attrs) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) + !isnothing(res_attrs) && push!(attributes, namedattribute("res_attrs", res_attrs)) + !isnothing(function_entry_count) && push!(attributes, namedattribute("function_entry_count", function_entry_count)) + !isnothing(memory) && push!(attributes, namedattribute("memory", memory)) create_operation( "llvm.func", location; @@ -1168,7 +1168,7 @@ function lshr(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.lshr", location; @@ -1188,7 +1188,7 @@ function landingpad(operand_0::Vector{Value}; res::MLIRType, cleanup=nothing, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (cleanup != nothing) && push!(attributes, namedattribute("cleanup", cleanup)) + !isnothing(cleanup) && push!(attributes, namedattribute("cleanup", cleanup)) create_operation( "llvm.landingpad", location; @@ -1208,12 +1208,12 @@ function load(addr::Value; res::MLIRType, access_groups=nothing, alias_scopes=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (access_groups != nothing) && push!(attributes, namedattribute("access_groups", access_groups)) - (alias_scopes != nothing) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) - (noalias_scopes != nothing) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (volatile_ != nothing) && push!(attributes, namedattribute("volatile_", volatile_)) - (nontemporal != nothing) && push!(attributes, namedattribute("nontemporal", nontemporal)) + !isnothing(access_groups) && push!(attributes, namedattribute("access_groups", access_groups)) + !isnothing(alias_scopes) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) + !isnothing(noalias_scopes) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) create_operation( "llvm.load", location; @@ -1259,7 +1259,7 @@ function mul(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.mul", location; @@ -1312,7 +1312,7 @@ function or(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.or", location; @@ -1370,7 +1370,7 @@ function return_(arg=nothing::Union{Nothing, Value}; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (arg != nothing) && push!(operands, arg) + !isnothing(arg) && push!(operands, arg) create_operation( "llvm.return", location; @@ -1390,7 +1390,7 @@ function sdiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.sdiv", location; @@ -1448,7 +1448,7 @@ function srem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.srem", location; @@ -1468,7 +1468,7 @@ function select(condition::Value, trueValue::Value, falseValue::Value; res=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.select", location; @@ -1488,7 +1488,7 @@ function shl(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.shl", location; @@ -1527,12 +1527,12 @@ function store(value::Value, addr::Value; access_groups=nothing, alias_scopes=no owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (access_groups != nothing) && push!(attributes, namedattribute("access_groups", access_groups)) - (alias_scopes != nothing) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) - (noalias_scopes != nothing) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (volatile_ != nothing) && push!(attributes, namedattribute("volatile_", volatile_)) - (nontemporal != nothing) && push!(attributes, namedattribute("nontemporal", nontemporal)) + !isnothing(access_groups) && push!(attributes, namedattribute("access_groups", access_groups)) + !isnothing(alias_scopes) && push!(attributes, namedattribute("alias_scopes", alias_scopes)) + !isnothing(noalias_scopes) && push!(attributes, namedattribute("noalias_scopes", noalias_scopes)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) create_operation( "llvm.store", location; @@ -1552,7 +1552,7 @@ function sub(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.sub", location; @@ -1573,8 +1573,8 @@ function switch(value::Value, defaultOperands::Vector{Value}, caseOperands::Vect successors = Block[defaultDestination, caseDestinations..., ] attributes = NamedAttribute[namedattribute("case_operand_segments", case_operand_segments), ] push!(attributes, operandsegmentsizes([1, length(defaultOperands), length(caseOperands), ])) - (case_values != nothing) && push!(attributes, namedattribute("case_values", case_values)) - (branch_weights != nothing) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) create_operation( "llvm.switch", location; @@ -1666,7 +1666,7 @@ function tbaa_tag(; sym_name, base_type, access_type, offset, constant=nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("base_type", base_type), namedattribute("access_type", access_type), namedattribute("offset", offset), ] - (constant != nothing) && push!(attributes, namedattribute("constant", constant)) + !isnothing(constant) && push!(attributes, namedattribute("constant", constant)) create_operation( "llvm.tbaa_tag", location; @@ -1720,7 +1720,7 @@ function tbaa_type_desc(; sym_name, identity=nothing, members, offsets, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("members", members), namedattribute("offsets", offsets), ] - (identity != nothing) && push!(attributes, namedattribute("identity", identity)) + !isnothing(identity) && push!(attributes, namedattribute("identity", identity)) create_operation( "llvm.tbaa_type_desc", location; @@ -1759,7 +1759,7 @@ function udiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.udiv", location; @@ -1798,7 +1798,7 @@ function urem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.urem", location; @@ -1867,7 +1867,7 @@ function xor(lhs::Value, rhs::Value; res=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "llvm.xor", location; diff --git a/src/Dialects/16/Linalg.jl b/src/Dialects/16/Linalg.jl index 9154fc3b..85c2230e 100644 --- a/src/Dialects/16/Linalg.jl +++ b/src/Dialects/16/Linalg.jl @@ -48,7 +48,7 @@ function index(; result=nothing::Union{Nothing, MLIRType}, dim, location=Locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dim", dim), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "linalg.index", location; @@ -86,4 +86,1648 @@ function yield(values::Vector{Value}; location=Location()) ) end +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`batch_matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function batch_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.batch_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`batch_matmul_transpose_b` + +dimensions transposed. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function batch_matmul_transpose_b(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.batch_matmul_transpose_b", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`batch_matvec` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function batch_matvec(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.batch_matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`batch_reduce_matmul` + +The partial multiplication results are reduced into a 2D output. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function batch_reduce_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.batch_reduce_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`broadcast` + +Broadcast the input into the given shape by adding `dimensions`. + +# Example +``` + %bcast = linalg.broadcast + ins(%input:tensor<16xf32>) + inits(%init:tensor<16x64xf32>) + dimensions = [1] +``` +""" +function broadcast(input::Value, init::Value; result::Vector{MLIRType}, dimensions, region::Region, location=Location()) + results = MLIRType[result..., ] + operands = Value[input, init, ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimensions", dimensions), ] + + create_operation( + "linalg.broadcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_1d_ncw_fcw` + +Layout: + * Input: NCW. + * Kernel: FCW. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_1d_ncw_fcw(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_1d_ncw_fcw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_1d_nwc_wcf` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_1d_nwc_wcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_1d_nwc_wcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_1d` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_1d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_1d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_nchw_fchw` + +Layout: + * Input: NCHW. + * Kernel: FCHW. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d_nchw_fchw(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_2d_nchw_fchw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_ngchw_fgchw` + +Layout: + * Input: NGCHW. + * Kernel: FGCHW. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d_ngchw_fgchw(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_2d_ngchw_fgchw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_nhwc_fhwc` + +Layout: + * Input: NHWC. + * Kernel: FHWC. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d_nhwc_fhwc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_2d_nhwc_fhwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_nhwc_hwcf` + +Layout: + * Input: NHWC. + * Kernel: HWCF. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d_nhwc_hwcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_2d_nhwc_hwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d_nhwc_hwcf_q` + +Layout: + * Input: NHWC. + * Kernel: HWCF. + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. This includes the zero +point offsets common to quantized operations. +""" +function conv_2d_nhwc_hwcf_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_2d_nhwc_hwcf_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_2d` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_2d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_3d_ndhwc_dhwcf` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_3d_ndhwc_dhwcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_3d_ndhwc_dhwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_3d_ndhwc_dhwcf_q` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. This includes the zero +point offsets common to quantized operations. +""" +function conv_3d_ndhwc_dhwcf_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.conv_3d_ndhwc_dhwcf_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`conv_3d` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function conv_3d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.conv_3d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`copy` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function copy(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, cast=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + create_operation( + "linalg.copy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_1d_nwc_wc` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. Multiplier is set to 1 +which is a special case for most depthwise convolutions. +""" +function depthwise_conv_1d_nwc_wc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_1d_nwc_wc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_1d_nwc_wcm` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_1d_nwc_wcm(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_1d_nwc_wcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nchw_chw` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. Multiplier is set to 1 +which is a special case for most depthwise convolutions. +""" +function depthwise_conv_2d_nchw_chw(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_2d_nchw_chw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwc` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. Multiplier is set to 1 +which is a special case for most depthwise convolutions. +""" +function depthwise_conv_2d_nhwc_hwc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwc_q` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_2d_nhwc_hwc_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwcm` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_2d_nhwc_hwcm(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_2d_nhwc_hwcm_q` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_2d_nhwc_hwcm_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_3d_ndhwc_dhwc` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. Multiplier is set to 1 +which is a special case for most depthwise convolutions. +""" +function depthwise_conv_3d_ndhwc_dhwc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_3d_ndhwc_dhwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`depthwise_conv_3d_ndhwc_dhwcm` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function depthwise_conv_3d_ndhwc_dhwcm(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.depthwise_conv_3d_ndhwc_dhwcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`dot` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function dot(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.dot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`elemwise_binary` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function elemwise_binary(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, fun=nothing, cast=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(fun) && push!(attributes, namedattribute("fun", fun)) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + create_operation( + "linalg.elemwise_binary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`elemwise_unary` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function elemwise_unary(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, fun=nothing, cast=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(fun) && push!(attributes, namedattribute("fun", fun)) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + create_operation( + "linalg.elemwise_unary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`fill` + +Works for arbitrary ranked output tensors since the operation performs scalar +accesses only and is thus rank polymorphic. Numeric casting is performed on +the value operand, promoting it to the same data type as the output. +""" +function fill(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.fill", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`fill_rng_2d` + +The operation generations pseudo random numbers using a linear congruential +generator. It provides no guarantees regarding the distribution of the +generated random numbers. Instead of generating the random numbers +sequentially, it instantiates one random number generator per data element +and runs them in parallel. The seed operand and the indices of the data +element seed the random number generation. The min and max operands limit +the range of the generated random numbers. +""" +function fill_rng_2d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.fill_rng_2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`generic` + +Generic Linalg op form where the key properties of the computation are +specified as attributes. In pretty form, a `linalg.generic` op is written +as: + + ```mlir + linalg.generic #trait_attribute + ins(%A, %B : memref, + memref) + outs(%C : memref) + attrs = {other-optional-attributes} + {region} + ``` + +Where #trait_attributes is an alias of a dictionary attribute containing: + - doc [optional]: a documentation string + - indexing_maps: a list of AffineMapAttr, one AffineMapAttr per each input + and output view. Such AffineMapAttr specifies the mapping between the + loops and the indexing within each view. + - library_call [optional]: a StringAttr containing the name of an + external library function that the linalg.generic operation maps to. + The external library is assumed to be dynamically linked and no strong + compile-time guarantees are provided. In the absence of such a library + call, linalg.generic will always lower to loops. + - iterator_types: an ArrayAttr specifying the type of the enclosing loops. + Each element of the list represents and iterator of one of the following + types: + parallel, reduction, window + +# Example +Defining a #matmul_trait attribute in MLIR can be done as follows: + ```mlir + #matmul_accesses = [ + (m, n, k) -> (m, k), + (m, n, k) -> (k, n), + (m, n, k) -> (m, n) + ] + #matmul_trait = { + doc = \"C(m, n) += A(m, k) * B(k, n)\", + indexing_maps = #matmul_accesses, + library_call = \"linalg_matmul\", + iterator_types = [\"parallel\", \"parallel\", \"reduction\"] + } + ``` + +And can be reused in multiple places as: + ```mlir + linalg.generic #matmul_trait + ins(%A, %B : memref, + memref) + outs(%C : memref) + {other-optional-attributes} { + ^bb0(%a: f32, %b: f32, %c: f32) : + %d = arith.mulf %a, %b: f32 + %e = arith.addf %c, %d: f32 + linalg.yield %e : f32 + } + ``` + +This may lower to either: + ```mlir + call @linalg_matmul(%A, %B, %C) : + (memref, + memref, + memref) + -> () + ``` + +or IR resembling: +```mlir +scf.for %m = %c0 to %M step %c1 { + scf.for %n = %c0 to %N step %c1 { + scf.for %k = %c0 to %K step %c1 { + %a = load %A[%m, %k] : memref + %b = load %B[%k, %n] : memref + %c = load %C[%m, %n] : memref + %d = arith.mulf %a, %b: f32 + %e = arith.addf %c, %d: f32 + store %e, %C[%m, %n] : memref + } + } +} +``` + +To allow progressive lowering from the value world (a.k.a tensor values) to +the buffer world (a.k.a memref values), a `linalg.generic` op allows mixing +tensors and buffers operands and tensor results. + +```mlir +%C = linalg.generic #trait_attribute + ins(%A, %B : tensor, memref) + outs(%C : tensor) + {other-optional-attributes} + {region} + -> (tensor) +``` +""" +function generic(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, indexing_maps, iterator_types, doc=nothing, library_call=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(doc) && push!(attributes, namedattribute("doc", doc)) + !isnothing(library_call) && push!(attributes, namedattribute("library_call", library_call)) + + create_operation( + "linalg.generic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`map` + +Models elementwise operations on tensors in terms of arithmetic operations +on the corresponding elements. + +# Example +``` + %add = linalg.map + ins(%lhs, %rhs : tensor<64xf32>, tensor<64xf32>) + outs(%init: tensor<64xf32>) + (%lhs_elem: f32, %rhs_elem: f32) { + %0 = arith.addf %lhs_elem, %rhs_elem: f32 + linalg.yield %0: f32 + } +``` + +Shortened print form is available. Applies to simple maps with one +non-yield operation inside the body. + +The example above will be printed as: +``` + %add = linalg.map { arith.addf } + ins(%lhs, %rhs : tensor<64xf32>, tensor<64xf32>) + outs(%init: tensor<64xf32>) +``` +""" +function map(inputs::Vector{Value}, init::Value; result::Vector{MLIRType}, mapper::Region, location=Location()) + results = MLIRType[result..., ] + operands = Value[inputs..., init, ] + owned_regions = Region[mapper, ] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "linalg.map", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, cast=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + create_operation( + "linalg.matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`matmul_transpose_b` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function matmul_transpose_b(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, cast=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + create_operation( + "linalg.matmul_transpose_b", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`matmul_unsigned` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function matmul_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.matmul_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`matvec` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function matvec(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`mmt4d` + +Differences from linalg.matmul: +* The right hand side is transposed, whence the \'t\' in \'mmt\'. +* The input and output tensors have a 4D shape instead of a 2D shape. They + are interpreted as 2D matrices with one level of 2D tile subdivision, + whence the 2+2=4 dimensions. The inner tile dimensions are identified with + \'0\' suffixes below, for instance the LHS matrix shape (M, K, M0, K0) reads + as: MxK tiles, each of shape M0xK0. +""" +function mmt4d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.mmt4d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nchw_max` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nchw_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nchw_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nchw_sum` + +Layout: + * Input: NCHW. + * Kernel: HW. + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nchw_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nchw_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_ncw_max` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_ncw_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_ncw_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_ncw_sum` + +Layout: + * Input: NCW. + * Kernel: W. + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_ncw_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_ncw_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_ndhwc_max` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_ndhwc_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_ndhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_ndhwc_min` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_ndhwc_min(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_ndhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_ndhwc_sum` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_ndhwc_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_ndhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_max` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_max_unsigned` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_max_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nhwc_max_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_min` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_min(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_min_unsigned` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_min_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nhwc_min_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nhwc_sum` + +Layout: + * Input: NHWC. + * Kernel: HW. + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nhwc_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nwc_max` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nwc_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nwc_max_unsigned` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nwc_max_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nwc_max_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nwc_min` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nwc_min(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nwc_min_unsigned` + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nwc_min_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nwc_min_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`pooling_nwc_sum` + +Layout: + * Input: NWC. + * Kernel: W. + +Numeric casting is performed on the input operand, promoting it to the same +data type as the accumulator/output. +""" +function pooling_nwc_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + create_operation( + "linalg.pooling_nwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`quantized_batch_matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. The quantized variant +includes zero-point adjustments for the left and right operands of the +matmul. +""" +function quantized_batch_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.quantized_batch_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`quantized_matmul` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. The quantized variant +includes zero-point adjustments for the left and right operands of the +matmul. +""" +function quantized_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.quantized_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`reduce` + +Executes `combiner` on the `dimensions` of `inputs` and returns the +reduced result. The `dimensions` attribute needs to list the reduction +dimensions in increasing order. + +# Example +``` + %reduce = linalg.reduce + ins(%input:tensor<16x32x64xf32>) + outs(%init:tensor<16x64xf32>) + dimensions = [1] + (%in: f32, %out: f32) { + %0 = arith.addf %out, %in: f32 + linalg.yield %0: f32 + } +``` + +Shortened print form is available. Applies to simple (not variadic) reduces +with one non-yield operation inside the body. Applies only if the operation +takes `%out` as the first argument. + +The example above will be printed as: +``` + %reduce = linalg.reduce { arith.addf } + ins(%input:tensor<16x32x64xf32>) + outs(%init:tensor<16x64xf32>) + dimensions = [1] +``` +""" +function reduce(inputs::Vector{Value}, inits::Vector{Value}; result_0::Vector{MLIRType}, dimensions, combiner::Region, location=Location()) + results = MLIRType[result_0..., ] + operands = Value[inputs..., inits..., ] + owned_regions = Region[combiner, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimensions", dimensions), ] + + create_operation( + "linalg.reduce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`transpose` + +Permutes the dimensions of `input` according to the given `permutation`. + `dim(result, i) = dim(input, permutation[i])` + +This op actually moves data, unlike `memref.transpose` which is a metadata +operation only that produces a transposed \"view\". + +# Example +``` + %transpose = linalg.transpose + ins(%input:tensor<16x64xf32>) + outs(%init:tensor<64x16xf32>) + permutation = [1, 0] +``` +""" +function transpose(input::Value, init::Value; result::Vector{MLIRType}, permutation, region::Region, location=Location()) + results = MLIRType[result..., ] + operands = Value[input, init, ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation", permutation), ] + + create_operation( + "linalg.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`vecmat` + +Numeric casting is performed on the operands to the inner multiply, promoting +them to the same data type as the accumulator/output. +""" +function vecmat(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{MLIRType}, region::Region, location=Location()) + results = MLIRType[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + create_operation( + "linalg.vecmat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + end # linalg diff --git a/src/Dialects/16/MLProgram.jl b/src/Dialects/16/MLProgram.jl index 105b9b7c..be4dce72 100644 --- a/src/Dialects/16/MLProgram.jl +++ b/src/Dialects/16/MLProgram.jl @@ -31,9 +31,9 @@ function func(; sym_name, function_type, arg_attrs=nothing, res_attrs=nothing, s owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("function_type", function_type), ] - (arg_attrs != nothing) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) - (res_attrs != nothing) && push!(attributes, namedattribute("res_attrs", res_attrs)) - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(arg_attrs) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) + !isnothing(res_attrs) && push!(attributes, namedattribute("res_attrs", res_attrs)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "ml_program.func", location; @@ -57,20 +57,20 @@ such a load can be considered to have no side effects. %0 = ml_program.global_load_const @foobar : tensor ``` """ -# function global_load_const(; result::MLIRType, global, location=Location()) -# results = MLIRType[result, ] -# operands = Value[] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[namedattribute("global", global), ] +function global_load_const(; result::MLIRType, global_, location=Location()) + results = MLIRType[result, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] -# create_operation( -# "ml_program.global_load_const", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "ml_program.global_load_const", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `global_load_graph` @@ -92,20 +92,20 @@ without additional consideration to evaluation order constraints. ordering (%token -> !ml_program.token) : tensor ``` """ -# function global_load_graph(consumeTokens::Vector{Value}; result::MLIRType, produceToken::MLIRType, global, location=Location()) -# results = MLIRType[result, produceToken, ] -# operands = Value[consumeTokens..., ] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[namedattribute("global", global), ] +function global_load_graph(consumeTokens::Vector{Value}; result::MLIRType, produceToken::MLIRType, global_, location=Location()) + results = MLIRType[result, produceToken, ] + operands = Value[consumeTokens..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] -# create_operation( -# "ml_program.global_load_graph", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "ml_program.global_load_graph", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `global_load` @@ -127,20 +127,20 @@ without additional consideration to evaluation order constraints. See %0 = ml_program.global_load @foobar : tensor ``` """ -# function global_load(; result::MLIRType, global, location=Location()) -# results = MLIRType[result, ] -# operands = Value[] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[namedattribute("global", global), ] +function global_load(; result::MLIRType, global_, location=Location()) + results = MLIRType[result, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] -# create_operation( -# "ml_program.global_load", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "ml_program.global_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `global_` @@ -178,9 +178,9 @@ function global_(; sym_name, type, is_mutable=nothing, value=nothing, sym_visibi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("type", type), ] - (is_mutable != nothing) && push!(attributes, namedattribute("is_mutable", is_mutable)) - (value != nothing) && push!(attributes, namedattribute("value", value)) - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(is_mutable) && push!(attributes, namedattribute("is_mutable", is_mutable)) + !isnothing(value) && push!(attributes, namedattribute("value", value)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "ml_program.global", location; @@ -210,20 +210,20 @@ without additional consideration to evaluation order constraints. ordering (%in_token -> !ml_program.token) : tensor ``` """ -# function global_store_graph(value::Value, consumeTokens::Vector{Value}; produceToken::MLIRType, global, location=Location()) -# results = MLIRType[produceToken, ] -# operands = Value[value, consumeTokens..., ] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[namedattribute("global", global), ] +function global_store_graph(value::Value, consumeTokens::Vector{Value}; produceToken::MLIRType, global_, location=Location()) + results = MLIRType[produceToken, ] + operands = Value[value, consumeTokens..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] -# create_operation( -# "ml_program.global_store_graph", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "ml_program.global_store_graph", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `global_store` @@ -245,20 +245,20 @@ without additional consideration to evaluation order constraints. See ml_program.global_store @foobar = %0 : tensor ``` """ -# function global_store(value::Value; global, location=Location()) -# results = MLIRType[] -# operands = Value[value, ] -# owned_regions = Region[] -# successors = Block[] -# attributes = NamedAttribute[namedattribute("global", global), ] +function global_store(value::Value; global_, location=Location()) + results = MLIRType[] + operands = Value[value, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] -# create_operation( -# "ml_program.global_store", location; -# operands, owned_regions, successors, attributes, -# results=results, -# result_inference=false -# ) -# end + create_operation( + "ml_program.global_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `output` @@ -334,9 +334,9 @@ function subgraph(; sym_name, function_type, arg_attrs=nothing, res_attrs=nothin owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("function_type", function_type), ] - (arg_attrs != nothing) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) - (res_attrs != nothing) && push!(attributes, namedattribute("res_attrs", res_attrs)) - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(arg_attrs) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) + !isnothing(res_attrs) && push!(attributes, namedattribute("res_attrs", res_attrs)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "ml_program.subgraph", location; diff --git a/src/Dialects/16/Math.jl b/src/Dialects/16/Math.jl index 55921127..fe4f50b1 100644 --- a/src/Dialects/16/Math.jl +++ b/src/Dialects/16/Math.jl @@ -25,8 +25,8 @@ function absf(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.absf", location; @@ -56,7 +56,7 @@ function absi(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.absi", location; @@ -99,8 +99,8 @@ function atan2(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.atan2", location; @@ -136,8 +136,8 @@ function atan(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.atan", location; @@ -169,8 +169,8 @@ function cbrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.cbrt", location; @@ -206,8 +206,8 @@ function ceil(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.ceil", location; @@ -244,8 +244,8 @@ function copysign(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.copysign", location; @@ -281,8 +281,8 @@ function cos(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.cos", location; @@ -311,7 +311,7 @@ function ctlz(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.ctlz", location; @@ -340,7 +340,7 @@ function cttz(operand::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.cttz", location; @@ -369,7 +369,7 @@ function ctpop(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.ctpop", location; @@ -405,8 +405,8 @@ function erf(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.erf", location; @@ -442,8 +442,8 @@ function exp2(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.exp2", location; @@ -481,8 +481,8 @@ function expm1(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.expm1", location; @@ -518,8 +518,8 @@ function exp(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.exp", location; @@ -567,8 +567,8 @@ function fpowi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.fpowi", location; @@ -604,8 +604,8 @@ function floor(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.floor", location; @@ -646,8 +646,8 @@ function fma(a::Value, b::Value, c::Value; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.fma", location; @@ -683,7 +683,7 @@ function ipowi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "math.ipowi", location; @@ -713,8 +713,8 @@ function log10(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.log10", location; @@ -746,8 +746,8 @@ function log1p(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.log1p", location; @@ -777,8 +777,8 @@ function log2(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.log2", location; @@ -808,8 +808,8 @@ function log(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.log", location; @@ -845,8 +845,8 @@ function powf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.powf", location; @@ -885,8 +885,8 @@ function roundeven(operand::Value; result=nothing::Union{Nothing, MLIRType}, fas owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.roundeven", location; @@ -925,8 +925,8 @@ function round(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.round", location; @@ -956,8 +956,8 @@ function rsqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.rsqrt", location; @@ -993,8 +993,8 @@ function sin(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.sin", location; @@ -1024,8 +1024,8 @@ function sqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.sqrt", location; @@ -1055,8 +1055,8 @@ function tan(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.tan", location; @@ -1086,8 +1086,8 @@ function tanh(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmath owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.tanh", location; @@ -1125,8 +1125,8 @@ function trunc(operand::Value; result=nothing::Union{Nothing, MLIRType}, fastmat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (fastmath != nothing) && push!(attributes, namedattribute("fastmath", fastmath)) + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) create_operation( "math.trunc", location; diff --git a/src/Dialects/16/MemRef.jl b/src/Dialects/16/MemRef.jl index a5ff8e08..9b65a9e6 100644 --- a/src/Dialects/16/MemRef.jl +++ b/src/Dialects/16/MemRef.jl @@ -53,7 +53,7 @@ function atomic_rmw(value::Value, memref::Value, indices::Vector{Value}; result= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kind", kind), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "memref.atomic_rmw", location; @@ -196,7 +196,7 @@ function load(memref::Value, indices::Vector{Value}; result=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "memref.load", location; @@ -254,7 +254,7 @@ function alloc(dynamicSizes::Vector{Value}, symbolOperands::Vector{Value}; memre successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "memref.alloc", location; @@ -308,7 +308,7 @@ function alloca(dynamicSizes::Vector{Value}, symbolOperands::Vector{Value}; memr successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "memref.alloca", location; @@ -584,7 +584,7 @@ function dim(source::Value, index::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "memref.dim", location; @@ -776,7 +776,7 @@ function extract_aligned_pointer_as_index(source::Value; aligned_pointer=nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (aligned_pointer != nothing) && push!(results, aligned_pointer) + !isnothing(aligned_pointer) && push!(results, aligned_pointer) create_operation( "memref.extract_aligned_pointer_as_index", location; @@ -836,10 +836,10 @@ function extract_strided_metadata(source::Value; base_buffer=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (base_buffer != nothing) && push!(results, base_buffer) - (offset != nothing) && push!(results, offset) - (sizes != nothing) && push!(results, sizes...) - (strides != nothing) && push!(results, strides...) + !isnothing(base_buffer) && push!(results, base_buffer) + !isnothing(offset) && push!(results, offset) + !isnothing(sizes) && push!(results, sizes...) + !isnothing(strides) && push!(results, strides...) create_operation( "memref.extract_strided_metadata", location; @@ -922,10 +922,10 @@ function global_(; sym_name, sym_visibility=nothing, type, initial_value=nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("type", type), ] - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) - (initial_value != nothing) && push!(attributes, namedattribute("initial_value", initial_value)) - (constant != nothing) && push!(attributes, namedattribute("constant", constant)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(initial_value) && push!(attributes, namedattribute("initial_value", initial_value)) + !isnothing(constant) && push!(attributes, namedattribute("constant", constant)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "memref.global", location; @@ -986,7 +986,7 @@ function rank(memref::Value; result_0=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "memref.rank", location; @@ -1060,8 +1060,8 @@ function realloc(source::Value, dynamicResultSize=nothing::Union{Nothing, Value} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (dynamicResultSize != nothing) && push!(operands, dynamicResultSize) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(dynamicResultSize) && push!(operands, dynamicResultSize) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "memref.realloc", location; diff --git a/src/Dialects/16/NVGPU.jl b/src/Dialects/16/NVGPU.jl index ab2ffaed..d2f2c697 100644 --- a/src/Dialects/16/NVGPU.jl +++ b/src/Dialects/16/NVGPU.jl @@ -61,9 +61,9 @@ function device_async_copy(dst::Value, dstIndices::Vector{Value}, src::Value, sr owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("dstElements", dstElements), ] - (srcElements != nothing) && push!(operands, srcElements) + !isnothing(srcElements) && push!(operands, srcElements) push!(attributes, operandsegmentsizes([1, length(dstIndices), 1, length(srcIndices), (srcElements==nothing) ? 0 : 1])) - (bypassL1 != nothing) && push!(attributes, namedattribute("bypassL1", bypassL1)) + !isnothing(bypassL1) && push!(attributes, namedattribute("bypassL1", bypassL1)) create_operation( "nvgpu.device_async_copy", location; @@ -129,7 +129,7 @@ function device_async_wait(asyncDependencies::Value; numGroups=nothing, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (numGroups != nothing) && push!(attributes, namedattribute("numGroups", numGroups)) + !isnothing(numGroups) && push!(attributes, namedattribute("numGroups", numGroups)) create_operation( "nvgpu.device_async_wait", location; @@ -202,8 +202,8 @@ function mma_sp_sync(matrixA::Value, matrixB::Value, matrixC::Value, sparseMetad owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("mmaShape", mmaShape), ] - (sparsitySelector != nothing) && push!(attributes, namedattribute("sparsitySelector", sparsitySelector)) - (tf32Enabled != nothing) && push!(attributes, namedattribute("tf32Enabled", tf32Enabled)) + !isnothing(sparsitySelector) && push!(attributes, namedattribute("sparsitySelector", sparsitySelector)) + !isnothing(tf32Enabled) && push!(attributes, namedattribute("tf32Enabled", tf32Enabled)) create_operation( "nvgpu.mma.sp.sync", location; @@ -241,7 +241,7 @@ function mma_sync(matrixA::Value, matrixB::Value, matrixC::Value; res::MLIRType, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("mmaShape", mmaShape), ] - (tf32Enabled != nothing) && push!(attributes, namedattribute("tf32Enabled", tf32Enabled)) + !isnothing(tf32Enabled) && push!(attributes, namedattribute("tf32Enabled", tf32Enabled)) create_operation( "nvgpu.mma.sync", location; diff --git a/src/Dialects/16/OpenACC.jl b/src/Dialects/16/OpenACC.jl index 099a545a..6df1d71b 100644 --- a/src/Dialects/16/OpenACC.jl +++ b/src/Dialects/16/OpenACC.jl @@ -29,9 +29,9 @@ function data(ifCond=nothing::Union{Nothing, Value}; copyOperands::Vector{Value} owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1length(copyOperands), length(copyinOperands), length(copyinReadonlyOperands), length(copyoutOperands), length(copyoutZeroOperands), length(createOperands), length(createZeroOperands), length(noCreateOperands), length(presentOperands), length(deviceptrOperands), length(attachOperands), ])) - (defaultAttr != nothing) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) create_operation( "acc.data", location; @@ -58,12 +58,12 @@ function enter_data(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(copyinOperands), length(createOperands), length(createZeroOperands), length(attachOperands), ])) - (async != nothing) && push!(attributes, namedattribute("async", async)) - (wait != nothing) && push!(attributes, namedattribute("wait", wait)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) create_operation( "acc.enter_data", location; @@ -90,13 +90,13 @@ function exit_data(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(copyoutOperands), length(deleteOperands), length(detachOperands), ])) - (async != nothing) && push!(attributes, namedattribute("async", async)) - (wait != nothing) && push!(attributes, namedattribute("wait", wait)) - (finalize != nothing) && push!(attributes, namedattribute("finalize", finalize)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + !isnothing(finalize) && push!(attributes, namedattribute("finalize", finalize)) create_operation( "acc.exit_data", location; @@ -125,8 +125,8 @@ function init(deviceTypeOperands::Vector{Value}, deviceNumOperand=nothing::Union owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (deviceNumOperand != nothing) && push!(operands, deviceNumOperand) - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(deviceNumOperand) && push!(operands, deviceNumOperand) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([length(deviceTypeOperands), (deviceNumOperand==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) create_operation( @@ -163,17 +163,17 @@ function loop(gangNum=nothing::Union{Nothing, Value}; gangStatic=nothing::Union{ owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (gangNum != nothing) && push!(operands, gangNum) - (gangStatic != nothing) && push!(operands, gangStatic) - (workerNum != nothing) && push!(operands, workerNum) - (vectorLength != nothing) && push!(operands, vectorLength) + !isnothing(gangNum) && push!(operands, gangNum) + !isnothing(gangStatic) && push!(operands, gangStatic) + !isnothing(workerNum) && push!(operands, workerNum) + !isnothing(vectorLength) && push!(operands, vectorLength) push!(attributes, operandsegmentsizes([(gangNum==nothing) ? 0 : 1(gangStatic==nothing) ? 0 : 1(workerNum==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1length(tileOperands), length(privateOperands), length(reductionOperands), ])) - (collapse != nothing) && push!(attributes, namedattribute("collapse", collapse)) - (seq != nothing) && push!(attributes, namedattribute("seq", seq)) - (independent != nothing) && push!(attributes, namedattribute("independent", independent)) - (auto_ != nothing) && push!(attributes, namedattribute("auto_", auto_)) - (reductionOp != nothing) && push!(attributes, namedattribute("reductionOp", reductionOp)) - (exec_mapping != nothing) && push!(attributes, namedattribute("exec_mapping", exec_mapping)) + !isnothing(collapse) && push!(attributes, namedattribute("collapse", collapse)) + !isnothing(seq) && push!(attributes, namedattribute("seq", seq)) + !isnothing(independent) && push!(attributes, namedattribute("independent", independent)) + !isnothing(auto_) && push!(attributes, namedattribute("auto_", auto_)) + !isnothing(reductionOp) && push!(attributes, namedattribute("reductionOp", reductionOp)) + !isnothing(exec_mapping) && push!(attributes, namedattribute("exec_mapping", exec_mapping)) create_operation( "acc.loop", location; @@ -204,18 +204,18 @@ function parallel(async=nothing::Union{Nothing, Value}; waitOperands::Vector{Val owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (async != nothing) && push!(operands, async) - (numGangs != nothing) && push!(operands, numGangs) - (numWorkers != nothing) && push!(operands, numWorkers) - (vectorLength != nothing) && push!(operands, vectorLength) - (ifCond != nothing) && push!(operands, ifCond) - (selfCond != nothing) && push!(operands, selfCond) + !isnothing(async) && push!(operands, async) + !isnothing(numGangs) && push!(operands, numGangs) + !isnothing(numWorkers) && push!(operands, numWorkers) + !isnothing(vectorLength) && push!(operands, vectorLength) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(selfCond) && push!(operands, selfCond) push!(attributes, operandsegmentsizes([(async==nothing) ? 0 : 1length(waitOperands), (numGangs==nothing) ? 0 : 1(numWorkers==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1(selfCond==nothing) ? 0 : 1length(reductionOperands), length(copyOperands), length(copyinOperands), length(copyinReadonlyOperands), length(copyoutOperands), length(copyoutZeroOperands), length(createOperands), length(createZeroOperands), length(noCreateOperands), length(presentOperands), length(devicePtrOperands), length(attachOperands), length(gangPrivateOperands), length(gangFirstPrivateOperands), ])) - (asyncAttr != nothing) && push!(attributes, namedattribute("asyncAttr", asyncAttr)) - (waitAttr != nothing) && push!(attributes, namedattribute("waitAttr", waitAttr)) - (selfAttr != nothing) && push!(attributes, namedattribute("selfAttr", selfAttr)) - (reductionOp != nothing) && push!(attributes, namedattribute("reductionOp", reductionOp)) - (defaultAttr != nothing) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + !isnothing(asyncAttr) && push!(attributes, namedattribute("asyncAttr", asyncAttr)) + !isnothing(waitAttr) && push!(attributes, namedattribute("waitAttr", waitAttr)) + !isnothing(selfAttr) && push!(attributes, namedattribute("selfAttr", selfAttr)) + !isnothing(reductionOp) && push!(attributes, namedattribute("reductionOp", reductionOp)) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) create_operation( "acc.parallel", location; @@ -244,8 +244,8 @@ function shutdown(deviceTypeOperands::Vector{Value}, deviceNumOperand=nothing::U owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (deviceNumOperand != nothing) && push!(operands, deviceNumOperand) - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(deviceNumOperand) && push!(operands, deviceNumOperand) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([length(deviceTypeOperands), (deviceNumOperand==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) create_operation( @@ -299,13 +299,13 @@ function update(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing::Uni owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (ifCond != nothing) && push!(operands, ifCond) - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(deviceTypeOperands), length(hostOperands), length(deviceOperands), ])) - (async != nothing) && push!(attributes, namedattribute("async", async)) - (wait != nothing) && push!(attributes, namedattribute("wait", wait)) - (ifPresent != nothing) && push!(attributes, namedattribute("ifPresent", ifPresent)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + !isnothing(ifPresent) && push!(attributes, namedattribute("ifPresent", ifPresent)) create_operation( "acc.update", location; @@ -334,11 +334,11 @@ function wait(waitOperands::Vector{Value}, asyncOperand=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (asyncOperand != nothing) && push!(operands, asyncOperand) - (waitDevnum != nothing) && push!(operands, waitDevnum) - (ifCond != nothing) && push!(operands, ifCond) + !isnothing(asyncOperand) && push!(operands, asyncOperand) + !isnothing(waitDevnum) && push!(operands, waitDevnum) + !isnothing(ifCond) && push!(operands, ifCond) push!(attributes, operandsegmentsizes([length(waitOperands), (asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) - (async != nothing) && push!(attributes, namedattribute("async", async)) + !isnothing(async) && push!(attributes, namedattribute("async", async)) create_operation( "acc.wait", location; diff --git a/src/Dialects/16/OpenMP.jl b/src/Dialects/16/OpenMP.jl index 2551b4cd..31fc416f 100644 --- a/src/Dialects/16/OpenMP.jl +++ b/src/Dialects/16/OpenMP.jl @@ -44,8 +44,8 @@ function atomic_capture(; hint_val=nothing, memory_order_val=nothing, region::Re owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (hint_val != nothing) && push!(attributes, namedattribute("hint_val", hint_val)) - (memory_order_val != nothing) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) create_operation( "omp.atomic.capture", location; @@ -76,8 +76,8 @@ function atomic_read(x::Value, v::Value; hint_val=nothing, memory_order_val=noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (hint_val != nothing) && push!(attributes, namedattribute("hint_val", hint_val)) - (memory_order_val != nothing) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) create_operation( "omp.atomic.read", location; @@ -123,8 +123,8 @@ function atomic_update(x::Value; hint_val=nothing, memory_order_val=nothing, reg owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (hint_val != nothing) && push!(attributes, namedattribute("hint_val", hint_val)) - (memory_order_val != nothing) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) create_operation( "omp.atomic.update", location; @@ -157,8 +157,8 @@ function atomic_write(address::Value, value::Value; hint_val=nothing, memory_ord owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (hint_val != nothing) && push!(attributes, namedattribute("hint_val", hint_val)) - (memory_order_val != nothing) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) create_operation( "omp.atomic.write", location; @@ -201,7 +201,7 @@ function cancel(if_expr=nothing::Union{Nothing, Value}; cancellation_construct_t owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("cancellation_construct_type_val", cancellation_construct_type_val), ] - (if_expr != nothing) && push!(operands, if_expr) + !isnothing(if_expr) && push!(operands, if_expr) create_operation( "omp.cancel", location; @@ -246,7 +246,7 @@ function critical_declare(; sym_name, hint_val=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), ] - (hint_val != nothing) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) create_operation( "omp.critical.declare", location; @@ -268,7 +268,7 @@ function critical(; name=nothing, region::Region, location=Location()) owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (name != nothing) && push!(attributes, namedattribute("name", name)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) create_operation( "omp.critical", location; @@ -346,8 +346,8 @@ function ordered(depend_vec_vars::Vector{Value}; depend_type_val=nothing, num_lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (depend_type_val != nothing) && push!(attributes, namedattribute("depend_type_val", depend_type_val)) - (num_loops_val != nothing) && push!(attributes, namedattribute("num_loops_val", num_loops_val)) + !isnothing(depend_type_val) && push!(attributes, namedattribute("depend_type_val", depend_type_val)) + !isnothing(num_loops_val) && push!(attributes, namedattribute("num_loops_val", num_loops_val)) create_operation( "omp.ordered", location; @@ -374,7 +374,7 @@ function ordered_region(; simd=nothing, region::Region, location=Location()) owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (simd != nothing) && push!(attributes, namedattribute("simd", simd)) + !isnothing(simd) && push!(attributes, namedattribute("simd", simd)) create_operation( "omp.ordered_region", location; @@ -422,11 +422,11 @@ function parallel(if_expr_var=nothing::Union{Nothing, Value}; num_threads_var=no owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr_var != nothing) && push!(operands, if_expr_var) - (num_threads_var != nothing) && push!(operands, num_threads_var) + !isnothing(if_expr_var) && push!(operands, if_expr_var) + !isnothing(num_threads_var) && push!(operands, num_threads_var) push!(attributes, operandsegmentsizes([(if_expr_var==nothing) ? 0 : 1(num_threads_var==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), length(reduction_vars), ])) - (reductions != nothing) && push!(attributes, namedattribute("reductions", reductions)) - (proc_bind_val != nothing) && push!(attributes, namedattribute("proc_bind_val", proc_bind_val)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(proc_bind_val) && push!(attributes, namedattribute("proc_bind_val", proc_bind_val)) create_operation( "omp.parallel", location; @@ -555,8 +555,8 @@ function sections(reduction_vars::Vector{Value}, allocate_vars::Vector{Value}, a successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(reduction_vars), length(allocate_vars), length(allocators_vars), ])) - (reductions != nothing) && push!(attributes, namedattribute("reductions", reductions)) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) create_operation( "omp.sections", location; @@ -617,13 +617,13 @@ function simdloop(lowerBound::Vector{Value}, upperBound::Vector{Value}, step::Ve owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr != nothing) && push!(operands, if_expr) + !isnothing(if_expr) && push!(operands, if_expr) push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(aligned_vars), (if_expr==nothing) ? 0 : 1length(nontemporal_vars), ])) - (alignment_values != nothing) && push!(attributes, namedattribute("alignment_values", alignment_values)) - (order_val != nothing) && push!(attributes, namedattribute("order_val", order_val)) - (simdlen != nothing) && push!(attributes, namedattribute("simdlen", simdlen)) - (safelen != nothing) && push!(attributes, namedattribute("safelen", safelen)) - (inclusive != nothing) && push!(attributes, namedattribute("inclusive", inclusive)) + !isnothing(alignment_values) && push!(attributes, namedattribute("alignment_values", alignment_values)) + !isnothing(order_val) && push!(attributes, namedattribute("order_val", order_val)) + !isnothing(simdlen) && push!(attributes, namedattribute("simdlen", simdlen)) + !isnothing(safelen) && push!(attributes, namedattribute("safelen", safelen)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) create_operation( "omp.simdloop", location; @@ -649,7 +649,7 @@ function single(allocate_vars::Vector{Value}, allocators_vars::Vector{Value}; no successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(allocate_vars), length(allocators_vars), ])) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) create_operation( "omp.single", location; @@ -685,11 +685,11 @@ function target(if_expr=nothing::Union{Nothing, Value}; device=nothing::Union{No owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr != nothing) && push!(operands, if_expr) - (device != nothing) && push!(operands, device) - (thread_limit != nothing) && push!(operands, thread_limit) + !isnothing(if_expr) && push!(operands, if_expr) + !isnothing(device) && push!(operands, device) + !isnothing(thread_limit) && push!(operands, thread_limit) push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1(thread_limit==nothing) ? 0 : 1])) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) create_operation( "omp.target", location; @@ -736,8 +736,8 @@ function target_data(if_expr=nothing::Union{Nothing, Value}; device=nothing::Uni owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[namedattribute("map_types", map_types), ] - (if_expr != nothing) && push!(operands, if_expr) - (device != nothing) && push!(operands, device) + !isnothing(if_expr) && push!(operands, if_expr) + !isnothing(device) && push!(operands, device) push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1length(use_device_ptr), length(use_device_addr), length(map_operands), ])) create_operation( @@ -778,10 +778,10 @@ function target_enter_data(if_expr=nothing::Union{Nothing, Value}; device=nothin owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("map_types", map_types), ] - (if_expr != nothing) && push!(operands, if_expr) - (device != nothing) && push!(operands, device) + !isnothing(if_expr) && push!(operands, if_expr) + !isnothing(device) && push!(operands, device) push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1length(map_operands), ])) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) create_operation( "omp.target_enter_data", location; @@ -821,10 +821,10 @@ function target_exit_data(if_expr=nothing::Union{Nothing, Value}; device=nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("map_types", map_types), ] - (if_expr != nothing) && push!(operands, if_expr) - (device != nothing) && push!(operands, device) + !isnothing(if_expr) && push!(operands, if_expr) + !isnothing(device) && push!(operands, device) push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1length(map_operands), ])) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) create_operation( "omp.target_exit_data", location; @@ -865,7 +865,7 @@ function taskgroup(task_reduction_vars::Vector{Value}, allocate_vars::Vector{Val successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(task_reduction_vars), length(allocate_vars), length(allocators_vars), ])) - (task_reductions != nothing) && push!(attributes, namedattribute("task_reductions", task_reductions)) + !isnothing(task_reductions) && push!(attributes, namedattribute("task_reductions", task_reductions)) create_operation( "omp.taskgroup", location; @@ -979,18 +979,18 @@ function taskloop(lowerBound::Vector{Value}, upperBound::Vector{Value}, step::Ve owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr != nothing) && push!(operands, if_expr) - (final_expr != nothing) && push!(operands, final_expr) - (priority != nothing) && push!(operands, priority) - (grain_size != nothing) && push!(operands, grain_size) - (num_tasks != nothing) && push!(operands, num_tasks) + !isnothing(if_expr) && push!(operands, if_expr) + !isnothing(final_expr) && push!(operands, final_expr) + !isnothing(priority) && push!(operands, priority) + !isnothing(grain_size) && push!(operands, grain_size) + !isnothing(num_tasks) && push!(operands, num_tasks) push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), (if_expr==nothing) ? 0 : 1(final_expr==nothing) ? 0 : 1length(in_reduction_vars), length(reduction_vars), (priority==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), (grain_size==nothing) ? 0 : 1(num_tasks==nothing) ? 0 : 1])) - (inclusive != nothing) && push!(attributes, namedattribute("inclusive", inclusive)) - (untied != nothing) && push!(attributes, namedattribute("untied", untied)) - (mergeable != nothing) && push!(attributes, namedattribute("mergeable", mergeable)) - (in_reductions != nothing) && push!(attributes, namedattribute("in_reductions", in_reductions)) - (reductions != nothing) && push!(attributes, namedattribute("reductions", reductions)) - (nogroup != nothing) && push!(attributes, namedattribute("nogroup", nogroup)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + !isnothing(untied) && push!(attributes, namedattribute("untied", untied)) + !isnothing(mergeable) && push!(attributes, namedattribute("mergeable", mergeable)) + !isnothing(in_reductions) && push!(attributes, namedattribute("in_reductions", in_reductions)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nogroup) && push!(attributes, namedattribute("nogroup", nogroup)) create_operation( "omp.taskloop", location; @@ -1048,13 +1048,13 @@ function task(if_expr=nothing::Union{Nothing, Value}; final_expr=nothing::Union{ owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (if_expr != nothing) && push!(operands, if_expr) - (final_expr != nothing) && push!(operands, final_expr) - (priority != nothing) && push!(operands, priority) + !isnothing(if_expr) && push!(operands, if_expr) + !isnothing(final_expr) && push!(operands, final_expr) + !isnothing(priority) && push!(operands, priority) push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(final_expr==nothing) ? 0 : 1length(in_reduction_vars), (priority==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), ])) - (untied != nothing) && push!(attributes, namedattribute("untied", untied)) - (mergeable != nothing) && push!(attributes, namedattribute("mergeable", mergeable)) - (in_reductions != nothing) && push!(attributes, namedattribute("in_reductions", in_reductions)) + !isnothing(untied) && push!(attributes, namedattribute("untied", untied)) + !isnothing(mergeable) && push!(attributes, namedattribute("mergeable", mergeable)) + !isnothing(in_reductions) && push!(attributes, namedattribute("in_reductions", in_reductions)) create_operation( "omp.task", location; @@ -1229,16 +1229,16 @@ function wsloop(lowerBound::Vector{Value}, upperBound::Vector{Value}, step::Vect owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (schedule_chunk_var != nothing) && push!(operands, schedule_chunk_var) + !isnothing(schedule_chunk_var) && push!(operands, schedule_chunk_var) push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(linear_vars), length(linear_step_vars), length(reduction_vars), (schedule_chunk_var==nothing) ? 0 : 1])) - (reductions != nothing) && push!(attributes, namedattribute("reductions", reductions)) - (schedule_val != nothing) && push!(attributes, namedattribute("schedule_val", schedule_val)) - (schedule_modifier != nothing) && push!(attributes, namedattribute("schedule_modifier", schedule_modifier)) - (simd_modifier != nothing) && push!(attributes, namedattribute("simd_modifier", simd_modifier)) - (nowait != nothing) && push!(attributes, namedattribute("nowait", nowait)) - (ordered_val != nothing) && push!(attributes, namedattribute("ordered_val", ordered_val)) - (order_val != nothing) && push!(attributes, namedattribute("order_val", order_val)) - (inclusive != nothing) && push!(attributes, namedattribute("inclusive", inclusive)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(schedule_val) && push!(attributes, namedattribute("schedule_val", schedule_val)) + !isnothing(schedule_modifier) && push!(attributes, namedattribute("schedule_modifier", schedule_modifier)) + !isnothing(simd_modifier) && push!(attributes, namedattribute("simd_modifier", simd_modifier)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(ordered_val) && push!(attributes, namedattribute("ordered_val", ordered_val)) + !isnothing(order_val) && push!(attributes, namedattribute("order_val", order_val)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) create_operation( "omp.wsloop", location; diff --git a/src/Dialects/16/PDL.jl b/src/Dialects/16/PDL.jl index f20df0ec..fe858977 100644 --- a/src/Dialects/16/PDL.jl +++ b/src/Dialects/16/PDL.jl @@ -108,8 +108,8 @@ function attribute(valueType=nothing::Union{Nothing, Value}; attr::MLIRType, val owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (valueType != nothing) && push!(operands, valueType) - (value != nothing) && push!(attributes, namedattribute("value", value)) + !isnothing(valueType) && push!(operands, valueType) + !isnothing(value) && push!(attributes, namedattribute("value", value)) create_operation( "pdl.attribute", location; @@ -174,7 +174,7 @@ function operand(valueType=nothing::Union{Nothing, Value}; value::MLIRType, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (valueType != nothing) && push!(operands, valueType) + !isnothing(valueType) && push!(operands, valueType) create_operation( "pdl.operand", location; @@ -211,7 +211,7 @@ function operands(valueType=nothing::Union{Nothing, Value}; value::MLIRType, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (valueType != nothing) && push!(operands, valueType) + !isnothing(valueType) && push!(operands, valueType) create_operation( "pdl.operands", location; @@ -325,7 +325,7 @@ function operation(operandValues::Vector{Value}, attributeValues::Vector{Value}, successors = Block[] attributes = NamedAttribute[namedattribute("attributeValueNames", attributeValueNames), ] push!(attributes, operandsegmentsizes([length(operandValues), length(attributeValues), length(typeValues), ])) - (opName != nothing) && push!(attributes, namedattribute("opName", opName)) + !isnothing(opName) && push!(attributes, namedattribute("opName", opName)) create_operation( "pdl.operation", location; @@ -365,7 +365,7 @@ function pattern(; benefit, sym_name=nothing, bodyRegion::Region, location=Locat owned_regions = Region[bodyRegion, ] successors = Block[] attributes = NamedAttribute[namedattribute("benefit", benefit), ] - (sym_name != nothing) && push!(attributes, namedattribute("sym_name", sym_name)) + !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) create_operation( "pdl.pattern", location; @@ -448,7 +448,7 @@ function replace(opValue::Value, replOperation=nothing::Union{Nothing, Value}; r owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (replOperation != nothing) && push!(operands, replOperation) + !isnothing(replOperation) && push!(operands, replOperation) push!(attributes, operandsegmentsizes([1, (replOperation==nothing) ? 0 : 1length(replValues), ])) create_operation( @@ -531,7 +531,7 @@ function results(parent::Value; val::MLIRType, index=nothing, location=Location( owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (index != nothing) && push!(attributes, namedattribute("index", index)) + !isnothing(index) && push!(attributes, namedattribute("index", index)) create_operation( "pdl.results", location; @@ -586,9 +586,9 @@ function rewrite(root=nothing::Union{Nothing, Value}; externalArgs::Vector{Value owned_regions = Region[bodyRegion, ] successors = Block[] attributes = NamedAttribute[] - (root != nothing) && push!(operands, root) + !isnothing(root) && push!(operands, root) push!(attributes, operandsegmentsizes([(root==nothing) ? 0 : 1length(externalArgs), ])) - (name != nothing) && push!(attributes, namedattribute("name", name)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) create_operation( "pdl.rewrite", location; @@ -622,7 +622,7 @@ function type(; result::MLIRType, constantType=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (constantType != nothing) && push!(attributes, namedattribute("constantType", constantType)) + !isnothing(constantType) && push!(attributes, namedattribute("constantType", constantType)) create_operation( "pdl.type", location; @@ -656,7 +656,7 @@ function types(; result::MLIRType, constantTypes=nothing, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (constantTypes != nothing) && push!(attributes, namedattribute("constantTypes", constantTypes)) + !isnothing(constantTypes) && push!(attributes, namedattribute("constantTypes", constantTypes)) create_operation( "pdl.types", location; diff --git a/src/Dialects/16/PDLInterp.jl b/src/Dialects/16/PDLInterp.jl index bc47773e..be730450 100644 --- a/src/Dialects/16/PDLInterp.jl +++ b/src/Dialects/16/PDLInterp.jl @@ -182,7 +182,7 @@ function check_operand_count(inputOp::Value; count, compareAtLeast=nothing, true owned_regions = Region[] successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[namedattribute("count", count), ] - (compareAtLeast != nothing) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) + !isnothing(compareAtLeast) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) create_operation( "pdl_interp.check_operand_count", location; @@ -245,7 +245,7 @@ function check_result_count(inputOp::Value; count, compareAtLeast=nothing, trueD owned_regions = Region[] successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[namedattribute("count", count), ] - (compareAtLeast != nothing) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) + !isnothing(compareAtLeast) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) create_operation( "pdl_interp.check_result_count", location; @@ -392,7 +392,7 @@ function create_operation(inputOperands::Vector{Value}, inputAttributes::Vector{ successors = Block[] attributes = NamedAttribute[namedattribute("name", name), namedattribute("inputAttributeNames", inputAttributeNames), ] push!(attributes, operandsegmentsizes([length(inputOperands), length(inputAttributes), length(inputResultTypes), ])) - (inferredResultTypes != nothing) && push!(attributes, namedattribute("inferredResultTypes", inferredResultTypes)) + !isnothing(inferredResultTypes) && push!(attributes, namedattribute("inferredResultTypes", inferredResultTypes)) create_operation( "pdl_interp.create_operation", location; @@ -633,8 +633,8 @@ function func(; sym_name, function_type, arg_attrs=nothing, res_attrs=nothing, b owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("function_type", function_type), ] - (arg_attrs != nothing) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) - (res_attrs != nothing) && push!(attributes, namedattribute("res_attrs", res_attrs)) + !isnothing(arg_attrs) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) + !isnothing(res_attrs) && push!(attributes, namedattribute("res_attrs", res_attrs)) create_operation( "pdl_interp.func", location; @@ -785,7 +785,7 @@ function get_operands(inputOp::Value; value::MLIRType, index=nothing, location=L owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (index != nothing) && push!(attributes, namedattribute("index", index)) + !isnothing(index) && push!(attributes, namedattribute("index", index)) create_operation( "pdl_interp.get_operands", location; @@ -852,7 +852,7 @@ function get_results(inputOp::Value; value::MLIRType, index=nothing, location=Lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (index != nothing) && push!(attributes, namedattribute("index", index)) + !isnothing(index) && push!(attributes, namedattribute("index", index)) create_operation( "pdl_interp.get_results", location; @@ -976,8 +976,8 @@ function record_match(inputs::Vector{Value}, matchedOps::Vector{Value}; rewriter successors = Block[dest, ] attributes = NamedAttribute[namedattribute("rewriter", rewriter), namedattribute("benefit", benefit), ] push!(attributes, operandsegmentsizes([length(inputs), length(matchedOps), ])) - (rootKind != nothing) && push!(attributes, namedattribute("rootKind", rootKind)) - (generatedOps != nothing) && push!(attributes, namedattribute("generatedOps", generatedOps)) + !isnothing(rootKind) && push!(attributes, namedattribute("rootKind", rootKind)) + !isnothing(generatedOps) && push!(attributes, namedattribute("generatedOps", generatedOps)) create_operation( "pdl_interp.record_match", location; diff --git a/src/Dialects/16/SCF.jl b/src/Dialects/16/SCF.jl index 21b57066..1eb68c5b 100644 --- a/src/Dialects/16/SCF.jl +++ b/src/Dialects/16/SCF.jl @@ -320,7 +320,7 @@ function foreach_thread(num_threads::Vector{Value}, outputs::Vector{Value}; resu successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([length(num_threads), length(outputs), ])) - (mapping != nothing) && push!(attributes, namedattribute("mapping", mapping)) + !isnothing(mapping) && push!(attributes, namedattribute("mapping", mapping)) create_operation( "scf.foreach_thread", location; diff --git a/src/Dialects/16/SPIRV.jl b/src/Dialects/16/SPIRV.jl index bddaf5ac..6171637a 100644 --- a/src/Dialects/16/SPIRV.jl +++ b/src/Dialects/16/SPIRV.jl @@ -822,7 +822,7 @@ function BitCount(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.BitCount", location; @@ -880,7 +880,7 @@ function BitFieldInsert(base::Value, insert::Value, offset::Value, count::Value; owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.BitFieldInsert", location; @@ -938,7 +938,7 @@ function BitFieldSExtract(base::Value, offset::Value, count::Value; result=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.BitFieldSExtract", location; @@ -978,7 +978,7 @@ function BitFieldUExtract(base::Value, offset::Value, count::Value; result=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.BitFieldUExtract", location; @@ -1022,7 +1022,7 @@ function BitReverse(operand::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.BitReverse", location; @@ -1118,7 +1118,7 @@ function BitwiseAnd(operand1::Value, operand2::Value; result=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.BitwiseAnd", location; @@ -1160,7 +1160,7 @@ function BitwiseOr(operand1::Value, operand2::Value; result=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.BitwiseOr", location; @@ -1202,7 +1202,7 @@ function BitwiseXor(operand1::Value, operand2::Value; result=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.BitwiseXor", location; @@ -1253,7 +1253,7 @@ function BranchConditional(condition::Value, trueTargetOperands::Vector{Value}, successors = Block[trueTarget, falseTarget, ] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([1, length(trueTargetOperands), length(falseTargetOperands), ])) - (branch_weights != nothing) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) create_operation( "spirv.BranchConditional", location; @@ -1329,7 +1329,7 @@ function CL_ceil(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.ceil", location; @@ -1370,7 +1370,7 @@ function CL_cos(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.cos", location; @@ -1411,7 +1411,7 @@ function CL_erf(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.erf", location; @@ -1452,7 +1452,7 @@ function CL_exp(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.exp", location; @@ -1493,7 +1493,7 @@ function CL_fabs(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.fabs", location; @@ -1535,7 +1535,7 @@ function CL_fmax(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.fmax", location; @@ -1576,7 +1576,7 @@ function CL_fmin(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.fmin", location; @@ -1617,7 +1617,7 @@ function CL_floor(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.floor", location; @@ -1656,7 +1656,7 @@ function CL_fma(x::Value, y::Value, z::Value; result=nothing::Union{Nothing, MLI owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.fma", location; @@ -1697,7 +1697,7 @@ function CL_log(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.log", location; @@ -1739,7 +1739,7 @@ function CL_pow(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.pow", location; @@ -1780,7 +1780,7 @@ function CL_rint(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.rint", location; @@ -1820,7 +1820,7 @@ function CL_round(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.round", location; @@ -1861,7 +1861,7 @@ function CL_rsqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.rsqrt", location; @@ -1902,7 +1902,7 @@ function CL_s_abs(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.s_abs", location; @@ -1940,7 +1940,7 @@ function CL_s_max(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.s_max", location; @@ -1978,7 +1978,7 @@ function CL_s_min(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.s_min", location; @@ -2019,7 +2019,7 @@ function CL_sin(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.sin", location; @@ -2060,7 +2060,7 @@ function CL_sqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.sqrt", location; @@ -2101,7 +2101,7 @@ function CL_tanh(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.tanh", location; @@ -2139,7 +2139,7 @@ function CL_u_max(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.u_max", location; @@ -2177,7 +2177,7 @@ function CL_u_min(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.CL.u_min", location; @@ -2627,10 +2627,10 @@ function CopyMemory(target::Value, source::Value; memory_access=nothing, alignme owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) - (source_memory_access != nothing) && push!(attributes, namedattribute("source_memory_access", source_memory_access)) - (source_alignment != nothing) && push!(attributes, namedattribute("source_alignment", source_alignment)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(source_memory_access) && push!(attributes, namedattribute("source_memory_access", source_memory_access)) + !isnothing(source_alignment) && push!(attributes, namedattribute("source_alignment", source_alignment)) create_operation( "spirv.CopyMemory", location; @@ -2823,7 +2823,7 @@ function FAdd(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FAdd", location; @@ -2905,7 +2905,7 @@ function FDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FDiv", location; @@ -2948,7 +2948,7 @@ function FMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FMod", location; @@ -2990,7 +2990,7 @@ function FMul(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FMul", location; @@ -3030,7 +3030,7 @@ function FNegate(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FNegate", location; @@ -3072,7 +3072,7 @@ function FOrdEqual(operand1::Value, operand2::Value; result=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FOrdEqual", location; @@ -3114,7 +3114,7 @@ function FOrdGreaterThanEqual(operand1::Value, operand2::Value; result=nothing:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FOrdGreaterThanEqual", location; @@ -3156,7 +3156,7 @@ function FOrdGreaterThan(operand1::Value, operand2::Value; result=nothing::Union owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FOrdGreaterThan", location; @@ -3198,7 +3198,7 @@ function FOrdLessThanEqual(operand1::Value, operand2::Value; result=nothing::Uni owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FOrdLessThanEqual", location; @@ -3240,7 +3240,7 @@ function FOrdLessThan(operand1::Value, operand2::Value; result=nothing::Union{No owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FOrdLessThan", location; @@ -3282,7 +3282,7 @@ function FOrdNotEqual(operand1::Value, operand2::Value; result=nothing::Union{No owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FOrdNotEqual", location; @@ -3326,7 +3326,7 @@ function FRem(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FRem", location; @@ -3367,7 +3367,7 @@ function FSub(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FSub", location; @@ -3409,7 +3409,7 @@ function FUnordEqual(operand1::Value, operand2::Value; result=nothing::Union{Not owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FUnordEqual", location; @@ -3451,7 +3451,7 @@ function FUnordGreaterThanEqual(operand1::Value, operand2::Value; result=nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FUnordGreaterThanEqual", location; @@ -3493,7 +3493,7 @@ function FUnordGreaterThan(operand1::Value, operand2::Value; result=nothing::Uni owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FUnordGreaterThan", location; @@ -3535,7 +3535,7 @@ function FUnordLessThanEqual(operand1::Value, operand2::Value; result=nothing::U owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FUnordLessThanEqual", location; @@ -3577,7 +3577,7 @@ function FUnordLessThan(operand1::Value, operand2::Value; result=nothing::Union{ owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FUnordLessThan", location; @@ -3619,7 +3619,7 @@ function FUnordNotEqual(operand1::Value, operand2::Value; result=nothing::Union{ owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.FUnordNotEqual", location; @@ -3664,8 +3664,8 @@ function func(; function_type, arg_attrs=nothing, res_attrs=nothing, sym_name, f owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("function_type", function_type), namedattribute("sym_name", sym_name), namedattribute("function_control", function_control), ] - (arg_attrs != nothing) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) - (res_attrs != nothing) && push!(attributes, namedattribute("res_attrs", res_attrs)) + !isnothing(arg_attrs) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) + !isnothing(res_attrs) && push!(attributes, namedattribute("res_attrs", res_attrs)) create_operation( "spirv.func", location; @@ -3711,7 +3711,7 @@ function FunctionCall(arguments::Vector{Value}; return_value=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("callee", callee), ] - (return_value != nothing) && push!(results, return_value) + !isnothing(return_value) && push!(results, return_value) create_operation( "spirv.FunctionCall", location; @@ -3756,7 +3756,7 @@ function GL_Acos(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Acos", location; @@ -3801,7 +3801,7 @@ function GL_Asin(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Asin", location; @@ -3846,7 +3846,7 @@ function GL_Atan(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Atan", location; @@ -3888,7 +3888,7 @@ function GL_Ceil(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Ceil", location; @@ -3931,7 +3931,7 @@ function GL_Cos(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Cos", location; @@ -3974,7 +3974,7 @@ function GL_Cosh(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Cosh", location; @@ -4017,7 +4017,7 @@ function GL_Exp(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Exp", location; @@ -4058,7 +4058,7 @@ function GL_FAbs(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.FAbs", location; @@ -4140,7 +4140,7 @@ function GL_FMax(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.FMax", location; @@ -4182,7 +4182,7 @@ function GL_FMin(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.FMin", location; @@ -4216,7 +4216,7 @@ function GL_FMix(x::Value, y::Value, a::Value; result=nothing::Union{Nothing, ML owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.FMix", location; @@ -4257,7 +4257,7 @@ function GL_FSign(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.FSign", location; @@ -4286,7 +4286,7 @@ function GL_FindUMsb(operand::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.FindUMsb", location; @@ -4328,7 +4328,7 @@ function GL_Floor(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Floor", location; @@ -4472,7 +4472,7 @@ function GL_InverseSqrt(operand::Value; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.InverseSqrt", location; @@ -4522,7 +4522,7 @@ function GL_Ldexp(x::Value, exp::Value; y=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (y != nothing) && push!(results, y) + !isnothing(y) && push!(results, y) create_operation( "spirv.GL.Ldexp", location; @@ -4566,7 +4566,7 @@ function GL_Log(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Log", location; @@ -4611,7 +4611,7 @@ function GL_Pow(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Pow", location; @@ -4654,7 +4654,7 @@ function GL_RoundEven(operand::Value; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.RoundEven", location; @@ -4698,7 +4698,7 @@ function GL_Round(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Round", location; @@ -4738,7 +4738,7 @@ function GL_SAbs(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.SAbs", location; @@ -4818,7 +4818,7 @@ function GL_SMax(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.SMax", location; @@ -4859,7 +4859,7 @@ function GL_SMin(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.SMin", location; @@ -4899,7 +4899,7 @@ function GL_SSign(operand::Value; result=nothing::Union{Nothing, MLIRType}, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.SSign", location; @@ -4942,7 +4942,7 @@ function GL_Sin(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Sin", location; @@ -4985,7 +4985,7 @@ function GL_Sinh(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Sinh", location; @@ -5026,7 +5026,7 @@ function GL_Sqrt(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Sqrt", location; @@ -5069,7 +5069,7 @@ function GL_Tan(operand::Value; result=nothing::Union{Nothing, MLIRType}, locati owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Tan", location; @@ -5112,7 +5112,7 @@ function GL_Tanh(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.Tanh", location; @@ -5192,7 +5192,7 @@ function GL_UMax(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.UMax", location; @@ -5233,7 +5233,7 @@ function GL_UMin(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GL.UMin", location; @@ -5354,17 +5354,17 @@ spirv.GlobalVariable @var2 bind(1, 2) : !spirv.ptr spirv.GlobalVariable @var3 built_in(\"GlobalInvocationId\") : !spirv.ptr, Input> ``` """ -function GlobalVariable(; type, sym_name, initializer=nothing, binding=nothing, descriptor_set=nothing, builtin=nothing, location=Location()) +function GlobalVariable(; type, sym_name, initializer=nothing, location_=nothing, binding=nothing, descriptor_set=nothing, builtin=nothing, location=Location()) results = MLIRType[] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("type", type), namedattribute("sym_name", sym_name), ] - (initializer != nothing) && push!(attributes, namedattribute("initializer", initializer)) - (location != nothing) && push!(attributes, namedattribute("location", location)) - (binding != nothing) && push!(attributes, namedattribute("binding", binding)) - (descriptor_set != nothing) && push!(attributes, namedattribute("descriptor_set", descriptor_set)) - (builtin != nothing) && push!(attributes, namedattribute("builtin", builtin)) + !isnothing(initializer) && push!(attributes, namedattribute("initializer", initializer)) + !isnothing(location) && push!(attributes, namedattribute("location", location_)) + !isnothing(binding) && push!(attributes, namedattribute("binding", binding)) + !isnothing(descriptor_set) && push!(attributes, namedattribute("descriptor_set", descriptor_set)) + !isnothing(builtin) && push!(attributes, namedattribute("builtin", builtin)) create_operation( "spirv.GlobalVariable", location; @@ -5425,7 +5425,7 @@ function GroupBroadcast(value::Value, localid::Value; result=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupBroadcast", location; @@ -5473,7 +5473,7 @@ function GroupFAdd(x::Value; result=nothing::Union{Nothing, MLIRType}, execution owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupFAdd", location; @@ -5521,7 +5521,7 @@ function GroupFMax(x::Value; result=nothing::Union{Nothing, MLIRType}, execution owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupFMax", location; @@ -5569,7 +5569,7 @@ function GroupFMin(x::Value; result=nothing::Union{Nothing, MLIRType}, execution owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupFMin", location; @@ -5618,7 +5618,7 @@ function KHR_GroupFMul(x::Value; result=nothing::Union{Nothing, MLIRType}, execu owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.KHR.GroupFMul", location; @@ -5666,7 +5666,7 @@ function GroupIAdd(x::Value; result=nothing::Union{Nothing, MLIRType}, execution owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupIAdd", location; @@ -5715,7 +5715,7 @@ function KHR_GroupIMul(x::Value; result=nothing::Union{Nothing, MLIRType}, execu owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.KHR.GroupIMul", location; @@ -5816,7 +5816,7 @@ function GroupNonUniformBroadcast(value::Value, id::Value; result=nothing::Union owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupNonUniformBroadcast", location; @@ -5853,7 +5853,7 @@ function GroupNonUniformElect(; result=nothing::Union{Nothing, MLIRType}, execut owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupNonUniformElect", location; @@ -5911,7 +5911,7 @@ function GroupNonUniformFAdd(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spirv.GroupNonUniformFAdd", location; @@ -5972,7 +5972,7 @@ function GroupNonUniformFMax(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spirv.GroupNonUniformFMax", location; @@ -6033,7 +6033,7 @@ function GroupNonUniformFMin(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spirv.GroupNonUniformFMin", location; @@ -6091,7 +6091,7 @@ function GroupNonUniformFMul(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spirv.GroupNonUniformFMul", location; @@ -6147,7 +6147,7 @@ function GroupNonUniformIAdd(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spirv.GroupNonUniformIAdd", location; @@ -6203,7 +6203,7 @@ function GroupNonUniformIMul(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spirv.GroupNonUniformIMul", location; @@ -6259,7 +6259,7 @@ function GroupNonUniformSMax(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spirv.GroupNonUniformSMax", location; @@ -6315,7 +6315,7 @@ function GroupNonUniformSMin(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spirv.GroupNonUniformSMin", location; @@ -6356,7 +6356,7 @@ function GroupNonUniformShuffleDown(value::Value, delta::Value; result=nothing:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupNonUniformShuffleDown", location; @@ -6395,7 +6395,7 @@ function GroupNonUniformShuffle(value::Value, id::Value; result=nothing::Union{N owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupNonUniformShuffle", location; @@ -6435,7 +6435,7 @@ function GroupNonUniformShuffleUp(value::Value, delta::Value; result=nothing::Un owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupNonUniformShuffleUp", location; @@ -6475,7 +6475,7 @@ function GroupNonUniformShuffleXor(value::Value, mask::Value; result=nothing::Un owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupNonUniformShuffleXor", location; @@ -6532,7 +6532,7 @@ function GroupNonUniformUMax(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spirv.GroupNonUniformUMax", location; @@ -6589,7 +6589,7 @@ function GroupNonUniformUMin(value::Value, cluster_size=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (cluster_size != nothing) && push!(operands, cluster_size) + !isnothing(cluster_size) && push!(operands, cluster_size) create_operation( "spirv.GroupNonUniformUMin", location; @@ -6638,7 +6638,7 @@ function GroupSMax(x::Value; result=nothing::Union{Nothing, MLIRType}, execution owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupSMax", location; @@ -6687,7 +6687,7 @@ function GroupSMin(x::Value; result=nothing::Union{Nothing, MLIRType}, execution owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupSMin", location; @@ -6735,7 +6735,7 @@ function GroupUMax(x::Value; result=nothing::Union{Nothing, MLIRType}, execution owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupUMax", location; @@ -6784,7 +6784,7 @@ function GroupUMin(x::Value; result=nothing::Union{Nothing, MLIRType}, execution owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.GroupUMin", location; @@ -6875,7 +6875,7 @@ function IAdd(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.IAdd", location; @@ -6917,7 +6917,7 @@ function IEqual(operand1::Value, operand2::Value; result=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.IEqual", location; @@ -6964,7 +6964,7 @@ function IMul(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.IMul", location; @@ -7010,8 +7010,8 @@ function INTEL_JointMatrixLoad(pointer::Value, stride::Value; result::MLIRType, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("layout", layout), namedattribute("scope", scope), ] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "spirv.INTEL.JointMatrixLoad", location; @@ -7061,7 +7061,7 @@ function INTEL_JointMatrixMad(a::Value, b::Value, c::Value; result=nothing::Unio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("scope", scope), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.INTEL.JointMatrixMad", location; @@ -7111,8 +7111,8 @@ function INTEL_JointMatrixStore(pointer::Value, object::Value, stride::Value; la owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("layout", layout), namedattribute("scope", scope), ] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "spirv.INTEL.JointMatrixStore", location; @@ -7149,7 +7149,7 @@ function INTEL_JointMatrixWorkItemLength(; result=nothing::Union{Nothing, MLIRTy owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("joint_matrix_type", joint_matrix_type), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.INTEL.JointMatrixWorkItemLength", location; @@ -7282,7 +7282,7 @@ function INotEqual(operand1::Value, operand2::Value; result=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.INotEqual", location; @@ -7375,7 +7375,7 @@ function ISub(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.ISub", location; @@ -7427,7 +7427,7 @@ function ImageDrefGather(sampledimage::Value, coordinate::Value, dref::Value, op owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (imageoperands != nothing) && push!(attributes, namedattribute("imageoperands", imageoperands)) + !isnothing(imageoperands) && push!(attributes, namedattribute("imageoperands", imageoperands)) create_operation( "spirv.ImageDrefGather", location; @@ -7459,7 +7459,7 @@ function Image(sampledimage::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.Image", location; @@ -7587,7 +7587,7 @@ function IsInf(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.IsInf", location; @@ -7629,7 +7629,7 @@ function IsNan(operand::Value; result=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.IsNan", location; @@ -7755,8 +7755,8 @@ function Load(ptr::Value; value::MLIRType, memory_access=nothing, alignment=noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "spirv.Load", location; @@ -7797,7 +7797,7 @@ function LogicalAnd(operand1::Value, operand2::Value; result=nothing::Union{Noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.LogicalAnd", location; @@ -7838,7 +7838,7 @@ function LogicalEqual(operand1::Value, operand2::Value; result=nothing::Union{No owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.LogicalEqual", location; @@ -7879,7 +7879,7 @@ function LogicalNotEqual(operand1::Value, operand2::Value; result=nothing::Union owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.LogicalNotEqual", location; @@ -7917,7 +7917,7 @@ function LogicalNot(operand::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.LogicalNot", location; @@ -7958,7 +7958,7 @@ function LogicalOr(operand1::Value, operand2::Value; result=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.LogicalOr", location; @@ -8087,7 +8087,7 @@ function MatrixTimesScalar(matrix::Value, scalar::Value; result=nothing::Union{N owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.MatrixTimesScalar", location; @@ -8219,8 +8219,8 @@ function module_(; addressing_model, memory_model, vce_triple=nothing, sym_name= owned_regions = Region[region_0, ] successors = Block[] attributes = NamedAttribute[namedattribute("addressing_model", addressing_model), namedattribute("memory_model", memory_model), ] - (vce_triple != nothing) && push!(attributes, namedattribute("vce_triple", vce_triple)) - (sym_name != nothing) && push!(attributes, namedattribute("sym_name", sym_name)) + !isnothing(vce_triple) && push!(attributes, namedattribute("vce_triple", vce_triple)) + !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) create_operation( "spirv.module", location; @@ -8257,7 +8257,7 @@ function NV_CooperativeMatrixLength(; result=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("cooperative_matrix_type", cooperative_matrix_type), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.NV.CooperativeMatrixLength", location; @@ -8326,7 +8326,7 @@ function NV_CooperativeMatrixLoad(pointer::Value, stride::Value, columnmajor::Va owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) create_operation( "spirv.NV.CooperativeMatrixLoad", location; @@ -8389,7 +8389,7 @@ function NV_CooperativeMatrixMulAdd(a::Value, b::Value, c::Value; result=nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.NV.CooperativeMatrixMulAdd", location; @@ -8444,7 +8444,7 @@ function NV_CooperativeMatrixStore(pointer::Value, object::Value, stride::Value, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) create_operation( "spirv.NV.CooperativeMatrixStore", location; @@ -8486,7 +8486,7 @@ function Not(operand::Value; result=nothing::Union{Nothing, MLIRType}, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.Not", location; @@ -8529,7 +8529,7 @@ function Ordered(operand1::Value, operand2::Value; result=nothing::Union{Nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.Ordered", location; @@ -8809,7 +8809,7 @@ function SDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.SDiv", location; @@ -8864,7 +8864,7 @@ function SDotAccSat(vector1::Value, vector2::Value, accumulator::Value; result:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (format != nothing) && push!(attributes, namedattribute("format", format)) + !isnothing(format) && push!(attributes, namedattribute("format", format)) create_operation( "spirv.SDotAccSat", location; @@ -8914,7 +8914,7 @@ function SDot(vector1::Value, vector2::Value; result::MLIRType, format=nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (format != nothing) && push!(attributes, namedattribute("format", format)) + !isnothing(format) && push!(attributes, namedattribute("format", format)) create_operation( "spirv.SDot", location; @@ -8956,7 +8956,7 @@ function SGreaterThanEqual(operand1::Value, operand2::Value; result=nothing::Uni owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.SGreaterThanEqual", location; @@ -8998,7 +8998,7 @@ function SGreaterThan(operand1::Value, operand2::Value; result=nothing::Union{No owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.SGreaterThan", location; @@ -9040,7 +9040,7 @@ function SLessThanEqual(operand1::Value, operand2::Value; result=nothing::Union{ owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.SLessThanEqual", location; @@ -9082,7 +9082,7 @@ function SLessThan(operand1::Value, operand2::Value; result=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.SLessThan", location; @@ -9127,7 +9127,7 @@ function SMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.SMod", location; @@ -9203,7 +9203,7 @@ function SNegate(operand::Value; result=nothing::Union{Nothing, MLIRType}, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.SNegate", location; @@ -9248,7 +9248,7 @@ function SRem(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.SRem", location; @@ -9305,7 +9305,7 @@ function SUDotAccSat(vector1::Value, vector2::Value, accumulator::Value; result: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (format != nothing) && push!(attributes, namedattribute("format", format)) + !isnothing(format) && push!(attributes, namedattribute("format", format)) create_operation( "spirv.SUDotAccSat", location; @@ -9357,7 +9357,7 @@ function SUDot(vector1::Value, vector2::Value; result::MLIRType, format=nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (format != nothing) && push!(attributes, namedattribute("format", format)) + !isnothing(format) && push!(attributes, namedattribute("format", format)) create_operation( "spirv.SUDot", location; @@ -9412,7 +9412,7 @@ function Select(condition::Value, true_value::Value, false_value::Value; result= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.Select", location; @@ -9500,7 +9500,7 @@ function ShiftLeftLogical(operand1::Value, operand2::Value; result=nothing::Unio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.ShiftLeftLogical", location; @@ -9549,7 +9549,7 @@ function ShiftRightArithmetic(operand1::Value, operand2::Value; result=nothing:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.ShiftRightArithmetic", location; @@ -9599,7 +9599,7 @@ function ShiftRightLogical(operand1::Value, operand2::Value; result=nothing::Uni owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.ShiftRightLogical", location; @@ -9825,8 +9825,8 @@ function Store(ptr::Value, value::Value; memory_access=nothing, alignment=nothin owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (memory_access != nothing) && push!(attributes, namedattribute("memory_access", memory_access)) - (alignment != nothing) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) create_operation( "spirv.Store", location; @@ -9953,7 +9953,7 @@ function UDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.UDiv", location; @@ -10010,7 +10010,7 @@ function UDotAccSat(vector1::Value, vector2::Value, accumulator::Value; result:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (format != nothing) && push!(attributes, namedattribute("format", format)) + !isnothing(format) && push!(attributes, namedattribute("format", format)) create_operation( "spirv.UDotAccSat", location; @@ -10062,7 +10062,7 @@ function UDot(vector1::Value, vector2::Value; result::MLIRType, format=nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (format != nothing) && push!(attributes, namedattribute("format", format)) + !isnothing(format) && push!(attributes, namedattribute("format", format)) create_operation( "spirv.UDot", location; @@ -10104,7 +10104,7 @@ function UGreaterThanEqual(operand1::Value, operand2::Value; result=nothing::Uni owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.UGreaterThanEqual", location; @@ -10146,7 +10146,7 @@ function UGreaterThan(operand1::Value, operand2::Value; result=nothing::Union{No owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.UGreaterThan", location; @@ -10188,7 +10188,7 @@ function ULessThanEqual(operand1::Value, operand2::Value; result=nothing::Union{ owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.ULessThanEqual", location; @@ -10230,7 +10230,7 @@ function ULessThan(operand1::Value, operand2::Value; result=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.ULessThan", location; @@ -10273,7 +10273,7 @@ function UMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, M owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.UMod", location; @@ -10394,7 +10394,7 @@ function Unordered(operand1::Value, operand2::Value; result=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.Unordered", location; @@ -10470,7 +10470,7 @@ function Variable(initializer=nothing::Union{Nothing, Value}; pointer::MLIRType, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("storage_class", storage_class), ] - (initializer != nothing) && push!(operands, initializer) + !isnothing(initializer) && push!(operands, initializer) create_operation( "spirv.Variable", location; @@ -10508,7 +10508,7 @@ function VectorExtractDynamic(vector::Value, index::Value; result=nothing::Union owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.VectorExtractDynamic", location; @@ -10558,7 +10558,7 @@ function VectorInsertDynamic(vector::Value, component::Value, index::Value; resu owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "spirv.VectorInsertDynamic", location; diff --git a/src/Dialects/16/Shape.jl b/src/Dialects/16/Shape.jl index ed709c5d..0f95c0fe 100644 --- a/src/Dialects/16/Shape.jl +++ b/src/Dialects/16/Shape.jl @@ -21,7 +21,7 @@ function add(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.add", location; @@ -88,7 +88,7 @@ function assuming_all(inputs::Vector{Value}; result=nothing::Union{Nothing, MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.assuming_all", location; @@ -175,7 +175,7 @@ function broadcast(shapes::Vector{Value}; result::MLIRType, error=nothing, locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (error != nothing) && push!(attributes, namedattribute("error", error)) + !isnothing(error) && push!(attributes, namedattribute("error", error)) create_operation( "shape.broadcast", location; @@ -230,7 +230,7 @@ function const_shape(; result=nothing::Union{Nothing, MLIRType}, shape, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("shape", shape), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.const_shape", location; @@ -255,7 +255,7 @@ function const_size(; result=nothing::Union{Nothing, MLIRType}, value, location= owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("value", value), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.const_size", location; @@ -286,7 +286,7 @@ function const_witness(; result=nothing::Union{Nothing, MLIRType}, passing, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("passing", passing), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.const_witness", location; @@ -317,7 +317,7 @@ function cstr_broadcastable(shapes::Vector{Value}; result=nothing::Union{Nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.cstr_broadcastable", location; @@ -346,7 +346,7 @@ function cstr_eq(shapes::Vector{Value}; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.cstr_eq", location; @@ -381,7 +381,7 @@ function cstr_require(pred::Value; result=nothing::Union{Nothing, MLIRType}, msg owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("msg", msg), ] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.cstr_require", location; @@ -429,7 +429,7 @@ function dim(value::Value, index::Value; extent=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (extent != nothing) && push!(results, extent) + !isnothing(extent) && push!(results, extent) create_operation( "shape.dim", location; @@ -462,7 +462,7 @@ function div(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.div", location; @@ -485,7 +485,7 @@ function from_extent_tensor(input::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.from_extent_tensor", location; @@ -514,7 +514,7 @@ function from_extents(extents::Vector{Value}; shape=nothing::Union{Nothing, MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (shape != nothing) && push!(results, shape) + !isnothing(shape) && push!(results, shape) create_operation( "shape.from_extents", location; @@ -537,9 +537,9 @@ function func(; sym_name, function_type, arg_attrs=nothing, res_attrs=nothing, s owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("function_type", function_type), ] - (arg_attrs != nothing) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) - (res_attrs != nothing) && push!(attributes, namedattribute("res_attrs", res_attrs)) - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(arg_attrs) && push!(attributes, namedattribute("arg_attrs", arg_attrs)) + !isnothing(res_attrs) && push!(attributes, namedattribute("res_attrs", res_attrs)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "shape.func", location; @@ -574,7 +574,7 @@ function function_library(; sym_name, sym_visibility=nothing, mapping, body::Reg owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("mapping", mapping), ] - (sym_visibility != nothing) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) create_operation( "shape.function_library", location; @@ -596,7 +596,7 @@ function get_extent(shape::Value, dim::Value; extent=nothing::Union{Nothing, MLI owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (extent != nothing) && push!(results, extent) + !isnothing(extent) && push!(results, extent) create_operation( "shape.get_extent", location; @@ -621,7 +621,7 @@ function index_to_size(arg::Value; result=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.index_to_size", location; @@ -655,7 +655,7 @@ function is_broadcastable(shapes::Vector{Value}; result=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.is_broadcastable", location; @@ -679,7 +679,7 @@ function max(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.max", location; @@ -722,8 +722,8 @@ function meet(arg0::Value, arg1::Value; result=nothing::Union{Nothing, MLIRType} owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (error != nothing) && push!(attributes, namedattribute("error", error)) + !isnothing(result) && push!(results, result) + !isnothing(error) && push!(attributes, namedattribute("error", error)) create_operation( "shape.meet", location; @@ -747,7 +747,7 @@ function min(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.min", location; @@ -773,7 +773,7 @@ function mul(lhs::Value, rhs::Value; result=nothing::Union{Nothing, MLIRType}, l owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.mul", location; @@ -798,7 +798,7 @@ function num_elements(shape::Value; result=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.num_elements", location; @@ -819,7 +819,7 @@ function rank(shape::Value; rank=nothing::Union{Nothing, MLIRType}, location=Loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (rank != nothing) && push!(results, rank) + !isnothing(rank) && push!(results, rank) create_operation( "shape.rank", location; @@ -915,7 +915,7 @@ function shape_eq(shapes::Vector{Value}; result=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.shape_eq", location; @@ -937,7 +937,7 @@ function shape_of(arg::Value; result=nothing::Union{Nothing, MLIRType}, location owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.shape_of", location; @@ -961,7 +961,7 @@ function size_to_index(arg::Value; result=nothing::Union{Nothing, MLIRType}, loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.size_to_index", location; @@ -1130,7 +1130,7 @@ function with_shape(operand::Value, shape::Value; result=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "shape.with_shape", location; diff --git a/src/Dialects/16/SparseTensor.jl b/src/Dialects/16/SparseTensor.jl index 8535b2b6..c6e88076 100644 --- a/src/Dialects/16/SparseTensor.jl +++ b/src/Dialects/16/SparseTensor.jl @@ -112,8 +112,8 @@ function binary(x::Value, y::Value; output::MLIRType, left_identity=nothing, rig owned_regions = Region[overlapRegion, leftRegion, rightRegion, ] successors = Block[] attributes = NamedAttribute[] - (left_identity != nothing) && push!(attributes, namedattribute("left_identity", left_identity)) - (right_identity != nothing) && push!(attributes, namedattribute("right_identity", right_identity)) + !isnothing(left_identity) && push!(attributes, namedattribute("left_identity", left_identity)) + !isnothing(right_identity) && push!(attributes, namedattribute("right_identity", right_identity)) create_operation( "sparse_tensor.binary", location; @@ -152,7 +152,7 @@ function compress(values::Value, filled::Value, added::Value, count::Value, tens owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "sparse_tensor.compress", location; @@ -392,7 +392,7 @@ function storage_specifier_get(specifier::Value; result::MLIRType, specifierKind owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("specifierKind", specifierKind), ] - (dim != nothing) && push!(attributes, namedattribute("dim", dim)) + !isnothing(dim) && push!(attributes, namedattribute("dim", dim)) create_operation( "sparse_tensor.storage_specifier.get", location; @@ -438,7 +438,7 @@ function insert(value::Value, tensor::Value, indices::Vector{Value}; result=noth owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "sparse_tensor.insert", location; @@ -482,8 +482,8 @@ function load(tensor::Value; result=nothing::Union{Nothing, MLIRType}, hasInsert owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (hasInserts != nothing) && push!(attributes, namedattribute("hasInserts", hasInserts)) + !isnothing(result) && push!(results, result) + !isnothing(hasInserts) && push!(attributes, namedattribute("hasInserts", hasInserts)) create_operation( "sparse_tensor.load", location; @@ -524,7 +524,7 @@ function new(source::Value; result::MLIRType, expandSymmetry=nothing, location=L owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (expandSymmetry != nothing) && push!(attributes, namedattribute("expandSymmetry", expandSymmetry)) + !isnothing(expandSymmetry) && push!(attributes, namedattribute("expandSymmetry", expandSymmetry)) create_operation( "sparse_tensor.new", location; @@ -554,7 +554,7 @@ function number_of_entries(tensor::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "sparse_tensor.number_of_entries", location; @@ -648,10 +648,10 @@ function push_back(curSize::Value, inBuffer::Value, value::Value, n=nothing::Uni owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (n != nothing) && push!(operands, n) - (outBuffer != nothing) && push!(results, outBuffer) - (newSize != nothing) && push!(results, newSize) - (inbounds != nothing) && push!(attributes, namedattribute("inbounds", inbounds)) + !isnothing(n) && push!(operands, n) + !isnothing(outBuffer) && push!(results, outBuffer) + !isnothing(newSize) && push!(results, newSize) + !isnothing(inbounds) && push!(attributes, namedattribute("inbounds", inbounds)) create_operation( "sparse_tensor.push_back", location; @@ -705,7 +705,7 @@ function reduce(x::Value, y::Value, identity::Value; output=nothing::Union{Nothi owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (output != nothing) && push!(results, output) + !isnothing(output) && push!(results, output) create_operation( "sparse_tensor.reduce", location; @@ -771,7 +771,7 @@ function select(x::Value; output=nothing::Union{Nothing, MLIRType}, region::Regi owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - (output != nothing) && push!(results, output) + !isnothing(output) && push!(results, output) create_operation( "sparse_tensor.select", location; @@ -801,8 +801,8 @@ function storage_specifier_set(specifier::Value, value::Value; result=nothing::U owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("specifierKind", specifierKind), ] - (result != nothing) && push!(results, result) - (dim != nothing) && push!(attributes, namedattribute("dim", dim)) + !isnothing(result) && push!(results, result) + !isnothing(dim) && push!(attributes, namedattribute("dim", dim)) create_operation( "sparse_tensor.storage_specifier.set", location; @@ -845,9 +845,9 @@ function sort_coo(n::Value, xy::Value, ys::Vector{Value}; nx=nothing, ny=nothing owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (nx != nothing) && push!(attributes, namedattribute("nx", nx)) - (ny != nothing) && push!(attributes, namedattribute("ny", ny)) - (stable != nothing) && push!(attributes, namedattribute("stable", stable)) + !isnothing(nx) && push!(attributes, namedattribute("nx", nx)) + !isnothing(ny) && push!(attributes, namedattribute("ny", ny)) + !isnothing(stable) && push!(attributes, namedattribute("stable", stable)) create_operation( "sparse_tensor.sort_coo", location; @@ -903,7 +903,7 @@ function sort(n::Value, xs::Vector{Value}, ys::Vector{Value}; stable=nothing, lo successors = Block[] attributes = NamedAttribute[] push!(attributes, operandsegmentsizes([1, length(xs), length(ys), ])) - (stable != nothing) && push!(attributes, namedattribute("stable", stable)) + !isnothing(stable) && push!(attributes, namedattribute("stable", stable)) create_operation( "sparse_tensor.sort", location; @@ -1179,7 +1179,7 @@ function yield(result=nothing::Union{Nothing, Value}; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(operands, result) + !isnothing(result) && push!(operands, result) create_operation( "sparse_tensor.yield", location; diff --git a/src/Dialects/16/Tensor.jl b/src/Dialects/16/Tensor.jl index 327e0802..6339b085 100644 --- a/src/Dialects/16/Tensor.jl +++ b/src/Dialects/16/Tensor.jl @@ -114,7 +114,7 @@ function dim(source::Value, index::Value; result=nothing::Union{Nothing, MLIRTyp owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "tensor.dim", location; @@ -216,7 +216,7 @@ function extract(tensor::Value, indices::Vector{Value}; result=nothing::Union{No owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "tensor.extract", location; @@ -439,7 +439,7 @@ function gather(source::Value, indices::Value; result::MLIRType, gather_dims, un owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("gather_dims", gather_dims), ] - (unique != nothing) && push!(attributes, namedattribute("unique", unique)) + !isnothing(unique) && push!(attributes, namedattribute("unique", unique)) create_operation( "tensor.gather", location; @@ -511,7 +511,7 @@ function insert(scalar::Value, dest::Value, indices::Vector{Value}; result=nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "tensor.insert", location; @@ -583,7 +583,7 @@ function insert_slice(source::Value, dest::Value, offsets::Vector{Value}, sizes: successors = Block[] attributes = NamedAttribute[namedattribute("static_offsets", static_offsets), namedattribute("static_sizes", static_sizes), namedattribute("static_strides", static_strides), ] push!(attributes, operandsegmentsizes([1, 1, length(offsets), length(sizes), length(strides), ])) - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "tensor.insert_slice", location; @@ -638,10 +638,10 @@ function pack(source::Value, dest::Value, padding_value=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("inner_dims_pos", inner_dims_pos), namedattribute("static_inner_tiles", static_inner_tiles), ] - (padding_value != nothing) && push!(operands, padding_value) + !isnothing(padding_value) && push!(operands, padding_value) push!(attributes, operandsegmentsizes([1, 1, (padding_value==nothing) ? 0 : 1length(inner_tiles), ])) - (result != nothing) && push!(results, result) - (outer_dims_perm != nothing) && push!(attributes, namedattribute("outer_dims_perm", outer_dims_perm)) + !isnothing(result) && push!(results, result) + !isnothing(outer_dims_perm) && push!(attributes, namedattribute("outer_dims_perm", outer_dims_perm)) create_operation( "tensor.pack", location; @@ -730,7 +730,7 @@ function pad(source::Value, low::Vector{Value}, high::Vector{Value}; result::MLI successors = Block[] attributes = NamedAttribute[namedattribute("static_low", static_low), namedattribute("static_high", static_high), ] push!(attributes, operandsegmentsizes([1, length(low), length(high), ])) - (nofold != nothing) && push!(attributes, namedattribute("nofold", nofold)) + !isnothing(nofold) && push!(attributes, namedattribute("nofold", nofold)) create_operation( "tensor.pad", location; @@ -835,7 +835,7 @@ function rank(tensor::Value; result_0=nothing::Union{Nothing, MLIRType}, locatio owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "tensor.rank", location; @@ -1000,7 +1000,7 @@ function scatter(source::Value, dest::Value, indices::Value; result::MLIRType, s owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("scatter_dims", scatter_dims), ] - (unique != nothing) && push!(attributes, namedattribute("unique", unique)) + !isnothing(unique) && push!(attributes, namedattribute("unique", unique)) create_operation( "tensor.scatter", location; @@ -1080,8 +1080,8 @@ function unpack(source::Value, dest::Value, inner_tiles::Vector{Value}; result=n owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("inner_dims_pos", inner_dims_pos), namedattribute("static_inner_tiles", static_inner_tiles), ] - (result != nothing) && push!(results, result) - (outer_dims_perm != nothing) && push!(attributes, namedattribute("outer_dims_perm", outer_dims_perm)) + !isnothing(result) && push!(results, result) + !isnothing(outer_dims_perm) && push!(attributes, namedattribute("outer_dims_perm", outer_dims_perm)) create_operation( "tensor.unpack", location; diff --git a/src/Dialects/16/Tosa.jl b/src/Dialects/16/Tosa.jl index f4d0dcdb..53bdd8da 100644 --- a/src/Dialects/16/Tosa.jl +++ b/src/Dialects/16/Tosa.jl @@ -126,7 +126,7 @@ function avg_pool2d(input::Value; output::MLIRType, kernel, stride, pad, quantiz owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kernel", kernel), namedattribute("stride", stride), namedattribute("pad", pad), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.avg_pool2d", location; @@ -354,7 +354,7 @@ function const_(; output=nothing::Union{Nothing, MLIRType}, value, location=Loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("value", value), ] - (output != nothing) && push!(results, output) + !isnothing(output) && push!(results, output) create_operation( "tosa.const", location; @@ -376,7 +376,7 @@ function conv2d(input::Value, weight::Value, bias::Value; output::MLIRType, pad, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.conv2d", location; @@ -397,7 +397,7 @@ function conv3d(input::Value, weight::Value, bias::Value; output::MLIRType, pad, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.conv3d", location; @@ -456,7 +456,7 @@ function depthwise_conv2d(input::Value, weight::Value, bias::Value; output::MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.depthwise_conv2d", location; @@ -498,7 +498,7 @@ function equal(input1::Value, input2::Value; output=nothing::Union{Nothing, MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (output != nothing) && push!(results, output) + !isnothing(output) && push!(results, output) create_operation( "tosa.equal", location; @@ -559,7 +559,7 @@ function fully_connected(input::Value, weight::Value, bias::Value; output::MLIRT owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.fully_connected", location; @@ -745,7 +745,7 @@ function logical_not(input1::Value; output=nothing::Union{Nothing, MLIRType}, lo owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (output != nothing) && push!(results, output) + !isnothing(output) && push!(results, output) create_operation( "tosa.logical_not", location; @@ -831,7 +831,7 @@ function matmul(a::Value, b::Value; c::MLIRType, quantization_info=nothing, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.matmul", location; @@ -938,7 +938,7 @@ function negate(input1::Value; output::MLIRType, quantization_info=nothing, loca owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.negate", location; @@ -959,8 +959,8 @@ function pad(input1::Value, padding::Value, pad_const=nothing::Union{Nothing, Va owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (pad_const != nothing) && push!(operands, pad_const) - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(pad_const) && push!(operands, pad_const) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.pad", location; @@ -1478,7 +1478,7 @@ function transpose_conv2d(input::Value, filter::Value, bias::Value; output::MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("out_pad", out_pad), namedattribute("stride", stride), namedattribute("out_shape", out_shape), ] - (quantization_info != nothing) && push!(attributes, namedattribute("quantization_info", quantization_info)) + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) create_operation( "tosa.transpose_conv2d", location; diff --git a/src/Dialects/16/Transform.jl b/src/Dialects/16/Transform.jl index d975106c..f78a44f7 100644 --- a/src/Dialects/16/Transform.jl +++ b/src/Dialects/16/Transform.jl @@ -72,7 +72,7 @@ function alternatives(scope=nothing::Union{Nothing, Value}; results::Vector{MLIR owned_regions = Region[alternatives..., ] successors = Block[] attributes = NamedAttribute[] - (scope != nothing) && push!(operands, scope) + !isnothing(scope) && push!(operands, scope) create_operation( "transform.alternatives", location; @@ -240,8 +240,8 @@ function merge_handles(handles::Vector{Value}; result=nothing::Union{Nothing, ML owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) - (deduplicate != nothing) && push!(attributes, namedattribute("deduplicate", deduplicate)) + !isnothing(result) && push!(results, result) + !isnothing(deduplicate) && push!(attributes, namedattribute("deduplicate", deduplicate)) create_operation( "transform.merge_handles", location; @@ -299,8 +299,8 @@ function print(target=nothing::Union{Nothing, Value}; name=nothing, location=Loc owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (target != nothing) && push!(operands, target) - (name != nothing) && push!(attributes, namedattribute("name", name)) + !isnothing(target) && push!(operands, target) + !isnothing(name) && push!(attributes, namedattribute("name", name)) create_operation( "transform.print", location; @@ -387,7 +387,7 @@ function sequence(root=nothing::Union{Nothing, Value}; results::Vector{MLIRType} owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[namedattribute("failure_propagation_mode", failure_propagation_mode), ] - (root != nothing) && push!(operands, root) + !isnothing(root) && push!(operands, root) create_operation( "transform.sequence", location; @@ -468,7 +468,7 @@ function with_pdl_patterns(root=nothing::Union{Nothing, Value}; body::Region, lo owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - (root != nothing) && push!(operands, root) + !isnothing(root) && push!(operands, root) create_operation( "transform.with_pdl_patterns", location; @@ -500,4 +500,1761 @@ function yield(operands::Vector{Value}; location=Location()) ) end +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`affine_simplify_bounded_affine_ops` + +Simplify the targeted affine.min / affine.max ops given the supplied +lower and upper bounds for values that may be used as target op operands. + +# Example +``` +%0 = transform.structured.match ops{[\"affine.min\", \"affine.max\"]} in %arg1 +%1 = transform.structured.match ops{[\"gpu.lane_id\"]} in %arg1 +transform.affine.simplify_bounded_affine_ops %0 with [%1] within [0] and [32] + +// Multiple bounds can be specified. +transform.affine.simplify_bounded_affine_ops %0 with [%1, %2] within [0, 5] and [32, 50] +``` + +Bounded op handles (`%1` and `%2) must be mapped to ops that have a single +result of index type. The sets of target ops and bounded ops must not +overlap. + +#### Return modes + +Target ops must be affine.min or affine.max ops. This transform consumes the +target handle and does not produce any handle. It reads the bounded op +handles. + +TODO: Support affine.apply targets. +TODO: Allow mixed PDL_Operation/int64_t for lower_bounds and upper_bounds. +""" +function affine_simplify_bounded_affine_ops(target::Value, bounded_values::Vector{Value}; lower_bounds, upper_bounds, location=Location()) + results = MLIRType[] + operands = Value[target, bounded_values..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("lower_bounds", lower_bounds), namedattribute("upper_bounds", upper_bounds), ] + + create_operation( + "transform.affine.simplify_bounded_affine_ops", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`bufferization_empty_tensor_to_alloc_tensor` + +Replace a tensor.empty with a bufferization.tensor_alloc. + +#### Return modes + +This operation consumes the `target` handle and produces the `transformed` +handle. `target` is expected to be a `tensor.empty` operation. The transform +always succeeds. +""" +function bufferization_empty_tensor_to_alloc_tensor(target::Value; transformed::MLIRType, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "transform.bufferization.empty_tensor_to_alloc_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`bufferization_one_shot_bufferize` + +Indicates that the given `target` op should be bufferized with One-Shot +Bufferize. The bufferization can be configured with various attributes that +corresponding to options in `BufferizationOptions` and the +`one-shot-bufferize` pass. More information can be found in the pass +documentation. + +If `target_is_module` is set, `target` must be a module. In that case the +`target` handle can be reused by other transform ops. When bufferizing other +ops, the `target` handled is freed after bufferization and can no longer be +used. + +Note: Only ops that implement `BufferizableOpInterface` are bufferized. All +other ops are ignored if `allow_unknown_ops`. If `allow_unknown_ops` is +unset, this transform fails when an unknown/non-bufferizable op is found. +Many ops implement `BufferizableOpInterface` via an external model. These +external models must be registered when applying this transform op; +otherwise, said ops would be considered non-bufferizable. +""" +function bufferization_one_shot_bufferize(target::Value; function_boundary_type_conversion=nothing, allow_return_allocs=nothing, allow_unknown_ops=nothing, bufferize_function_boundaries=nothing, create_deallocs=nothing, target_is_module=nothing, test_analysis_only=nothing, print_conflicts=nothing, location=Location()) + results = MLIRType[] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(function_boundary_type_conversion) && push!(attributes, namedattribute("function_boundary_type_conversion", function_boundary_type_conversion)) + !isnothing(allow_return_allocs) && push!(attributes, namedattribute("allow_return_allocs", allow_return_allocs)) + !isnothing(allow_unknown_ops) && push!(attributes, namedattribute("allow_unknown_ops", allow_unknown_ops)) + !isnothing(bufferize_function_boundaries) && push!(attributes, namedattribute("bufferize_function_boundaries", bufferize_function_boundaries)) + !isnothing(create_deallocs) && push!(attributes, namedattribute("create_deallocs", create_deallocs)) + !isnothing(target_is_module) && push!(attributes, namedattribute("target_is_module", target_is_module)) + !isnothing(test_analysis_only) && push!(attributes, namedattribute("test_analysis_only", test_analysis_only)) + !isnothing(print_conflicts) && push!(attributes, namedattribute("print_conflicts", print_conflicts)) + + create_operation( + "transform.bufferization.one_shot_bufferize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`gpu_map_foreach_to_blocks` + +Target the gpu_launch op and rewrite the top level `scf.foreach_thread` +to distributed gpu.block_id attribute. If `generate_gpu_launch` attribute +is set, then first generates `gpu_launch` and moves the top level +`scf.foreach_thread` inside. + +The operation searches top level `scf.foreach_thread` ops under +`gpu_launch` and maps each such op to GPU blocks. Mapping is +one-to-one and the induction variables of `scf.foreach_thread` are +rewritten to gpu.block_id according to the `thread_dim_mapping` attribute. + +Dynamic, `scf.foreach_thread` trip counts are currently not supported. +Dynamic block dim sizes are currently not supported. + +Only **bufferized** scf.foreach_thread are currently supported. +Only scf.foreach_thread distributed to **at most 3 dimensions** are +currently supported. + +The operation alters the block size of the given gpu_launch using +gridDim argument. + +#### Return modes: + +This operation ignores non-gpu_launch ops and drops them in the return. + +If any scf.foreach_thread with tensors is found, the transform definitely +fails. + +If all the scf.foreach_thread operations contained within the LaunchOp +referred to by the `target` PDLOperation lower to GPU properly, the +transform succeeds. Otherwise the transform definitely fails. + +The returned handle points to the same LaunchOp operand, consuming it and +producing a new SSA value to satisfy chaining and linearity of the IR +properties. +""" +function gpu_map_foreach_to_blocks(target::Value; result::MLIRType, gridDim=nothing, generate_gpu_launch=nothing, location=Location()) + results = MLIRType[result, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(gridDim) && push!(attributes, namedattribute("gridDim", gridDim)) + !isnothing(generate_gpu_launch) && push!(attributes, namedattribute("generate_gpu_launch", generate_gpu_launch)) + + create_operation( + "transform.gpu.map_foreach_to_blocks", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`gpu_map_nested_foreach_to_threads` + +Target the `gpu.launch op` and rewrite all `scf.foreach_thread` +nested in it to distributed `gpu.thread_id` attribute. + +The operation searches for `scf.foreach_thread` ops nested under `target` +and maps each such op to GPU threads. Mapping is one-to-one and the +induction variables of `scf.foreach_thread` are rewritten to +`gpu.thread_id` according to the `mapping` attribute. + +Sibling `scf.foreach_thread` are supported in which case, the union of +the number of threads is computed and may result in predication. + +Multiple scf.foreach_thread are supported per `gpu.launch` in which case, +the max of all the threads is computed and taken for the global +`gpu.thread_id`. If necessary, `scf.foreach_thread` that do not use the +whole thread range result in predicated computations. + +Dynamic `scf.foreach_thread` trip counts are currently not supported. +Dynamic block dim sizes are currently not supported. + +Only **bufferized** `scf.foreach_thread` are currently supported. +Only `scf.foreach_thread` distributed to **at most 3 dimensions** are +currently supported. + +Barriers are inserted after each scf.foreach_thread op for now. + +The operation alters the block size of the given gpu_launch using +blockDim argument. + +#### Return modes: + +This operation ignores non-gpu_launch ops and drops them in the return. + +If any scf.foreach_thread with tensors is found, the transform definitely +fails. + +If all the scf.foreach_thread operations contained within the LaunchOp +referred to by the `target` PDLOperation lower to GPU properly, the +transform succeeds. Otherwise the transform definitely fails. + +The returned handle points to the same LaunchOp operand, consuming it and +producing a new SSA value to satisfy chaining and linearity of the IR +properties. + +#### Example: + +``` +gpu.launch blocks(%bx, %by, %bz) in (%x = %0, %y = %1, %z = %2) + threads(%tx, %ty, %tz) in (%tx = %3, %ty = %4, %tz = %5) { + scf.foreach_thread (%i, %j) in (7, 9) { + ... // body 1 + } {mapping = [#gpu.thread, #gpu.thread, #gpu.thread]} + scf.foreach_thread (%i) in (12) { + ... // body 2 + } {mapping = [#gpu.thread]} + gpu.terminator +} +``` +is translated to: + +``` +%bdimX = arith.constant 12 : index +%bdimY = arith.constant 9 : index +gpu.launch blocks(%bx, %by, %bz) in (%x = %0, %y = %1, %z = %2) + threads(%tx, %ty, %tz) in (%tx = %bdimX, %ty = %bdimY, %tz = %5) { + if (threadIdx.x < 9 && threadIdx.y < 7) { + ... // body 1 + } + gpu.barrier + if (threadIdx.y < 1) { + ... // body 2 + } + gpu.barrier + gpu.terminator +} +``` +""" +function gpu_map_nested_foreach_to_threads(target::Value; result::MLIRType, blockDim=nothing, syncAfterDistribute=nothing, location=Location()) + results = MLIRType[result, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(blockDim) && push!(attributes, namedattribute("blockDim", blockDim)) + !isnothing(syncAfterDistribute) && push!(attributes, namedattribute("syncAfterDistribute", syncAfterDistribute)) + + create_operation( + "transform.gpu.map_nested_foreach_to_threads", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`structured_decompose` + +Decomposes named complex operations, such as higher-dimensional +(depthwise) convolutions, into combinations of lower-dimensional equivalents +when possible. + +#### Return modes + +This operation ignores non-Linalg ops and drops them in the return. +If all the operations referred to by the `target` PDLOperation decompose +properly, the transform succeeds. Otherwise the transform silently fails. +The return handle points to only the subset of successfully produced +computational operations, which can be empty. +""" +function structured_decompose(target::Value; transformed::MLIRType, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "transform.structured.decompose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_fuse_into_containing_op` + +Fuses the `producer_op` into the `containing_op`. +Returns a handle to the fused ops. + +The producer is typically a slice of a tileable op (i.e., implements +TilingInterface). In that case, this transform computes the accessed +producer slice inside of the containing op (\"tile and fuse\"). Otherwise, +the entire producer is cloned inside the containing op (\"clone and fuse\"). + +The containing op handle must be associated with exactly one payload op. The +producer op handle may be associated with multiple payload ops. This +transform fuses producers one-by-one, always picking an unspecified producer +that has at least one use inside the containing op among the +producers. + +Note: If a producer has multiple uses inside the containing op, it is +currently tiled and/or cloned multiple times into the containing op. +TODO: Reuse already fused OpResults instead of tiling/cloning a second time +when possible. Fuse producers according to a topological sorting to achieve +the largest amount of reuse. + +#### Return modes + +If at least one producer could not be fused, this operation fails silently. +This is the case when tiling fails or when no producer op could be found +among the remaining producers that has at least one use within the +containing op. I.e., \"producers\" that are not consumed within the containing +op are rejected by this operation. + +This operation reads and frees the producer handle. +This operation reads the containing op handle. +""" +function structured_fuse_into_containing_op(producer_op::Value, containing_op::Value; fused_op::MLIRType, location=Location()) + results = MLIRType[fused_op, ] + operands = Value[producer_op, containing_op, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "transform.structured.fuse_into_containing_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_fuse` + +Tiles the operations pointed to by the target handle and fuses their +producers greedily using the options provided as attributes. +""" +function structured_fuse(target::Value; transformed::MLIRType, loops::Vector{MLIRType}, tile_sizes=nothing, tile_interchange=nothing, location=Location()) + results = MLIRType[transformed, loops..., ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + !isnothing(tile_interchange) && push!(attributes, namedattribute("tile_interchange", tile_interchange)) + + create_operation( + "transform.structured.fuse", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_generalize` + +Transforms a named structured operation into the generic form with the +explicit attached region. + +#### Return modes + +This operation ignores non-Linalg ops and drops them in the return. +If all the operations referred to by the `target` PDLOperation generalize +properly, the transform succeeds. Otherwise the transform silently fails. +The return handle points to only the subset of successfully produced +equivalent generic operations, which can be empty or contain the original +ops if they were already in generic form. +""" +function structured_generalize(target::Value; transformed::MLIRType, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "transform.structured.generalize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_interchange` + +Interchanges the iterators of the operations pointed to by the target handle +using the iterator interchange attribute. + +#### Return modes + +This operation ignores non-linalg::Generic ops and drops them in the return. +This operation fails if the interchange attribute is invalid. +If all the operations referred to by the `target` PDLOperation interchange +properly, the transform succeeds. +If any interchange fails, the transform definitely fails. +The return handle points to only the subset of successfully produced +interchanged operations, which can be empty. +""" +function structured_interchange(target::Value; transformed::MLIRType, iterator_interchange=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(iterator_interchange) && push!(attributes, namedattribute("iterator_interchange", iterator_interchange)) + + create_operation( + "transform.structured.interchange", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_masked_vectorize` + +Vectorize the target ops, which must be Linalg ops, with masked vectors +of the specified size. + +The vector sizes can be either static or dynamic (SSA values). In case of +SSA values, the handle must be mapped to exactly one payload op with +exactly one index-typed result. + +#### Return modes: + +This operation produces a definite failure if the dynamic vector sizes (SSA +values) do not satify the constraints mentioned above. It produces a +silenceable failure if at least one target op is not a Linalg op or fails to +vectorize. +""" +function structured_masked_vectorize(target::Value, vector_sizes::Vector{Value}; static_vector_sizes=nothing, location=Location()) + results = MLIRType[] + operands = Value[target, vector_sizes..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_vector_sizes) && push!(attributes, namedattribute("static_vector_sizes", static_vector_sizes)) + + create_operation( + "transform.structured.masked_vectorize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_match` + +Match op with the specified constraints, within the target op. + +The following constraints are supported: + - interface: an optional MatchInterfaceEnum specifying an enum + representation for an interface to target. + - ops: an optional StrArrayAttr specifying the concrete name of an op. + Multiple names can be specified. Matched ops must have one of specified + names. + - attribute: the matched op must have all specified attributes (with their + specified values). + - filter_result_type: the matched op must return exactly this one type. + +Note: Only ops that satisfy all specified constraints are matched. + +TODO: Extend with regions to allow a limited form of constraints. + +#### Return modes + +This op traverses the ops nested under `target` and returns the handles to +all the operations that match the requirements. + +This op fails if the target is not a handle to exactly one operation. +Otherwise it succeeds. + +This operation does not consume the target handle and produces new handles: +it is a navigation op. +""" +function structured_match(target::Value; results::MLIRType, ops=nothing, interface=nothing, op_attrs=nothing, filter_result_type=nothing, location=Location()) + results = MLIRType[results, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ops) && push!(attributes, namedattribute("ops", ops)) + !isnothing(interface) && push!(attributes, namedattribute("interface", interface)) + !isnothing(op_attrs) && push!(attributes, namedattribute("op_attrs", op_attrs)) + !isnothing(filter_result_type) && push!(attributes, namedattribute("filter_result_type", filter_result_type)) + + create_operation( + "transform.structured.match", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_multitile_sizes` + +Emits the IR computing the tile sizes `s1` and `s2` such that: + + - there exists a combination of `n` tiles of size `s1` and `m` tiles of + size `s2` that covers the entirety of the iteration space `dimension` of + the target structured op; + - `s1`, `s2` is less than or equal to `target_size`; + - `s1` and `s2` are divisible by `divisor. + +For example, for a dimension of size 54 with target size 12 and divisor 2, +this can emit the IR computing the tile size 10, used for 3 tiles, and 12, +used for 2 tiles, totally 10*3 + 12*2 = 54. Note that when the divisor does +not divide the original dimension size, it is impossible to compute such +tile sizes. An assertion is emitted to guard against this in the dynamic +case. + +Expects the target size and the divisor to be strictly positive. Folds the +IR as much as possible, normally obtaining constant sizes and numbers of +tiles for a statically known dimension. + +This does *not* consume the target handle and produces three handles each +pointing to single-result index-typed operations (which may be arithmetic +constant operations) defining the two respective tile sizes and the product +of the first tile size with the number of tiles of that size (useful for +splitting the iteration space). + +This operation composes with the regular tiling when applied per-dimension: + +```mlir +%sz1, %sz2, %split = structured.multitile_sizes %target + { target_size = 10, dimension = 1 } + : !transform.any_op, !transform.param, + !transform.param, !transform.param +%low, %high = structured.split %target after %split { dimension = 1 } + : !transform.any_op, !transform.param +%tiled_low, %loop1 = structured.tile %low [0, %sz1] + : (!transform.any_op, !transform.param) + -> (!transform.any_op, !transform.any_op) +%tiled_high, %loop2 = structured.tile %high [0, %sz2] + : (!transform.any_op, !transform.param) + -> (!transform.any_op, !transform.any_op) +%common = merge_handles %tiled_low, %tiled_high : !transform.any_op + +%sz3, %sz4, %split = structured.multitile_size %target + { target_size = 42, dimension = 0 } + : !transform.any_op, !transform.any_op, + !transform.any_op, !transform.any_op +%sz3r, %sz4r, %splitr = replicate num(%common) %sz3, %sz4, %splitr + : !transform.any_op, !transform.any_op, !transform.any_op +structured.split %common after %splitr { dimension = 0 } + : !transform.any_op, !transform.any_op +// ... +``` +""" +function structured_multitile_sizes(target::Value; low_size::MLIRType, high_size::MLIRType, split_point::MLIRType, dimension, target_size, divisor=nothing, location=Location()) + results = MLIRType[low_size, high_size, split_point, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), namedattribute("target_size", target_size), ] + !isnothing(divisor) && push!(attributes, namedattribute("divisor", divisor)) + + create_operation( + "transform.structured.multitile_sizes", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_pack` + +Pack a LinalgOp by applying a data tiling transformation on the op and +packing the operands according to the `packed_sizes` specification. + +Iterator dimensions are tiled in their canonical order in the op spec. +Operands are packed according to the same canonical order of the op iterator +dimensions. + +Specifying a packed size of 0 for an iterator removes it from consideration +for packing. + +`tensor.pack` (resp. `tensor.unpack`) operations are inserted for the operands +(resp. results) that need to be packed (resp. unpacked) according to the +`packed_sizes` specification. + +#### Example + +Consider a `linalg.matmul` with indexing maps: +``` + // M N K M K + // affine_map<(d0, d1, d2) -> (d0, d2)> + // K N + // affine_map<(d0, d1, d2) -> (d2, d1)> + // M N + // affine_map<(d0, d1, d2) -> (d0, d1)> + %0 = linalg.matmul ins(%A, %B: tensor, tensor) + outs( %C: tensor) +``` + +Specifying packed_sizes [2, 3, 4] results in tiling the iterator dimensions +M, N and K, in this order, in both the op and its operands. +``` + // M N K m n k M K m k + // affine_map<(d0, d1, d2, d3, d4, d5) -> (d0, d2, d3, d5)> + // K N n k + // affine_map<(d0, d1, d2, d3, d4, d5) -> (d2, d1, d4, d5)> + // M N m n + // affine_map<(d0, d1, d2, d3, d4, d5) -> (d0, d1, d3, d4)> + %0 = linalg.generic_representing_some_higher_d_matmul + ins(%A, %B: tensor, tensor) + outs( %C: tensor) +``` +In particular, note that the second operand `B` has shape `KxNxnxk` (and not +`KxNxkxn` as one could expect by looking **only** at the operand). + +Other layouts can be obtained unsurprisingly from this canonical +transformation by composing the resulting operation with a (future) +`transform.structured.pack_transpose` op. +This composition allows separating concerns and composes better compared +to adding additional permutation attributes to this transform op. + +#### Return modes + +This operation applies to a single Linalg op, otherwise it fails. +This operation may produce a definiteFailure if the packing fails for any +reason. + +The returned handle point to the packed LinalgOp. +""" +function structured_pack(target::Value, packed_sizes::Vector{Value}; packed_op::MLIRType, static_packed_sizes=nothing, location=Location()) + results = MLIRType[packed_op, ] + operands = Value[target, packed_sizes..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_packed_sizes) && push!(attributes, namedattribute("static_packed_sizes", static_packed_sizes)) + + create_operation( + "transform.structured.pack", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_pack_transpose` + +Apply a transposition to a single `tensor.pack` (resp. `tensor.unpack`) and +update the `linalg.generic` op that consumes (resp. produces) the operation. + +This transform allows composing a simple `structured.pack` with additional +transpositions to e.g. match the data format required by a specific library +call or ISA instruction. + +The transpose spec must specify at least one of `outer_perm` or `inner_perm` +attributes, which will act upon the `outer_dims_perm` or `inner_dims_pos` of +the specified `tensor.pack` or `tensor.unpack` op. + +If the `target` of this op is a `tensor.pack` then a new `tensor.empty` will +be created along with transposed versions of the `tensor.pack` and the +consuming `linalg.generic`, which is expected to be the sole consumer. + +If the `target` of this op is a `tensor.unpack` then the whole pack / compute +/ unpack chain will be transposed and transposed clones of `tensor.pack`, +the consuming `linalg.generic` and the tail `tensor.pack` will be created. + +#### Return modes + +This operation targets a single `tensor.pack` / `tensor.unpack` op and a +single matching `linalg.generic` that consumes / produces the op. Otherwise, +it produces a silenceableFailure. + +This operation may produce a silenceableFailure if the transpose spec is +ill-formed (i.e. `outer_perm` or `inner_perm` are not permutations of the +proper rank) or if the tranposition of all involved operations fails for any +reason. + +This operation returns 3 handles, one to the transformed LinalgOp, one to +the transformed `tensor.pack` and one to the transformed `tensor.unpack`. +The last handle for `tensor.unpack` is empty if `target_pack_or_unpack_op` +was not itself a `tensor.unpack`. +""" +function structured_pack_transpose(target_pack_or_un_pack_op::Value, target_linalg_op::Value; packed_op::MLIRType, pack_op::MLIRType, un_pack_op::MLIRType, outer_perm=nothing, inner_perm=nothing, location=Location()) + results = MLIRType[packed_op, pack_op, un_pack_op, ] + operands = Value[target_pack_or_un_pack_op, target_linalg_op, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(outer_perm) && push!(attributes, namedattribute("outer_perm", outer_perm)) + !isnothing(inner_perm) && push!(attributes, namedattribute("inner_perm", inner_perm)) + + create_operation( + "transform.structured.pack_transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_pad` + +Pads the operations pointed to by the target handle using the options +provides as operation attributes. + +#### Return modes + +This operation ignores non-Linalg ops and drops them in the return. +This operation may produce a definiteFailure if the padding fails for any +reason. +If all the operations referred to by the `target` PDLOperation pad +properly, the transform succeeds. Otherwise the transform silently fails. +The return handle points to only the subset of successfully produced +padded operations, which can be empty. +""" +function structured_pad(target::Value; transformed::MLIRType, padding_values=nothing, padding_dimensions=nothing, pack_paddings=nothing, hoist_paddings=nothing, transpose_paddings=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(padding_values) && push!(attributes, namedattribute("padding_values", padding_values)) + !isnothing(padding_dimensions) && push!(attributes, namedattribute("padding_dimensions", padding_dimensions)) + !isnothing(pack_paddings) && push!(attributes, namedattribute("pack_paddings", pack_paddings)) + !isnothing(hoist_paddings) && push!(attributes, namedattribute("hoist_paddings", hoist_paddings)) + !isnothing(transpose_paddings) && push!(attributes, namedattribute("transpose_paddings", transpose_paddings)) + + create_operation( + "transform.structured.pad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_promote` + +Promotes the specified operands of the target into a separate memory buffer. + +At this point, this transform does not allow customizing alloc/dealloc +functions nor the behavior on copy in/out operations. + +#### Return modes + +This operation applies to a single Linalg op that satisfies the +`promoteSubviewsPrecondition`, otherwise it fails. + +If the operations referred to by the `target` PDLOperation promote +properly, the transform succeeds. + +When successful, the return handle points to the \$target operation that +was modified inplace. +""" +function structured_promote(target::Value; transformed::MLIRType, operands_to_promote=nothing, use_full_tile_buffers=nothing, use_full_tiles_by_default=nothing, use_alloca=nothing, alignment=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(operands_to_promote) && push!(attributes, namedattribute("operands_to_promote", operands_to_promote)) + !isnothing(use_full_tile_buffers) && push!(attributes, namedattribute("use_full_tile_buffers", use_full_tile_buffers)) + !isnothing(use_full_tiles_by_default) && push!(attributes, namedattribute("use_full_tiles_by_default", use_full_tiles_by_default)) + !isnothing(use_alloca) && push!(attributes, namedattribute("use_alloca", use_alloca)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + create_operation( + "transform.structured.promote", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_replace` + +Replace all `target` payload ops with the single op that is contained in +this op\'s region. All targets must have zero arguments and must be isolated +from above. + +This op is for debugging/experiments only. + +#### Return modes + +This operation consumes the `target` handle. +""" +function structured_replace(target::Value; replacement::MLIRType, bodyRegion::Region, location=Location()) + results = MLIRType[replacement, ] + operands = Value[target, ] + owned_regions = Region[bodyRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "transform.structured.replace", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_scalarize` + +Indicates that ops of a specific kind in the given function should be +scalarized (i.e. their dynamic dimensions tiled by 1). + +#### Return modes: + +This operation ignores non-Linalg ops and drops them in the return. +This operation produces `definiteFailure` if the scalarization fails for any +reason. +If all the operations referred to by the `target` PDLOperation scalarize +properly, the transform succeeds. Otherwise the transform silently fails. + +The return handle points to only the subset of successfully produced +tiled-by-1 operations, which can be empty. + +This operation does not return handles to the tiled loop. +We make this design choice because it is hard to know ahead of time the +number of loops that will be produced (it depends on the number of dynamic +dimensions after multiple transformations have been applied). +Loops can always be recovered by navigating from the tiled operations if +needed. +""" +function structured_scalarize(target::Value; result::MLIRType, location=Location()) + results = MLIRType[result, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "transform.structured.scalarize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_split` + +Indicates that the given `target` op should be split into two complementary +parts, which combined cover the entire iteration domain of the original op. +The split is performed along the iteration space dimension provided as +attribute. In case of dimension overflow, the transformation fails. The +split is performed at the dimension iterator value specified as either the +static split point attribute when it is known at transform IR construction +time or as the handle to an operation producing a single index-typed value +when it is computed by payload IR. In the latter case, the static split +point must be set to `ShapedType::kDynamic` and the dynamic size handle +must point to as many value-producing operations as there are structured +operations pointed to by the target handle. + +The operation consumes the target handle, but preserves the split point +handle if provided. It produces two new handles pointing to the two parts +of the structured op after splitting, in the same order as the target +operand, with the first handle corresponding to the part with lower +iteration space indices. +""" +function structured_split(target::Value, dynamic_split_point=nothing::Union{Nothing, Value}; first::MLIRType, second::MLIRType, dimension, static_split_point, location=Location()) + results = MLIRType[first, second, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), namedattribute("static_split_point", static_split_point), ] + !isnothing(dynamic_split_point) && push!(operands, dynamic_split_point) + + create_operation( + "transform.structured.split", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_split_reduction` + +Indicates that the given `target` op should be transformed with the +`splitReduction` transformation and split factor provided as attribute. + +The `splitReduction` transformation splits the first single linalg op +reduction into a parallel and reduction dimension. +A new `linalg.generic` op is created to perform the rest of the reduction. + +The transformation supports different configurations attributes: + - split_factor: the factor by which to split (i.e. the size of the + remaining reduction after splitting). + - insert_split_dimension: the dimension in the temporary tensor into + which the new parallel dimension is inserted. + - inner_parallel: specifies whether the parallel dimension is before or + after the reduction dimension in the splitting op. + - use_scaling_algorithm: whether to use a scaling based formulation that + does not create an ExpandShapeOp (default: do not use scaling) + - use_alloc: whether to use an alloc op to allocate the temporary + tensor (default: do not use alloc op) + +#### Return modes + +This operation ignores non-Linalg ops and drops them in the return. +This operation produces `definiteFailure` if the splitting fails for any +reason. + +If all the operations referred to by the `target` PDLOperation split +properly, the transform succeeds. Otherwise the transform silently fails. +The 4 returned handles points to only the subset of successfully produced +computational operations, which can all be empty. +This 4 returned handles point to: + - the init op (or tensor_alloc op if use_alloc = true), + - the fill op used to initialize the neutral element, + - the split op and + - the result-combining op. + +#### Example (default: `use_scaling_algorithm = false, use_alloc = false`): + +``` + %r = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, + affine_map<(d0) -> ()>], + iterator_types = [\"reduction\"]} + ins(%in : tensor<32xf32>) + outs(%out : tensor) { + ^bb0(%arg1: f32, %arg2: f32): + %y = arith.addf %arg1, %arg2 : f32 + linalg.yield %y : f32 + } -> tensor +``` + +is split into: + +``` + %cst = arith.constant 0.000000e+00 : f32 + %0 = tensor.expand_shape %in [[0, 1]] : tensor<32xf32> into tensor<4x8xf32> + %1 = tensor.empty() : tensor<4xf32> + %2 = linalg.fill ins(%cst : f32) outs(%1 : tensor<4xf32>) -> tensor<4xf32> + %3 = linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, + affine_map<(d0, d1) -> (d0)>], + iterator_types = [\"parallel\", \"reduction\"]} + ins(%0 : tensor<4x8xf32>) outs(%2 : tensor<4xf32>) { + ^bb0(%arg3: f32, %arg5: f32): + %5 = arith.addf %arg3, %arg4 : f32 + linalg.yield %5 : f32 + } -> tensor<4xf32> + %r = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, + affine_map<(d0) -> ()>], + iterator_types = [\"reduction\"]} + ins(%3 : tensor<4xf32>) outs(%out : tensor) { + ^bb0(%arg3: f32, %arg4: f32): + %5 = arith.addf %arg3, %arg4 : f32 + linalg.yield %5 : f32 + } -> tensor +``` + +#### Example (`use_scaling_algorithm = true, use_alloc = true`): + +Instead of introducing an ExpandShapeOp, this scaling-based implementation +rewrites a reduction dimension `k` into `k * split_factor + kk`. +The dimension `kk` is added as an extra parallel dimension to the +intermediate output tensor at position `insert_split_dimension`. + +Consider a minimal example where `k` is reduced: + O(i, j) += I(i, j, k) +Assume i=3, j=5, k=128, split_factor=16 and insert_split_dimension=0. +The compute is rewritten as: + a. O_i(kk, i, j) += I(i, j, 16 * k + kk) + b. O(i, j) += O_i(kk, i, j) +The intermediate tensor O_i is of shape (128/16)x3x5 == 8x3x5. + +#### Example: + +``` + %0 = linalg.matmul ins(%A, %B: tensor<16x256xf32>, tensor<256x32xf32>) + outs(%C: tensor<16x32xf32>) -> tensor<16x32xf32> +``` + +Is transformed to: + +``` + #map0 = affine_map<(d0, d1, d2, d3) -> (d0, d2 * 4 + d3)> + #map1 = affine_map<(d0, d1, d2, d3) -> (d2 * 4 + d3, d1)> + #map2 = affine_map<(d0, d1, d2, d3) -> (d2, d3)> + #map3 = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)> + #map4 = affine_map<(d0, d1, d2) -> (d0, d1, d2)> + #map5 = affine_map<(d0, d1, d2) -> (d0, d1)> + %0 = tensor.empty() : tensor<16x32x64xf32> + %cst = arith.constant 0.000000e+00 : f32 + %1 = linalg.fill ins(%cst : f32) outs(%0 : tensor<16x32x64xf32>) -> + tensor<16x32x64xf32> + %2 = tensor.empty() : tensor<64x4xi1> + + %3 = linalg.generic {indexing_maps = [#map0, #map1, #map2, #map3], + iterator_types = [\"parallel\", \"parallel\", \"parallel\", \"reduction\"]} + ins(%A, %B, %2 : tensor<16x256xf32>, tensor<256x32xf32>, tensor<64x4xi1>) + outs(%1 : tensor<16x32x64xf32>) { + ^bb0(%arg3: f32, %arg4: f32, %arg5: i1, %arg6: f32): + %5 = arith.mulf %arg3, %arg4 : f32 + %6 = arith.addf %arg6, %5 : f32 + linalg.yield %6 : f32 + } -> tensor<16x32x64xf32> + + %4 = linalg.generic {indexing_maps = [#map4, #map5], + iterator_types = [\"parallel\", \"parallel\", \"reduction\"]} + ins(%3 : tensor<16x32x64xf32>) + outs(%C : tensor<16x32xf32>) { + ^bb0(%arg3: f32, %arg4: f32): + %5 = arith.addf %arg3, %arg4 : f32 + linalg.yield %5 : f32 + } -> tensor<16x32xf32> + + return %4 : tensor<16x32xf32> +``` +""" +function structured_split_reduction(target::Value; init_or_alloc_op::MLIRType, fill_op::MLIRType, split_linalg_op::MLIRType, combining_linalg_op::MLIRType, split_factor=nothing, insert_split_dimension=nothing, inner_parallel=nothing, use_scaling_algorithm=nothing, use_alloc=nothing, location=Location()) + results = MLIRType[init_or_alloc_op, fill_op, split_linalg_op, combining_linalg_op, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(split_factor) && push!(attributes, namedattribute("split_factor", split_factor)) + !isnothing(insert_split_dimension) && push!(attributes, namedattribute("insert_split_dimension", insert_split_dimension)) + !isnothing(inner_parallel) && push!(attributes, namedattribute("inner_parallel", inner_parallel)) + !isnothing(use_scaling_algorithm) && push!(attributes, namedattribute("use_scaling_algorithm", use_scaling_algorithm)) + !isnothing(use_alloc) && push!(attributes, namedattribute("use_alloc", use_alloc)) + + create_operation( + "transform.structured.split_reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_tile` + +Indicates that the given `target` op should be tiled with the given sizes. +This transform generates a loop nest with a smaller (\"tiled\") target +operation in its body. Currently limited to LinalgOps. + +Tile sizes may be known at transformation time, in which case they are +expected to be provided in the `static_size` attribute, or not, in which +case the tile value must be computed by the payload IR and the handle to the +operation computing it must be provided through `dynamic_sizes`. When the +sizes are not known statically, the corresponding entry in the +`static_sizes` attribute must be set to `ShapedType::kDynamic`. Only +the dynamic sizes must be provided in `dynamic_sizes`, i.e., there should +be as many handles as `ShapedType::kDynamic` values in the +`static_sizes` attribute. A static size of `0` indicates that the dimension +should not be tiled. No loop will be generated for such dimensions. If all +tile sizes are `0`, this transform is effectively a no-op. + +This op returns handles to the tiled op (in the generated loop nest) and the +generated loops. The number of loops is the number of tile sizes that are +statically known to be non-zero. + +#### Return modes + +On success, the resulting handles are associated with co-indexed lists of +tiled operations and loops around them. + +This operation only supports Linalg ops and produces a silenceable failure +if the input contains any non-Linalg ops. The ops preceding it in the list +associated with the `target` handle will have been tiled. + +This operation produces a silenceable failure if the `dynamic_sizes` handles +are associated with lists of payload operations of a size different than +that of the list associated with the `target` handle. + +If the internal implementation of tiling for any of the operations fails, +produces a definite failure. +""" +function structured_tile(target::Value, dynamic_sizes::Vector{Value}; tiled_linalg_op::MLIRType, loops::Vector{MLIRType}, static_sizes=nothing, interchange=nothing, location=Location()) + results = MLIRType[tiled_linalg_op, loops..., ] + operands = Value[target, dynamic_sizes..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_sizes) && push!(attributes, namedattribute("static_sizes", static_sizes)) + !isnothing(interchange) && push!(attributes, namedattribute("interchange", interchange)) + + create_operation( + "transform.structured.tile", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_tile_reduction_using_foreach_thread` + +Tile a PartialReductionOpInterface op to a tiled `scf.foreach_thread` doing +partial reduction. + +This transformation tiles the `target` along the reduction dimensions. It +creates a tensor initialized with the identity value. Then it creates a +`scf.foreach_thread` loops with the number threads given by `num_threads`. +The op is tiled op with a size equal to `floordiv(size, num_threads)`. +All the partial reduction value is are parallel inserted to create a new +tensor. After the loop a merge operation is created to do a final reduction +with the partial reductions tensor. +If an extra `tile_sizes` parameter is passed the tiles are cyclically +distributed on the threads of the `scf.foreach_threads` loop. + +#### Return modes + +This 4 returned handles point to: + - the parent foreach_thread op, + - the fill op used to initialize the neutral element, + - the parallel tiled op and + - the result-combining op. + +#### Example: + +``` + %red = linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, + affine_map<(d0, d1) -> (d0)>], + iterator_types = [\"parallel\", \"reduction\"]} + ins(%arg0 : tensor) + outs(%out : tensor) { + ^bb0(%arg7: f32, %arg9: f32): + %1 = arith.addf %arg7, %arg9 : f32 + linalg.yield %1 : f32 + } -> tensor + return %red : tensor +``` + +is transformed into: + +``` + %0 = tensor.empty(%dim_1) : tensor + %1 = linalg.fill ins(%cst : f32) outs(%0 : tensor) -> tensor + %2 = scf.foreach_thread (%arg2) in (%c5) shared_outs(%arg3 = %1) -> (tensor) { + %4 = affine.min #map(%arg2)[%dim_0] + %5 = affine.max #map1(%4) + %extracted_slice = tensor.extract_slice %arg3[0, %arg2] [%dim, 1] [1, 1] : tensor to tensor + %6 = affine.apply #map2(%arg2)[%dim_0] + %extracted_slice_2 = tensor.extract_slice %arg0[0, %6] [%dim, %5] [1, 1] : tensor to tensor + %extracted_slice_3 = tensor.extract_slice %extracted_slice[0] [%dim] [1] : tensor to tensor + %7 = linalg.generic {indexing_maps = [#map3, #map4], iterator_types = [\"parallel\", \"reduction\"]} ins(%extracted_slice_2 : tensor) outs(%extracted_slice_3 : tensor) { + ^bb0(%in: f32, %out: f32): + %9 = arith.addf %in, %out : f32 + linalg.yield %9 : f32 + } -> tensor + scf.foreach_thread.perform_concurrently { + tensor.parallel_insert_slice %7 into %arg3[0, %arg2] [%dim, 1] [1, 1] : tensor into tensor + } + } {mapping = []} + %3 = linalg.generic {indexing_maps = [#map3, #map4], iterator_types = [\"parallel\", \"reduction\"]} ins(%2 : tensor) outs(%arg1 : tensor) { + ^bb0(%in: f32, %out: f32): + %4 = arith.addf %in, %out : f32 + linalg.yield %4 : f32 + } -> tensor +``` +""" +function structured_tile_reduction_using_foreach_thread(target::Value; foreach_thread_op::MLIRType, fill_op::MLIRType, split_linalg_op::MLIRType, combining_linalg_op::MLIRType, num_threads=nothing, tile_sizes=nothing, mapping=nothing, location=Location()) + results = MLIRType[foreach_thread_op, fill_op, split_linalg_op, combining_linalg_op, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(num_threads) && push!(attributes, namedattribute("num_threads", num_threads)) + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + !isnothing(mapping) && push!(attributes, namedattribute("mapping", mapping)) + + create_operation( + "transform.structured.tile_reduction_using_foreach_thread", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_tile_reduction_using_scf` + +Indicates that the given `target` op should be transformed with the +`tileReduction` transformation with the tile size provided as attribute. + +This transformation tiles the `target` along the reduction dimensions. It +creates a tensor initialized with the identity value. Then it creates nested +loops with a parallel version of `target` op inside. The parallel op +dimensions are less or equal to the tile size passed by user. +After the loop a merge operation is created to do a final reduction with the +partial reductions. +The initial tensor always uses the tile size dimension. This may overallocate +if the tile size is greater than the reduction dimension. + +#### Return modes + +This 4 returned handles point to: + - the parent for op, + - the fill op used to initialize the neutral element, + - the parallel tiled op and + - the result-combining op. + +#### Example: + +``` + %red = linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, + affine_map<(d0, d1) -> (d0)>], + iterator_types = [\"parallel\", \"reduction\"]} + ins(%arg0 : tensor) + outs(%out : tensor) { + ^bb0(%arg7: f32, %arg9: f32): + %1 = arith.addf %arg7, %arg9 : f32 + linalg.yield %1 : f32 + } -> tensor + return %red : tensor +``` + +is transformed into: + +``` + %0 = tensor.empty(%dim_1) : tensor + %1 = linalg.fill ins(%cst : f32) outs(%0 : tensor) -> tensor + %2 = scf.for %arg2 = %c0 to %dim_0 step %c5 iter_args(%arg3 = %1) -> (tensor) { + %extracted_slice = tensor.extract_slice %1[0, 0] [%dim, 5] [1, 1] : tensor to tensor + %extracted_slice_2 = tensor.extract_slice %arg0[0, %arg2] [%dim, 5] [1, 1] : tensor to tensor + %4 = linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, + affine_map<(d0, d1) -> (d0, d1)>], + iterator_types = [\"parallel\", \"parallel\"]} + ins(%extracted_slice_2 : tensor) + outs(%extracted_slice : tensor) { + ^bb0(%in: f32, %out: f32): + %5 = arith.addf %in, %out : f32 + linalg.yield %5 : f32 + } -> tensor + %dim_3 = tensor.dim %1, %c0 : tensor + %inserted_slice = tensor.insert_slice %4 into %arg3[0, 0] [%dim_3, 5] [1, 1] : tensor into tensor + scf.yield %inserted_slice : tensor + } + %3 = linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, + affine_map<(d0, d1) -> (d0)>], + iterator_types = [\"parallel\", \"reduction\"]} + ins(%2 : tensor) + outs(%arg1 : tensor) { + ^bb0(%in: f32, %out: f32): + %4 = arith.addf %in, %out : f32 + linalg.yield %4 : f32 + } -> tensor +``` +""" +function structured_tile_reduction_using_scf(target::Value; for_op::MLIRType, fill_op::MLIRType, split_linalg_op::MLIRType, combining_linalg_op::MLIRType, tile_sizes=nothing, location=Location()) + results = MLIRType[for_op, fill_op, split_linalg_op, combining_linalg_op, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + + create_operation( + "transform.structured.tile_reduction_using_scf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_tile_to_foreach_thread_op` + +Tile a TilingInterface op to a tiled `scf.foreach_thread`. + +Tiling is applied by either specifying `num_threads` or `tile_size`. If +`num_threads` is specified, then the tile size for each dimension `i` is +calculated dynamically via `ceilDiv(dimSize[i], num_threads[i])`. +`num_threads` and `tile_size` can be either static index attributes or SSA +values of PDL operation handle type (or a mix thereof). Operation handles +must be mapped to exactly one op that has exactly one result of index type. + +Static zero tile sizes indicate that the dimension is not tiled and can be +thought of as tiling by the full size of data. + +It is the user\'s responsibility to ensure that `num_threads/tile_sizes` is +a valid tiling specification (i.e. that only tiles parallel dimensions, +e.g. in the Linalg case). + +If non-empty, the `mapping` is added as an attribute to the +resulting `scf.foreach_thread`. + +Note: `tile_sizes` and `num_threads` are variadic. Each tile size/number of +threads can be an index attribute or a transform handle that is mapped to +exactly one payload op with exactly one index result. + +#### Return modes + +This operation ignores ops that do not implement the TilingInterface and +drops them in the return. + +If all the operations referred to by the `target` PDLOperation tile +successfully, the transform succeeds. +Otherwise the transform silently fails. + +The two returned handles point to only the subset of successfully produced +tiled operations, which can all be empty. + +These two returned handles point to: + - the new scf.foreach_thread op, + - the tiled op that implements TilingInterface. + +#### Example using `num_threads` + +``` +%0 = pdl_match @match_matmul in %arg1 +%3:2 = transform.structured.tile_to_foreach_thread_op %0 num_threads [10, 20] +``` + +#### Example using `tile_sizes` + +``` +%0 = pdl_match @match_matmul in %arg1 +%sz = pdl_match @match_size_op in %arg1 +%3:2 = transform.structured.tile_to_foreach_thread_op %0 tile_sizes [0, %sz, 20] +``` +""" +function structured_tile_to_foreach_thread_op(target::Value, num_threads::Vector{Value}, tile_sizes::Vector{Value}, packed_num_threads=nothing::Union{Nothing, Value}; packed_tile_sizes=nothing::Union{Nothing, Value}, foreach_thread_op::MLIRType, tiled_op::MLIRType, static_num_threads=nothing, static_tile_sizes=nothing, mapping=nothing, location=Location()) + results = MLIRType[foreach_thread_op, tiled_op, ] + operands = Value[target, num_threads..., tile_sizes..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(packed_num_threads) && push!(operands, packed_num_threads) + !isnothing(packed_tile_sizes) && push!(operands, packed_tile_sizes) + push!(attributes, operandsegmentsizes([1, length(num_threads), length(tile_sizes), (packed_num_threads==nothing) ? 0 : 1(packed_tile_sizes==nothing) ? 0 : 1])) + !isnothing(static_num_threads) && push!(attributes, namedattribute("static_num_threads", static_num_threads)) + !isnothing(static_tile_sizes) && push!(attributes, namedattribute("static_tile_sizes", static_tile_sizes)) + !isnothing(mapping) && push!(attributes, namedattribute("mapping", mapping)) + + create_operation( + "transform.structured.tile_to_foreach_thread_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_tile_to_scf_for` + +Indicates that the given `target` op should be tiled with the given sizes. +This transform generates a loop nest with a smaller (\"tiled\") target +operation in its body. The target must implement TilingInterface. + +Tile sizes may be known at transformation time, in which case they are +expected to be provided in the `static_size` attribute, or not, in which +case the tile value must be computed by the payload IR and the handle to the +operation computing it must be provided through `dynamic_sizes`. When the +sizes are not known statically, the corresponding entry in the +`static_sizes` attribute must be set to `ShapedType::kDynamic`. Only +the dynamic sizes must be provided in `dynamic_sizes`, i.e., there should +be as many handles as `ShapedType::kDynamic` values in the +`static_sizes` attribute. A static size of `0` indicates that the dimension +should not be tiled. No loop will be generated for such dimensions. If all +tile sizes are `0`, this transform is effectively a no-op. + +This op returns handles to the tiled op (in the generated loop nest) and the +generated loops. The number of loops is the number of tile sizes that are +statically known to be non-zero. + +#### Return modes + +On success, the resulting handles are associated with co-indexed lists of +tiled operations and loops around them. + +This operation only supports TilingInterface ops and produces a silenceable +failure if the input contains any non-TilingInterface ops. The ops preceding +it in the list associated with the `target` handle will have been tiled. + +This operation produces a silenceable failure if the `dynamic_sizes` handles +are associated with lists of payload operations of a size different than +that of the list associated with the `target` handle. + +If the internal implementation of tiling for any of the operations fails, +produces a definite failure. +""" +function structured_tile_to_scf_for(target::Value, dynamic_sizes::Vector{Value}; tiled_linalg_op::MLIRType, loops::Vector{MLIRType}, static_sizes=nothing, interchange=nothing, location=Location()) + results = MLIRType[tiled_linalg_op, loops..., ] + operands = Value[target, dynamic_sizes..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_sizes) && push!(attributes, namedattribute("static_sizes", static_sizes)) + !isnothing(interchange) && push!(attributes, namedattribute("interchange", interchange)) + + create_operation( + "transform.structured.tile_to_scf_for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`structured_vectorize` + +Indicates that the given `target` op all the ops it contains should be +vectorized with the configuration specified by the attributes of this op. +This vectorization only handles structured ops that operate on shaped types +and does not vectorize loops or straight-line. Internally, it applies a +set of rewrite patterns, some of which enable vectorization and some of +which clean up the results. Therefore, it can only be applied to an op with +the \"isolated from above property\". If finer granularity is required, it can +be achieved by outlining the target part of the payload IR into, e.g., a +function, performing the transformation, and inlining it back. This +transformation only fails if the entire pattern rewriting failed, i.e., it +does **not** fail when no ops were vectorized. + +Note that this transformation is invalidating the handles to any payload IR +operation that is contained inside the vectorization target. + +This transformation supports the following attributes: + - `vectorize_padding`: a UnitAttr to activate the vectorization of + `tensor.pad` ops. Different pipelines may prefer to lower such ops to + loops. + - `disable_multi_reduction_to_contract_patterns`: a UnitAttr to deactivate + the rewrite of `vector.multi_reduction` to `vector.contract`. This is + intended to be used in tests only. + - `disable_transfer_permutation_map_lowering_patterns`: a UnitAttr to + deactivate the rewrite of `vector.transfer` with permutation maps into + explicit `vector.transpose` operations. This is intended to be used in + tests only but may be promotoed to a first class attribute in the future. + +#### Return modes: + +This operation produces `definiteFailure` if vectorization fails for any +reason. +The operation always returns the handle to the target op that is expected +to be isolated from above. +""" +function structured_vectorize(target::Value; transformed::MLIRType, vectorize_padding=nothing, vectorize_nd_extract=nothing, disable_multi_reduction_to_contract_patterns=nothing, disable_transfer_permutation_map_lowering_patterns=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(vectorize_padding) && push!(attributes, namedattribute("vectorize_padding", vectorize_padding)) + !isnothing(vectorize_nd_extract) && push!(attributes, namedattribute("vectorize_nd_extract", vectorize_nd_extract)) + !isnothing(disable_multi_reduction_to_contract_patterns) && push!(attributes, namedattribute("disable_multi_reduction_to_contract_patterns", disable_multi_reduction_to_contract_patterns)) + !isnothing(disable_transfer_permutation_map_lowering_patterns) && push!(attributes, namedattribute("disable_transfer_permutation_map_lowering_patterns", disable_transfer_permutation_map_lowering_patterns)) + + create_operation( + "transform.structured.vectorize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`memref_multibuffer` + +Transformation to do multi-buffering/array expansion to remove +dependencies on the temporary allocation between consecutive loop +iterations. This transform expands the size of an allocation by +a given multiplicative factor and fixes up any users of the +multibuffered allocation. + +#### Return modes + +This operation returns the new allocation if multi-buffering +succeeds, and failure otherwise. +""" +function memref_multibuffer(target::Value; transformed::MLIRType, factor, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("factor", factor), ] + + create_operation( + "transform.memref.multibuffer", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`loop_get_parent_for` + +Produces a handle to the n-th (default 1) parent `scf.for` or `affine.for` +(when the affine flag is true) loop for each Payload IR operation +associated with the operand. Fails if such a loop cannot be found. The list +of operations associated with the handle contains parent operations in the +same order as the list associated with the operand, except for operations +that are parents to more than one input which are only present once. +""" +function loop_get_parent_for(target::Value; parent::MLIRType, num_loops=nothing, affine=nothing, location=Location()) + results = MLIRType[parent, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(num_loops) && push!(attributes, namedattribute("num_loops", num_loops)) + !isnothing(affine) && push!(attributes, namedattribute("affine", affine)) + + create_operation( + "transform.loop.get_parent_for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`loop_coalesce` + +Given a perfect loop nest identified by the outermost loop, +perform loop coalescing in a bottom-up one-by-one manner. + +#### Return modes + +The return handle points to the coalesced loop if coalescing happens, or +the given input loop if coalescing does not happen. +""" +function loop_coalesce(target::Value; transformed::MLIRType, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + create_operation( + "transform.loop.coalesce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`loop_outline` + +Moves the loop into a separate function with the specified name and +replaces the loop in the Payload IR with a call to that function. Takes +care of forwarding values that are used in the loop as function arguments. +If the operand is associated with more than one loop, each loop will be +outlined into a separate function. The provided name is used as a _base_ +for forming actual function names following SymbolTable auto-renaming +scheme to avoid duplicate symbols. Expects that all ops in the Payload IR +have a SymbolTable ancestor (typically true because of the top-level +module). Returns the handle to the list of outlined functions in the same +order as the operand handle. +""" +function loop_outline(target::Value; transformed::MLIRType, func_name, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("func_name", func_name), ] + + create_operation( + "transform.loop.outline", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`loop_peel` + +Updates the given loop so that its step evenly divides its range and puts +the remaining iteration into a separate loop or a conditional. + +In the absence of sufficient static information, this op may peel a loop, +even if the step always divides the range evenly at runtime. + +#### Return modes + +This operation ignores non-scf::ForOp ops and drops them in the return. + +This operation always succeeds and returns the scf::ForOp with the +postcondition: \"the loop trip count is divisible by the step\". +This operation may return the same unmodified loop handle when peeling did +not modify the IR (i.e. the loop trip count was already divisible). + +Note that even though the Payload IR modification may be performed +in-place, this operation consumes the operand handle and produces a new +one. + +TODO: Return both the peeled loop and the remainder loop. +""" +function loop_peel(target::Value; transformed::MLIRType, fail_if_already_divisible=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(fail_if_already_divisible) && push!(attributes, namedattribute("fail_if_already_divisible", fail_if_already_divisible)) + + create_operation( + "transform.loop.peel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`loop_pipeline` + +Transforms the given loops one by one to achieve software pipelining for +each of them. That is, performs some amount of reads from memory before the +loop rather than inside the loop, the same amount of writes into memory +after the loop, and updates each iteration to read the data for a following +iteration rather than the current one. + +The amount is specified by the attributes. + +The values read and about to be stored are transferred as loop iteration +arguments. Currently supports memref and vector transfer operations as +memory reads/writes. + +#### Return modes + +This operation ignores non-scf::For ops and drops them in the return. +If all the operations referred to by the `target` PDLOperation pipeline +properly, the transform succeeds. Otherwise the transform silently fails. +The return handle points to only the subset of successfully produced +pipelined loops, which can be empty. +""" +function loop_pipeline(target::Value; transformed::MLIRType, iteration_interval=nothing, read_latency=nothing, location=Location()) + results = MLIRType[transformed, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(iteration_interval) && push!(attributes, namedattribute("iteration_interval", iteration_interval)) + !isnothing(read_latency) && push!(attributes, namedattribute("read_latency", read_latency)) + + create_operation( + "transform.loop.pipeline", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`loop_unroll` + +Unrolls each loop associated with the given handle to have up to the given +number of loop body copies per iteration. If the unroll factor is larger +than the loop trip count, the latter is used as the unroll factor instead. + +#### Return modes + +This operation ignores non-scf::For, non-affine::For ops and drops them in +the return. If all the operations referred to by the `target` PDLOperation +unroll properly, the transform succeeds. Otherwise the transform silently +fails. + +Does not return handles as the operation may result in the loop being +removed after a full unrolling. +""" +function loop_unroll(target::Value; factor, location=Location()) + results = MLIRType[] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("factor", factor), ] + + create_operation( + "transform.loop.unroll", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType +import ..Dialects: namedattribute, operandsegmentsizes +import ...API + + +""" +`vector_lower_vectors` + +Indicates that the vector operations nested under the isolated from above op +`target` should be lowered to finer-grained vector primitives. + +At this time, the transform is all or nothing. + +This is usally a late step that is run after bufferization as part of the +process of lowering to e.g. LLVM or NVVM. +""" +function vector_lower_vectors(target::Value; results::MLIRType, contraction_lowering=nothing, multireduction_lowering=nothing, split_transfers=nothing, transpose_lowering=nothing, transpose_avx2_lowering=nothing, unroll_vector_transfers=nothing, location=Location()) + results = MLIRType[results, ] + operands = Value[target, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(contraction_lowering) && push!(attributes, namedattribute("contraction_lowering", contraction_lowering)) + !isnothing(multireduction_lowering) && push!(attributes, namedattribute("multireduction_lowering", multireduction_lowering)) + !isnothing(split_transfers) && push!(attributes, namedattribute("split_transfers", split_transfers)) + !isnothing(transpose_lowering) && push!(attributes, namedattribute("transpose_lowering", transpose_lowering)) + !isnothing(transpose_avx2_lowering) && push!(attributes, namedattribute("transpose_avx2_lowering", transpose_avx2_lowering)) + !isnothing(unroll_vector_transfers) && push!(attributes, namedattribute("unroll_vector_transfers", unroll_vector_transfers)) + + create_operation( + "transform.vector.lower_vectors", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + end # transform diff --git a/src/Dialects/16/Vector.jl b/src/Dialects/16/Vector.jl index 3f4351de..caa5461e 100644 --- a/src/Dialects/16/Vector.jl +++ b/src/Dialects/16/Vector.jl @@ -25,7 +25,7 @@ function vscale(; res=nothing::Union{Nothing, MLIRType}, location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "vector.vscale", location; @@ -336,7 +336,7 @@ function contract(lhs::Value, rhs::Value, acc::Value, masks::Vector{Value}; resu owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] - (kind != nothing) && push!(attributes, namedattribute("kind", kind)) + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) create_operation( "vector.contract", location; @@ -465,8 +465,8 @@ function extractelement(vector::Value, position=nothing::Union{Nothing, Value}; owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (position != nothing) && push!(operands, position) - (result != nothing) && push!(results, result) + !isnothing(position) && push!(operands, position) + !isnothing(result) && push!(results, result) create_operation( "vector.extractelement", location; @@ -495,7 +495,7 @@ function extract(vector::Value; result_0=nothing::Union{Nothing, MLIRType}, posi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("position", position), ] - (result_0 != nothing) && push!(results, result_0) + !isnothing(result_0) && push!(results, result_0) create_operation( "vector.extract", location; @@ -569,7 +569,7 @@ function fma(lhs::Value, rhs::Value, acc::Value; result=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (result != nothing) && push!(results, result) + !isnothing(result) && push!(results, result) create_operation( "vector.fma", location; @@ -690,8 +690,8 @@ function insertelement(source::Value, dest::Value, position=nothing::Union{Nothi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (position != nothing) && push!(operands, position) - (result != nothing) && push!(results, result) + !isnothing(position) && push!(operands, position) + !isnothing(result) && push!(results, result) create_operation( "vector.insertelement", location; @@ -721,7 +721,7 @@ function insert(source::Value, dest::Value; res=nothing::Union{Nothing, MLIRType owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("position", position), ] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "vector.insert", location; @@ -759,7 +759,7 @@ function insert_strided_slice(source::Value, dest::Value; res=nothing::Union{Not owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("offsets", offsets), namedattribute("strides", strides), ] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "vector.insert_strided_slice", location; @@ -894,7 +894,7 @@ function mask(mask::Value, passthru=nothing::Union{Nothing, Value}; results::Vec owned_regions = Region[maskRegion, ] successors = Block[] attributes = NamedAttribute[] - (passthru != nothing) && push!(operands, passthru) + !isnothing(passthru) && push!(operands, passthru) create_operation( "vector.mask", location; @@ -1055,7 +1055,7 @@ function multi_reduction(source::Value, acc::Value; dest=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dims", reduction_dims), ] - (dest != nothing) && push!(results, dest) + !isnothing(dest) && push!(results, dest) create_operation( "vector.multi_reduction", location; @@ -1121,7 +1121,7 @@ function outerproduct(lhs::Value, rhs::Value, acc::Vector{Value}; result_0::MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (kind != nothing) && push!(attributes, namedattribute("kind", kind)) + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) create_operation( "vector.outerproduct", location; @@ -1198,7 +1198,7 @@ function reduction(vector::Value, acc=nothing::Union{Nothing, Value}; dest::MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kind", kind), ] - (acc != nothing) && push!(operands, acc) + !isnothing(acc) && push!(operands, acc) create_operation( "vector.reduction", location; @@ -1381,7 +1381,7 @@ function scalable_insert(source::Value, dest::Value; res=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("pos", pos), ] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "vector.scalable.insert", location; @@ -1414,8 +1414,8 @@ function scan(source::Value, initial_value::Value; dest=nothing::Union{Nothing, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dim", reduction_dim), namedattribute("inclusive", inclusive), ] - (dest != nothing) && push!(results, dest) - (accumulated_value != nothing) && push!(results, accumulated_value) + !isnothing(dest) && push!(results, dest) + !isnothing(accumulated_value) && push!(results, accumulated_value) create_operation( "vector.scan", location; @@ -1564,7 +1564,7 @@ function shuffle(v1::Value, v2::Value; vector=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("mask", mask), ] - (vector != nothing) && push!(results, vector) + !isnothing(vector) && push!(results, vector) create_operation( "vector.shuffle", location; @@ -1849,9 +1849,9 @@ function transfer_read(source::Value, indices::Vector{Value}, padding::Value, ma owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] - (mask != nothing) && push!(operands, mask) + !isnothing(mask) && push!(operands, mask) push!(attributes, operandsegmentsizes([1, length(indices), 1, (mask==nothing) ? 0 : 1])) - (in_bounds != nothing) && push!(attributes, namedattribute("in_bounds", in_bounds)) + !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) create_operation( "vector.transfer_read", location; @@ -1966,10 +1966,10 @@ function transfer_write(vector::Value, source::Value, indices::Vector{Value}, ma owned_regions = Region[] successors = Block[] attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] - (mask != nothing) && push!(operands, mask) + !isnothing(mask) && push!(operands, mask) push!(attributes, operandsegmentsizes([1, 1, length(indices), (mask==nothing) ? 0 : 1])) - (result != nothing) && push!(results, result) - (in_bounds != nothing) && push!(attributes, namedattribute("in_bounds", in_bounds)) + !isnothing(result) && push!(results, result) + !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) create_operation( "vector.transfer_write", location; diff --git a/src/Dialects/16/X86Vector.jl b/src/Dialects/16/X86Vector.jl index 43f5bd89..2e18f0a6 100644 --- a/src/Dialects/16/X86Vector.jl +++ b/src/Dialects/16/X86Vector.jl @@ -15,7 +15,7 @@ function avx_intr_dp_ps_256(a::Value, b::Value, c::Value; res=nothing::Union{Not owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx.intr.dp.ps.256", location; @@ -49,7 +49,7 @@ function avx_intr_dot(a::Value, b::Value; res=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx.intr.dot", location; @@ -69,7 +69,7 @@ function avx512_intr_mask_compress(a::Value, src::Value, k::Value; res=nothing:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.compress", location; @@ -100,9 +100,9 @@ function avx512_mask_compress(k::Value, a::Value, src=nothing::Union{Nothing, Va owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (src != nothing) && push!(operands, src) - (dst != nothing) && push!(results, dst) - (constant_src != nothing) && push!(attributes, namedattribute("constant_src", constant_src)) + !isnothing(src) && push!(operands, src) + !isnothing(dst) && push!(results, dst) + !isnothing(constant_src) && push!(attributes, namedattribute("constant_src", constant_src)) create_operation( "x86vector.avx512.mask.compress", location; @@ -132,7 +132,7 @@ function avx512_mask_rndscale(src::Value, k::Value, a::Value, imm::Value, roundi owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (dst != nothing) && push!(results, dst) + !isnothing(dst) && push!(results, dst) create_operation( "x86vector.avx512.mask.rndscale", location; @@ -152,7 +152,7 @@ function avx512_intr_mask_rndscale_pd_512(src::Value, k::Value, a::Value, imm::V owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.rndscale.pd.512", location; @@ -172,7 +172,7 @@ function avx512_intr_mask_rndscale_ps_512(src::Value, k::Value, a::Value, imm::V owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.rndscale.ps.512", location; @@ -202,7 +202,7 @@ function avx512_mask_scalef(src::Value, a::Value, b::Value, k::Value, rounding:: owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (dst != nothing) && push!(results, dst) + !isnothing(dst) && push!(results, dst) create_operation( "x86vector.avx512.mask.scalef", location; @@ -222,7 +222,7 @@ function avx512_intr_mask_scalef_pd_512(src::Value, a::Value, b::Value, k::Value owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.scalef.pd.512", location; @@ -242,7 +242,7 @@ function avx512_intr_mask_scalef_ps_512(src::Value, a::Value, b::Value, k::Value owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx512.intr.mask.scalef.ps.512", location; @@ -262,7 +262,7 @@ function avx_intr_rsqrt_ps_256(a::Value; res=nothing::Union{Nothing, MLIRType}, owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (res != nothing) && push!(results, res) + !isnothing(res) && push!(results, res) create_operation( "x86vector.avx.intr.rsqrt.ps.256", location; @@ -282,7 +282,7 @@ function avx_rsqrt(a::Value; b=nothing::Union{Nothing, MLIRType}, location=Locat owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (b != nothing) && push!(results, b) + !isnothing(b) && push!(results, b) create_operation( "x86vector.avx.rsqrt", location; @@ -333,8 +333,8 @@ function avx512_vp2intersect(a::Value, b::Value; k1=nothing::Union{Nothing, MLIR owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - (k1 != nothing) && push!(results, k1) - (k2 != nothing) && push!(results, k2) + !isnothing(k1) && push!(results, k1) + !isnothing(k2) && push!(results, k2) create_operation( "x86vector.avx512.vp2intersect", location;