diff --git a/src/Dialects/14/AMX.jl b/src/Dialects/14/AMX.jl index df410261..f2647be7 100644 --- a/src/Dialects/14/AMX.jl +++ b/src/Dialects/14/AMX.jl @@ -1,39 +1,25 @@ module amx -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `tdpbf16ps` """ -function tdpbf16ps( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value, - operand_4::Value, - operand_5::Value; - res::IR.Type, - location=Location(), -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4, operand_5] +function tdpbf16ps(operand_0::Value, operand_1::Value, operand_2::Value, operand_3::Value, operand_4::Value, operand_5::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4, operand_5, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbf16ps", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tdpbf16ps", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -41,31 +27,18 @@ end `tdpbssd` """ -function tdpbssd( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value, - operand_4::Value, - operand_5::Value; - res::IR.Type, - location=Location(), -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4, operand_5] +function tdpbssd(operand_0::Value, operand_1::Value, operand_2::Value, operand_3::Value, operand_4::Value, operand_5::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4, operand_5, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbssd", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tdpbssd", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -73,31 +46,18 @@ end `tdpbsud` """ -function tdpbsud( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value, - operand_4::Value, - operand_5::Value; - res::IR.Type, - location=Location(), -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4, operand_5] +function tdpbsud(operand_0::Value, operand_1::Value, operand_2::Value, operand_3::Value, operand_4::Value, operand_5::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4, operand_5, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbsud", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tdpbsud", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -105,31 +65,18 @@ end `tdpbusd` """ -function tdpbusd( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value, - operand_4::Value, - operand_5::Value; - res::IR.Type, - location=Location(), -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4, operand_5] +function tdpbusd(operand_0::Value, operand_1::Value, operand_2::Value, operand_3::Value, operand_4::Value, operand_5::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4, operand_5, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbusd", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tdpbusd", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -137,31 +84,18 @@ end `tdpbuud` """ -function tdpbuud( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value, - operand_4::Value, - operand_5::Value; - res::IR.Type, - location=Location(), -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4, operand_5] +function tdpbuud(operand_0::Value, operand_1::Value, operand_2::Value, operand_3::Value, operand_4::Value, operand_5::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4, operand_5, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbuud", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tdpbuud", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -169,29 +103,18 @@ end `tileloadd64` """ -function tileloadd64( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - res::IR.Type, - location=Location(), -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2, operand_3] +function tileloadd64(operand_0::Value, operand_1::Value, operand_2::Value, operand_3::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, operand_3, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tileloadd64", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tileloadd64", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -199,29 +122,18 @@ end `tilestored64` """ -function tilestored64( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value, - operand_4::Value; - location=Location(), -) +function tilestored64(operand_0::Value, operand_1::Value, operand_2::Value, operand_3::Value, operand_4::Value; location=Location()) results = IR.Type[] - operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4] + operands = Value[operand_0, operand_1, operand_2, operand_3, operand_4, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tilestored64", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tilestored64", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -230,21 +142,17 @@ end """ function tilezero(operand_0::Value, operand_1::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0, operand_1] + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tilezero", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tilezero", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -263,21 +171,17 @@ corresponding tile configuration. ``` """ function tile_load(base::Value, indices::Vector{Value}; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[base, indices...] + results = IR.Type[res, ] + operands = Value[base, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_load", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tile_load", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -297,21 +201,17 @@ pairs of \"bf16\"). The operation is eventually lowered into the ``` """ function tile_mulf(lhs::Value, rhs::Value, acc::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[lhs, rhs, acc] + results = IR.Type[res, ] + operands = Value[lhs, rhs, acc, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_mulf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tile_mulf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -333,32 +233,20 @@ instructions with the corresponding tile configuration. : vector<16x64xi8>, vector<16x64xi8>, vector<16x16xi32> ``` """ -function tile_muli( - lhs::Value, - rhs::Value, - acc::Value; - res::IR.Type, - isZextLhs=nothing, - isZextRhs=nothing, - location=Location(), -) - results = IR.Type[res,] - operands = Value[lhs, rhs, acc] +function tile_muli(lhs::Value, rhs::Value, acc::Value; res::IR.Type, isZextLhs=nothing, isZextRhs=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[lhs, rhs, acc, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(isZextLhs) && push!(attributes, namedattribute("isZextLhs", isZextLhs)) !isnothing(isZextRhs) && push!(attributes, namedattribute("isZextRhs", isZextRhs)) - - return IR.create_operation( - "amx.tile_muli", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tile_muli", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -378,20 +266,16 @@ corresponding tile configuration. """ function tile_store(base::Value, indices::Vector{Value}, val::Value; location=Location()) results = IR.Type[] - operands = Value[base, indices..., val] + operands = Value[base, indices..., val, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_store", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tile_store", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -409,21 +293,17 @@ vector type of the result. This is eventually lowered into the ``` """ function tile_zero(; res::IR.Type, location=Location()) - results = IR.Type[res,] + results = IR.Type[res, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_zero", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "amx.tile_zero", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Affine.jl b/src/Dialects/14/Affine.jl index 429afec9..cb171ba6 100644 --- a/src/Dialects/14/Affine.jl +++ b/src/Dialects/14/Affine.jl @@ -1,9 +1,8 @@ module affine -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `apply` @@ -28,21 +27,17 @@ have ‘index’ type. ``` """ function apply(mapOperands::Vector{Value}; result_0::IR.Type, map, location=Location()) - results = IR.Type[result_0,] - operands = Value[mapOperands...,] + results = IR.Type[result_0, ] + operands = Value[mapOperands..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("map", map),] - - return IR.create_operation( - "affine.apply", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.apply", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -153,24 +148,18 @@ If the `affine.for` defines any values, a yield terminator must be explicitly present. The number and types of the \"affine.for\" results must match the initial values in the `iter_args` binding and the yield operands. """ -function for_( - operand_0::Vector{Value}; results::Vector{IR.Type}, region::Region, location=Location() -) - results = IR.Type[results...,] - operands = Value[operand_0...,] - owned_regions = Region[region,] +function for_(operand_0::Vector{Value}; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[operand_0..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "affine.for", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "affine.for", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -244,28 +233,18 @@ func @pad_edges(%I : memref<10x10xf32>) -> (memref<12x12xf32) { } ``` """ -function if_( - operand_0::Vector{Value}; - results::Vector{IR.Type}, - thenRegion::Region, - elseRegion::Region, - location=Location(), -) - results = IR.Type[results...,] - operands = Value[operand_0...,] - owned_regions = Region[thenRegion, elseRegion] +function if_(operand_0::Vector{Value}; results_::Vector{IR.Type}, thenRegion::Region, elseRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[operand_0..., ] + owned_regions = Region[thenRegion, elseRegion, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "affine.if", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "affine.if", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -292,21 +271,17 @@ Example 2: Uses \'symbol\' keyword for symbols \'%n\' and \'%m\'. ``` """ function load(memref::Value, indices::Vector{Value}; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[memref, indices...] + results = IR.Type[result, ] + operands = Value[memref, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "affine.load", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "affine.load", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -322,22 +297,18 @@ affine map. %0 = affine.max (d0) -> (1000, d0 + 512) (%i0) : index ``` """ -function max(operands::Vector{Value}; result_0::IR.Type, map, location=Location()) - results = IR.Type[result_0,] - operands = Value[operands...,] +function max(operands_::Vector{Value}; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("map", map),] - - return IR.create_operation( - "affine.max", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.max", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -363,22 +334,18 @@ input operands and result must all have \'index\' type. %0 = affine.min affine_map<(d0)[s0] -> (1000, d0 + 512, s0)> (%arg0)[%arg1] ``` """ -function min(operands::Vector{Value}; result_0::IR.Type, map, location=Location()) - results = IR.Type[result_0,] - operands = Value[operands...,] +function min(operands_::Vector{Value}; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("map", map),] - - return IR.create_operation( - "affine.min", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.min", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -447,40 +414,18 @@ affine.parallel (%ii, %jj) = (0, 0) to (%N, %M) step (32, 32) { } ``` """ -function parallel( - mapOperands::Vector{Value}; - results::Vector{IR.Type}, - reductions, - lowerBoundsMap, - lowerBoundsGroups, - upperBoundsMap, - upperBoundsGroups, - steps, - region::Region, - location=Location(), -) - results = IR.Type[results...,] - operands = Value[mapOperands...,] - owned_regions = Region[region,] +function parallel(mapOperands::Vector{Value}; results_::Vector{IR.Type}, reductions, lowerBoundsMap, lowerBoundsGroups, upperBoundsMap, upperBoundsGroups, steps, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[mapOperands..., ] + owned_regions = Region[region, ] successors = Block[] - attributes = NamedAttribute[ - namedattribute("reductions", reductions), - namedattribute("lowerBoundsMap", lowerBoundsMap), - namedattribute("lowerBoundsGroups", lowerBoundsGroups), - namedattribute("upperBoundsMap", upperBoundsMap), - namedattribute("upperBoundsGroups", upperBoundsGroups), - namedattribute("steps", steps), - ] - - return IR.create_operation( - "affine.parallel", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("reductions", reductions), namedattribute("lowerBoundsMap", lowerBoundsMap), namedattribute("lowerBoundsGroups", lowerBoundsGroups), namedattribute("upperBoundsMap", upperBoundsMap), namedattribute("upperBoundsGroups", upperBoundsGroups), namedattribute("steps", steps), ] + + IR.create_operation( + "affine.parallel", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -502,33 +447,18 @@ local keep in cache). The cache type specifier is either \'data\' or \'instr\' and specifies whether the prefetch is performed on data cache or on instruction cache. """ -function prefetch( - memref::Value, - indices::Vector{Value}; - isWrite, - localityHint, - isDataCache, - location=Location(), -) +function prefetch(memref::Value, indices::Vector{Value}; isWrite, localityHint, isDataCache, location=Location()) results = IR.Type[] - operands = Value[memref, indices...] + operands = Value[memref, indices..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("isWrite", isWrite), - namedattribute("localityHint", localityHint), - namedattribute("isDataCache", isDataCache), - ] - - return IR.create_operation( - "affine.prefetch", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("isWrite", isWrite), namedattribute("localityHint", localityHint), namedattribute("isDataCache", isDataCache), ] + + IR.create_operation( + "affine.prefetch", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -556,20 +486,16 @@ affine.store %v0, %0[%i0 + symbol(%n), %i1 + symbol(%m)] : memref<100x100xf32> """ function store(value::Value, memref::Value, indices::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[value, memref, indices...] + operands = Value[value, memref, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "affine.store", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "affine.store", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -612,24 +538,18 @@ TODOs: * Consider adding a permutation map to permute the slice that is read from memory (see [vector.transfer_read](../Vector/#vectortransfer_read-vectortransferreadop)). """ -function vector_load( - memref::Value, indices::Vector{Value}; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[memref, indices...] +function vector_load(memref::Value, indices::Vector{Value}; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[memref, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "affine.vector_load", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "affine.vector_load", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -674,24 +594,18 @@ TODOs: * Consider adding a permutation map to permute the slice that is written to memory (see [vector.transfer_write](../Vector/#vectortransfer_write-vectortransferwriteop)). """ -function vector_store( - value::Value, memref::Value, indices::Vector{Value}; location=Location() -) +function vector_store(value::Value, memref::Value, indices::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[value, memref, indices...] + operands = Value[value, memref, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "affine.vector_store", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "affine.vector_store", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -709,22 +623,18 @@ Otherwise, it has to be present in the syntax to indicate which values are yielded. ``` """ -function yield(operands::Vector{Value}; location=Location()) +function yield(operands_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[operands...,] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "affine.yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "affine.yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Arithmetic.jl b/src/Dialects/14/Arithmetic.jl index c2538c8e..c21831e3 100644 --- a/src/Dialects/14/Arithmetic.jl +++ b/src/Dialects/14/Arithmetic.jl @@ -1,9 +1,8 @@ module arith -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `addf` @@ -29,25 +28,19 @@ floating point tensor. TODO: In the distant future, this will accept optional attributes for fast math, contraction, rounding mode, and other controls. """ -function addf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function addf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.addf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.addf", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -72,25 +65,19 @@ has no standard attributes. %x = arith.addi %y, %z : tensor<4x?xi8> ``` """ -function addi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function addi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.addi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.addi", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -115,25 +102,19 @@ has no standard attributes. %x = arith.andi %y, %z : tensor<4x?xi8> ``` """ -function andi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function andi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.andi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.andi", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -156,21 +137,17 @@ integer is little-endian) a proper lowering would add operations to swap the order of words in addition to the bitcast. """ function bitcast(in::Value; out::IR.Type, location=Location()) - results = IR.Type[out,] - operands = Value[in,] + results = IR.Type[out, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arith.bitcast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.bitcast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -189,25 +166,19 @@ value divided by -1) is TBD; do NOT assume any specific behavior. %a = arith.ceildivsi %b, %c : i64 ``` """ -function ceildivsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function ceildivsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.ceildivsi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.ceildivsi", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -228,25 +199,19 @@ behavior. %a = arith.ceildivui %b, %c : i64 ``` """ -function ceildivui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function ceildivui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.ceildivui", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.ceildivui", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -278,21 +243,17 @@ attribute by the parser. ``` """ function cmpf(lhs::Value, rhs::Value; result::IR.Type, predicate, location=Location()) - results = IR.Type[result,] - operands = Value[lhs, rhs] + results = IR.Type[result, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("predicate", predicate),] - - return IR.create_operation( - "arith.cmpf", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "arith.cmpf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -362,21 +323,17 @@ complement or large positives ``` """ function cmpi(lhs::Value, rhs::Value; result::IR.Type, predicate, location=Location()) - results = IR.Type[result,] - operands = Value[lhs, rhs] + results = IR.Type[result, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("predicate", predicate),] - - return IR.create_operation( - "arith.cmpi", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "arith.cmpi", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -398,21 +355,17 @@ forms simple integer and floating point constants. ``` """ function constant(; result::IR.Type, value, location=Location()) - results = IR.Type[result,] + results = IR.Type[result, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("value", value),] - - return IR.create_operation( - "arith.constant", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("value", value), ] + + IR.create_operation( + "arith.constant", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -420,25 +373,19 @@ end `divf` """ -function divf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function divf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.divf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.divf", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -464,25 +411,19 @@ value divided by -1) is TBD; do NOT assume any specific behavior. %x = arith.divsi %y, %z : tensor<4x?xi8> ``` """ -function divsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function divsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.divsi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.divsi", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -509,25 +450,19 @@ behavior. %x = arith.divui %y, %z : tensor<4x?xi8> ``` """ -function divui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function divui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.divui", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.divui", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -539,21 +474,17 @@ The destination type must to be strictly wider than the source type. When operating on vectors, casts elementwise. """ function extf(in::Value; out::IR.Type, location=Location()) - results = IR.Type[out,] - operands = Value[in,] + results = IR.Type[out, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.extf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -578,21 +509,17 @@ of the most-significant bit of the input. ``` """ function extsi(in::Value; out::IR.Type, location=Location()) - results = IR.Type[out,] - operands = Value[in,] + results = IR.Type[out, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extsi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.extsi", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -616,21 +543,17 @@ The top-most (N - M) bits of the output are filled with zeros. ``` """ function extui(in::Value; out::IR.Type, location=Location()) - results = IR.Type[out,] - operands = Value[in,] + results = IR.Type[out, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extui", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.extui", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -642,21 +565,17 @@ towards zero) signed integer value. When operating on vectors, casts elementwise. """ function fptosi(in::Value; out::IR.Type, location=Location()) - results = IR.Type[out,] - operands = Value[in,] + results = IR.Type[out, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arith.fptosi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.fptosi", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -668,21 +587,17 @@ towards zero) unsigned integer value. When operating on vectors, casts elementwise. """ function fptoui(in::Value; out::IR.Type, location=Location()) - results = IR.Type[out,] - operands = Value[in,] + results = IR.Type[out, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arith.fptoui", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.fptoui", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -702,25 +617,19 @@ value divided by -1) is TBD; do NOT assume any specific behavior. ``` """ -function floordivsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function floordivsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.floordivsi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.floordivsi", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -733,21 +642,17 @@ a wider integer, the value is sign-extended. If casting to a narrower integer, the value is truncated. """ function index_cast(in::Value; out::IR.Type, location=Location()) - results = IR.Type[out,] - operands = Value[in,] + results = IR.Type[out, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arith.index_cast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.index_cast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -770,25 +675,19 @@ If one of the arguments is NaN, then the result is also NaN. %a = arith.maxf %b, %c : f64 ``` """ -function maxf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function maxf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.maxf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.maxf", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -796,25 +695,19 @@ end `maxsi` """ -function maxsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function maxsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.maxsi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.maxsi", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -822,25 +715,19 @@ end `maxui` """ -function maxui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function maxui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.maxui", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.maxui", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -863,25 +750,19 @@ If one of the arguments is NaN, then the result is also NaN. %a = arith.minf %b, %c : f64 ``` """ -function minf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function minf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.minf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.minf", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -889,25 +770,19 @@ end `minsi` """ -function minsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function minsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.minsi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.minsi", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -915,25 +790,19 @@ end `minui` """ -function minui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function minui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.minui", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.minui", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -961,25 +830,19 @@ floating point tensor. TODO: In the distant future, this will accept optional attributes for fast math, contraction, rounding mode, and other controls. """ -function mulf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function mulf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.mulf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.mulf", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -987,25 +850,19 @@ end `muli` """ -function muli( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function muli(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.muli", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.muli", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1030,23 +887,19 @@ It has no standard attributes. %x = arith.negf %y : tensor<4x?xf8> ``` """ -function negf(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function negf(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.negf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.negf", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1071,25 +924,19 @@ standard attributes. %x = arith.ori %y, %z : tensor<4x?xi8> ``` """ -function ori( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function ori(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.ori", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.ori", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1097,25 +944,19 @@ end `remf` """ -function remf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function remf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.remf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.remf", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1141,25 +982,19 @@ behavior. %x = arith.remsi %y, %z : tensor<4x?xi8> ``` """ -function remsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function remsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.remsi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.remsi", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1185,25 +1020,19 @@ behavior. %x = arith.remui %y, %z : tensor<4x?xi8> ``` """ -function remui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function remui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.remui", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.remui", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1216,21 +1045,17 @@ rounded using the default rounding mode. When operating on vectors, casts elementwise. """ function sitofp(in::Value; out::IR.Type, location=Location()) - results = IR.Type[out,] - operands = Value[in,] + results = IR.Type[out, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arith.sitofp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.sitofp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1248,25 +1073,19 @@ amount. The low order bits are filled with zeros. %3 = arith.shli %1, %2 : (i8, i8) -> i8 // %3 is 0b00101000 ``` """ -function shli( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function shli(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.shli", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.shli", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1288,25 +1107,19 @@ value (which means that the sign of the value is preserved). %5 = arith.shrsi %4, %2 : (i8, i8) -> i8 // %5 is 0b00001100 ``` """ -function shrsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function shrsi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.shrsi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.shrsi", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1325,25 +1138,19 @@ always filled with zeros. %3 = arith.shrui %1, %2 : (i8, i8) -> i8 // %3 is 0b00010100 ``` """ -function shrui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function shrui(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.shrui", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.shrui", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1371,25 +1178,19 @@ floating point tensor. TODO: In the distant future, this will accept optional attributes for fast math, contraction, rounding mode, and other controls. """ -function subf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function subf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.subf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.subf", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1397,25 +1198,19 @@ end `subi` """ -function subi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function subi(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.subi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.subi", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1428,21 +1223,17 @@ If the value cannot be exactly represented, it is rounded using the default rounding mode. When operating on vectors, casts elementwise. """ function truncf(in::Value; out::IR.Type, location=Location()) - results = IR.Type[out,] - operands = Value[in,] + results = IR.Type[out, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arith.truncf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.truncf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1465,21 +1256,17 @@ The top-most (N - M) bits of the input are discarded. ``` """ function trunci(in::Value; out::IR.Type, location=Location()) - results = IR.Type[out,] - operands = Value[in,] + results = IR.Type[out, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arith.trunci", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.trunci", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1492,21 +1279,17 @@ rounded using the default rounding mode. When operating on vectors, casts elementwise. """ function uitofp(in::Value; out::IR.Type, location=Location()) - results = IR.Type[out,] - operands = Value[in,] + results = IR.Type[out, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arith.uitofp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.uitofp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1531,25 +1314,19 @@ has no standard attributes. %x = arith.xori %y, %z : tensor<4x?xi8> ``` """ -function xori( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function xori(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "arith.xori", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arith.xori", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/14/ArmNeon.jl b/src/Dialects/14/ArmNeon.jl index 86894441..93c4251f 100644 --- a/src/Dialects/14/ArmNeon.jl +++ b/src/Dialects/14/ArmNeon.jl @@ -1,9 +1,8 @@ module arm_neon -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `intr_smull` @@ -17,21 +16,17 @@ Source: https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics """ function intr_smull(a::Value, b::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[a, b] + results = IR.Type[res, ] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.intr.smull", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_neon.intr.smull", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -48,21 +43,17 @@ res[i] := a[i] + dot_product(b[i, ...], c[i, ...]) ``` """ function _2d_sdot(a::Value, b::Value, c::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[a, b, c] + results = IR.Type[res, ] + operands = Value[a, b, c, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.2d.sdot", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_neon.2d.sdot", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -77,21 +68,17 @@ Source: https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics """ function intr_sdot(a::Value, b::Value, c::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[a, b, c] + results = IR.Type[res, ] + operands = Value[a, b, c, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.intr.sdot", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_neon.intr.sdot", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/ArmSVE.jl b/src/Dialects/14/ArmSVE.jl index 1ef23ed3..3ace27f1 100644 --- a/src/Dialects/14/ArmSVE.jl +++ b/src/Dialects/14/ArmSVE.jl @@ -1,32 +1,25 @@ module arm_sve -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `intr_fadd` """ -function intr_fadd( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_fadd(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fadd", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.fadd", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -37,24 +30,18 @@ The `arm_sve.masked.addf` operation takes one scalable vector mask and two scalable vector operands, and perform floating point addition on active lanes. Inactive lanes will keep the value of the first operand. """ -function masked_addf( - mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[mask, src1, src2] +function masked_addf(mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[mask, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.addf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.masked.addf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -62,24 +49,18 @@ end `intr_add` """ -function intr_add( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_add(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.add", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.add", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -90,24 +71,18 @@ The `arm_sve.masked.addi` operation takes one scalable vector mask and two scalable vector operands, and perform integer addition on active lanes. Inactive lanes will keep the value of the first operand. """ -function masked_addi( - mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[mask, src1, src2] +function masked_addi(mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[mask, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.addi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.masked.addi", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -115,24 +90,18 @@ end `intr_fdiv` """ -function intr_fdiv( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_fdiv(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fdiv", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.fdiv", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -143,24 +112,18 @@ The `arm_sve.masked.divf` operation takes one scalable vector mask and two scalable vector operands, and perform floating point division on active lanes. Inactive lanes will keep the value of the first operand. """ -function masked_divf( - mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[mask, src1, src2] +function masked_divf(mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[mask, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.masked.divf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -168,24 +131,18 @@ end `intr_fmul` """ -function intr_fmul( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_fmul(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fmul", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.fmul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -196,24 +153,18 @@ The `arm_sve.masked.mulf` operation takes one scalable vector mask and two scalable vector operands, and perform floating point multiplication on active lanes. Inactive lanes will keep the value of the first operand. """ -function masked_mulf( - mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[mask, src1, src2] +function masked_mulf(mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[mask, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.mulf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.masked.mulf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -221,24 +172,18 @@ end `intr_mul` """ -function intr_mul( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_mul(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.mul", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.mul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -249,24 +194,18 @@ The `arm_sve.masked.muli` operation takes one scalable vector mask and two scalable vector operands, and perform integer multiplication on active lanes. Inactive lanes will keep the value of the first operand. """ -function masked_muli( - mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[mask, src1, src2] +function masked_muli(mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[mask, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.muli", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.masked.muli", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -274,24 +213,18 @@ end `intr_sdiv` """ -function intr_sdiv( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_sdiv(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sdiv", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.sdiv", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -302,24 +235,18 @@ The `arm_sve.masked.divi_signed` operation takes one scalable vector mask and two scalable vector operands, and perform integer signed division on active lanes. Inactive lanes will keep the value of the first operand. """ -function masked_divi_signed( - mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[mask, src1, src2] +function masked_divi_signed(mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[mask, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divi_signed", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.masked.divi_signed", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -327,24 +254,18 @@ end `intr_fsub` """ -function intr_fsub( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_fsub(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fsub", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.fsub", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -355,24 +276,18 @@ The `arm_sve.masked.subf` operation takes one scalable vector mask and two scalable vector operands, and perform floating point subtraction on active lanes. Inactive lanes will keep the value of the first operand. """ -function masked_subf( - mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[mask, src1, src2] +function masked_subf(mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[mask, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.subf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.masked.subf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -380,24 +295,18 @@ end `intr_sub` """ -function intr_sub( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_sub(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sub", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.sub", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -408,24 +317,18 @@ The `arm_sve.masked.subi` operation takes one scalable vector mask and two scalable vector operands, and perform integer subtraction on active lanes. Inactive lanes will keep the value of the first operand. """ -function masked_subi( - mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[mask, src1, src2] +function masked_subi(mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[mask, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.subi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.masked.subi", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -433,24 +336,18 @@ end `intr_udiv` """ -function intr_udiv( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_udiv(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.udiv", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.udiv", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -461,24 +358,18 @@ The `arm_sve.masked.divi_unsigned` operation takes one scalable vector mask and two scalable vector operands, and perform integer unsigned division on active lanes. Inactive lanes will keep the value of the first operand. """ -function masked_divi_unsigned( - mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[mask, src1, src2] +function masked_divi_unsigned(mask::Value, src1::Value, src2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[mask, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divi_unsigned", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.masked.divi_unsigned", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -486,24 +377,18 @@ end `intr_sdot` """ -function intr_sdot( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_sdot(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sdot", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.sdot", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -522,21 +407,17 @@ Source: https://developer.arm.com/documentation/100987/0000 """ function sdot(acc::Value, src1::Value, src2::Value; dst::IR.Type, location=Location()) - results = IR.Type[dst,] - operands = Value[acc, src1, src2] + results = IR.Type[dst, ] + operands = Value[acc, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.sdot", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.sdot", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -544,24 +425,18 @@ end `intr_smmla` """ -function intr_smmla( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_smmla(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.smmla", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.smmla", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -583,21 +458,17 @@ Source: https://developer.arm.com/documentation/100987/0000 """ function smmla(acc::Value, src1::Value, src2::Value; dst::IR.Type, location=Location()) - results = IR.Type[dst,] - operands = Value[acc, src1, src2] + results = IR.Type[dst, ] + operands = Value[acc, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.smmla", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.smmla", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -605,24 +476,18 @@ end `intr_udot` """ -function intr_udot( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_udot(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.udot", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.udot", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -641,21 +506,17 @@ Source: https://developer.arm.com/documentation/100987/0000 """ function udot(acc::Value, src1::Value, src2::Value; dst::IR.Type, location=Location()) - results = IR.Type[dst,] - operands = Value[acc, src1, src2] + results = IR.Type[dst, ] + operands = Value[acc, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.udot", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.udot", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -663,24 +524,18 @@ end `intr_ummla` """ -function intr_ummla( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_ummla(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.ummla", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.intr.ummla", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -702,21 +557,17 @@ Source: https://developer.arm.com/documentation/100987/0000 """ function ummla(acc::Value, src1::Value, src2::Value; dst::IR.Type, location=Location()) - results = IR.Type[dst,] - operands = Value[acc, src1, src2] + results = IR.Type[dst, ] + operands = Value[acc, src1, src2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.ummla", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "arm_sve.ummla", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Async.jl b/src/Dialects/14/Async.jl index 58126d74..4b404f73 100644 --- a/src/Dialects/14/Async.jl +++ b/src/Dialects/14/Async.jl @@ -1,9 +1,8 @@ module async -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `add_to_group` @@ -20,25 +19,19 @@ for the group lifetime. %2 = async.add_to_group %1, %0 : !async.token ``` """ -function add_to_group( - operand::Value, group::Value; rank=nothing::Union{Nothing,IR.Type}, location=Location() -) +function add_to_group(operand::Value, group::Value; rank=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand, group] + operands = Value[operand, group, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(rank) && push!(results, rank) - - return IR.create_operation( - "async.add_to_group", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.add_to_group", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -64,20 +57,16 @@ async.await_all %0 """ function await_all(operand::Value; location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.await_all", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.await_all", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -97,23 +86,19 @@ async.await %0 : !async.token %2 = async.await %1 : !async.value ``` """ -function await(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function await(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "async.await", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.await", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -123,23 +108,19 @@ end The `async.coro.begin` allocates a coroutine frame and returns a handle to the coroutine. """ -function coro_begin(id::Value; handle=nothing::Union{Nothing,IR.Type}, location=Location()) +function coro_begin(id::Value; handle=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[id,] + operands = Value[id, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(handle) && push!(results, handle) - - return IR.create_operation( - "async.coro.begin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.coro.begin", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -152,20 +133,16 @@ coroutine. It the start part of the coroutine is is no-op. """ function coro_end(handle::Value; location=Location()) results = IR.Type[] - operands = Value[handle,] + operands = Value[handle, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.end", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.coro.end", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -177,20 +154,16 @@ async.coro.begin operation. """ function coro_free(id::Value, handle::Value; location=Location()) results = IR.Type[] - operands = Value[id, handle] + operands = Value[id, handle, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.free", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.coro.free", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -199,23 +172,19 @@ end The `async.coro.id` returns a switched-resume coroutine identifier. """ -function coro_id(; id=nothing::Union{Nothing,IR.Type}, location=Location()) +function coro_id(; id=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(id) && push!(results, id) - - return IR.create_operation( - "async.coro.id", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.coro.id", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -224,25 +193,19 @@ end The `async.coro.saves` saves the coroutine state. """ -function coro_save( - handle::Value; state=nothing::Union{Nothing,IR.Type}, location=Location() -) +function coro_save(handle::Value; state=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[handle,] + operands = Value[handle, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(state) && push!(results, state) - - return IR.create_operation( - "async.coro.save", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.coro.save", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -258,28 +221,18 @@ In switched-resume lowering coroutine can be already in resumed state when suspend operation is called, in this case control will be transferred to the `resume` successor skipping the `suspend` successor. """ -function coro_suspend( - state::Value; - suspendDest::Block, - resumeDest::Block, - cleanupDest::Block, - location=Location(), -) +function coro_suspend(state::Value; suspendDest::Block, resumeDest::Block, cleanupDest::Block, location=Location()) results = IR.Type[] - operands = Value[state,] + operands = Value[state, ] owned_regions = Region[] - successors = Block[suspendDest, resumeDest, cleanupDest] + successors = Block[suspendDest, resumeDest, cleanupDest, ] attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.suspend", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.coro.suspend", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -300,25 +253,19 @@ wait until the number of added tokens or values reaches the group size. async.await_all %group ``` """ -function create_group( - size::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function create_group(size::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[size,] + operands = Value[size, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "async.create_group", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.create_group", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -363,30 +310,19 @@ In the example above asynchronous execution starts only after dependency token and value argument become ready. Unwrapped value passed to the attached body region as an %unwrapped value of f32 type. """ -function execute( - dependencies::Vector{Value}, - operands::Vector{Value}; - token::IR.Type, - results::Vector{IR.Type}, - body::Region, - location=Location(), -) - results = IR.Type[token, results...] - operands = Value[dependencies..., operands...] - owned_regions = Region[body,] +function execute(dependencies::Vector{Value}, operands_::Vector{Value}; token::IR.Type, results_::Vector{IR.Type}, body::Region, location=Location()) + results = IR.Type[token, results_..., ] + operands = Value[dependencies..., operands_..., ] + owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(dependencies), length(operands)])) - - return IR.create_operation( - "async.execute", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(dependencies), length(operands), ])) + + IR.create_operation( + "async.execute", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -398,20 +334,16 @@ The `async.runtime.add_ref` operation adds a reference(s) to async value """ function runtime_add_ref(operand::Value; count, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("count", count),] - - return IR.create_operation( - "async.runtime.add_ref", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("count", count), ] + + IR.create_operation( + "async.runtime.add_ref", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -421,25 +353,19 @@ end The `async.runtime.add_to_group` adds an async token or value to the async group. Returns the rank of the added element in the group. """ -function runtime_add_to_group( - operand::Value, group::Value; rank=nothing::Union{Nothing,IR.Type}, location=Location() -) +function runtime_add_to_group(operand::Value, group::Value; rank=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand, group] + operands = Value[operand, group, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(rank) && push!(results, rank) - - return IR.create_operation( - "async.runtime.add_to_group", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.add_to_group", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -452,20 +378,16 @@ the runtime. """ function runtime_await_and_resume(operand::Value, handle::Value; location=Location()) results = IR.Type[] - operands = Value[operand, handle] + operands = Value[operand, handle, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.await_and_resume", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.await_and_resume", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -477,20 +399,16 @@ operand becomes available or error. """ function runtime_await(operand::Value; location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.await", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.await", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -500,25 +418,19 @@ end The `async.runtime.create_group` operation creates an async dialect group of the given size. Group created in the empty state. """ -function runtime_create_group( - size::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function runtime_create_group(size::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[size,] + operands = Value[size, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "async.runtime.create_group", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.create_group", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -529,21 +441,17 @@ The `async.runtime.create` operation creates an async dialect token or value. Tokens and values are created in the non-ready state. """ function runtime_create(; result::IR.Type, location=Location()) - results = IR.Type[result,] + results = IR.Type[result, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.create", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.create", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -555,20 +463,16 @@ The `async.runtime.drop_ref` operation drops a reference(s) to async value """ function runtime_drop_ref(operand::Value; count, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("count", count),] - - return IR.create_operation( - "async.runtime.drop_ref", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("count", count), ] + + IR.create_operation( + "async.runtime.drop_ref", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -580,25 +484,19 @@ group (any of the async runtime values) is in the error state. It is the caller responsibility to check error state after the call to `await` or resuming after `await_and_resume`. """ -function runtime_is_error( - operand::Value; is_error=nothing::Union{Nothing,IR.Type}, location=Location() -) +function runtime_is_error(operand::Value; is_error=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(is_error) && push!(results, is_error) - - return IR.create_operation( - "async.runtime.is_error", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.is_error", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -609,21 +507,17 @@ The `async.runtime.load` operation loads the value from the runtime async.value storage. """ function runtime_load(storage::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[storage,] + results = IR.Type[result, ] + operands = Value[storage, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.load", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.load", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -633,25 +527,19 @@ end The `async.runtime.num_worker_threads` operation gets the number of threads in the threadpool from the runtime. """ -function runtime_num_worker_threads(; - result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function runtime_num_worker_threads(; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "async.runtime.num_worker_threads", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.num_worker_threads", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -663,20 +551,16 @@ managed by the runtime. """ function runtime_resume(handle::Value; location=Location()) results = IR.Type[] - operands = Value[handle,] + operands = Value[handle, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.resume", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.resume", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -688,20 +572,16 @@ state to available. """ function runtime_set_available(operand::Value; location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.set_available", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.set_available", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -713,20 +593,16 @@ state to error. """ function runtime_set_error(operand::Value; location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.set_error", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.set_error", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -738,20 +614,16 @@ async.value storage. """ function runtime_store(value::Value, storage::Value; location=Location()) results = IR.Type[] - operands = Value[value, storage] + operands = Value[value, storage, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.store", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.runtime.store", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -761,22 +633,18 @@ end The `async.yield` is a special terminator operation for the block inside `async.execute` operation. """ -function yield(operands::Vector{Value}; location=Location()) +function yield(operands_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[operands...,] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "async.yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "async.yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Bufferization.jl b/src/Dialects/14/Bufferization.jl index b61e6c30..91e38552 100644 --- a/src/Dialects/14/Bufferization.jl +++ b/src/Dialects/14/Bufferization.jl @@ -1,9 +1,8 @@ module bufferization -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `clone` @@ -22,21 +21,17 @@ of the clone operation after the clone operation thus leads to undefined behavior. """ function clone(input::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.clone", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "bufferization.clone", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -58,21 +53,17 @@ unrealized_conversion_cast and is intended for use in the context of gradual bufferization. """ function to_memref(tensor::Value; memref::IR.Type, location=Location()) - results = IR.Type[memref,] - operands = Value[tensor,] + results = IR.Type[memref, ] + operands = Value[tensor, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.to_memref", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "bufferization.to_memref", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -98,21 +89,17 @@ If tensor load is used in the bufferization steps, mutating the source buffer after loading leads to undefined behavior. """ function to_tensor(memref::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[memref,] + results = IR.Type[result, ] + operands = Value[memref, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.to_tensor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "bufferization.to_tensor", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Builtin.jl b/src/Dialects/14/Builtin.jl index 3f8cacdb..046d6359 100644 --- a/src/Dialects/14/Builtin.jl +++ b/src/Dialects/14/Builtin.jl @@ -1,9 +1,8 @@ module builtin -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `func` @@ -47,23 +46,16 @@ func @example_fn_attr() attributes {dialectName.attrName = false} function func(; sym_name, type, sym_visibility=nothing, body::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] - attributes = NamedAttribute[ - namedattribute("sym_name", sym_name), namedattribute("type", type) - ] - !isnothing(sym_visibility) && - push!(attributes, namedattribute("sym_visibility", sym_visibility)) - - return IR.create_operation( - "builtin.func", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("type", type), ] + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + + IR.create_operation( + "builtin.func", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -86,27 +78,20 @@ module { } ``` """ -function module_(; - sym_name=nothing, sym_visibility=nothing, body::Region, location=Location() -) +function module_(; sym_name=nothing, sym_visibility=nothing, body::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) - !isnothing(sym_visibility) && - push!(attributes, namedattribute("sym_visibility", sym_visibility)) - - return IR.create_operation( - "builtin.module", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(sym_visibility) && push!(attributes, namedattribute("sym_visibility", sym_visibility)) + + IR.create_operation( + "builtin.module", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -144,24 +129,18 @@ operands of arity 0-N. %result3 = unrealized_conversion_cast %operand, %operand : !foo.type, !foo.type to !bar.tuple_type ``` """ -function unrealized_conversion_cast( - inputs::Vector{Value}; outputs::Vector{IR.Type}, location=Location() -) - results = IR.Type[outputs...,] - operands = Value[inputs...,] +function unrealized_conversion_cast(inputs::Vector{Value}; outputs::Vector{IR.Type}, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[inputs..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "builtin.unrealized_conversion_cast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "builtin.unrealized_conversion_cast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Complex.jl b/src/Dialects/14/Complex.jl index ae38e3b7..62ffc11b 100644 --- a/src/Dialects/14/Complex.jl +++ b/src/Dialects/14/Complex.jl @@ -1,9 +1,8 @@ module complex -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `abs` @@ -17,21 +16,17 @@ The `abs` op takes a single complex number and computes its absolute value. ``` """ function abs(complex::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[complex,] + results = IR.Type[result, ] + operands = Value[complex, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "complex.abs", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.abs", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -46,25 +41,19 @@ The `add` operation takes two complex numbers and returns their sum. %a = complex.add %b, %c : complex ``` """ -function add( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function add(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "complex.add", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.add", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -81,21 +70,17 @@ attribute containing the real and imaginary parts. ``` """ function constant(; complex::IR.Type, value, location=Location()) - results = IR.Type[complex,] + results = IR.Type[complex, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("value", value),] - - return IR.create_operation( - "complex.constant", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("value", value), ] + + IR.create_operation( + "complex.constant", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -112,21 +97,17 @@ floating-point operands, the real and the imaginary part. ``` """ function create(real::Value, imaginary::Value; complex::IR.Type, location=Location()) - results = IR.Type[complex,] - operands = Value[real, imaginary] + results = IR.Type[complex, ] + operands = Value[real, imaginary, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "complex.create", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.create", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -140,25 +121,19 @@ division: %a = complex.div %b, %c : complex ``` """ -function div( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function div(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "complex.div", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.div", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -173,25 +148,19 @@ The `eq` op takes two complex numbers and returns whether they are equal. %a = complex.eq %b, %c : complex ``` """ -function eq( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function eq(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "complex.eq", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.eq", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -208,23 +177,19 @@ it, i.e. `exp(x)` or `e^(x)`, where `x` is the input value. %a = complex.exp %b : complex ``` """ -function exp(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function exp(complex::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[complex,] + operands = Value[complex, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "complex.exp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.exp", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -240,21 +205,17 @@ The `im` op takes a single complex number and extracts the imaginary part. ``` """ function im(complex::Value; imaginary::IR.Type, location=Location()) - results = IR.Type[imaginary,] - operands = Value[complex,] + results = IR.Type[imaginary, ] + operands = Value[complex, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "complex.im", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.im", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -272,23 +233,19 @@ approximately equal to 2.718281. %a = complex.log1p %b : complex ``` """ -function log1p(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function log1p(complex::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[complex,] + operands = Value[complex, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "complex.log1p", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.log1p", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -305,23 +262,19 @@ logarithm of it, i.e. `log(x)` or `log_e(x)`, where `x` is the input value. %a = complex.log %b : complex ``` """ -function log(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function log(complex::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[complex,] + operands = Value[complex, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "complex.log", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.log", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -334,25 +287,19 @@ The `mul` operation takes two complex numbers and returns their product: %a = complex.mul %b, %c : complex ``` """ -function mul( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function mul(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "complex.mul", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.mul", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -367,23 +314,19 @@ The `neg` op takes a single complex number `complex` and returns `-complex`. %a = complex.neg %b : complex ``` """ -function neg(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function neg(complex::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[complex,] + operands = Value[complex, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "complex.neg", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.neg", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -399,25 +342,19 @@ equal. %a = complex.neq %b, %c : complex ``` """ -function neq( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function neq(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "complex.neq", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.neq", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -433,21 +370,17 @@ The `re` op takes a single complex number and extracts the real part. ``` """ function re(complex::Value; real::IR.Type, location=Location()) - results = IR.Type[real,] - operands = Value[complex,] + results = IR.Type[real, ] + operands = Value[complex, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "complex.re", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.re", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -463,23 +396,19 @@ it, i.e. `y = sign(x) = x / |x|` if `x != 0`, otherwise `y = 0`. %a = complex.sign %b : complex ``` """ -function sign(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function sign(complex::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[complex,] + operands = Value[complex, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "complex.sign", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.sign", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -494,25 +423,19 @@ The `sub` operation takes two complex numbers and returns their difference. %a = complex.sub %b, %c : complex ``` """ -function sub( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function sub(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "complex.sub", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "complex.sub", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/14/EmitC.jl b/src/Dialects/14/EmitC.jl index 825a3091..695756dc 100644 --- a/src/Dialects/14/EmitC.jl +++ b/src/Dialects/14/EmitC.jl @@ -1,9 +1,8 @@ module emitc -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `apply` @@ -24,21 +23,17 @@ can be applied to a single operand. ``` """ function apply(operand::Value; result::IR.Type, applicableOperator, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("applicableOperator", applicableOperator),] - - return IR.create_operation( - "emitc.apply", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("applicableOperator", applicableOperator), ] + + IR.create_operation( + "emitc.apply", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -61,32 +56,20 @@ specifying order of operands and attributes in the call as follows: %0 = \"emitc.call\"() {callee = \"foo\"} : () -> i32 ``` """ -function call( - operands::Vector{Value}; - result_0::Vector{IR.Type}, - callee, - args=nothing, - template_args=nothing, - location=Location(), -) - results = IR.Type[result_0...,] - operands = Value[operands...,] +function call(operands_::Vector{Value}; result_0::Vector{IR.Type}, callee, args=nothing, template_args=nothing, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("callee", callee),] + attributes = NamedAttribute[namedattribute("callee", callee), ] !isnothing(args) && push!(attributes, namedattribute("args", args)) - !isnothing(template_args) && - push!(attributes, namedattribute("template_args", template_args)) - - return IR.create_operation( - "emitc.call", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(template_args) && push!(attributes, namedattribute("template_args", template_args)) + + IR.create_operation( + "emitc.call", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -112,21 +95,17 @@ attribute and the EmitC opaque type. ``` """ function constant(; result_0::IR.Type, value, location=Location()) - results = IR.Type[result_0,] + results = IR.Type[result_0, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("value", value),] - - return IR.create_operation( - "emitc.constant", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("value", value), ] + + IR.create_operation( + "emitc.constant", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -157,19 +136,14 @@ function include_(; include_, is_standard_include=nothing, location=Location()) operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("include", include_),] - !isnothing(is_standard_include) && - push!(attributes, namedattribute("is_standard_include", is_standard_include)) - - return IR.create_operation( - "emitc.include", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("include", include_), ] + !isnothing(is_standard_include) && push!(attributes, namedattribute("is_standard_include", is_standard_include)) + + IR.create_operation( + "emitc.include", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/GPU.jl b/src/Dialects/14/GPU.jl index bc74766c..51de7a43 100644 --- a/src/Dialects/14/GPU.jl +++ b/src/Dialects/14/GPU.jl @@ -1,9 +1,8 @@ module gpu -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `all_reduce` @@ -30,30 +29,20 @@ accumulation as code region. The accumulation operation must be one of: Either none or all work items of a workgroup need to execute this op in convergence. """ -function all_reduce( - value::Value; - result_0=nothing::Union{Nothing,IR.Type}, - op=nothing, - body::Region, - location=Location(), -) +function all_reduce(value::Value; result_0=nothing::Union{Nothing, IR.Type}, op=nothing, body::Region, location=Location()) results = IR.Type[] - operands = Value[value,] - owned_regions = Region[body,] + operands = Value[value, ] + owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] !isnothing(result_0) && push!(results, result_0) !isnothing(op) && push!(attributes, namedattribute("op", op)) - - return IR.create_operation( - "gpu.all_reduce", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.all_reduce", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -76,36 +65,20 @@ that case, it also returns a !gpu.async.token. %memref, %token = gpu.alloc async [%dep] (%width) : memref<64x?xf32, 1> ``` """ -function alloc( - asyncDependencies::Vector{Value}, - dynamicSizes::Vector{Value}, - symbolOperands::Vector{Value}; - memref::IR.Type, - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - results = IR.Type[memref,] - operands = Value[asyncDependencies..., dynamicSizes..., symbolOperands...] +function alloc(asyncDependencies::Vector{Value}, dynamicSizes::Vector{Value}, symbolOperands::Vector{Value}; memref::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[memref, ] + operands = Value[asyncDependencies..., dynamicSizes..., symbolOperands..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - push!( - attributes, - operandsegmentsizes([ - length(asyncDependencies), length(dynamicSizes), length(symbolOperands) - ]), - ) + push!(attributes, operandsegmentsizes([length(asyncDependencies), length(dynamicSizes), length(symbolOperands), ])) !isnothing(asyncToken) && push!(results, asyncToken) - - return IR.create_operation( - "gpu.alloc", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.alloc", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -134,16 +107,12 @@ function barrier(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.barrier", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.barrier", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -159,25 +128,19 @@ the x, y, or z `dimension`. %bDimX = gpu.block_dim x ``` """ -function block_dim(; - result_0=nothing::Union{Nothing,IR.Type}, dimension, location=Location() -) +function block_dim(; result_0=nothing::Union{Nothing, IR.Type}, dimension, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("dimension", dimension),] + attributes = NamedAttribute[namedattribute("dimension", dimension), ] !isnothing(result_0) && push!(results, result_0) - - return IR.create_operation( - "gpu.block_dim", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.block_dim", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -193,25 +156,19 @@ along the x, y, or z `dimension`. %bIdY = gpu.block_id y ``` """ -function block_id(; - result_0=nothing::Union{Nothing,IR.Type}, dimension, location=Location() -) +function block_id(; result_0=nothing::Union{Nothing, IR.Type}, dimension, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("dimension", dimension),] + attributes = NamedAttribute[namedattribute("dimension", dimension), ] !isnothing(result_0) && push!(results, result_0) - - return IR.create_operation( - "gpu.block_id", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.block_id", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -235,28 +192,19 @@ that case, it returns a !gpu.async.token. %token = gpu.dealloc async [%dep] %memref : memref<8x64xf32, 1> ``` """ -function dealloc( - asyncDependencies::Vector{Value}, - memref::Value; - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function dealloc(asyncDependencies::Vector{Value}, memref::Value; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[asyncDependencies..., memref] + operands = Value[asyncDependencies..., memref, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(asyncToken) && push!(results, asyncToken) - - return IR.create_operation( - "gpu.dealloc", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.dealloc", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -322,19 +270,15 @@ attribution. function func(; body::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.func", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.func", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -367,19 +311,15 @@ or not intended to be run on the separate device. function module_(; body::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.module", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.module", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -395,25 +335,19 @@ Returns the number of thread blocks in the grid along the x, y, or z %gDimZ = gpu.grid_dim z ``` """ -function grid_dim(; - result_0=nothing::Union{Nothing,IR.Type}, dimension, location=Location() -) +function grid_dim(; result_0=nothing::Union{Nothing, IR.Type}, dimension, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("dimension", dimension),] + attributes = NamedAttribute[namedattribute("dimension", dimension), ] !isnothing(result_0) && push!(results, result_0) - - return IR.create_operation( - "gpu.grid_dim", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.grid_dim", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -431,20 +365,16 @@ the host after synchronizing with the device kernel completion. """ function host_register(value::Value; location=Location()) results = IR.Type[] - operands = Value[value,] + operands = Value[value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.host_register", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.host_register", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -529,59 +459,21 @@ module attributes {gpu.container_module} { } ``` """ -function launch_func( - asyncDependencies::Vector{Value}, - gridSizeX::Value, - gridSizeY::Value, - gridSizeZ::Value, - blockSizeX::Value, - blockSizeY::Value, - blockSizeZ::Value, - dynamicSharedMemorySize=nothing::Union{Nothing,Value}; - operands::Vector{Value}, - asyncToken=nothing::Union{Nothing,IR.Type}, - kernel, - location=Location(), -) +function launch_func(asyncDependencies::Vector{Value}, gridSizeX::Value, gridSizeY::Value, gridSizeZ::Value, blockSizeX::Value, blockSizeY::Value, blockSizeZ::Value, dynamicSharedMemorySize=nothing::Union{Nothing, Value}; operands_::Vector{Value}, asyncToken=nothing::Union{Nothing, IR.Type}, kernel, location=Location()) results = IR.Type[] - operands = Value[ - asyncDependencies..., - gridSizeX, - gridSizeY, - gridSizeZ, - blockSizeX, - blockSizeY, - blockSizeZ, - operands..., - ] + operands = Value[asyncDependencies..., gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ, operands_..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("kernel", kernel),] + attributes = NamedAttribute[namedattribute("kernel", kernel), ] !isnothing(dynamicSharedMemorySize) && push!(operands, dynamicSharedMemorySize) - push!( - attributes, - operandsegmentsizes([ - length(asyncDependencies), - 1, - 1, - 1, - 1, - 1, - 1, - (dynamicSharedMemorySize == nothing) ? 0 : 1length(operands), - ]), - ) + push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1length(operands), ])) !isnothing(asyncToken) && push!(results, asyncToken) - - return IR.create_operation( - "gpu.launch_func", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.launch_func", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -653,33 +545,19 @@ know what value corresponds to threadIdx.x for coalescing). We can recover these properties by analyzing the operations producing values, but it is easier just to have that information by construction. """ -function launch( - gridSizeX::Value, - gridSizeY::Value, - gridSizeZ::Value, - blockSizeX::Value, - blockSizeY::Value, - blockSizeZ::Value, - dynamicSharedMemorySize=nothing::Union{Nothing,Value}; - body::Region, - location=Location(), -) +function launch(gridSizeX::Value, gridSizeY::Value, gridSizeZ::Value, blockSizeX::Value, blockSizeY::Value, blockSizeZ::Value, dynamicSharedMemorySize=nothing::Union{Nothing, Value}; body::Region, location=Location()) results = IR.Type[] - operands = Value[gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ] - owned_regions = Region[body,] + operands = Value[gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ, ] + owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] !isnothing(dynamicSharedMemorySize) && push!(operands, dynamicSharedMemorySize) - - return IR.create_operation( - "gpu.launch", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.launch", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -701,29 +579,19 @@ that case, it returns a !gpu.async.token. %token = gpu.memcpy async [%dep] %dst, %src : memref, memref ``` """ -function memcpy( - asyncDependencies::Vector{Value}, - dst::Value, - src::Value; - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function memcpy(asyncDependencies::Vector{Value}, dst::Value, src::Value; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[asyncDependencies..., dst, src] + operands = Value[asyncDependencies..., dst, src, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(asyncToken) && push!(results, asyncToken) - - return IR.create_operation( - "gpu.memcpy", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.memcpy", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -745,29 +613,19 @@ that case, it returns a !gpu.async.token. %token = gpu.memset async [%dep] %dst, %value : memref, f32 ``` """ -function memset( - asyncDependencies::Vector{Value}, - dst::Value, - value::Value; - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function memset(asyncDependencies::Vector{Value}, dst::Value, value::Value; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[asyncDependencies..., dst, value] + operands = Value[asyncDependencies..., dst, value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(asyncToken) && push!(results, asyncToken) - - return IR.create_operation( - "gpu.memset", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.memset", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -782,16 +640,12 @@ function module_end(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.module_end", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.module_end", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -806,23 +660,19 @@ Returns the number of subgroups within a workgroup. %numSg = gpu.num_subgroups : index ``` """ -function num_subgroups(; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function num_subgroups(; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "gpu.num_subgroups", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.num_subgroups", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -837,20 +687,16 @@ imposed by one\'s target platform. """ function printf(args::Vector{Value}; format, location=Location()) results = IR.Type[] - operands = Value[args...,] + operands = Value[args..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("format", format),] - - return IR.create_operation( - "gpu.printf", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("format", format), ] + + IR.create_operation( + "gpu.printf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -861,22 +707,18 @@ A terminator operation for regions that appear in the body of `gpu.func` functions. The operands to the `gpu.return` are the result values returned by an invocation of the `gpu.func`. """ -function return_(operands::Vector{Value}; location=Location()) +function return_(operands_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[operands...,] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.return", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.return", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -901,32 +743,20 @@ shuffle. The width needs to be the same for all invocations that participate in the shuffle. Exactly the first `width` invocations of a subgroup need to execute this op in convergence. """ -function shuffle( - value::Value, - offset::Value, - width::Value; - result=nothing::Union{Nothing,IR.Type}, - valid=nothing::Union{Nothing,IR.Type}, - mode, - location=Location(), -) +function shuffle(value::Value, offset::Value, width::Value; result=nothing::Union{Nothing, IR.Type}, valid=nothing::Union{Nothing, IR.Type}, mode, location=Location()) results = IR.Type[] - operands = Value[value, offset, width] + operands = Value[value, offset, width, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("mode", mode),] + attributes = NamedAttribute[namedattribute("mode", mode), ] !isnothing(result) && push!(results, result) !isnothing(valid) && push!(results, valid) - - return IR.create_operation( - "gpu.shuffle", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.shuffle", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -942,23 +772,19 @@ workgroup. %sgId = gpu.subgroup_id : index ``` """ -function subgroup_id(; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function subgroup_id(; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "gpu.subgroup_id", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.subgroup_id", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -984,29 +810,19 @@ This op is meant to be used along with `gpu.subgroup_mma_store_matrix` and -> !gpu.mma_matrix<16x16xf16, \"COp\"> ``` """ -function subgroup_mma_compute( - opA::Value, - opB::Value, - opC::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function subgroup_mma_compute(opA::Value, opB::Value, opC::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[opA, opB, opC] + operands = Value[opA, opB, opC, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "gpu.subgroup_mma_compute", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.subgroup_mma_compute", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1034,21 +850,17 @@ This op is meant to be used along with `gpu.subgroup_mma_compute`. ``` """ function subgroup_mma_constant_matrix(value::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[value,] + results = IR.Type[res, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.subgroup_mma_constant_matrix", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.subgroup_mma_constant_matrix", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1072,24 +884,18 @@ This op is meant to be used along with `gpu.subgroup_mma_compute`. -> !gpu.mma_matrix<16x16xf16, \"COp\"> ``` """ -function subgroup_mma_elementwise( - args::Vector{Value}; res::IR.Type, operation, location=Location() -) - results = IR.Type[res,] - operands = Value[args...,] +function subgroup_mma_elementwise(args::Vector{Value}; res::IR.Type, operation, location=Location()) + results = IR.Type[res, ] + operands = Value[args..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("operation", operation),] - - return IR.create_operation( - "gpu.subgroup_mma_elementwise", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("operation", operation), ] + + IR.create_operation( + "gpu.subgroup_mma_elementwise", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1117,28 +923,18 @@ This op is often meant to be used along with `gpu.subgroup_mma_store_matrix` and : memref<32x32xf16, 3>, !gpu.mma_matrix<16x16xf16, \"AOp\"> ``` """ -function subgroup_mma_load_matrix( - srcMemref::Value, - indices::Vector{Value}; - res::IR.Type, - leadDimension, - location=Location(), -) - results = IR.Type[res,] - operands = Value[srcMemref, indices...] +function subgroup_mma_load_matrix(srcMemref::Value, indices::Vector{Value}; res::IR.Type, leadDimension, location=Location()) + results = IR.Type[res, ] + operands = Value[srcMemref, indices..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("leadDimension", leadDimension),] - - return IR.create_operation( - "gpu.subgroup_mma_load_matrix", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] + + IR.create_operation( + "gpu.subgroup_mma_load_matrix", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1164,24 +960,18 @@ gpu.subgroup_mma_store_matrix %D, %sg[%i,%j] : { leadDimension = 32 : i32} : !gpu.mma_matrix<16x16xf16, \"COp\">, memref<32x32xf16, 3> ``` """ -function subgroup_mma_store_matrix( - src::Value, dstMemref::Value, indices::Vector{Value}; leadDimension, location=Location() -) +function subgroup_mma_store_matrix(src::Value, dstMemref::Value, indices::Vector{Value}; leadDimension, location=Location()) results = IR.Type[] - operands = Value[src, dstMemref, indices...] + operands = Value[src, dstMemref, indices..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("leadDimension", leadDimension),] - - return IR.create_operation( - "gpu.subgroup_mma_store_matrix", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] + + IR.create_operation( + "gpu.subgroup_mma_store_matrix", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1196,23 +986,19 @@ Returns the number of threads within a subgroup. %sgSz = gpu.subgroup_size : index ``` """ -function subgroup_size(; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function subgroup_size(; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "gpu.subgroup_size", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.subgroup_size", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1229,16 +1015,12 @@ function terminator(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.terminator", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.terminator", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1254,25 +1036,19 @@ along the x, y, or z `dimension`. %tIdX = gpu.thread_id x ``` """ -function thread_id(; - result_0=nothing::Union{Nothing,IR.Type}, dimension, location=Location() -) +function thread_id(; result_0=nothing::Union{Nothing, IR.Type}, dimension, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("dimension", dimension),] + attributes = NamedAttribute[namedattribute("dimension", dimension), ] !isnothing(result_0) && push!(results, result_0) - - return IR.create_operation( - "gpu.thread_id", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.thread_id", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1309,27 +1085,19 @@ once this op completes. Example usage: gpu.wait [%t0, %t1] ``` """ -function wait( - asyncDependencies::Vector{Value}; - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function wait(asyncDependencies::Vector{Value}; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[asyncDependencies...,] + operands = Value[asyncDependencies..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(asyncToken) && push!(results, asyncToken) - - return IR.create_operation( - "gpu.wait", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.wait", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1347,20 +1115,16 @@ gpu.yield %f0, %f1 : f32, f32 """ function yield(values::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[values...,] + operands = Value[values..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "gpu.yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/LLVMIR.jl b/src/Dialects/14/LLVMIR.jl index 4a36ccd1..47c26372 100644 --- a/src/Dialects/14/LLVMIR.jl +++ b/src/Dialects/14/LLVMIR.jl @@ -1,33 +1,26 @@ module llvm -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `ashr` """ -function ashr( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function ashr(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.ashr", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.ashr", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -48,17 +41,13 @@ function access_group(; sym_name, location=Location()) operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("sym_name", sym_name),] - - return IR.create_operation( - "llvm.access_group", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("sym_name", sym_name), ] + + IR.create_operation( + "llvm.access_group", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -66,25 +55,19 @@ end `add` """ -function add( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function add(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.add", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.add", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -93,21 +76,17 @@ end """ function addrspacecast(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.addrspacecast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.addrspacecast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -141,21 +120,17 @@ llvm.mlir.global @const(42 : i32) : i32 ``` """ function mlir_addressof(; res::IR.Type, global_name, location=Location()) - results = IR.Type[res,] + results = IR.Type[res, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("global_name", global_name),] - - return IR.create_operation( - "llvm.mlir.addressof", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("global_name", global_name), ] + + IR.create_operation( + "llvm.mlir.addressof", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -172,18 +147,14 @@ function alias_scope_domain(; sym_name, description=nothing, location=Location() operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("sym_name", sym_name),] + attributes = NamedAttribute[namedattribute("sym_name", sym_name), ] !isnothing(description) && push!(attributes, namedattribute("description", description)) - - return IR.create_operation( - "llvm.alias_scope_domain", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.alias_scope_domain", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -225,20 +196,14 @@ function alias_scope(; sym_name, domain, description=nothing, location=Location( operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("sym_name", sym_name), namedattribute("domain", domain) - ] + attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("domain", domain), ] !isnothing(description) && push!(attributes, namedattribute("description", description)) - - return IR.create_operation( - "llvm.alias_scope", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.alias_scope", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -247,22 +212,18 @@ end """ function alloca(arraySize::Value; res::IR.Type, alignment=nothing, location=Location()) - results = IR.Type[res,] - operands = Value[arraySize,] + results = IR.Type[res, ] + operands = Value[arraySize, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "llvm.alloca", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.alloca", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -270,25 +231,19 @@ end `and` """ -function and( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function and(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.and", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.and", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -298,20 +253,16 @@ end """ function intr_assume(cond::Value; location=Location()) results = IR.Type[] - operands = Value[cond,] + operands = Value[cond, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.assume", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.assume", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -319,33 +270,18 @@ end `cmpxchg` """ -function cmpxchg( - ptr::Value, - cmp::Value, - val::Value; - res::IR.Type, - success_ordering, - failure_ordering, - location=Location(), -) - results = IR.Type[res,] - operands = Value[ptr, cmp, val] - owned_regions = Region[] - successors = Block[] - attributes = NamedAttribute[ - namedattribute("success_ordering", success_ordering), - namedattribute("failure_ordering", failure_ordering), - ] - - return IR.create_operation( - "llvm.cmpxchg", - location; - operands, - owned_regions, - successors, - attributes, +function cmpxchg(ptr::Value, cmp::Value, val::Value; res::IR.Type, success_ordering, failure_ordering, location=Location()) + results = IR.Type[res, ] + operands = Value[ptr, cmp, val, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("success_ordering", success_ordering), namedattribute("failure_ordering", failure_ordering), ] + + IR.create_operation( + "llvm.cmpxchg", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -353,26 +289,18 @@ end `atomicrmw` """ -function atomicrmw( - ptr::Value, val::Value; res::IR.Type, bin_op, ordering, location=Location() -) - results = IR.Type[res,] - operands = Value[ptr, val] +function atomicrmw(ptr::Value, val::Value; res::IR.Type, bin_op, ordering, location=Location()) + results = IR.Type[res, ] + operands = Value[ptr, val, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("bin_op", bin_op), namedattribute("ordering", ordering) - ] - - return IR.create_operation( - "llvm.atomicrmw", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("bin_op", bin_op), namedattribute("ordering", ordering), ] + + IR.create_operation( + "llvm.atomicrmw", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -380,25 +308,19 @@ end `intr_bitreverse` """ -function intr_bitreverse( - in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_bitreverse(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.bitreverse", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.bitreverse", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -407,21 +329,17 @@ end """ function bitcast(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.bitcast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.bitcast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -431,20 +349,16 @@ end """ function br(destOperands::Vector{Value}; dest::Block, location=Location()) results = IR.Type[] - operands = Value[destOperands...,] + operands = Value[destOperands..., ] owned_regions = Region[] - successors = Block[dest,] + successors = Block[dest, ] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.br", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.br", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -478,31 +392,20 @@ llvm.call @bar(%0) : (f32) -> () llvm.call %1(%0) : (f32) -> () ``` """ -function call( - operand_0::Vector{Value}; - result_0::Vector{IR.Type}, - callee=nothing, - fastmathFlags=nothing, - location=Location(), -) - results = IR.Type[result_0...,] - operands = Value[operand_0...,] +function call(operand_0::Vector{Value}; result_0::Vector{IR.Type}, callee=nothing, fastmathFlags=nothing, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[operand_0..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) - !isnothing(fastmathFlags) && - push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.call", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + + IR.create_operation( + "llvm.call", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -510,36 +413,20 @@ end `cond_br` """ -function cond_br( - condition::Value, - trueDestOperands::Vector{Value}, - falseDestOperands::Vector{Value}; - branch_weights=nothing, - trueDest::Block, - falseDest::Block, - location=Location(), -) +function cond_br(condition::Value, trueDestOperands::Vector{Value}, falseDestOperands::Vector{Value}; branch_weights=nothing, trueDest::Block, falseDest::Block, location=Location()) results = IR.Type[] - operands = Value[condition, trueDestOperands..., falseDestOperands...] + operands = Value[condition, trueDestOperands..., falseDestOperands..., ] owned_regions = Region[] - successors = Block[trueDest, falseDest] + successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[] - push!( - attributes, - operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands)]), - ) - !isnothing(branch_weights) && - push!(attributes, namedattribute("branch_weights", branch_weights)) - - return IR.create_operation( - "llvm.cond_br", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands), ])) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) + + IR.create_operation( + "llvm.cond_br", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -574,21 +461,17 @@ Examples: ``` """ function mlir_constant(; res::IR.Type, value, location=Location()) - results = IR.Type[res,] + results = IR.Type[res, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("value", value),] - - return IR.create_operation( - "llvm.mlir.constant", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("value", value), ] + + IR.create_operation( + "llvm.mlir.constant", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -596,25 +479,19 @@ end `intr_copysign` """ -function intr_copysign( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_copysign(a::Value, b::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.copysign", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.copysign", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -623,21 +500,17 @@ end """ function intr_coro_align(; res::IR.Type, location=Location()) - results = IR.Type[res,] + results = IR.Type[res, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.align", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.coro.align", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -646,21 +519,17 @@ end """ function intr_coro_begin(token::Value, mem::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[token, mem] + results = IR.Type[res, ] + operands = Value[token, mem, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.begin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.coro.begin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -669,21 +538,17 @@ end """ function intr_coro_end(handle::Value, unwind::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[handle, unwind] + results = IR.Type[res, ] + operands = Value[handle, unwind, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.end", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.coro.end", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -692,21 +557,17 @@ end """ function intr_coro_free(id::Value, handle::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[id, handle] + results = IR.Type[res, ] + operands = Value[id, handle, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.free", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.coro.free", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -714,29 +575,18 @@ end `intr_coro_id` """ -function intr_coro_id( - align::Value, - promise::Value, - coroaddr::Value, - fnaddrs::Value; - res::IR.Type, - location=Location(), -) - results = IR.Type[res,] - operands = Value[align, promise, coroaddr, fnaddrs] +function intr_coro_id(align::Value, promise::Value, coroaddr::Value, fnaddrs::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[align, promise, coroaddr, fnaddrs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.id", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.coro.id", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -746,20 +596,16 @@ end """ function intr_coro_resume(handle::Value; location=Location()) results = IR.Type[] - operands = Value[handle,] + operands = Value[handle, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.resume", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.coro.resume", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -768,21 +614,17 @@ end """ function intr_coro_save(handle::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[handle,] + results = IR.Type[res, ] + operands = Value[handle, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.save", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.coro.save", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -791,21 +633,17 @@ end """ function intr_coro_size(; res::IR.Type, location=Location()) - results = IR.Type[res,] + results = IR.Type[res, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.size", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.coro.size", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -814,21 +652,17 @@ end """ function intr_coro_suspend(save::Value, final::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[save, final] + results = IR.Type[res, ] + operands = Value[save, final, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.suspend", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.coro.suspend", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -836,23 +670,19 @@ end `intr_cos` """ -function intr_cos(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_cos(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.cos", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.cos", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -861,21 +691,17 @@ end """ function intr_ctlz(in::Value, zero_undefined::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[in, zero_undefined] + results = IR.Type[res, ] + operands = Value[in, zero_undefined, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.ctlz", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.ctlz", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -884,21 +710,17 @@ end """ function intr_cttz(in::Value, zero_undefined::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[in, zero_undefined] + results = IR.Type[res, ] + operands = Value[in, zero_undefined, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.cttz", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.cttz", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -906,23 +728,19 @@ end `intr_ctpop` """ -function intr_ctpop(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_ctpop(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.ctpop", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.ctpop", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -931,21 +749,17 @@ end """ function intr_eh_typeid_for(type_info::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[type_info,] + results = IR.Type[res, ] + operands = Value[type_info, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.eh.typeid.for", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.eh.typeid.for", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -953,23 +767,19 @@ end `intr_exp2` """ -function intr_exp2(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_exp2(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.exp2", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.exp2", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -977,23 +787,19 @@ end `intr_exp` """ -function intr_exp(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_exp(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.exp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.exp", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1002,21 +808,17 @@ end """ function extractelement(vector::Value, position::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[vector, position] + results = IR.Type[res, ] + operands = Value[vector, position, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.extractelement", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.extractelement", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1025,21 +827,17 @@ end """ function extractvalue(container::Value; res::IR.Type, position, location=Location()) - results = IR.Type[res,] - operands = Value[container,] + results = IR.Type[res, ] + operands = Value[container, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("position", position),] - - return IR.create_operation( - "llvm.extractvalue", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "llvm.extractvalue", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1047,23 +845,19 @@ end `intr_fabs` """ -function intr_fabs(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_fabs(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.fabs", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.fabs", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1071,31 +865,20 @@ end `fadd` """ -function fadd( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) +function fadd(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - !isnothing(fastmathFlags) && - push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.fadd", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + + IR.create_operation( + "llvm.fadd", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1103,23 +886,19 @@ end `intr_ceil` """ -function intr_ceil(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_ceil(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.ceil", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.ceil", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1127,31 +906,19 @@ end `fcmp` """ -function fcmp( - lhs::Value, - rhs::Value; - res::IR.Type, - predicate, - fastmathFlags=nothing, - location=Location(), -) - results = IR.Type[res,] - operands = Value[lhs, rhs] - owned_regions = Region[] - successors = Block[] - attributes = NamedAttribute[namedattribute("predicate", predicate),] - !isnothing(fastmathFlags) && - push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.fcmp", - location; - operands, - owned_regions, - successors, - attributes, +function fcmp(lhs::Value, rhs::Value; res::IR.Type, predicate, fastmathFlags=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[lhs, rhs, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + + IR.create_operation( + "llvm.fcmp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1159,31 +926,20 @@ end `fdiv` """ -function fdiv( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) +function fdiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - !isnothing(fastmathFlags) && - push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.fdiv", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + + IR.create_operation( + "llvm.fdiv", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1191,23 +947,19 @@ end `intr_floor` """ -function intr_floor(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_floor(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.floor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.floor", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1215,25 +967,19 @@ end `intr_fma` """ -function intr_fma( - a::Value, b::Value, c::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_fma(a::Value, b::Value, c::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b, c] + operands = Value[a, b, c, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.fma", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.fma", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1241,25 +987,19 @@ end `intr_fmuladd` """ -function intr_fmuladd( - a::Value, b::Value, c::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_fmuladd(a::Value, b::Value, c::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b, c] + operands = Value[a, b, c, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.fmuladd", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.fmuladd", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1267,31 +1007,20 @@ end `fmul` """ -function fmul( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) +function fmul(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - !isnothing(fastmathFlags) && - push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.fmul", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + + IR.create_operation( + "llvm.fmul", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1299,30 +1028,20 @@ end `fneg` """ -function fneg( - operand::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) +function fneg(operand::Value; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - !isnothing(fastmathFlags) && - push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.fneg", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + + IR.create_operation( + "llvm.fneg", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1331,21 +1050,17 @@ end """ function fpext(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fpext", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.fpext", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1354,21 +1069,17 @@ end """ function fptosi(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptosi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.fptosi", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1377,21 +1088,17 @@ end """ function fptoui(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptoui", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.fptoui", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1400,21 +1107,17 @@ end """ function fptrunc(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptrunc", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.fptrunc", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1422,31 +1125,20 @@ end `frem` """ -function frem( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) +function frem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - !isnothing(fastmathFlags) && - push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.frem", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + + IR.create_operation( + "llvm.frem", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1454,31 +1146,20 @@ end `fsub` """ -function fsub( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) +function fsub(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - !isnothing(fastmathFlags) && - push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.fsub", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + + IR.create_operation( + "llvm.fsub", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1491,19 +1172,13 @@ function fence(; ordering, syncscope, location=Location()) operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("ordering", ordering), namedattribute("syncscope", syncscope) - ] - - return IR.create_operation( - "llvm.fence", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("ordering", ordering), namedattribute("syncscope", syncscope), ] + + IR.create_operation( + "llvm.fence", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1511,23 +1186,19 @@ end `freeze` """ -function freeze(val::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function freeze(val::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[val,] + operands = Value[val, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.freeze", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.freeze", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1535,24 +1206,18 @@ end `getelementptr` """ -function getelementptr( - base::Value, indices::Vector{Value}; res::IR.Type, structIndices, location=Location() -) - results = IR.Type[res,] - operands = Value[base, indices...] +function getelementptr(base::Value, indices::Vector{Value}; res::IR.Type, structIndices, location=Location()) + results = IR.Type[res, ] + operands = Value[base, indices..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("structIndices", structIndices),] - - return IR.create_operation( - "llvm.getelementptr", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("structIndices", structIndices), ] + + IR.create_operation( + "llvm.getelementptr", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1561,21 +1226,17 @@ end """ function intr_get_active_lane_mask(base::Value, n::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[base, n] + results = IR.Type[res, ] + operands = Value[base, n, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.get.active.lane.mask", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.get.active.lane.mask", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1606,19 +1267,13 @@ function mlir_global_ctors(; ctors, priorities, location=Location()) operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("ctors", ctors), namedattribute("priorities", priorities) - ] - - return IR.create_operation( - "llvm.mlir.global_ctors", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("ctors", ctors), namedattribute("priorities", priorities), ] + + IR.create_operation( + "llvm.mlir.global_ctors", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1646,19 +1301,13 @@ function mlir_global_dtors(; dtors, priorities, location=Location()) operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("dtors", dtors), namedattribute("priorities", priorities) - ] - - return IR.create_operation( - "llvm.mlir.global_dtors", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("dtors", dtors), namedattribute("priorities", priorities), ] + + IR.create_operation( + "llvm.mlir.global_dtors", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1759,47 +1408,25 @@ Examples: llvm.mlir.global private constant @y(dense<1.0> : tensor<8xf32>) { alignment = 32 : i64 } : !llvm.array<8 x f32> ``` """ -function mlir_global(; - global_type, - constant=nothing, - sym_name, - linkage, - dso_local=nothing, - value=nothing, - alignment=nothing, - addr_space=nothing, - unnamed_addr=nothing, - section=nothing, - initializer::Region, - location=Location(), -) +function mlir_global(; global_type, constant=nothing, sym_name, linkage, dso_local=nothing, value=nothing, alignment=nothing, addr_space=nothing, unnamed_addr=nothing, section=nothing, initializer::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[initializer,] + owned_regions = Region[initializer, ] successors = Block[] - attributes = NamedAttribute[ - namedattribute("global_type", global_type), - namedattribute("sym_name", sym_name), - namedattribute("linkage", linkage), - ] + attributes = NamedAttribute[namedattribute("global_type", global_type), namedattribute("sym_name", sym_name), namedattribute("linkage", linkage), ] !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(unnamed_addr) && push!(attributes, namedattribute("unnamed_addr", unnamed_addr)) !isnothing(section) && push!(attributes, namedattribute("section", section)) - - return IR.create_operation( - "llvm.mlir.global", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.mlir.global", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1808,21 +1435,17 @@ end """ function icmp(lhs::Value, rhs::Value; res::IR.Type, predicate, location=Location()) - results = IR.Type[res,] - operands = Value[lhs, rhs] + results = IR.Type[res, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("predicate", predicate),] - - return IR.create_operation( - "llvm.icmp", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "llvm.icmp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1836,42 +1459,23 @@ written, or referenced. Attempting to define or reference any symbol or any global behavior is considered undefined behavior at this time. """ -function inline_asm( - operands::Vector{Value}; - res=nothing::Union{Nothing,IR.Type}, - asm_string, - constraints, - has_side_effects=nothing, - is_align_stack=nothing, - asm_dialect=nothing, - operand_attrs=nothing, - location=Location(), -) +function inline_asm(operands_::Vector{Value}; res=nothing::Union{Nothing, IR.Type}, asm_string, constraints, has_side_effects=nothing, is_align_stack=nothing, asm_dialect=nothing, operand_attrs=nothing, location=Location()) results = IR.Type[] - operands = Value[operands...,] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("asm_string", asm_string), namedattribute("constraints", constraints) - ] + attributes = NamedAttribute[namedattribute("asm_string", asm_string), namedattribute("constraints", constraints), ] !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(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)) - - return IR.create_operation( - "llvm.inline_asm", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(operand_attrs) && push!(attributes, namedattribute("operand_attrs", operand_attrs)) + + IR.create_operation( + "llvm.inline_asm", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1879,24 +1483,18 @@ end `insertelement` """ -function insertelement( - vector::Value, value::Value, position::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[vector, value, position] +function insertelement(vector::Value, value::Value, position::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[vector, value, position, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.insertelement", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.insertelement", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1904,24 +1502,18 @@ end `insertvalue` """ -function insertvalue( - container::Value, value::Value; res::IR.Type, position, location=Location() -) - results = IR.Type[res,] - operands = Value[container, value] +function insertvalue(container::Value, value::Value; res::IR.Type, position, location=Location()) + results = IR.Type[res, ] + operands = Value[container, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("position", position),] - - return IR.create_operation( - "llvm.insertvalue", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "llvm.insertvalue", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1930,21 +1522,17 @@ end """ function inttoptr(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.inttoptr", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.inttoptr", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1952,38 +1540,20 @@ end `invoke` """ -function invoke( - callee_operands::Vector{Value}, - normalDestOperands::Vector{Value}, - unwindDestOperands::Vector{Value}; - result_0::Vector{IR.Type}, - callee=nothing, - normalDest::Block, - unwindDest::Block, - location=Location(), -) - results = IR.Type[result_0...,] - operands = Value[callee_operands..., normalDestOperands..., unwindDestOperands...] - owned_regions = Region[] - successors = Block[normalDest, unwindDest] +function invoke(callee_operands::Vector{Value}, normalDestOperands::Vector{Value}, unwindDestOperands::Vector{Value}; result_0::Vector{IR.Type}, callee=nothing, normalDest::Block, unwindDest::Block, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[callee_operands..., normalDestOperands..., unwindDestOperands..., ] + owned_regions = Region[] + successors = Block[normalDest, unwindDest, ] attributes = NamedAttribute[] - push!( - attributes, - operandsegmentsizes([ - length(callee_operands), length(normalDestOperands), length(unwindDestOperands) - ]), - ) + push!(attributes, operandsegmentsizes([length(callee_operands), length(normalDestOperands), length(unwindDestOperands), ])) !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) - - return IR.create_operation( - "llvm.invoke", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.invoke", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2016,33 +1586,22 @@ llvm.func internal @internal_func() { } ``` """ -function func(; - linkage=nothing, - dso_local=nothing, - personality=nothing, - passthrough=nothing, - body::Region, - location=Location(), -) +function func(; linkage=nothing, dso_local=nothing, personality=nothing, passthrough=nothing, body::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] !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)) - - return IR.create_operation( - "llvm.func", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.func", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2050,25 +1609,19 @@ end `lshr` """ -function lshr( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function lshr(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.lshr", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.lshr", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2076,25 +1629,19 @@ end `landingpad` """ -function landingpad( - operand_0::Vector{Value}; res::IR.Type, cleanup=nothing, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0...,] +function landingpad(operand_0::Vector{Value}; res::IR.Type, cleanup=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(cleanup) && push!(attributes, namedattribute("cleanup", cleanup)) - - return IR.create_operation( - "llvm.landingpad", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.landingpad", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2102,41 +1649,24 @@ end `load` """ -function load( - addr::Value; - res::IR.Type, - access_groups=nothing, - alias_scopes=nothing, - noalias_scopes=nothing, - alignment=nothing, - volatile_=nothing, - nontemporal=nothing, - location=Location(), -) - results = IR.Type[res,] - operands = Value[addr,] +function load(addr::Value; res::IR.Type, access_groups=nothing, alias_scopes=nothing, noalias_scopes=nothing, alignment=nothing, volatile_=nothing, nontemporal=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[addr, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !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(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)) - - return IR.create_operation( - "llvm.load", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.load", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2144,23 +1674,19 @@ end `intr_log10` """ -function intr_log10(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_log10(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.log10", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.log10", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2168,23 +1694,19 @@ end `intr_log2` """ -function intr_log2(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_log2(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.log2", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.log2", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2192,23 +1714,19 @@ end `intr_log` """ -function intr_log(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_log(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.log", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.log", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2216,29 +1734,18 @@ end `intr_masked_load` """ -function intr_masked_load( - data::Value, - mask::Value, - pass_thru::Vector{Value}; - res::IR.Type, - alignment, - location=Location(), -) - results = IR.Type[res,] - operands = Value[data, mask, pass_thru...] +function intr_masked_load(data::Value, mask::Value, pass_thru::Vector{Value}; res::IR.Type, alignment, location=Location()) + results = IR.Type[res, ] + operands = Value[data, mask, pass_thru..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.load", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "llvm.intr.masked.load", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2246,24 +1753,18 @@ end `intr_masked_store` """ -function intr_masked_store( - value::Value, data::Value, mask::Value; alignment, location=Location() -) +function intr_masked_store(value::Value, data::Value, mask::Value; alignment, location=Location()) results = IR.Type[] - operands = Value[value, data, mask] + operands = Value[value, data, mask, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.store", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "llvm.intr.masked.store", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2271,28 +1772,18 @@ end `intr_matrix_column_major_load` """ -function intr_matrix_column_major_load( - data::Value, stride::Value; res::IR.Type, isVolatile, rows, columns, location=Location() -) - results = IR.Type[res,] - operands = Value[data, stride] +function intr_matrix_column_major_load(data::Value, stride::Value; res::IR.Type, isVolatile, rows, columns, location=Location()) + results = IR.Type[res, ] + operands = Value[data, stride, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("isVolatile", isVolatile), - namedattribute("rows", rows), - namedattribute("columns", columns), - ] - - return IR.create_operation( - "llvm.intr.matrix.column.major.load", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("isVolatile", isVolatile), namedattribute("rows", rows), namedattribute("columns", columns), ] + + IR.create_operation( + "llvm.intr.matrix.column.major.load", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2300,34 +1791,18 @@ end `intr_matrix_column_major_store` """ -function intr_matrix_column_major_store( - matrix::Value, - data::Value, - stride::Value; - isVolatile, - rows, - columns, - location=Location(), -) +function intr_matrix_column_major_store(matrix::Value, data::Value, stride::Value; isVolatile, rows, columns, location=Location()) results = IR.Type[] - operands = Value[matrix, data, stride] - owned_regions = Region[] - successors = Block[] - attributes = NamedAttribute[ - namedattribute("isVolatile", isVolatile), - namedattribute("rows", rows), - namedattribute("columns", columns), - ] - - return IR.create_operation( - "llvm.intr.matrix.column.major.store", - location; - operands, - owned_regions, - successors, - attributes, + operands = Value[matrix, data, stride, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("isVolatile", isVolatile), namedattribute("rows", rows), namedattribute("columns", columns), ] + + IR.create_operation( + "llvm.intr.matrix.column.major.store", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2335,34 +1810,18 @@ end `intr_matrix_multiply` """ -function intr_matrix_multiply( - lhs::Value, - rhs::Value; - res::IR.Type, - lhs_rows, - lhs_columns, - rhs_columns, - location=Location(), -) - results = IR.Type[res,] - operands = Value[lhs, rhs] - owned_regions = Region[] - successors = Block[] - attributes = NamedAttribute[ - namedattribute("lhs_rows", lhs_rows), - namedattribute("lhs_columns", lhs_columns), - namedattribute("rhs_columns", rhs_columns), - ] - - return IR.create_operation( - "llvm.intr.matrix.multiply", - location; - operands, - owned_regions, - successors, - attributes, +function intr_matrix_multiply(lhs::Value, rhs::Value; res::IR.Type, lhs_rows, lhs_columns, rhs_columns, location=Location()) + results = IR.Type[res, ] + operands = Value[lhs, rhs, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("lhs_rows", lhs_rows), namedattribute("lhs_columns", lhs_columns), namedattribute("rhs_columns", rhs_columns), ] + + IR.create_operation( + "llvm.intr.matrix.multiply", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2370,26 +1829,18 @@ end `intr_matrix_transpose` """ -function intr_matrix_transpose( - matrix::Value; res::IR.Type, rows, columns, location=Location() -) - results = IR.Type[res,] - operands = Value[matrix,] +function intr_matrix_transpose(matrix::Value; res::IR.Type, rows, columns, location=Location()) + results = IR.Type[res, ] + operands = Value[matrix, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("rows", rows), namedattribute("columns", columns) - ] - - return IR.create_operation( - "llvm.intr.matrix.transpose", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("rows", rows), namedattribute("columns", columns), ] + + IR.create_operation( + "llvm.intr.matrix.transpose", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2397,25 +1848,19 @@ end `intr_maxnum` """ -function intr_maxnum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_maxnum(a::Value, b::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.maxnum", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.maxnum", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2423,25 +1868,19 @@ end `intr_maximum` """ -function intr_maximum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_maximum(a::Value, b::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.maximum", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.maximum", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2449,24 +1888,18 @@ end `intr_memcpy_inline` """ -function intr_memcpy_inline( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) +function intr_memcpy_inline(dst::Value, src::Value, len::Value, isVolatile::Value; location=Location()) results = IR.Type[] - operands = Value[dst, src, len, isVolatile] + operands = Value[dst, src, len, isVolatile, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memcpy.inline", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.memcpy.inline", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2474,24 +1907,18 @@ end `intr_memcpy` """ -function intr_memcpy( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) +function intr_memcpy(dst::Value, src::Value, len::Value, isVolatile::Value; location=Location()) results = IR.Type[] - operands = Value[dst, src, len, isVolatile] + operands = Value[dst, src, len, isVolatile, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memcpy", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.memcpy", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2499,24 +1926,18 @@ end `intr_memmove` """ -function intr_memmove( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) +function intr_memmove(dst::Value, src::Value, len::Value, isVolatile::Value; location=Location()) results = IR.Type[] - operands = Value[dst, src, len, isVolatile] + operands = Value[dst, src, len, isVolatile, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memmove", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.memmove", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2524,24 +1945,18 @@ end `intr_memset` """ -function intr_memset( - dst::Value, val::Value, len::Value, isVolatile::Value; location=Location() -) +function intr_memset(dst::Value, val::Value, len::Value, isVolatile::Value; location=Location()) results = IR.Type[] - operands = Value[dst, val, len, isVolatile] + operands = Value[dst, val, len, isVolatile, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memset", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.memset", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2560,19 +1975,15 @@ llvm.metadata op defines one or more metadata nodes. function metadata(; sym_name, body::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] - attributes = NamedAttribute[namedattribute("sym_name", sym_name),] - - return IR.create_operation( - "llvm.metadata", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("sym_name", sym_name), ] + + IR.create_operation( + "llvm.metadata", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2580,25 +1991,19 @@ end `intr_minnum` """ -function intr_minnum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_minnum(a::Value, b::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.minnum", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.minnum", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2606,25 +2011,19 @@ end `intr_minimum` """ -function intr_minimum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_minimum(a::Value, b::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.minimum", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.minimum", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2632,25 +2031,19 @@ end `mul` """ -function mul( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function mul(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.mul", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.mul", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2673,21 +2066,17 @@ Examples: ``` """ function mlir_null(; res::IR.Type, location=Location()) - results = IR.Type[res,] + results = IR.Type[res, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.mlir.null", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.mlir.null", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2695,25 +2084,19 @@ end `or` """ -function or( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function or(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.or", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.or", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2722,21 +2105,17 @@ end """ function intr_powi(a::Value, b::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[a, b] + results = IR.Type[res, ] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.powi", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.powi", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2744,25 +2123,19 @@ end `intr_pow` """ -function intr_pow( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_pow(a::Value, b::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.pow", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.pow", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2770,24 +2143,18 @@ end `intr_prefetch` """ -function intr_prefetch( - addr::Value, rw::Value, hint::Value, cache::Value; location=Location() -) +function intr_prefetch(addr::Value, rw::Value, hint::Value, cache::Value; location=Location()) results = IR.Type[] - operands = Value[addr, rw, hint, cache] + operands = Value[addr, rw, hint, cache, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.prefetch", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.prefetch", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2796,21 +2163,17 @@ end """ function ptrtoint(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.ptrtoint", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.ptrtoint", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2820,20 +2183,16 @@ end """ function resume(value::Value; location=Location()) results = IR.Type[] - operands = Value[value,] + operands = Value[value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.resume", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.resume", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2843,20 +2202,16 @@ end """ function return_(args::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[args...,] + operands = Value[args..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.return", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.return", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2864,24 +2219,18 @@ end `intr_sadd_with_overflow` """ -function intr_sadd_with_overflow( - operand_0::Value, operand_1::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1] +function intr_sadd_with_overflow(operand_0::Value, operand_1::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.sadd.with.overflow", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.sadd.with.overflow", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2889,25 +2238,19 @@ end `sdiv` """ -function sdiv( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function sdiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.sdiv", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.sdiv", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2916,21 +2259,17 @@ end """ function sext(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.sext", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.sext", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2939,21 +2278,17 @@ end """ function sitofp(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.sitofp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.sitofp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2961,25 +2296,19 @@ end `intr_smax` """ -function intr_smax( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_smax(a::Value, b::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.smax", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.smax", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2987,25 +2316,19 @@ end `intr_smin` """ -function intr_smin( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_smin(a::Value, b::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.smin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.smin", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3013,24 +2336,18 @@ end `intr_smul_with_overflow` """ -function intr_smul_with_overflow( - operand_0::Value, operand_1::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1] +function intr_smul_with_overflow(operand_0::Value, operand_1::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.smul.with.overflow", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.smul.with.overflow", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3038,25 +2355,19 @@ end `srem` """ -function srem( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function srem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.srem", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.srem", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3064,24 +2375,18 @@ end `intr_ssub_with_overflow` """ -function intr_ssub_with_overflow( - operand_0::Value, operand_1::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1] +function intr_ssub_with_overflow(operand_0::Value, operand_1::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.ssub.with.overflow", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.ssub.with.overflow", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3089,29 +2394,19 @@ end `select` """ -function select( - condition::Value, - trueValue::Value, - falseValue::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function select(condition::Value, trueValue::Value, falseValue::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[condition, trueValue, falseValue] + operands = Value[condition, trueValue, falseValue, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.select", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.select", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3119,25 +2414,19 @@ end `shl` """ -function shl( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function shl(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.shl", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.shl", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3146,21 +2435,17 @@ end """ function shufflevector(v1::Value, v2::Value; res::IR.Type, mask, location=Location()) - results = IR.Type[res,] - operands = Value[v1, v2] + results = IR.Type[res, ] + operands = Value[v1, v2, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("mask", mask),] - - return IR.create_operation( - "llvm.shufflevector", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("mask", mask), ] + + IR.create_operation( + "llvm.shufflevector", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3168,23 +2453,19 @@ end `intr_sin` """ -function intr_sin(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_sin(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.sin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.sin", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3192,23 +2473,19 @@ end `intr_sqrt` """ -function intr_sqrt(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) +function intr_sqrt(in::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[in,] + operands = Value[in, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.sqrt", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.sqrt", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3218,20 +2495,16 @@ end """ function intr_stackrestore(ptr::Value; location=Location()) results = IR.Type[] - operands = Value[ptr,] + operands = Value[ptr, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.stackrestore", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.stackrestore", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3240,21 +2513,17 @@ end """ function intr_stacksave(; res::IR.Type, location=Location()) - results = IR.Type[res,] + results = IR.Type[res, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.stacksave", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.stacksave", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3262,41 +2531,24 @@ end `store` """ -function store( - value::Value, - addr::Value; - access_groups=nothing, - alias_scopes=nothing, - noalias_scopes=nothing, - alignment=nothing, - volatile_=nothing, - nontemporal=nothing, - location=Location(), -) +function store(value::Value, addr::Value; access_groups=nothing, alias_scopes=nothing, noalias_scopes=nothing, alignment=nothing, volatile_=nothing, nontemporal=nothing, location=Location()) results = IR.Type[] - operands = Value[value, addr] + operands = Value[value, addr, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !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(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)) - - return IR.create_operation( - "llvm.store", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.store", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3304,25 +2556,19 @@ end `sub` """ -function sub( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function sub(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.sub", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.sub", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3330,40 +2576,21 @@ end `switch` """ -function switch( - value::Value, - defaultOperands::Vector{Value}, - caseOperands::Vector{Value}; - case_values=nothing, - case_operand_segments, - branch_weights=nothing, - defaultDestination::Block, - caseDestinations::Vector{Block}, - location=Location(), -) +function switch(value::Value, defaultOperands::Vector{Value}, caseOperands::Vector{Value}; case_values=nothing, case_operand_segments, branch_weights=nothing, defaultDestination::Block, caseDestinations::Vector{Block}, location=Location()) results = IR.Type[] - operands = Value[value, defaultOperands..., caseOperands...] + operands = Value[value, defaultOperands..., caseOperands..., ] owned_regions = Region[] - successors = Block[defaultDestination, caseDestinations...] - attributes = NamedAttribute[namedattribute( - "case_operand_segments", case_operand_segments - ),] - push!( - attributes, operandsegmentsizes([1, length(defaultOperands), length(caseOperands)]) - ) + successors = Block[defaultDestination, caseDestinations..., ] + attributes = NamedAttribute[namedattribute("case_operand_segments", case_operand_segments), ] + push!(attributes, operandsegmentsizes([1, length(defaultOperands), length(caseOperands), ])) !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) - !isnothing(branch_weights) && - push!(attributes, namedattribute("branch_weights", branch_weights)) - - return IR.create_operation( - "llvm.switch", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) + + IR.create_operation( + "llvm.switch", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3372,21 +2599,17 @@ end """ function trunc(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.trunc", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.trunc", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3394,24 +2617,18 @@ end `intr_uadd_with_overflow` """ -function intr_uadd_with_overflow( - operand_0::Value, operand_1::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1] +function intr_uadd_with_overflow(operand_0::Value, operand_1::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.uadd.with.overflow", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.uadd.with.overflow", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3419,25 +2636,19 @@ end `udiv` """ -function udiv( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function udiv(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.udiv", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.udiv", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3446,21 +2657,17 @@ end """ function uitofp(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.uitofp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.uitofp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3468,25 +2675,19 @@ end `intr_umax` """ -function intr_umax( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_umax(a::Value, b::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.umax", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.umax", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3494,25 +2695,19 @@ end `intr_umin` """ -function intr_umin( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function intr_umin(a::Value, b::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.intr.umin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.umin", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3520,24 +2715,18 @@ end `intr_umul_with_overflow` """ -function intr_umul_with_overflow( - operand_0::Value, operand_1::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1] +function intr_umul_with_overflow(operand_0::Value, operand_1::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.umul.with.overflow", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.umul.with.overflow", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3545,25 +2734,19 @@ end `urem` """ -function urem( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function urem(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.urem", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.urem", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3571,24 +2754,18 @@ end `intr_usub_with_overflow` """ -function intr_usub_with_overflow( - operand_0::Value, operand_1::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1] +function intr_usub_with_overflow(operand_0::Value, operand_1::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.usub.with.overflow", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.usub.with.overflow", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3608,21 +2785,17 @@ IR dialect type wrapping an LLVM IR structure type. ``` """ function mlir_undef(; res::IR.Type, location=Location()) - results = IR.Type[res,] + results = IR.Type[res, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.mlir.undef", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.mlir.undef", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3636,16 +2809,12 @@ function unreachable(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.unreachable", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.unreachable", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3653,25 +2822,19 @@ end `xor` """ -function xor( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function xor(lhs::Value, rhs::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "llvm.xor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.xor", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3680,21 +2843,17 @@ end """ function zext(arg::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[arg,] + results = IR.Type[res, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.zext", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.zext", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3702,24 +2861,18 @@ end `intr_masked_compressstore` """ -function intr_masked_compressstore( - operand_0::Value, operand_1::Value, operand_2::Value; location=Location() -) +function intr_masked_compressstore(operand_0::Value, operand_1::Value, operand_2::Value; location=Location()) results = IR.Type[] - operands = Value[operand_0, operand_1, operand_2] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.masked.compressstore", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.masked.compressstore", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3727,24 +2880,18 @@ end `intr_masked_expandload` """ -function intr_masked_expandload( - operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1, operand_2] +function intr_masked_expandload(operand_0::Value, operand_1::Value, operand_2::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, operand_2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.masked.expandload", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.masked.expandload", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3752,29 +2899,18 @@ end `intr_masked_gather` """ -function intr_masked_gather( - ptrs::Value, - mask::Value, - pass_thru::Vector{Value}; - res::IR.Type, - alignment, - location=Location(), -) - results = IR.Type[res,] - operands = Value[ptrs, mask, pass_thru...] +function intr_masked_gather(ptrs::Value, mask::Value, pass_thru::Vector{Value}; res::IR.Type, alignment, location=Location()) + results = IR.Type[res, ] + operands = Value[ptrs, mask, pass_thru..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.gather", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "llvm.intr.masked.gather", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3782,24 +2918,18 @@ end `intr_masked_scatter` """ -function intr_masked_scatter( - value::Value, ptrs::Value, mask::Value; alignment, location=Location() -) +function intr_masked_scatter(value::Value, ptrs::Value, mask::Value; alignment, location=Location()) results = IR.Type[] - operands = Value[value, ptrs, mask] + operands = Value[value, ptrs, mask, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.scatter", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "llvm.intr.masked.scatter", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3808,21 +2938,17 @@ end """ function intr_vector_reduce_add(operand_0::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0,] + results = IR.Type[res, ] + operands = Value[operand_0, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.add", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.add", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3831,21 +2957,17 @@ end """ function intr_vector_reduce_and(operand_0::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0,] + results = IR.Type[res, ] + operands = Value[operand_0, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.and", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.and", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3853,25 +2975,19 @@ end `intr_vector_reduce_fadd` """ -function intr_vector_reduce_fadd( - operand_0::Value, operand_1::Value; res::IR.Type, reassoc=nothing, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1] +function intr_vector_reduce_fadd(operand_0::Value, operand_1::Value; res::IR.Type, reassoc=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(reassoc) && push!(attributes, namedattribute("reassoc", reassoc)) - - return IR.create_operation( - "llvm.intr.vector.reduce.fadd", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.fadd", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3880,21 +2996,17 @@ end """ function intr_vector_reduce_fmax(operand_0::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0,] + results = IR.Type[res, ] + operands = Value[operand_0, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.fmax", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.fmax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3903,21 +3015,17 @@ end """ function intr_vector_reduce_fmin(operand_0::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0,] + results = IR.Type[res, ] + operands = Value[operand_0, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.fmin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.fmin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3925,25 +3033,19 @@ end `intr_vector_reduce_fmul` """ -function intr_vector_reduce_fmul( - operand_0::Value, operand_1::Value; res::IR.Type, reassoc=nothing, location=Location() -) - results = IR.Type[res,] - operands = Value[operand_0, operand_1] +function intr_vector_reduce_fmul(operand_0::Value, operand_1::Value; res::IR.Type, reassoc=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[operand_0, operand_1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(reassoc) && push!(attributes, namedattribute("reassoc", reassoc)) - - return IR.create_operation( - "llvm.intr.vector.reduce.fmul", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.fmul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3952,21 +3054,17 @@ end """ function intr_vector_reduce_mul(operand_0::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0,] + results = IR.Type[res, ] + operands = Value[operand_0, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.mul", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.mul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3975,21 +3073,17 @@ end """ function intr_vector_reduce_or(operand_0::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0,] + results = IR.Type[res, ] + operands = Value[operand_0, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.or", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.or", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3998,21 +3092,17 @@ end """ function intr_vector_reduce_smax(operand_0::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0,] + results = IR.Type[res, ] + operands = Value[operand_0, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.smax", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.smax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4021,21 +3111,17 @@ end """ function intr_vector_reduce_smin(operand_0::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0,] + results = IR.Type[res, ] + operands = Value[operand_0, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.smin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.smin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4044,21 +3130,17 @@ end """ function intr_vector_reduce_umax(operand_0::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0,] + results = IR.Type[res, ] + operands = Value[operand_0, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.umax", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.umax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4067,21 +3149,17 @@ end """ function intr_vector_reduce_umin(operand_0::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0,] + results = IR.Type[res, ] + operands = Value[operand_0, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.umin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.umin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4090,21 +3168,17 @@ end """ function intr_vector_reduce_xor(operand_0::Value; res::IR.Type, location=Location()) - results = IR.Type[res,] - operands = Value[operand_0,] + results = IR.Type[res, ] + operands = Value[operand_0, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.xor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vector.reduce.xor", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4113,21 +3187,17 @@ end """ function intr_vscale(; res::IR.Type, location=Location()) - results = IR.Type[res,] + results = IR.Type[res, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vscale", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "llvm.intr.vscale", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Linalg.jl b/src/Dialects/14/Linalg.jl index 97f7e61b..2c40ce75 100644 --- a/src/Dialects/14/Linalg.jl +++ b/src/Dialects/14/Linalg.jl @@ -1,9 +1,8 @@ module linalg -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `index` @@ -42,23 +41,19 @@ scf.for %i = %c0 to %0 step %c1 { } ``` """ -function index(; result=nothing::Union{Nothing,IR.Type}, dim, location=Location()) +function index(; result=nothing::Union{Nothing, IR.Type}, dim, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("dim", dim),] + attributes = NamedAttribute[namedattribute("dim", dim), ] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "linalg.index", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "linalg.index", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -68,24 +63,18 @@ end `linalg.init_tensor` is an operation that materializes a tensor of a given shape. The shape could be dynamic or static. """ -function init_tensor( - sizes::Vector{Value}; result::IR.Type, static_sizes, location=Location() -) - results = IR.Type[result,] - operands = Value[sizes...,] +function init_tensor(sizes::Vector{Value}; result::IR.Type, static_sizes, location=Location()) + results = IR.Type[result, ] + operands = Value[sizes..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("static_sizes", static_sizes),] - - return IR.create_operation( - "linalg.init_tensor", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("static_sizes", static_sizes), ] + + IR.create_operation( + "linalg.init_tensor", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -158,45 +147,20 @@ linalg.tiled_loop (%i) = (%c0) to (%c24) step (%c4) } ``` """ -function tiled_loop( - lowerBound::Vector{Value}, - upperBound::Vector{Value}, - step::Vector{Value}, - inputs::Vector{Value}, - outputs::Vector{Value}; - results::Vector{IR.Type}, - iterator_types, - distribution_types=nothing, - region::Region, - location=Location(), -) - results = IR.Type[results...,] - operands = Value[lowerBound..., upperBound..., step..., inputs..., outputs...] - owned_regions = Region[region,] +function tiled_loop(lowerBound::Vector{Value}, upperBound::Vector{Value}, step::Vector{Value}, inputs::Vector{Value}, outputs::Vector{Value}; results_::Vector{IR.Type}, iterator_types, distribution_types=nothing, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[lowerBound..., upperBound..., step..., inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] - attributes = NamedAttribute[namedattribute("iterator_types", iterator_types),] - push!( - attributes, - operandsegmentsizes([ - length(lowerBound), - length(upperBound), - length(step), - length(inputs), - length(outputs), - ]), - ) - !isnothing(distribution_types) && - push!(attributes, namedattribute("distribution_types", distribution_types)) - - return IR.create_operation( - "linalg.tiled_loop", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("iterator_types", iterator_types), ] + push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(inputs), length(outputs), ])) + !isnothing(distribution_types) && push!(attributes, namedattribute("distribution_types", distribution_types)) + + IR.create_operation( + "linalg.tiled_loop", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -215,27 +179,22 @@ linalg.yield %f0, %f1 : f32, f32 """ function yield(values::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[values...,] + operands = Value[values..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "linalg.yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "linalg.yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `batch_matmul` @@ -243,29 +202,19 @@ import ...API 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function batch_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.batch_matmul", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matmul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -275,29 +224,19 @@ end 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function batch_matvec(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.batch_matvec", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matvec", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -307,33 +246,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function conv_1d_nwc_wcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.conv_1d_nwc_wcf", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_1d_nwc_wcf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -343,29 +268,19 @@ end 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function conv_1d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_1d", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_1d", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -379,33 +294,19 @@ Layout: 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function conv_2d_nchw_fchw(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.conv_2d_nchw_fchw", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_2d_nchw_fchw", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -419,33 +320,19 @@ Layout: 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function conv_2d_nhwc_hwcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.conv_2d_nhwc_hwcf", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_2d_nhwc_hwcf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -460,33 +347,19 @@ 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function conv_2d_nhwc_hwcf_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.conv_2d_nhwc_hwcf_q", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_2d_nhwc_hwcf_q", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -496,29 +369,19 @@ end 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function conv_2d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_2d", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_2d", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -528,33 +391,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function conv_3d_ndhwc_dhwcf(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.conv_3d_ndhwc_dhwcf", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_3d_ndhwc_dhwcf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -564,29 +413,19 @@ end 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function conv_3d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_3d", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_3d", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -597,33 +436,19 @@ 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function depthwise_conv_1d_nwc_wc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.depthwise_conv_1d_nwc_wc", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.depthwise_conv_1d_nwc_wc", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -634,33 +459,19 @@ 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function depthwise_conv_2d_nhwc_hwc(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwc", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -670,33 +481,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function depthwise_conv_2d_nhwc_hwc_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwc_q", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc_q", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -706,33 +503,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function depthwise_conv_2d_nhwc_hwcm(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwcm", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -742,33 +525,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function depthwise_conv_2d_nhwc_hwcm_q(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwcm_q", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm_q", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -778,29 +547,19 @@ end 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function dot(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.dot", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.dot", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -808,29 +567,19 @@ end `fill` """ -function fill( - value::Value, - output::Value; - result=nothing::Union{Nothing,IR.Type}, - region::Region, - location=Location(), -) +function fill(value::Value, output::Value; result=nothing::Union{Nothing, IR.Type}, region::Region, location=Location()) results = IR.Type[] - operands = Value[value, output] - owned_regions = Region[region,] + operands = Value[value, output, ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "linalg.fill", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "linalg.fill", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -845,29 +594,19 @@ 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function fill_rng_2d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.fill_rng_2d", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.fill_rng_2d", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -970,39 +709,21 @@ tensors and buffers operands and tensor results. -> (tensor) ``` """ -function generic( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - indexing_maps, - iterator_types, - doc=nothing, - library_call=nothing, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function generic(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, indexing_maps, iterator_types, doc=nothing, library_call=nothing, region::Region, location=Location()) + results = IR.Type[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)])) + 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)) - - return IR.create_operation( - "linalg.generic", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(library_call) && push!(attributes, namedattribute("library_call", library_call)) + + IR.create_operation( + "linalg.generic", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1012,29 +733,19 @@ end 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matmul", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matmul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1044,29 +755,19 @@ end 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function matmul_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matmul_unsigned", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matmul_unsigned", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1076,29 +777,19 @@ end 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function matvec(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matvec", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matvec", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1113,29 +804,19 @@ Differences from linalg.matmul: \'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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function mmt4d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.mmt4d", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.mmt4d", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1145,33 +826,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function pooling_nchw_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.pooling_nchw_max", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.pooling_nchw_max", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1181,33 +848,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function pooling_ndhwc_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.pooling_ndhwc_max", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.pooling_ndhwc_max", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1217,33 +870,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function pooling_ndhwc_min(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.pooling_ndhwc_min", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.pooling_ndhwc_min", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1253,33 +892,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function pooling_ndhwc_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.pooling_ndhwc_sum", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.pooling_ndhwc_sum", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1289,33 +914,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function pooling_nhwc_max(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.pooling_nhwc_max", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.pooling_nhwc_max", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1325,33 +936,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function pooling_nhwc_max_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.pooling_nhwc_max_unsigned", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.pooling_nhwc_max_unsigned", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1361,33 +958,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function pooling_nhwc_min(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.pooling_nhwc_min", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.pooling_nhwc_min", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1397,33 +980,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function pooling_nhwc_min_unsigned(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.pooling_nhwc_min_unsigned", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.pooling_nhwc_min_unsigned", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1433,33 +1002,19 @@ end 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{IR.Type}, - strides, - dilations, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function pooling_nhwc_sum(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[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)])) - - return IR.create_operation( - "linalg.pooling_nhwc_sum", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("strides", strides), namedattribute("dilations", dilations), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.pooling_nhwc_sum", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1471,29 +1026,19 @@ 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function quantized_batch_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.quantized_batch_matmul", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.quantized_batch_matmul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1505,29 +1050,19 @@ 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function quantized_matmul(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.quantized_matmul", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.quantized_matmul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1537,29 +1072,19 @@ end 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function soft_plus_2d(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.soft_plus_2d", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.soft_plus_2d", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1569,29 +1094,19 @@ end 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{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result_tensors...,] - operands = Value[inputs..., outputs...] - owned_regions = Region[region,] +function vecmat(inputs::Vector{Value}, outputs::Vector{Value}; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[inputs..., outputs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.vecmat", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.vecmat", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Math.jl b/src/Dialects/14/Math.jl index 97367533..1db31b89 100644 --- a/src/Dialects/14/Math.jl +++ b/src/Dialects/14/Math.jl @@ -1,9 +1,8 @@ module math -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `abs` @@ -25,23 +24,19 @@ a vector whose element type is float, or a tensor of floats. %x = math.abs %y : tensor<4x?xf8> ``` """ -function abs(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function abs(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.abs", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.abs", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -79,25 +74,19 @@ See also https://en.wikipedia.org/wiki/Atan2 %x = math.atan2 %y, %z : tensor<4x?xf32> ``` """ -function atan2( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function atan2(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.atan2", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.atan2", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -128,23 +117,19 @@ floats. It has no standard attributes. %x = math.atan %y : tensor<4x?xf8> ``` """ -function atan(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function atan(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.atan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.atan", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -175,23 +160,19 @@ It has no standard attributes. %x = math.ceil %y : tensor<4x?xf8> ``` """ -function ceil(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function ceil(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.ceil", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.ceil", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -223,25 +204,19 @@ attributes. %x = math.copysign %y, %z : tensor<4x?xf8> ``` """ -function copysign( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function copysign(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.copysign", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.copysign", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -272,23 +247,19 @@ It has no standard attributes. %x = math.cos %y : tensor<4x?xf8> ``` """ -function cos(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function cos(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.cos", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.cos", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -310,23 +281,19 @@ The `ctlz` operation computes the number of leading zeros of an integer value. %x = math.ctlz %y : tensor<4x?xi8> ``` """ -function ctlz(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function ctlz(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.ctlz", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.ctlz", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -348,23 +315,19 @@ The `cttz` operation computes the number of trailing zeros of an integer value. %x = math.cttz %y : tensor<4x?xi8> ``` """ -function cttz(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function cttz(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.cttz", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.cttz", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -386,23 +349,19 @@ The `ctpop` operation computes the number of set bits of an integer value. %x = math.ctpop %y : tensor<4x?xi8> ``` """ -function ctpop(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function ctpop(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.ctpop", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.ctpop", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -433,23 +392,19 @@ no standard attributes. %x = math.erf %y : tensor<4x?xf8> ``` """ -function erf(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function erf(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.erf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.erf", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -479,23 +434,19 @@ float, or a tensor of floats. It has no standard attributes. %x = math.exp2 %y : tensor<4x?xf8> ``` """ -function exp2(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function exp2(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.exp2", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.exp2", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -527,23 +478,19 @@ float, or a tensor of floats. It has no standard attributes. %x = math.expm1 %y : tensor<4x?xf8> ``` """ -function expm1(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function expm1(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.expm1", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.expm1", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -573,23 +520,19 @@ float, or a tensor of floats. It has no standard attributes. %x = math.exp %y : tensor<4x?xf8> ``` """ -function exp(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function exp(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.exp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.exp", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -620,23 +563,19 @@ It has no standard attributes. %x = math.floor %y : tensor<4x?xf8> ``` """ -function floor(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function floor(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.floor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.floor", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -672,29 +611,19 @@ The semantics of the operation correspond to those of the `llvm.fma` particular case of lowering to LLVM, this is guaranteed to lower to the `llvm.fma.*` intrinsic. """ -function fma( - a::Value, - b::Value, - c::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function fma(a::Value, b::Value, c::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b, c] + operands = Value[a, b, c, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.fma", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.fma", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -710,23 +639,19 @@ returns one result of the same type. %y = math.log10 %x : f64 ``` """ -function log10(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function log10(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.log10", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.log10", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -744,23 +669,19 @@ log1p(x) := log(1 + x) %y = math.log1p %x : f64 ``` """ -function log1p(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function log1p(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.log1p", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.log1p", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -776,23 +697,19 @@ returns one result of the same type. %y = math.log2 %x : f64 ``` """ -function log2(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function log2(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.log2", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.log2", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -808,23 +725,19 @@ returns one result of the same type. %y = math.log %x : f64 ``` """ -function log(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function log(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.log", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.log", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -855,25 +768,19 @@ floating point tensor. %x = math.powf %y, %z : tensor<4x?xbf16> ``` """ -function powf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function powf(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.powf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.powf", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -885,23 +792,19 @@ one operand and returns one result of the same type. This type may be a float scalar type, a vector whose element type is float, or a tensor of floats. It has no standard attributes. """ -function rsqrt(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function rsqrt(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.rsqrt", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.rsqrt", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -932,23 +835,19 @@ It has no standard attributes. %x = math.sin %y : tensor<4x?xf8> ``` """ -function sin(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function sin(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.sin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.sin", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -971,23 +870,19 @@ attributes. %x = math.sqrt %y : tensor<4x?xf32> ``` """ -function sqrt(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function sqrt(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.sqrt", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.sqrt", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1018,23 +913,19 @@ no standard attributes. %x = math.tanh %y : tensor<4x?xf8> ``` """ -function tanh(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function tanh(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "math.tanh", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "math.tanh", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/14/MemRef.jl b/src/Dialects/14/MemRef.jl index cd873662..7f2d1e4d 100644 --- a/src/Dialects/14/MemRef.jl +++ b/src/Dialects/14/MemRef.jl @@ -1,9 +1,8 @@ module memref -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `assume_alignment` @@ -17,20 +16,16 @@ optimization only, and the optimization is best-effort. """ function assume_alignment(memref::Value; alignment, location=Location()) results = IR.Type[] - operands = Value[memref,] + operands = Value[memref, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "memref.assume_alignment", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "memref.assume_alignment", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -51,29 +46,18 @@ result represents the latest value that was stored. %x = memref.atomic_rmw \"addf\" %value, %I[%i] : (f32, memref<10xf32>) -> f32 ``` """ -function atomic_rmw( - value::Value, - memref::Value, - indices::Vector{Value}; - result::IR.Type, - kind, - location=Location(), -) - results = IR.Type[result,] - operands = Value[value, memref, indices...] +function atomic_rmw(value::Value, memref::Value, indices::Vector{Value}; result::IR.Type, kind, location=Location()) + results = IR.Type[result, ] + operands = Value[value, memref, indices..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("kind", kind),] - - return IR.create_operation( - "memref.atomic_rmw", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("kind", kind), ] + + IR.create_operation( + "memref.atomic_rmw", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -85,20 +69,16 @@ GenericAtomicRMWOp region. """ function atomic_yield(result::Value; location=Location()) results = IR.Type[] - operands = Value[result,] + operands = Value[result, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.atomic_yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.atomic_yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -118,20 +98,16 @@ Otherwise, the result is undefined. They may have different layouts. """ function copy(source::Value, target::Value; location=Location()) results = IR.Type[] - operands = Value[source, target] + operands = Value[source, target, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.copy", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.copy", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -159,28 +135,18 @@ body of `GenericAtomicRMWOp`. } ``` """ -function generic_atomic_rmw( - memref::Value, - indices::Vector{Value}; - result::IR.Type, - atomic_body::Region, - location=Location(), -) - results = IR.Type[result,] - operands = Value[memref, indices...] - owned_regions = Region[atomic_body,] +function generic_atomic_rmw(memref::Value, indices::Vector{Value}; result::IR.Type, atomic_body::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[memref, indices..., ] + owned_regions = Region[atomic_body, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.generic_atomic_rmw", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.generic_atomic_rmw", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -223,21 +189,17 @@ techniques. This is possible because of the in these contexts. """ function load(memref::Value, indices::Vector{Value}; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[memref, indices...] + results = IR.Type[result, ] + operands = Value[memref, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.load", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.load", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -282,30 +244,20 @@ boundary. memref<8x64xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> ``` """ -function alloc( - dynamicSizes::Vector{Value}, - symbolOperands::Vector{Value}; - memref::IR.Type, - alignment=nothing, - location=Location(), -) - results = IR.Type[memref,] - operands = Value[dynamicSizes..., symbolOperands...] +function alloc(dynamicSizes::Vector{Value}, symbolOperands::Vector{Value}; memref::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[dynamicSizes..., symbolOperands..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands)])) + push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.alloc", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.alloc", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -346,30 +298,20 @@ specified, guarantees alignment at least to that boundary. If not specified, an alignment on any convenient boundary compatible with the type will be chosen. """ -function alloca( - dynamicSizes::Vector{Value}, - symbolOperands::Vector{Value}; - memref::IR.Type, - alignment=nothing, - location=Location(), -) - results = IR.Type[memref,] - operands = Value[dynamicSizes..., symbolOperands...] +function alloca(dynamicSizes::Vector{Value}, symbolOperands::Vector{Value}; memref::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[dynamicSizes..., symbolOperands..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands)])) + push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.alloca", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.alloca", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -407,22 +349,18 @@ operation: If `memref.alloca_scope` returns no value, the `memref.alloca_scope.return ` can be left out, and will be inserted implicitly. """ -function alloca_scope(; results::Vector{IR.Type}, bodyRegion::Region, location=Location()) - results = IR.Type[results...,] +function alloca_scope(; results_::Vector{IR.Type}, bodyRegion::Region, location=Location()) + results = IR.Type[results_..., ] operands = Value[] - owned_regions = Region[bodyRegion,] + owned_regions = Region[bodyRegion, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.alloca_scope", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.alloca_scope", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -438,22 +376,18 @@ to indicate which values are going to be returned. For example: memref.alloca_scope.return %value ``` """ -function alloca_scope_return(results::Vector{Value}; location=Location()) +function alloca_scope_return(results_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[results...,] + operands = Value[results_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.alloca_scope.return", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.alloca_scope.return", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -514,21 +448,17 @@ Erase rank information. ``` """ function cast(source::Value; dest::IR.Type, location=Location()) - results = IR.Type[dest,] - operands = Value[source,] + results = IR.Type[dest, ] + operands = Value[source, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.cast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.cast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -567,21 +497,17 @@ Examples: ``` """ function collapse_shape(src::Value; result::IR.Type, reassociation, location=Location()) - results = IR.Type[result,] - operands = Value[src,] + results = IR.Type[result, ] + operands = Value[src, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("reassociation", reassociation),] - - return IR.create_operation( - "memref.collapse_shape", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "memref.collapse_shape", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -602,20 +528,16 @@ memref.dealloc %0 : memref<8x64xf32, affine_map<(d0, d1) -> (d0, d1), 1>> """ function dealloc(memref::Value; location=Location()) results = IR.Type[] - operands = Value[memref,] + operands = Value[memref, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dealloc", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.dealloc", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -645,21 +567,17 @@ The specified memref type is that of the first operand. ``` """ function dim(source::Value, index::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[source, index] + results = IR.Type[result, ] + operands = Value[source, index, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dim", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.dim", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -710,22 +628,18 @@ TODO: add additional operands to allow source and destination striding, and multiple stride levels. TODO: Consider replacing src/dst memref indices with view memrefs. """ -function dma_start(operands::Vector{Value}; location=Location()) +function dma_start(operands_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[operands...,] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dma_start", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.dma_start", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -749,24 +663,18 @@ number of elements associated with the DMA operation. dma_wait %tag[%index], %num_elements : memref<1 x i32, affine_map<(d0) -> (d0)>, 2> ``` """ -function dma_wait( - tagMemRef::Value, tagIndices::Vector{Value}, numElements::Value; location=Location() -) +function dma_wait(tagMemRef::Value, tagIndices::Vector{Value}, numElements::Value; location=Location()) results = IR.Type[] - operands = Value[tagMemRef, tagIndices..., numElements] + operands = Value[tagMemRef, tagIndices..., numElements, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dma_wait", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.dma_wait", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -805,21 +713,17 @@ smaller rank. ``` """ function expand_shape(src::Value; result::IR.Type, reassociation, location=Location()) - results = IR.Type[result,] - operands = Value[src,] + results = IR.Type[result, ] + operands = Value[src, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("reassociation", reassociation),] - - return IR.create_operation( - "memref.expand_shape", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "memref.expand_shape", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -838,21 +742,17 @@ undefined. ``` """ function get_global(; result::IR.Type, name, location=Location()) - results = IR.Type[result,] + results = IR.Type[result, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "memref.get_global", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "memref.get_global", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -894,38 +794,22 @@ memref.global @z : memref<3xf16> = uninitialized memref.global constant @c : memref<2xi32> = dense<1, 4> ``` """ -function global_(; - sym_name, - sym_visibility=nothing, - type, - initial_value=nothing, - constant=nothing, - alignment=nothing, - location=Location(), -) +function global_(; sym_name, sym_visibility=nothing, type, initial_value=nothing, constant=nothing, alignment=nothing, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("sym_name", sym_name), namedattribute("type", type) - ] - !isnothing(sym_visibility) && - push!(attributes, namedattribute("sym_visibility", sym_visibility)) - !isnothing(initial_value) && - push!(attributes, namedattribute("initial_value", initial_value)) + attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("type", type), ] + !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)) - - return IR.create_operation( - "memref.global", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.global", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -947,33 +831,18 @@ in cache). The cache type specifier is either \'data\' or \'instr\' and specifies whether the prefetch is performed on data cache or on instruction cache. """ -function prefetch( - memref::Value, - indices::Vector{Value}; - isWrite, - localityHint, - isDataCache, - location=Location(), -) +function prefetch(memref::Value, indices::Vector{Value}; isWrite, localityHint, isDataCache, location=Location()) results = IR.Type[] - operands = Value[memref, indices...] + operands = Value[memref, indices..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("isWrite", isWrite), - namedattribute("localityHint", localityHint), - namedattribute("isDataCache", isDataCache), - ] - - return IR.create_operation( - "memref.prefetch", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("isWrite", isWrite), namedattribute("localityHint", localityHint), namedattribute("isDataCache", isDataCache), ] + + IR.create_operation( + "memref.prefetch", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -990,21 +859,17 @@ The `memref.rank` operation takes a memref operand and returns its rank. ``` """ function rank(memref::Value; result_0::IR.Type, location=Location()) - results = IR.Type[result_0,] - operands = Value[memref,] + results = IR.Type[result_0, ] + operands = Value[memref, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.rank", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.rank", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1028,40 +893,19 @@ memref.reinterpret_cast %unranked to : memref<*xf32> to memref ``` """ -function reinterpret_cast( - source::Value, - offsets::Vector{Value}, - sizes::Vector{Value}, - strides::Vector{Value}; - result::IR.Type, - static_offsets, - static_sizes, - static_strides, - location=Location(), -) - results = IR.Type[result,] - operands = Value[source, offsets..., sizes..., strides...] +function reinterpret_cast(source::Value, offsets::Vector{Value}, sizes::Vector{Value}, strides::Vector{Value}; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[source, offsets..., sizes..., strides..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("static_offsets", static_offsets), - namedattribute("static_sizes", static_sizes), - namedattribute("static_strides", static_strides), - ] - push!( - attributes, - operandsegmentsizes([1, length(offsets), length(sizes), length(strides)]), - ) - - return IR.create_operation( - "memref.reinterpret_cast", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("static_offsets", static_offsets), namedattribute("static_sizes", static_sizes), namedattribute("static_strides", static_strides), ] + push!(attributes, operandsegmentsizes([1, length(offsets), length(sizes), length(strides), ])) + + IR.create_operation( + "memref.reinterpret_cast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1101,21 +945,17 @@ Result type is unranked. ``` """ function reshape(source::Value, shape::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[source, shape] + results = IR.Type[result, ] + operands = Value[source, shape, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.reshape", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.reshape", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1151,20 +991,16 @@ in these contexts. """ function store(value::Value, memref::Value, indices::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[value, memref, indices...] + operands = Value[value, memref, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.store", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.store", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1182,21 +1018,17 @@ transformation. ``` """ function transpose(in::Value; result_0::IR.Type, permutation, location=Location()) - results = IR.Type[result_0,] - operands = Value[in,] + results = IR.Type[result_0, ] + operands = Value[in, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("permutation", permutation),] - - return IR.create_operation( - "memref.transpose", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("permutation", permutation), ] + + IR.create_operation( + "memref.transpose", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1238,28 +1070,18 @@ For now, a \"view\" op: memref<2048xi8> to memref ``` """ -function view( - source::Value, - byte_shift::Value, - sizes::Vector{Value}; - result_0::IR.Type, - location=Location(), -) - results = IR.Type[result_0,] - operands = Value[source, byte_shift, sizes...] +function view(source::Value, byte_shift::Value, sizes::Vector{Value}; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[source, byte_shift, sizes..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.view", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.view", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1398,40 +1220,19 @@ Example 5: ``` } """ -function subview( - source::Value, - offsets::Vector{Value}, - sizes::Vector{Value}, - strides::Vector{Value}; - result::IR.Type, - static_offsets, - static_sizes, - static_strides, - location=Location(), -) - results = IR.Type[result,] - operands = Value[source, offsets..., sizes..., strides...] +function subview(source::Value, offsets::Vector{Value}, sizes::Vector{Value}, strides::Vector{Value}; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[source, offsets..., sizes..., strides..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("static_offsets", static_offsets), - namedattribute("static_sizes", static_sizes), - namedattribute("static_strides", static_strides), - ] - push!( - attributes, - operandsegmentsizes([1, length(offsets), length(sizes), length(strides)]), - ) - - return IR.create_operation( - "memref.subview", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("static_offsets", static_offsets), namedattribute("static_sizes", static_sizes), namedattribute("static_strides", static_strides), ] + push!(attributes, operandsegmentsizes([1, length(offsets), length(sizes), length(strides), ])) + + IR.create_operation( + "memref.subview", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1452,20 +1253,16 @@ memref.tensor_store %8, %10 : memref<4x?xf32, #layout, memspace0> """ function tensor_store(tensor::Value, memref::Value; location=Location()) results = IR.Type[] - operands = Value[tensor, memref] + operands = Value[tensor, memref, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "memref.tensor_store", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "memref.tensor_store", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/OpenACC.jl b/src/Dialects/14/OpenACC.jl index 459d306f..e72d6e31 100644 --- a/src/Dialects/14/OpenACC.jl +++ b/src/Dialects/14/OpenACC.jl @@ -1,9 +1,8 @@ module acc -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `data` @@ -23,68 +22,21 @@ acc.data present(%a: memref<10x10xf32>, %b: memref<10x10xf32>, } ``` """ -function data( - ifCond=nothing::Union{Nothing,Value}; - copyOperands::Vector{Value}, - copyinOperands::Vector{Value}, - copyinReadonlyOperands::Vector{Value}, - copyoutOperands::Vector{Value}, - copyoutZeroOperands::Vector{Value}, - createOperands::Vector{Value}, - createZeroOperands::Vector{Value}, - noCreateOperands::Vector{Value}, - presentOperands::Vector{Value}, - deviceptrOperands::Vector{Value}, - attachOperands::Vector{Value}, - defaultAttr=nothing, - region::Region, - location=Location(), -) +function data(ifCond=nothing::Union{Nothing, Value}; copyOperands::Vector{Value}, copyinOperands::Vector{Value}, copyinReadonlyOperands::Vector{Value}, copyoutOperands::Vector{Value}, copyoutZeroOperands::Vector{Value}, createOperands::Vector{Value}, createZeroOperands::Vector{Value}, noCreateOperands::Vector{Value}, presentOperands::Vector{Value}, deviceptrOperands::Vector{Value}, attachOperands::Vector{Value}, defaultAttr=nothing, region::Region, location=Location()) results = IR.Type[] - operands = Value[ - copyOperands..., - copyinOperands..., - copyinReadonlyOperands..., - copyoutOperands..., - copyoutZeroOperands..., - createOperands..., - createZeroOperands..., - noCreateOperands..., - presentOperands..., - deviceptrOperands..., - attachOperands..., - ] - owned_regions = Region[region,] + operands = Value[copyOperands..., copyinOperands..., copyinReadonlyOperands..., copyoutOperands..., copyoutZeroOperands..., createOperands..., createZeroOperands..., noCreateOperands..., presentOperands..., deviceptrOperands..., attachOperands..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] !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), - ]), - ) + 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), ])) !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) - - return IR.create_operation( - "acc.data", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "acc.data", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -99,63 +51,24 @@ The \"acc.enter_data\" operation represents the OpenACC enter data directive. acc.enter_data create(%d1 : memref<10xf32>) attributes {async} ``` """ -function enter_data( - ifCond=nothing::Union{Nothing,Value}; - asyncOperand=nothing::Union{Nothing,Value}, - waitDevnum=nothing::Union{Nothing,Value}, - waitOperands::Vector{Value}, - copyinOperands::Vector{Value}, - createOperands::Vector{Value}, - createZeroOperands::Vector{Value}, - attachOperands::Vector{Value}, - async=nothing, - wait=nothing, - location=Location(), -) +function enter_data(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing::Union{Nothing, Value}, waitDevnum=nothing::Union{Nothing, Value}, waitOperands::Vector{Value}, copyinOperands::Vector{Value}, createOperands::Vector{Value}, createZeroOperands::Vector{Value}, attachOperands::Vector{Value}, async=nothing, wait=nothing, location=Location()) results = IR.Type[] - operands = Value[ - waitOperands..., - copyinOperands..., - createOperands..., - createZeroOperands..., - attachOperands..., - ] + operands = Value[waitOperands..., copyinOperands..., createOperands..., createZeroOperands..., attachOperands..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(ifCond) && push!(operands, ifCond) !isnothing(asyncOperand) && push!(operands, asyncOperand) !isnothing(waitDevnum) && push!(operands, waitDevnum) - push!( - attributes, - operandsegmentsizes([ - if (ifCond == nothing) - 0 - elseif 1(asyncOperand == nothing) - 0 - elseif 1(waitDevnum == nothing) - 0 - else - 1length(waitOperands) - end, - length(copyinOperands), - length(createOperands), - length(createZeroOperands), - length(attachOperands), - ]), - ) + push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(copyinOperands), length(createOperands), length(createZeroOperands), length(attachOperands), ])) !isnothing(async) && push!(attributes, namedattribute("async", async)) !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) - - return IR.create_operation( - "acc.enter_data", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "acc.enter_data", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -170,59 +83,25 @@ The \"acc.exit_data\" operation represents the OpenACC exit data directive. acc.exit_data delete(%d1 : memref<10xf32>) attributes {async} ``` """ -function exit_data( - ifCond=nothing::Union{Nothing,Value}; - asyncOperand=nothing::Union{Nothing,Value}, - waitDevnum=nothing::Union{Nothing,Value}, - waitOperands::Vector{Value}, - copyoutOperands::Vector{Value}, - deleteOperands::Vector{Value}, - detachOperands::Vector{Value}, - async=nothing, - wait=nothing, - finalize=nothing, - location=Location(), -) +function exit_data(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing::Union{Nothing, Value}, waitDevnum=nothing::Union{Nothing, Value}, waitOperands::Vector{Value}, copyoutOperands::Vector{Value}, deleteOperands::Vector{Value}, detachOperands::Vector{Value}, async=nothing, wait=nothing, finalize=nothing, location=Location()) results = IR.Type[] - operands = Value[ - waitOperands..., copyoutOperands..., deleteOperands..., detachOperands... - ] + operands = Value[waitOperands..., copyoutOperands..., deleteOperands..., detachOperands..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(ifCond) && push!(operands, ifCond) !isnothing(asyncOperand) && push!(operands, asyncOperand) !isnothing(waitDevnum) && push!(operands, waitDevnum) - push!( - attributes, - operandsegmentsizes([ - if (ifCond == nothing) - 0 - elseif 1(asyncOperand == nothing) - 0 - elseif 1(waitDevnum == nothing) - 0 - else - 1length(waitOperands) - end, - length(copyoutOperands), - length(deleteOperands), - length(detachOperands), - ]), - ) + push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(copyoutOperands), length(deleteOperands), length(detachOperands), ])) !isnothing(async) && push!(attributes, namedattribute("async", async)) !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) !isnothing(finalize) && push!(attributes, namedattribute("finalize", finalize)) - - return IR.create_operation( - "acc.exit_data", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "acc.exit_data", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -239,42 +118,21 @@ acc.init acc.init device_num(%dev1 : i32) ``` """ -function init( - deviceTypeOperands::Vector{Value}, - deviceNumOperand=nothing::Union{Nothing,Value}; - ifCond=nothing::Union{Nothing,Value}, - location=Location(), -) +function init(deviceTypeOperands::Vector{Value}, deviceNumOperand=nothing::Union{Nothing, Value}; ifCond=nothing::Union{Nothing, Value}, location=Location()) results = IR.Type[] - operands = Value[deviceTypeOperands...,] + operands = Value[deviceTypeOperands..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(deviceNumOperand) && push!(operands, deviceNumOperand) !isnothing(ifCond) && push!(operands, ifCond) - push!( - attributes, - operandsegmentsizes([ - length(deviceTypeOperands), - if (deviceNumOperand == nothing) - 0 - elseif 1(ifCond == nothing) - 0 - else - 1 - end, - ]), - ) - - return IR.create_operation( - "acc.init", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(deviceTypeOperands), (deviceNumOperand==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) + + IR.create_operation( + "acc.init", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -298,68 +156,29 @@ acc.loop gang vector { } attributes { collapse = 3 } ``` """ -function loop( - gangNum=nothing::Union{Nothing,Value}; - gangStatic=nothing::Union{Nothing,Value}, - workerNum=nothing::Union{Nothing,Value}, - vectorLength=nothing::Union{Nothing,Value}, - tileOperands::Vector{Value}, - privateOperands::Vector{Value}, - reductionOperands::Vector{Value}, - results::Vector{IR.Type}, - collapse=nothing, - seq=nothing, - independent=nothing, - auto_=nothing, - reductionOp=nothing, - exec_mapping=nothing, - region::Region, - location=Location(), -) - results = IR.Type[results...,] - operands = Value[tileOperands..., privateOperands..., reductionOperands...] - owned_regions = Region[region,] +function loop(gangNum=nothing::Union{Nothing, Value}; gangStatic=nothing::Union{Nothing, Value}, workerNum=nothing::Union{Nothing, Value}, vectorLength=nothing::Union{Nothing, Value}, tileOperands::Vector{Value}, privateOperands::Vector{Value}, reductionOperands::Vector{Value}, results_::Vector{IR.Type}, collapse=nothing, seq=nothing, independent=nothing, auto_=nothing, reductionOp=nothing, exec_mapping=nothing, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[tileOperands..., privateOperands..., reductionOperands..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] !isnothing(gangNum) && push!(operands, gangNum) !isnothing(gangStatic) && push!(operands, gangStatic) !isnothing(workerNum) && push!(operands, workerNum) !isnothing(vectorLength) && push!(operands, vectorLength) - push!( - attributes, - operandsegmentsizes([ - if (gangNum == nothing) - 0 - elseif 1(gangStatic == nothing) - 0 - elseif 1(workerNum == nothing) - 0 - elseif 1(vectorLength == nothing) - 0 - else - 1length(tileOperands) - end, - length(privateOperands), - length(reductionOperands), - ]), - ) + push!(attributes, operandsegmentsizes([(gangNum==nothing) ? 0 : 1(gangStatic==nothing) ? 0 : 1(workerNum==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1length(tileOperands), length(privateOperands), length(reductionOperands), ])) !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)) - - return IR.create_operation( - "acc.loop", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(exec_mapping) && push!(attributes, namedattribute("exec_mapping", exec_mapping)) + + IR.create_operation( + "acc.loop", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -378,55 +197,10 @@ acc.parallel num_gangs(%c10) num_workers(%c10) } ``` """ -function parallel( - async=nothing::Union{Nothing,Value}; - waitOperands::Vector{Value}, - numGangs=nothing::Union{Nothing,Value}, - numWorkers=nothing::Union{Nothing,Value}, - vectorLength=nothing::Union{Nothing,Value}, - ifCond=nothing::Union{Nothing,Value}, - selfCond=nothing::Union{Nothing,Value}, - reductionOperands::Vector{Value}, - copyOperands::Vector{Value}, - copyinOperands::Vector{Value}, - copyinReadonlyOperands::Vector{Value}, - copyoutOperands::Vector{Value}, - copyoutZeroOperands::Vector{Value}, - createOperands::Vector{Value}, - createZeroOperands::Vector{Value}, - noCreateOperands::Vector{Value}, - presentOperands::Vector{Value}, - devicePtrOperands::Vector{Value}, - attachOperands::Vector{Value}, - gangPrivateOperands::Vector{Value}, - gangFirstPrivateOperands::Vector{Value}, - asyncAttr=nothing, - waitAttr=nothing, - selfAttr=nothing, - reductionOp=nothing, - defaultAttr=nothing, - region::Region, - location=Location(), -) +function parallel(async=nothing::Union{Nothing, Value}; waitOperands::Vector{Value}, numGangs=nothing::Union{Nothing, Value}, numWorkers=nothing::Union{Nothing, Value}, vectorLength=nothing::Union{Nothing, Value}, ifCond=nothing::Union{Nothing, Value}, selfCond=nothing::Union{Nothing, Value}, reductionOperands::Vector{Value}, copyOperands::Vector{Value}, copyinOperands::Vector{Value}, copyinReadonlyOperands::Vector{Value}, copyoutOperands::Vector{Value}, copyoutZeroOperands::Vector{Value}, createOperands::Vector{Value}, createZeroOperands::Vector{Value}, noCreateOperands::Vector{Value}, presentOperands::Vector{Value}, devicePtrOperands::Vector{Value}, attachOperands::Vector{Value}, gangPrivateOperands::Vector{Value}, gangFirstPrivateOperands::Vector{Value}, asyncAttr=nothing, waitAttr=nothing, selfAttr=nothing, reductionOp=nothing, defaultAttr=nothing, region::Region, location=Location()) results = IR.Type[] - operands = Value[ - waitOperands..., - reductionOperands..., - copyOperands..., - copyinOperands..., - copyinReadonlyOperands..., - copyoutOperands..., - copyoutZeroOperands..., - createOperands..., - createZeroOperands..., - noCreateOperands..., - presentOperands..., - devicePtrOperands..., - attachOperands..., - gangPrivateOperands..., - gangFirstPrivateOperands..., - ] - owned_regions = Region[region,] + operands = Value[waitOperands..., reductionOperands..., copyOperands..., copyinOperands..., copyinReadonlyOperands..., copyoutOperands..., copyoutZeroOperands..., createOperands..., createZeroOperands..., noCreateOperands..., presentOperands..., devicePtrOperands..., attachOperands..., gangPrivateOperands..., gangFirstPrivateOperands..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] !isnothing(async) && push!(operands, async) @@ -435,53 +209,18 @@ function parallel( !isnothing(vectorLength) && push!(operands, vectorLength) !isnothing(ifCond) && push!(operands, ifCond) !isnothing(selfCond) && push!(operands, selfCond) - push!( - attributes, - operandsegmentsizes([ - (async == nothing) ? 0 : 1length(waitOperands), - if (numGangs == nothing) - 0 - elseif 1(numWorkers == nothing) - 0 - elseif 1(vectorLength == nothing) - 0 - elseif 1(ifCond == nothing) - 0 - elseif 1(selfCond == nothing) - 0 - else - 1length(reductionOperands) - end, - 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), - ]), - ) + 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), ])) !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)) - - return IR.create_operation( - "acc.parallel", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "acc.parallel", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -498,42 +237,21 @@ acc.shutdown acc.shutdown device_num(%dev1 : i32) ``` """ -function shutdown( - deviceTypeOperands::Vector{Value}, - deviceNumOperand=nothing::Union{Nothing,Value}; - ifCond=nothing::Union{Nothing,Value}, - location=Location(), -) +function shutdown(deviceTypeOperands::Vector{Value}, deviceNumOperand=nothing::Union{Nothing, Value}; ifCond=nothing::Union{Nothing, Value}, location=Location()) results = IR.Type[] - operands = Value[deviceTypeOperands...,] + operands = Value[deviceTypeOperands..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(deviceNumOperand) && push!(operands, deviceNumOperand) !isnothing(ifCond) && push!(operands, ifCond) - push!( - attributes, - operandsegmentsizes([ - length(deviceTypeOperands), - if (deviceNumOperand == nothing) - 0 - elseif 1(ifCond == nothing) - 0 - else - 1 - end, - ]), - ) - - return IR.create_operation( - "acc.shutdown", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(deviceTypeOperands), (deviceNumOperand==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) + + IR.create_operation( + "acc.shutdown", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -551,16 +269,12 @@ function terminator(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "acc.terminator", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "acc.terminator", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -578,59 +292,25 @@ add to \$hostOperands. acc.update device(%d1 : memref<10xf32>) attributes {async} ``` """ -function update( - ifCond=nothing::Union{Nothing,Value}; - asyncOperand=nothing::Union{Nothing,Value}, - waitDevnum=nothing::Union{Nothing,Value}, - waitOperands::Vector{Value}, - deviceTypeOperands::Vector{Value}, - hostOperands::Vector{Value}, - deviceOperands::Vector{Value}, - async=nothing, - wait=nothing, - ifPresent=nothing, - location=Location(), -) +function update(ifCond=nothing::Union{Nothing, Value}; asyncOperand=nothing::Union{Nothing, Value}, waitDevnum=nothing::Union{Nothing, Value}, waitOperands::Vector{Value}, deviceTypeOperands::Vector{Value}, hostOperands::Vector{Value}, deviceOperands::Vector{Value}, async=nothing, wait=nothing, ifPresent=nothing, location=Location()) results = IR.Type[] - operands = Value[ - waitOperands..., deviceTypeOperands..., hostOperands..., deviceOperands... - ] + operands = Value[waitOperands..., deviceTypeOperands..., hostOperands..., deviceOperands..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(ifCond) && push!(operands, ifCond) !isnothing(asyncOperand) && push!(operands, asyncOperand) !isnothing(waitDevnum) && push!(operands, waitDevnum) - push!( - attributes, - operandsegmentsizes([ - if (ifCond == nothing) - 0 - elseif 1(asyncOperand == nothing) - 0 - elseif 1(waitDevnum == nothing) - 0 - else - 1length(waitOperands) - end, - length(deviceTypeOperands), - length(hostOperands), - length(deviceOperands), - ]), - ) + push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(deviceTypeOperands), length(hostOperands), length(deviceOperands), ])) !isnothing(async) && push!(attributes, namedattribute("async", async)) !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) !isnothing(ifPresent) && push!(attributes, namedattribute("ifPresent", ifPresent)) - - return IR.create_operation( - "acc.update", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "acc.update", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -647,48 +327,23 @@ acc.wait(%value1: index) acc.wait() async(%async1: i32) ``` """ -function wait( - waitOperands::Vector{Value}, - asyncOperand=nothing::Union{Nothing,Value}; - waitDevnum=nothing::Union{Nothing,Value}, - ifCond=nothing::Union{Nothing,Value}, - async=nothing, - location=Location(), -) +function wait(waitOperands::Vector{Value}, asyncOperand=nothing::Union{Nothing, Value}; waitDevnum=nothing::Union{Nothing, Value}, ifCond=nothing::Union{Nothing, Value}, async=nothing, location=Location()) results = IR.Type[] - operands = Value[waitOperands...,] + operands = Value[waitOperands..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(asyncOperand) && push!(operands, asyncOperand) !isnothing(waitDevnum) && push!(operands, waitDevnum) !isnothing(ifCond) && push!(operands, ifCond) - push!( - attributes, - operandsegmentsizes([ - length(waitOperands), - if (asyncOperand == nothing) - 0 - elseif 1(waitDevnum == nothing) - 0 - elseif 1(ifCond == nothing) - 0 - else - 1 - end, - ]), - ) + push!(attributes, operandsegmentsizes([length(waitOperands), (asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) !isnothing(async) && push!(attributes, namedattribute("async", async)) - - return IR.create_operation( - "acc.wait", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "acc.wait", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -699,22 +354,18 @@ end acc ops (parallel and loop). It returns values to the immediately enclosing acc op. """ -function yield(operands::Vector{Value}; location=Location()) +function yield(operands_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[operands...,] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "acc.yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "acc.yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/OpenMP.jl b/src/Dialects/14/OpenMP.jl index 26a1ff05..2b5ba559 100644 --- a/src/Dialects/14/OpenMP.jl +++ b/src/Dialects/14/OpenMP.jl @@ -1,9 +1,8 @@ module omp -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `atomic_capture` @@ -38,27 +37,20 @@ The region has the following allowed forms: } ``` """ -function atomic_capture(; - hint=nothing, memory_order=nothing, region::Region, location=Location() -) +function atomic_capture(; hint=nothing, memory_order=nothing, region::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[region,] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] !isnothing(hint) && push!(attributes, namedattribute("hint", hint)) - !isnothing(memory_order) && - push!(attributes, namedattribute("memory_order", memory_order)) - - return IR.create_operation( - "omp.atomic.capture", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(memory_order) && push!(attributes, namedattribute("memory_order", memory_order)) + + IR.create_operation( + "omp.atomic.capture", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -77,27 +69,20 @@ optimization. `memory_order` indicates the memory ordering behavior of the construct. It can be one of `seq_cst`, `acq_rel`, `release`, `acquire` or `relaxed`. """ -function atomic_read( - x::Value, v::Value; hint=nothing, memory_order=nothing, location=Location() -) +function atomic_read(x::Value, v::Value; hint=nothing, memory_order=nothing, location=Location()) results = IR.Type[] - operands = Value[x, v] + operands = Value[x, v, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(hint) && push!(attributes, namedattribute("hint", hint)) - !isnothing(memory_order) && - push!(attributes, namedattribute("memory_order", memory_order)) - - return IR.create_operation( - "omp.atomic.read", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(memory_order) && push!(attributes, namedattribute("memory_order", memory_order)) + + IR.create_operation( + "omp.atomic.read", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -125,35 +110,21 @@ time constant. As the name suggests, this is just a hint for optimization. `memory_order` indicates the memory ordering behavior of the construct. It can be one of `seq_cst`, `acq_rel`, `release`, `acquire` or `relaxed`. """ -function atomic_update( - x::Value, - expr::Value; - isXBinopExpr=nothing, - binop, - hint=nothing, - memory_order=nothing, - location=Location(), -) +function atomic_update(x::Value, expr::Value; isXBinopExpr=nothing, binop, hint=nothing, memory_order=nothing, location=Location()) results = IR.Type[] - operands = Value[x, expr] + operands = Value[x, expr, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("binop", binop),] - !isnothing(isXBinopExpr) && - push!(attributes, namedattribute("isXBinopExpr", isXBinopExpr)) + attributes = NamedAttribute[namedattribute("binop", binop), ] + !isnothing(isXBinopExpr) && push!(attributes, namedattribute("isXBinopExpr", isXBinopExpr)) !isnothing(hint) && push!(attributes, namedattribute("hint", hint)) - !isnothing(memory_order) && - push!(attributes, namedattribute("memory_order", memory_order)) - - return IR.create_operation( - "omp.atomic.update", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(memory_order) && push!(attributes, namedattribute("memory_order", memory_order)) + + IR.create_operation( + "omp.atomic.update", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -174,27 +145,20 @@ optimization. `memory_order` indicates the memory ordering behavior of the construct. It can be one of `seq_cst`, `acq_rel`, `release`, `acquire` or `relaxed`. """ -function atomic_write( - address::Value, value::Value; hint=nothing, memory_order=nothing, location=Location() -) +function atomic_write(address::Value, value::Value; hint=nothing, memory_order=nothing, location=Location()) results = IR.Type[] - operands = Value[address, value] + operands = Value[address, value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(hint) && push!(attributes, namedattribute("hint", hint)) - !isnothing(memory_order) && - push!(attributes, namedattribute("memory_order", memory_order)) - - return IR.create_operation( - "omp.atomic.write", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(memory_order) && push!(attributes, namedattribute("memory_order", memory_order)) + + IR.create_operation( + "omp.atomic.write", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -210,16 +174,12 @@ function barrier(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "omp.barrier", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.barrier", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -235,18 +195,14 @@ function critical_declare(; sym_name, hint=nothing, location=Location()) operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("sym_name", sym_name),] + attributes = NamedAttribute[namedattribute("sym_name", sym_name), ] !isnothing(hint) && push!(attributes, namedattribute("hint", hint)) - - return IR.create_operation( - "omp.critical.declare", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.critical.declare", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -259,20 +215,16 @@ block (region) to be executed by only a single thread at a time. function critical(; name=nothing, region::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[region,] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] !isnothing(name) && push!(attributes, namedattribute("name", name)) - - return IR.create_operation( - "omp.critical", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.critical", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -286,20 +238,16 @@ specified or implied. """ function flush(varList::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[varList...,] + operands = Value[varList..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "omp.flush", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.flush", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -312,19 +260,15 @@ the master thread of the team. function master(; region::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[region,] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "omp.master", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.master", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -346,31 +290,20 @@ the index of the element of \"vec\" for the DEPEND(SINK: vec) clause. It contains the operands in multiple \"vec\" when multiple DEPEND(SINK: vec) clauses exist in one ORDERED directive. """ -function ordered( - depend_vec_vars::Vector{Value}; - depend_type_val=nothing, - num_loops_val=nothing, - location=Location(), -) +function ordered(depend_vec_vars::Vector{Value}; depend_type_val=nothing, num_loops_val=nothing, location=Location()) results = IR.Type[] - operands = Value[depend_vec_vars...,] + operands = Value[depend_vec_vars..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !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)) - - return IR.create_operation( - "omp.ordered", - location; - operands, - owned_regions, - successors, - attributes, + !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)) + + IR.create_operation( + "omp.ordered", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -388,20 +321,16 @@ specified. function ordered_region(; simd=nothing, region::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[region,] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] !isnothing(simd) && push!(attributes, namedattribute("simd", simd)) - - return IR.create_operation( - "omp.ordered_region", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.ordered_region", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -433,64 +362,23 @@ that specify the memory allocator to be used to obtain storage for private value The optional \$proc_bind_val attribute controls the thread affinity for the execution of the parallel region. """ -function parallel( - if_expr_var=nothing::Union{Nothing,Value}; - num_threads_var=nothing::Union{Nothing,Value}, - private_vars::Vector{Value}, - firstprivate_vars::Vector{Value}, - shared_vars::Vector{Value}, - copyin_vars::Vector{Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}, - default_val=nothing, - proc_bind_val=nothing, - region::Region, - location=Location(), -) +function parallel(if_expr_var=nothing::Union{Nothing, Value}; num_threads_var=nothing::Union{Nothing, Value}, private_vars::Vector{Value}, firstprivate_vars::Vector{Value}, shared_vars::Vector{Value}, copyin_vars::Vector{Value}, allocate_vars::Vector{Value}, allocators_vars::Vector{Value}, default_val=nothing, proc_bind_val=nothing, region::Region, location=Location()) results = IR.Type[] - operands = Value[ - private_vars..., - firstprivate_vars..., - shared_vars..., - copyin_vars..., - allocate_vars..., - allocators_vars..., - ] - owned_regions = Region[region,] + operands = Value[private_vars..., firstprivate_vars..., shared_vars..., copyin_vars..., allocate_vars..., allocators_vars..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] !isnothing(if_expr_var) && push!(operands, if_expr_var) !isnothing(num_threads_var) && push!(operands, num_threads_var) - push!( - attributes, - operandsegmentsizes([ - if (if_expr_var == nothing) - 0 - elseif 1(num_threads_var == nothing) - 0 - else - 1length(private_vars) - end, - length(firstprivate_vars), - length(shared_vars), - length(copyin_vars), - length(allocate_vars), - length(allocators_vars), - ]), - ) + 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), ])) !isnothing(default_val) && push!(attributes, namedattribute("default_val", default_val)) - !isnothing(proc_bind_val) && - push!(attributes, namedattribute("proc_bind_val", proc_bind_val)) - - return IR.create_operation( - "omp.parallel", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(proc_bind_val) && push!(attributes, namedattribute("proc_bind_val", proc_bind_val)) + + IR.create_operation( + "omp.parallel", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -516,31 +404,18 @@ Note that the MLIR type system does not allow for type-polymorphic reductions. Separate reduction declarations should be created for different element and accumulator types. """ -function reduction_declare(; - sym_name, - type, - initializerRegion::Region, - reductionRegion::Region, - atomicReductionRegion::Region, - location=Location(), -) +function reduction_declare(; sym_name, type, initializerRegion::Region, reductionRegion::Region, atomicReductionRegion::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[initializerRegion, reductionRegion, atomicReductionRegion] + owned_regions = Region[initializerRegion, reductionRegion, atomicReductionRegion, ] successors = Block[] - attributes = NamedAttribute[ - namedattribute("sym_name", sym_name), namedattribute("type", type) - ] - - return IR.create_operation( - "omp.reduction.declare", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("type", type), ] + + IR.create_operation( + "omp.reduction.declare", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -554,20 +429,16 @@ updated immediately. """ function reduction(operand::Value, accumulator::Value; location=Location()) results = IR.Type[] - operands = Value[operand, accumulator] + operands = Value[operand, accumulator, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "omp.reduction", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.reduction", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -581,19 +452,15 @@ sections construct. A section op should always be surrounded by an function section(; region::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[region,] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "omp.section", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.section", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -628,53 +495,21 @@ that specify the memory allocator to be used to obtain storage for private value The `nowait` attribute, when present, signifies that there should be no implicit barrier at the end of the construct. """ -function sections( - private_vars::Vector{Value}, - firstprivate_vars::Vector{Value}, - lastprivate_vars::Vector{Value}, - reduction_vars::Vector{Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}; - reductions=nothing, - nowait=nothing, - region::Region, - location=Location(), -) +function sections(private_vars::Vector{Value}, firstprivate_vars::Vector{Value}, lastprivate_vars::Vector{Value}, reduction_vars::Vector{Value}, allocate_vars::Vector{Value}, allocators_vars::Vector{Value}; reductions=nothing, nowait=nothing, region::Region, location=Location()) results = IR.Type[] - operands = Value[ - private_vars..., - firstprivate_vars..., - lastprivate_vars..., - reduction_vars..., - allocate_vars..., - allocators_vars..., - ] - owned_regions = Region[region,] + operands = Value[private_vars..., firstprivate_vars..., lastprivate_vars..., reduction_vars..., allocate_vars..., allocators_vars..., ] + owned_regions = Region[region, ] 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), - ]), - ) + push!(attributes, operandsegmentsizes([length(private_vars), length(firstprivate_vars), length(lastprivate_vars), length(reduction_vars), length(allocate_vars), length(allocators_vars), ])) !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.sections", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.sections", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -698,44 +533,23 @@ even if the target task is not yet completed. TODO: private, map, is_device_ptr, firstprivate, depend, defaultmap, in_reduction """ -function target( - if_expr=nothing::Union{Nothing,Value}; - device=nothing::Union{Nothing,Value}, - thread_limit=nothing::Union{Nothing,Value}, - nowait=nothing, - region::Region, - location=Location(), -) +function target(if_expr=nothing::Union{Nothing, Value}; device=nothing::Union{Nothing, Value}, thread_limit=nothing::Union{Nothing, Value}, nowait=nothing, region::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[region,] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] !isnothing(if_expr) && push!(operands, if_expr) !isnothing(device) && push!(operands, device) !isnothing(thread_limit) && push!(operands, thread_limit) - push!(attributes, operandsegmentsizes([ - if (if_expr == nothing) - 0 - elseif 1(device == nothing) - 0 - elseif 1(thread_limit == nothing) - 0 - else - 1 - end, - ])) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1(thread_limit==nothing) ? 0 : 1])) !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.target", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.target", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -751,16 +565,12 @@ function taskwait(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "omp.taskwait", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.taskwait", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -776,16 +586,12 @@ function taskyield(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "omp.taskyield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.taskyield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -803,16 +609,12 @@ function terminator(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "omp.terminator", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.terminator", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -876,83 +678,29 @@ The optional `order` attribute specifies which order the iterations of the associate loops are executed in. Currently the only option for this attribute is \"concurrent\". """ -function wsloop( - lowerBound::Vector{Value}, - upperBound::Vector{Value}, - step::Vector{Value}, - private_vars::Vector{Value}, - firstprivate_vars::Vector{Value}, - lastprivate_vars::Vector{Value}, - linear_vars::Vector{Value}, - linear_step_vars::Vector{Value}, - reduction_vars::Vector{Value}, - schedule_chunk_var=nothing::Union{Nothing,Value}; - reductions=nothing, - schedule_val=nothing, - schedule_modifier=nothing, - simd_modifier=nothing, - collapse_val=nothing, - nowait=nothing, - ordered_val=nothing, - order_val=nothing, - inclusive=nothing, - region::Region, - location=Location(), -) +function wsloop(lowerBound::Vector{Value}, upperBound::Vector{Value}, step::Vector{Value}, private_vars::Vector{Value}, firstprivate_vars::Vector{Value}, lastprivate_vars::Vector{Value}, linear_vars::Vector{Value}, linear_step_vars::Vector{Value}, reduction_vars::Vector{Value}, schedule_chunk_var=nothing::Union{Nothing, Value}; reductions=nothing, schedule_val=nothing, schedule_modifier=nothing, simd_modifier=nothing, collapse_val=nothing, nowait=nothing, ordered_val=nothing, order_val=nothing, inclusive=nothing, region::Region, location=Location()) results = IR.Type[] - operands = Value[ - lowerBound..., - upperBound..., - step..., - private_vars..., - firstprivate_vars..., - lastprivate_vars..., - linear_vars..., - linear_step_vars..., - reduction_vars..., - ] - owned_regions = Region[region,] + operands = Value[lowerBound..., upperBound..., step..., private_vars..., firstprivate_vars..., lastprivate_vars..., linear_vars..., linear_step_vars..., reduction_vars..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] !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, - ]), - ) + 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])) !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(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)) - - return IR.create_operation( - "omp.wsloop", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.wsloop", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -965,22 +713,18 @@ defined by the parent operation. If \"omp.yield\" has any operands, the operands must match the parent operation\'s results. """ -function yield(results::Vector{Value}; location=Location()) +function yield(results_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[results...,] + operands = Value[results_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "omp.yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "omp.yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/PDL.jl b/src/Dialects/14/PDL.jl index 69e1588c..617e5a7c 100644 --- a/src/Dialects/14/PDL.jl +++ b/src/Dialects/14/PDL.jl @@ -1,9 +1,8 @@ module pdl -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `apply_native_constraint` @@ -22,25 +21,19 @@ valued parameters. pdl.apply_native_constraint \"myConstraint\"[42, \"abc\", i32](%input, %attr, %op : !pdl.value, !pdl.attribute, !pdl.operation) ``` """ -function apply_native_constraint( - args::Vector{Value}; name, constParams=nothing, location=Location() -) +function apply_native_constraint(args::Vector{Value}; name, constParams=nothing, location=Location()) results = IR.Type[] - operands = Value[args...,] + operands = Value[args..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("name", name),] + attributes = NamedAttribute[namedattribute("name", name), ] !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) - - return IR.create_operation( - "pdl.apply_native_constraint", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl.apply_native_constraint", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -80,29 +73,19 @@ void registerNativeRewrite(PDLPatternModule &pdlModule) { } ``` """ -function apply_native_rewrite( - args::Vector{Value}; - results::Vector{IR.Type}, - name, - constParams=nothing, - location=Location(), -) - results = IR.Type[results...,] - operands = Value[args...,] +function apply_native_rewrite(args::Vector{Value}; results_::Vector{IR.Type}, name, constParams=nothing, location=Location()) + results = IR.Type[results_..., ] + operands = Value[args..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("name", name),] + attributes = NamedAttribute[namedattribute("name", name), ] !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) - - return IR.create_operation( - "pdl.apply_native_rewrite", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl.apply_native_rewrite", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -131,26 +114,20 @@ defined within a `pdl.rewrite` region, the constant value must be specified. %attr = pdl.attribute \"hello\" ``` """ -function attribute( - type=nothing::Union{Nothing,Value}; attr::IR.Type, value=nothing, location=Location() -) - results = IR.Type[attr,] +function attribute(type=nothing::Union{Nothing, Value}; attr::IR.Type, value=nothing, location=Location()) + results = IR.Type[attr, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(type) && push!(operands, type) !isnothing(value) && push!(attributes, namedattribute("value", value)) - - return IR.create_operation( - "pdl.attribute", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl.attribute", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -169,20 +146,16 @@ pdl.erase %root """ function erase(operation::Value; location=Location()) results = IR.Type[] - operands = Value[operation,] + operands = Value[operation, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl.erase", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl.erase", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -207,28 +180,24 @@ may partially constrain an operand by specifying an expected value type %operand = pdl.operand : %type ``` """ -function operand(type=nothing::Union{Nothing,Value}; val::IR.Type, location=Location()) - results = IR.Type[val,] +function operand(type=nothing::Union{Nothing, Value}; val::IR.Type, location=Location()) + results = IR.Type[val, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(type) && push!(operands, type) - - return IR.create_operation( - "pdl.operand", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl.operand", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end """ -`operands` +`operands_` `pdl.operands` operations capture external operand range edges into an operation node that originate from operations or block arguments not @@ -248,23 +217,19 @@ operands by specifying expected value types (via `pdl.types` operations). %typed_operands = pdl.operands : %types ``` """ -function operands(type=nothing::Union{Nothing,Value}; val::IR.Type, location=Location()) - results = IR.Type[val,] +function operands_(type=nothing::Union{Nothing, Value}; val::IR.Type, location=Location()) + results = IR.Type[val, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(type) && push!(operands, type) - - return IR.create_operation( - "pdl.operands", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl.operands", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -365,35 +330,20 @@ def MyOp { %op = pdl.operation \"foo.op\" -> (%result, %otherResults : !pdl.type, !pdl.range) ``` """ -function operation( - operands::Vector{Value}, - attributes::Vector{Value}, - types::Vector{Value}; - op::IR.Type, - name=nothing, - attributeNames, - location=Location(), -) - results = IR.Type[op,] - operands = Value[operands..., attributes..., types...] +function operation(operands_::Vector{Value}, attributes_::Vector{Value}, types::Vector{Value}; op::IR.Type, name=nothing, attributeNames, location=Location()) + results = IR.Type[op, ] + operands = Value[operands_..., attributes_..., types..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("attributeNames", attributeNames),] - push!( - attributes, - operandsegmentsizes([length(operands), length(attributes), length(types)]), - ) + attributes = NamedAttribute[namedattribute("attributeNames", attributeNames), ] + push!(attributes, operandsegmentsizes([length(operands), length(attributes), length(types), ])) !isnothing(name) && push!(attributes, namedattribute("name", name)) - - return IR.create_operation( - "pdl.operation", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl.operation", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -424,20 +374,16 @@ pdl.pattern : benefit(1) { function pattern(; benefit, sym_name=nothing, body::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] - attributes = NamedAttribute[namedattribute("benefit", benefit),] + attributes = NamedAttribute[namedattribute("benefit", benefit), ] !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) - - return IR.create_operation( - "pdl.pattern", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl.pattern", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -466,32 +412,20 @@ pdl.replace %root with (%vals : !pdl.range) pdl.replace %root with %otherOp ``` """ -function replace( - operation::Value, - replOperation=nothing::Union{Nothing,Value}; - replValues::Vector{Value}, - location=Location(), -) +function replace(operation::Value, replOperation=nothing::Union{Nothing, Value}; replValues::Vector{Value}, location=Location()) results = IR.Type[] - operands = Value[operation, replValues...] + operands = Value[operation, replValues..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(replOperation) && push!(operands, replOperation) - push!( - attributes, - operandsegmentsizes([1, (replOperation == nothing) ? 0 : 1length(replValues)]), - ) - - return IR.create_operation( - "pdl.replace", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([1, (replOperation==nothing) ? 0 : 1length(replValues), ])) + + IR.create_operation( + "pdl.replace", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -518,26 +452,22 @@ as defined by the ODS definition of the operation. ``` """ function result(parent::Value; val::IR.Type, index, location=Location()) - results = IR.Type[val,] - operands = Value[parent,] + results = IR.Type[val, ] + operands = Value[parent, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("index", index),] - - return IR.create_operation( - "pdl.result", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl.result", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end """ -`results` +`results_` `pdl.results` operations extract a result group from an operation within a pattern or rewrite region. If an index is provided, this operation extracts @@ -565,23 +495,19 @@ operation. %results = pdl.results 1 of %operation -> !pdl.value ``` """ -function results(parent::Value; val::IR.Type, index=nothing, location=Location()) - results = IR.Type[val,] - operands = Value[parent,] +function results_(parent::Value; val::IR.Type, index=nothing, location=Location()) + results = IR.Type[val, ] + operands = Value[parent, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(index) && push!(attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl.results", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl.results", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -625,34 +551,22 @@ pdl.rewrite { } ``` """ -function rewrite( - root=nothing::Union{Nothing,Value}; - externalArgs::Vector{Value}, - name=nothing, - externalConstParams=nothing, - body::Region, - location=Location(), -) +function rewrite(root=nothing::Union{Nothing, Value}; externalArgs::Vector{Value}, name=nothing, externalConstParams=nothing, body::Region, location=Location()) results = IR.Type[] - operands = Value[externalArgs...,] - owned_regions = Region[body,] + operands = Value[externalArgs..., ] + owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] !isnothing(root) && push!(operands, root) - push!(attributes, operandsegmentsizes([(root == nothing) ? 0 : 1length(externalArgs)])) + push!(attributes, operandsegmentsizes([(root==nothing) ? 0 : 1length(externalArgs), ])) !isnothing(name) && push!(attributes, namedattribute("name", name)) - !isnothing(externalConstParams) && - push!(attributes, namedattribute("externalConstParams", externalConstParams)) - - return IR.create_operation( - "pdl.rewrite", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(externalConstParams) && push!(attributes, namedattribute("externalConstParams", externalConstParams)) + + IR.create_operation( + "pdl.rewrite", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -675,22 +589,18 @@ partially constrain the result by specifying a constant `Type`. ``` """ function type(; result::IR.Type, type=nothing, location=Location()) - results = IR.Type[result,] + results = IR.Type[result, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(type) && push!(attributes, namedattribute("type", type)) - - return IR.create_operation( - "pdl.type", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl.type", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -713,22 +623,18 @@ an array of `Type`s. ``` """ function types(; result::IR.Type, types=nothing, location=Location()) - results = IR.Type[result,] + results = IR.Type[result, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(types) && push!(attributes, namedattribute("types", types)) - - return IR.create_operation( - "pdl.types", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl.types", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/PDLInterp.jl b/src/Dialects/14/PDLInterp.jl index 7193cbf3..1d9c787b 100644 --- a/src/Dialects/14/PDLInterp.jl +++ b/src/Dialects/14/PDLInterp.jl @@ -1,9 +1,8 @@ module pdl_interp -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `apply_constraint` @@ -22,30 +21,19 @@ false destination is taken. pdl_interp.apply_constraint \"myConstraint\"[42, \"abc\", i32](%input, %attr, %op : !pdl.value, !pdl.attribute, !pdl.operation) -> ^matchDest, ^failureDest ``` """ -function apply_constraint( - args::Vector{Value}; - name, - constParams=nothing, - trueDest::Block, - falseDest::Block, - location=Location(), -) +function apply_constraint(args::Vector{Value}; name, constParams=nothing, trueDest::Block, falseDest::Block, location=Location()) results = IR.Type[] - operands = Value[args...,] + operands = Value[args..., ] owned_regions = Region[] - successors = Block[trueDest, falseDest] - attributes = NamedAttribute[namedattribute("name", name),] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[namedattribute("name", name), ] !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) - - return IR.create_operation( - "pdl_interp.apply_constraint", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.apply_constraint", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -76,29 +64,19 @@ pdl_interp.apply_rewrite \"rewriter\"(%root : !pdl.operation, %value : !pdl.valu pdl_interp.apply_rewrite \"rewriter\"[42](%root : !pdl.operation, %value : !pdl.value) ``` """ -function apply_rewrite( - args::Vector{Value}; - results::Vector{IR.Type}, - name, - constParams=nothing, - location=Location(), -) - results = IR.Type[results...,] - operands = Value[args...,] +function apply_rewrite(args::Vector{Value}; results_::Vector{IR.Type}, name, constParams=nothing, location=Location()) + results = IR.Type[results_..., ] + operands = Value[args..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("name", name),] + attributes = NamedAttribute[namedattribute("name", name), ] !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) - - return IR.create_operation( - "pdl_interp.apply_rewrite", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.apply_rewrite", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -115,24 +93,18 @@ otherwise the false destination is taken. pdl_interp.are_equal %result1, %result2 : !pdl.value -> ^matchDest, ^failureDest ``` """ -function are_equal( - lhs::Value, rhs::Value; trueDest::Block, falseDest::Block, location=Location() -) +function are_equal(lhs::Value, rhs::Value; trueDest::Block, falseDest::Block, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] - successors = Block[trueDest, falseDest] + successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.are_equal", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.are_equal", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -153,18 +125,14 @@ function branch(; dest::Block, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] - successors = Block[dest,] + successors = Block[dest, ] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.branch", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.branch", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -181,24 +149,18 @@ true destination, otherwise the false destination is taken. pdl_interp.check_attribute %attr is 10 -> ^matchDest, ^failureDest ``` """ -function check_attribute( - attribute::Value; constantValue, trueDest::Block, falseDest::Block, location=Location() -) +function check_attribute(attribute::Value; constantValue, trueDest::Block, falseDest::Block, location=Location()) results = IR.Type[] - operands = Value[attribute,] + operands = Value[attribute, ] owned_regions = Region[] - successors = Block[trueDest, falseDest] - attributes = NamedAttribute[namedattribute("constantValue", constantValue),] - - return IR.create_operation( - "pdl_interp.check_attribute", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[namedattribute("constantValue", constantValue), ] + + IR.create_operation( + "pdl_interp.check_attribute", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -221,31 +183,19 @@ pdl_interp.check_operand_count of %op is 2 -> ^matchDest, ^failureDest pdl_interp.check_operand_count of %op is at_least 2 -> ^matchDest, ^failureDest ``` """ -function check_operand_count( - operation::Value; - count, - compareAtLeast=nothing, - trueDest::Block, - falseDest::Block, - location=Location(), -) +function check_operand_count(operation::Value; count, compareAtLeast=nothing, trueDest::Block, falseDest::Block, location=Location()) results = IR.Type[] - operands = Value[operation,] + operands = Value[operation, ] owned_regions = Region[] - successors = Block[trueDest, falseDest] - attributes = NamedAttribute[namedattribute("count", count),] - !isnothing(compareAtLeast) && - push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) - - return IR.create_operation( - "pdl_interp.check_operand_count", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[namedattribute("count", count), ] + !isnothing(compareAtLeast) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) + + IR.create_operation( + "pdl_interp.check_operand_count", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -262,24 +212,18 @@ destination, otherwise the false destination is taken. pdl_interp.check_operation_name of %op is \"foo.op\" -> ^matchDest, ^failureDest ``` """ -function check_operation_name( - operation::Value; name, trueDest::Block, falseDest::Block, location=Location() -) +function check_operation_name(operation::Value; name, trueDest::Block, falseDest::Block, location=Location()) results = IR.Type[] - operands = Value[operation,] + operands = Value[operation, ] owned_regions = Region[] - successors = Block[trueDest, falseDest] - attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.check_operation_name", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.check_operation_name", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -302,31 +246,19 @@ pdl_interp.check_result_count of %op is 2 -> ^matchDest, ^failureDest pdl_interp.check_result_count of %op is at_least 2 -> ^matchDest, ^failureDest ``` """ -function check_result_count( - operation::Value; - count, - compareAtLeast=nothing, - trueDest::Block, - falseDest::Block, - location=Location(), -) +function check_result_count(operation::Value; count, compareAtLeast=nothing, trueDest::Block, falseDest::Block, location=Location()) results = IR.Type[] - operands = Value[operation,] + operands = Value[operation, ] owned_regions = Region[] - successors = Block[trueDest, falseDest] - attributes = NamedAttribute[namedattribute("count", count),] - !isnothing(compareAtLeast) && - push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) - - return IR.create_operation( - "pdl_interp.check_result_count", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[namedattribute("count", count), ] + !isnothing(compareAtLeast) && push!(attributes, namedattribute("compareAtLeast", compareAtLeast)) + + IR.create_operation( + "pdl_interp.check_result_count", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -343,24 +275,18 @@ the false destination is taken. pdl_interp.check_type %type is i32 -> ^matchDest, ^failureDest ``` """ -function check_type( - value::Value; type, trueDest::Block, falseDest::Block, location=Location() -) +function check_type(value::Value; type, trueDest::Block, falseDest::Block, location=Location()) results = IR.Type[] - operands = Value[value,] + operands = Value[value, ] owned_regions = Region[] - successors = Block[trueDest, falseDest] - attributes = NamedAttribute[namedattribute("type", type),] - - return IR.create_operation( - "pdl_interp.check_type", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[namedattribute("type", type), ] + + IR.create_operation( + "pdl_interp.check_type", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -377,24 +303,18 @@ to the true destination, otherwise the false destination is taken. pdl_interp.check_types %type are [i32, i64] -> ^matchDest, ^failureDest ``` """ -function check_types( - value::Value; types, trueDest::Block, falseDest::Block, location=Location() -) +function check_types(value::Value; types, trueDest::Block, falseDest::Block, location=Location()) results = IR.Type[] - operands = Value[value,] + operands = Value[value, ] owned_regions = Region[] - successors = Block[trueDest, falseDest] - attributes = NamedAttribute[namedattribute("types", types),] - - return IR.create_operation( - "pdl_interp.check_types", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[namedattribute("types", types), ] + + IR.create_operation( + "pdl_interp.check_types", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -417,16 +337,12 @@ function continue_(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.continue", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.continue", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -443,21 +359,17 @@ interpreter for a specific constant attribute value. ``` """ function create_attribute(; attribute::IR.Type, value, location=Location()) - results = IR.Type[attribute,] + results = IR.Type[attribute, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("value", value),] - - return IR.create_operation( - "pdl_interp.create_attribute", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("value", value), ] + + IR.create_operation( + "pdl_interp.create_attribute", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -476,36 +388,19 @@ this operation. %op = pdl_interp.create_operation \"foo.op\"(%arg0 : !pdl.value) {\"attrA\" = %attr0} -> (%type : !pdl.type) ``` """ -function create_operation( - operands::Vector{Value}, - attributes::Vector{Value}, - types::Vector{Value}; - operation::IR.Type, - name, - attributeNames, - location=Location(), -) - results = IR.Type[operation,] - operands = Value[operands..., attributes..., types...] +function create_operation(operands_::Vector{Value}, attributes_::Vector{Value}, types::Vector{Value}; operation::IR.Type, name, attributeNames, location=Location()) + results = IR.Type[operation, ] + operands = Value[operands_..., attributes_..., types..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("name", name), namedattribute("attributeNames", attributeNames) - ] - push!( - attributes, - operandsegmentsizes([length(operands), length(attributes), length(types)]), - ) - - return IR.create_operation( - "pdl_interp.create_operation", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("name", name), namedattribute("attributeNames", attributeNames), ] + push!(attributes, operandsegmentsizes([length(operands), length(attributes), length(types), ])) + + IR.create_operation( + "pdl_interp.create_operation", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -522,21 +417,17 @@ pdl_interp.create_type i64 ``` """ function create_type(; result::IR.Type, value, location=Location()) - results = IR.Type[result,] + results = IR.Type[result, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("value", value),] - - return IR.create_operation( - "pdl_interp.create_type", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("value", value), ] + + IR.create_operation( + "pdl_interp.create_type", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -553,21 +444,17 @@ pdl_interp.create_types [i64, i64] ``` """ function create_types(; result::IR.Type, value, location=Location()) - results = IR.Type[result,] + results = IR.Type[result, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("value", value),] - - return IR.create_operation( - "pdl_interp.create_types", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("value", value), ] + + IR.create_operation( + "pdl_interp.create_types", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -586,20 +473,16 @@ pdl_interp.erase %root """ function erase(operation::Value; location=Location()) results = IR.Type[] - operands = Value[operation,] + operands = Value[operation, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.erase", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.erase", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -617,21 +500,17 @@ at the specified index. If the index is out of range, returns null. ``` """ function extract(range::Value; result::IR.Type, index, location=Location()) - results = IR.Type[result,] - operands = Value[range,] + results = IR.Type[result, ] + operands = Value[range, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("index", index),] - - return IR.create_operation( - "pdl_interp.extract", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.extract", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -653,16 +532,12 @@ function finalize(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.finalize", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.finalize", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -687,20 +562,16 @@ pdl_interp.foreach %op : !pdl.operation in %ops { """ function foreach(values::Value; region::Region, successor::Block, location=Location()) results = IR.Type[] - operands = Value[values,] - owned_regions = Region[region,] - successors = Block[successor,] + operands = Value[values, ] + owned_regions = Region[region, ] + successors = Block[successor, ] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.foreach", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.foreach", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -718,21 +589,17 @@ returned. ``` """ function get_attribute(operation::Value; attribute::IR.Type, name, location=Location()) - results = IR.Type[attribute,] - operands = Value[operation,] + results = IR.Type[attribute, ] + operands = Value[operation, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.get_attribute", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.get_attribute", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -749,21 +616,17 @@ specific attribute. ``` """ function get_attribute_type(value::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[value,] + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.get_attribute_type", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.get_attribute_type", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -782,21 +645,17 @@ or range of operand results, null is returned. ``` """ function get_defining_op(value::Value; operation::IR.Type, location=Location()) - results = IR.Type[operation,] - operands = Value[value,] + results = IR.Type[operation, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.get_defining_op", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.get_defining_op", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -814,21 +673,17 @@ null value is returned. ``` """ function get_operand(operation::Value; value::IR.Type, index, location=Location()) - results = IR.Type[value,] - operands = Value[operation,] + results = IR.Type[value, ] + operands = Value[operation, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("index", index),] - - return IR.create_operation( - "pdl_interp.get_operand", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.get_operand", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -856,22 +711,18 @@ the returned operand group corresponds to all operands of the operation. ``` """ function get_operands(operation::Value; value::IR.Type, index=nothing, location=Location()) - results = IR.Type[value,] - operands = Value[operation,] + results = IR.Type[value, ] + operands = Value[operation, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(index) && push!(attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl_interp.get_operands", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.get_operands", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -889,21 +740,17 @@ null value is returned. ``` """ function get_result(operation::Value; value::IR.Type, index, location=Location()) - results = IR.Type[value,] - operands = Value[operation,] + results = IR.Type[value, ] + operands = Value[operation, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("index", index),] - - return IR.create_operation( - "pdl_interp.get_result", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.get_result", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -931,22 +778,18 @@ the returned operand group corresponds to all results of the operation. ``` """ function get_results(operation::Value; value::IR.Type, index=nothing, location=Location()) - results = IR.Type[value,] - operands = Value[operation,] + results = IR.Type[value, ] + operands = Value[operation, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(index) && push!(attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl_interp.get_results", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.get_results", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -968,21 +811,17 @@ similarly to ResultRange::getUsers. ``` """ function get_users(value::Value; operations::IR.Type, location=Location()) - results = IR.Type[operations,] - operands = Value[value,] + results = IR.Type[operations, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.get_users", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.get_users", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1003,21 +842,17 @@ value or range thereof. ``` """ function get_value_type(value::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[value,] + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.get_value_type", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.get_value_type", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1035,21 +870,17 @@ that should be inferred. This signals to other operations, such as ``` """ function inferred_types(; type::IR.Type, location=Location()) - results = IR.Type[type,] + results = IR.Type[type, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.inferred_types", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.inferred_types", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1069,20 +900,16 @@ pdl_interp.is_not_null %value : !pdl.value -> ^matchDest, ^failureDest """ function is_not_null(value::Value; trueDest::Block, falseDest::Block, location=Location()) results = IR.Type[] - operands = Value[value,] + operands = Value[value, ] owned_regions = Region[] - successors = Block[trueDest, falseDest] + successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.is_not_null", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.is_not_null", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1101,37 +928,21 @@ rewriter. pdl_interp.record_match @rewriters::myRewriter(%root : !pdl.operation) : benefit(1), loc([%root, %op1]), root(\"foo.op\") -> ^nextDest ``` """ -function record_match( - inputs::Vector{Value}, - matchedOps::Vector{Value}; - rewriter, - rootKind=nothing, - generatedOps=nothing, - benefit, - dest::Block, - location=Location(), -) +function record_match(inputs::Vector{Value}, matchedOps::Vector{Value}; rewriter, rootKind=nothing, generatedOps=nothing, benefit, dest::Block, location=Location()) results = IR.Type[] - operands = Value[inputs..., matchedOps...] + operands = Value[inputs..., matchedOps..., ] owned_regions = Region[] - successors = Block[dest,] - attributes = NamedAttribute[ - namedattribute("rewriter", rewriter), namedattribute("benefit", benefit) - ] - push!(attributes, operandsegmentsizes([length(inputs), length(matchedOps)])) + successors = Block[dest, ] + attributes = NamedAttribute[namedattribute("rewriter", rewriter), namedattribute("benefit", benefit), ] + push!(attributes, operandsegmentsizes([length(inputs), length(matchedOps), ])) !isnothing(rootKind) && push!(attributes, namedattribute("rootKind", rootKind)) - !isnothing(generatedOps) && - push!(attributes, namedattribute("generatedOps", generatedOps)) - - return IR.create_operation( - "pdl_interp.record_match", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(generatedOps) && push!(attributes, namedattribute("generatedOps", generatedOps)) + + IR.create_operation( + "pdl_interp.record_match", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1152,20 +963,16 @@ pdl_interp.replace %root with (%val0, %val1 : !pdl.type, !pdl.type) """ function replace(operation::Value, replValues::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[operation, replValues...] + operands = Value[operation, replValues..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.replace", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "pdl_interp.replace", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1183,28 +990,18 @@ the default destination is taken. pdl_interp.switch_attribute %attr to [10, true](^10Dest, ^trueDest) -> ^defaultDest ``` """ -function switch_attribute( - attribute::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) +function switch_attribute(attribute::Value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) results = IR.Type[] - operands = Value[attribute,] + operands = Value[attribute, ] owned_regions = Region[] - successors = Block[defaultDest, cases...] - attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_attribute", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[defaultDest, cases..., ] + attributes = NamedAttribute[namedattribute("caseValues", caseValues), ] + + IR.create_operation( + "pdl_interp.switch_attribute", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1222,28 +1019,18 @@ otherwise the default destination is taken. pdl_interp.switch_operand_count of %op to [10, 2] -> ^10Dest, ^2Dest, ^defaultDest ``` """ -function switch_operand_count( - operation::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) +function switch_operand_count(operation::Value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) results = IR.Type[] - operands = Value[operation,] + operands = Value[operation, ] owned_regions = Region[] - successors = Block[defaultDest, cases...] - attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_operand_count", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[defaultDest, cases..., ] + attributes = NamedAttribute[namedattribute("caseValues", caseValues), ] + + IR.create_operation( + "pdl_interp.switch_operand_count", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1261,28 +1048,18 @@ the default destination is taken. pdl_interp.switch_operation_name of %op to [\"foo.op\", \"bar.op\"](^fooDest, ^barDest) -> ^defaultDest ``` """ -function switch_operation_name( - operation::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) +function switch_operation_name(operation::Value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) results = IR.Type[] - operands = Value[operation,] + operands = Value[operation, ] owned_regions = Region[] - successors = Block[defaultDest, cases...] - attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_operation_name", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[defaultDest, cases..., ] + attributes = NamedAttribute[namedattribute("caseValues", caseValues), ] + + IR.create_operation( + "pdl_interp.switch_operation_name", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1300,28 +1077,18 @@ otherwise the default destination is taken. pdl_interp.switch_result_count of %op to [0, 2](^0Dest, ^2Dest) -> ^defaultDest ``` """ -function switch_result_count( - operation::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) +function switch_result_count(operation::Value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) results = IR.Type[] - operands = Value[operation,] + operands = Value[operation, ] owned_regions = Region[] - successors = Block[defaultDest, cases...] - attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_result_count", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[defaultDest, cases..., ] + attributes = NamedAttribute[namedattribute("caseValues", caseValues), ] + + IR.create_operation( + "pdl_interp.switch_result_count", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1339,24 +1106,18 @@ is taken. pdl_interp.switch_type %type to [i32, i64] -> ^i32Dest, ^i64Dest, ^defaultDest ``` """ -function switch_type( - value::Value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location() -) +function switch_type(value::Value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) results = IR.Type[] - operands = Value[value,] + operands = Value[value, ] owned_regions = Region[] - successors = Block[defaultDest, cases...] - attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_type", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[defaultDest, cases..., ] + attributes = NamedAttribute[namedattribute("caseValues", caseValues), ] + + IR.create_operation( + "pdl_interp.switch_type", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1374,24 +1135,18 @@ destination is taken. pdl_interp.switch_types %type is [[i32], [i64, i64]] -> ^i32Dest, ^i64Dest, ^defaultDest ``` """ -function switch_types( - value::Value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location() -) +function switch_types(value::Value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) results = IR.Type[] - operands = Value[value,] + operands = Value[value, ] owned_regions = Region[] - successors = Block[defaultDest, cases...] - attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_types", - location; - operands, - owned_regions, - successors, - attributes, + successors = Block[defaultDest, cases..., ] + attributes = NamedAttribute[namedattribute("caseValues", caseValues), ] + + IR.create_operation( + "pdl_interp.switch_types", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Quant.jl b/src/Dialects/14/Quant.jl index fe3f5a3f..385bbfd5 100644 --- a/src/Dialects/14/Quant.jl +++ b/src/Dialects/14/Quant.jl @@ -1,9 +1,8 @@ module quant -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `const_fake_quant` @@ -13,39 +12,21 @@ same uniform quantization simulation as is done by the TensorFlow fake_quant_with_min_max_args op. See the fakeQuantAttrsToType() utility method and the quant-convert-simulated-quantization pass for further details. """ -function const_fake_quant( - inputs::Value; - outputs=nothing::Union{Nothing,IR.Type}, - min, - max, - num_bits, - narrow_range=nothing, - is_signed=nothing, - location=Location(), -) +function const_fake_quant(inputs::Value; outputs=nothing::Union{Nothing, IR.Type}, min, max, num_bits, narrow_range=nothing, is_signed=nothing, location=Location()) results = IR.Type[] - operands = Value[inputs,] + operands = Value[inputs, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("min", min), - namedattribute("max", max), - namedattribute("num_bits", num_bits), - ] + attributes = NamedAttribute[namedattribute("min", min), namedattribute("max", max), namedattribute("num_bits", num_bits), ] !isnothing(outputs) && push!(results, outputs) - !isnothing(narrow_range) && - push!(attributes, namedattribute("narrow_range", narrow_range)) + !isnothing(narrow_range) && push!(attributes, namedattribute("narrow_range", narrow_range)) !isnothing(is_signed) && push!(attributes, namedattribute("is_signed", is_signed)) - - return IR.create_operation( - "quant.const_fake_quant", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "quant.const_fake_quant", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -58,41 +39,21 @@ fake_quant_with_min_max_vars_per_channel op. See the fakeQuantAttrsToType() utility method and the quant-convert-simulated-quantization pass for further details. """ -function const_fake_quant_per_axis( - inputs::Value; - outputs=nothing::Union{Nothing,IR.Type}, - min, - max, - axis, - num_bits, - narrow_range=nothing, - is_signed=nothing, - location=Location(), -) +function const_fake_quant_per_axis(inputs::Value; outputs=nothing::Union{Nothing, IR.Type}, min, max, axis, num_bits, narrow_range=nothing, is_signed=nothing, location=Location()) results = IR.Type[] - operands = Value[inputs,] + operands = Value[inputs, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("min", min), - namedattribute("max", max), - namedattribute("axis", axis), - namedattribute("num_bits", num_bits), - ] + attributes = NamedAttribute[namedattribute("min", min), namedattribute("max", max), namedattribute("axis", axis), namedattribute("num_bits", num_bits), ] !isnothing(outputs) && push!(results, outputs) - !isnothing(narrow_range) && - push!(attributes, namedattribute("narrow_range", narrow_range)) + !isnothing(narrow_range) && push!(attributes, namedattribute("narrow_range", narrow_range)) !isnothing(is_signed) && push!(attributes, namedattribute("is_signed", is_signed)) - - return IR.create_operation( - "quant.const_fake_quant_per_axis", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "quant.const_fake_quant_per_axis", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -106,25 +67,19 @@ external connections. In such a case, during analysis, all coupled_ref nodes in a module which share a coupledKey will be considered to be directly connected as via an identity op for the purpose of type inference. """ -function coupled_ref( - arg::Value; result_0=nothing::Union{Nothing,IR.Type}, coupledKey, location=Location() -) +function coupled_ref(arg::Value; result_0=nothing::Union{Nothing, IR.Type}, coupledKey, location=Location()) results = IR.Type[] - operands = Value[arg,] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("coupledKey", coupledKey),] + attributes = NamedAttribute[namedattribute("coupledKey", coupledKey), ] !isnothing(result_0) && push!(results, result_0) - - return IR.create_operation( - "quant.coupled_ref", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "quant.coupled_ref", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -133,21 +88,17 @@ end """ function dcast(arg::Value; result_0::IR.Type, location=Location()) - results = IR.Type[result_0,] - operands = Value[arg,] + results = IR.Type[result_0, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "quant.dcast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "quant.dcast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -156,21 +107,17 @@ end """ function qcast(arg::Value; result_0::IR.Type, location=Location()) - results = IR.Type[result_0,] - operands = Value[arg,] + results = IR.Type[result_0, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "quant.qcast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "quant.qcast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -178,34 +125,18 @@ end `region` """ -function region( - inputs::Vector{Value}; - outputs::Vector{IR.Type}, - input_specs, - output_specs, - logical_kernel, - body::Region, - location=Location(), -) - results = IR.Type[outputs...,] - operands = Value[inputs...,] - owned_regions = Region[body,] +function region(inputs::Vector{Value}; outputs::Vector{IR.Type}, input_specs, output_specs, logical_kernel, body::Region, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[inputs..., ] + owned_regions = Region[body, ] successors = Block[] - attributes = NamedAttribute[ - namedattribute("input_specs", input_specs), - namedattribute("output_specs", output_specs), - namedattribute("logical_kernel", logical_kernel), - ] - - return IR.create_operation( - "quant.region", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("input_specs", input_specs), namedattribute("output_specs", output_specs), namedattribute("logical_kernel", logical_kernel), ] + + IR.create_operation( + "quant.region", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -213,22 +144,18 @@ end `return_` """ -function return_(results::Vector{Value}; location=Location()) +function return_(results_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[results...,] + operands = Value[results_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "quant.return", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "quant.return", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -252,32 +179,21 @@ Currently, only dim=2 is supported, which is interpreted as [min, max]. , axis=2 => N=6 ``` """ -function stats( - arg::Value; - result_0=nothing::Union{Nothing,IR.Type}, - layerStats, - axisStats=nothing, - axis=nothing, - location=Location(), -) +function stats(arg::Value; result_0=nothing::Union{Nothing, IR.Type}, layerStats, axisStats=nothing, axis=nothing, location=Location()) results = IR.Type[] - operands = Value[arg,] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("layerStats", layerStats),] + attributes = NamedAttribute[namedattribute("layerStats", layerStats), ] !isnothing(result_0) && push!(results, result_0) !isnothing(axisStats) && push!(attributes, namedattribute("axisStats", axisStats)) !isnothing(axis) && push!(attributes, namedattribute("axis", axis)) - - return IR.create_operation( - "quant.stats", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "quant.stats", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -290,25 +206,19 @@ Such statistics will be stored with the provided key, allowing this node to later be converted to a \'stats\' op if statistics with that key have been encountered. """ -function stats_ref( - arg::Value; result_0=nothing::Union{Nothing,IR.Type}, statsKey, location=Location() -) +function stats_ref(arg::Value; result_0=nothing::Union{Nothing, IR.Type}, statsKey, location=Location()) results = IR.Type[] - operands = Value[arg,] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("statsKey", statsKey),] + attributes = NamedAttribute[namedattribute("statsKey", statsKey), ] !isnothing(result_0) && push!(results, result_0) - - return IR.create_operation( - "quant.stats_ref", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "quant.stats_ref", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -317,21 +227,17 @@ end """ function scast(arg::Value; result_0::IR.Type, location=Location()) - results = IR.Type[result_0,] - operands = Value[arg,] + results = IR.Type[result_0, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "quant.scast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "quant.scast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/SCF.jl b/src/Dialects/14/SCF.jl index 59c7540d..55b7e8e8 100644 --- a/src/Dialects/14/SCF.jl +++ b/src/Dialects/14/SCF.jl @@ -1,9 +1,8 @@ module scf -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `condition` @@ -15,20 +14,16 @@ to the entry block of the region. Otherwise, the loop terminates. """ function condition(condition::Value, args::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[condition, args...] + operands = Value[condition, args..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "scf.condition", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "scf.condition", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -74,21 +69,17 @@ affine.for %i = 0 to 100 { ``` """ function execute_region(; result_0::Vector{IR.Type}, region::Region, location=Location()) - results = IR.Type[result_0...,] + results = IR.Type[result_0..., ] operands = Value[] - owned_regions = Region[region,] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "scf.execute_region", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "scf.execute_region", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -181,30 +172,18 @@ func @conditional_reduce(%buffer: memref<1024xf32>, %lb: index, } ``` """ -function for_( - lowerBound::Value, - upperBound::Value, - step::Value, - initArgs::Vector{Value}; - results::Vector{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[results...,] - operands = Value[lowerBound, upperBound, step, initArgs...] - owned_regions = Region[region,] +function for_(lowerBound::Value, upperBound::Value, step::Value, initArgs::Vector{Value}; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[lowerBound, upperBound, step, initArgs..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "scf.for", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "scf.for", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -254,28 +233,18 @@ scf.if %b { } ``` """ -function if_( - condition::Value; - results::Vector{IR.Type}, - thenRegion::Region, - elseRegion::Region, - location=Location(), -) - results = IR.Type[results...,] - operands = Value[condition,] - owned_regions = Region[thenRegion, elseRegion] +function if_(condition::Value; results_::Vector{IR.Type}, thenRegion::Region, elseRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[condition, ] + owned_regions = Region[thenRegion, elseRegion, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "scf.if", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "scf.if", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -325,36 +294,19 @@ scf.parallel (%iv) = (%lb) to (%ub) step (%step) init (%init) -> f32 { } ``` """ -function parallel( - lowerBound::Vector{Value}, - upperBound::Vector{Value}, - step::Vector{Value}, - initVals::Vector{Value}; - results::Vector{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[results...,] - operands = Value[lowerBound..., upperBound..., step..., initVals...] - owned_regions = Region[region,] +function parallel(lowerBound::Vector{Value}, upperBound::Vector{Value}, step::Vector{Value}, initVals::Vector{Value}; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[lowerBound..., upperBound..., step..., initVals..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - push!( - attributes, - operandsegmentsizes([ - length(lowerBound), length(upperBound), length(step), length(initVals) - ]), - ) - - return IR.create_operation( - "scf.parallel", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(initVals), ])) + + IR.create_operation( + "scf.parallel", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -396,20 +348,16 @@ scf.reduce(%operand) : f32 { """ function reduce(operand::Value; reductionOperator::Region, location=Location()) results = IR.Type[] - operands = Value[operand,] - owned_regions = Region[reductionOperator,] + operands = Value[operand, ] + owned_regions = Region[reductionOperator, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "scf.reduce", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "scf.reduce", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -426,20 +374,16 @@ scf.reduce.return %res : f32 """ function reduce_return(result::Value; location=Location()) results = IR.Type[] - operands = Value[result,] + operands = Value[result, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "scf.reduce.return", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "scf.reduce.return", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -557,28 +501,18 @@ assignment-list ::= assignment | assignment `,` assignment-list assignment ::= ssa-value `=` ssa-value ``` """ -function while_( - inits::Vector{Value}; - results::Vector{IR.Type}, - before::Region, - after::Region, - location=Location(), -) - results = IR.Type[results...,] - operands = Value[inits...,] - owned_regions = Region[before, after] +function while_(inits::Vector{Value}; results_::Vector{IR.Type}, before::Region, after::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[inits..., ] + owned_regions = Region[before, after, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "scf.while", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "scf.while", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -595,22 +529,18 @@ left out in the custom syntax and the builders will insert one implicitly. Otherwise, it has to be present in the syntax to indicate which values are yielded. """ -function yield(results::Vector{Value}; location=Location()) +function yield(results_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[results...,] + operands = Value[results_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "scf.yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "scf.yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/SPIRV.jl b/src/Dialects/14/SPIRV.jl index 96800804..b026a944 100644 --- a/src/Dialects/14/SPIRV.jl +++ b/src/Dialects/14/SPIRV.jl @@ -1,9 +1,8 @@ module spv -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `AccessChain` @@ -47,24 +46,18 @@ access-chain-op ::= ssa-id `=` `spv.AccessChain` ssa-use %3 = spv.Load \"Function\" %2 [\"Volatile\"] : !spv.array<4xf32> ``` """ -function AccessChain( - base_ptr::Value, indices::Vector{Value}; component_ptr::IR.Type, location=Location() -) - results = IR.Type[component_ptr,] - operands = Value[base_ptr, indices...] +function AccessChain(base_ptr::Value, indices::Vector{Value}; component_ptr::IR.Type, location=Location()) + results = IR.Type[component_ptr, ] + operands = Value[base_ptr, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.AccessChain", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.AccessChain", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -93,21 +86,17 @@ spv-address-of-op ::= ssa-id `=` `spv.mlir.addressof` symbol-ref-id ``` """ function mlir_addressof(; pointer::IR.Type, variable, location=Location()) - results = IR.Type[pointer,] + results = IR.Type[pointer, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("variable", variable),] - - return IR.create_operation( - "spv.mlir.addressof", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("variable", variable), ] + + IR.create_operation( + "spv.mlir.addressof", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -148,31 +137,18 @@ atomic-and-op ::= !spv.ptr ``` """ -function AtomicAnd( - pointer::Value, - value::Value; - result::IR.Type, - memory_scope, - semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value] +function AtomicAnd(pointer::Value, value::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicAnd", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicAnd", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -222,35 +198,18 @@ atomic-compare-exchange-op ::= : !spv.ptr ``` """ -function AtomicCompareExchange( - pointer::Value, - value::Value, - comparator::Value; - result::IR.Type, - memory_scope, - equal_semantics, - unequal_semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value, comparator] +function AtomicCompareExchange(pointer::Value, value::Value, comparator::Value; result::IR.Type, memory_scope, equal_semantics, unequal_semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, comparator, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), - namedattribute("equal_semantics", equal_semantics), - namedattribute("unequal_semantics", unequal_semantics), - ] - - return IR.create_operation( - "spv.AtomicCompareExchange", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("equal_semantics", equal_semantics), namedattribute("unequal_semantics", unequal_semantics), ] + + IR.create_operation( + "spv.AtomicCompareExchange", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -278,35 +237,18 @@ atomic-compare-exchange-weak-op ::= : !spv.ptr ``` """ -function AtomicCompareExchangeWeak( - pointer::Value, - value::Value, - comparator::Value; - result::IR.Type, - memory_scope, - equal_semantics, - unequal_semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value, comparator] +function AtomicCompareExchangeWeak(pointer::Value, value::Value, comparator::Value; result::IR.Type, memory_scope, equal_semantics, unequal_semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, comparator, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), - namedattribute("equal_semantics", equal_semantics), - namedattribute("unequal_semantics", unequal_semantics), - ] - - return IR.create_operation( - "spv.AtomicCompareExchangeWeak", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("equal_semantics", equal_semantics), namedattribute("unequal_semantics", unequal_semantics), ] + + IR.create_operation( + "spv.AtomicCompareExchangeWeak", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -343,31 +285,18 @@ atomic-exchange-op ::= : !spv.ptr ``` """ -function AtomicExchange( - pointer::Value, - value::Value; - result::IR.Type, - memory_scope, - semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value] +function AtomicExchange(pointer::Value, value::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicExchange", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicExchange", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -409,31 +338,18 @@ atomic-fadd-op ::= !spv.ptr ```mlir """ -function AtomicFAddEXT( - pointer::Value, - value::Value; - result::IR.Type, - memory_scope, - semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value] +function AtomicFAddEXT(pointer::Value, value::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicFAddEXT", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicFAddEXT", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -470,31 +386,18 @@ atomic-iadd-op ::= !spv.ptr ``` """ -function AtomicIAdd( - pointer::Value, - value::Value; - result::IR.Type, - memory_scope, - semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value] +function AtomicIAdd(pointer::Value, value::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicIAdd", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicIAdd", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -530,26 +433,18 @@ atomic-idecrement-op ::= !spv.ptr ``` """ -function AtomicIDecrement( - pointer::Value; result::IR.Type, memory_scope, semantics, location=Location() -) - results = IR.Type[result,] - operands = Value[pointer,] +function AtomicIDecrement(pointer::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicIDecrement", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicIDecrement", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -584,26 +479,18 @@ atomic-iincrement-op ::= !spv.ptr ``` """ -function AtomicIIncrement( - pointer::Value; result::IR.Type, memory_scope, semantics, location=Location() -) - results = IR.Type[result,] - operands = Value[pointer,] +function AtomicIIncrement(pointer::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicIIncrement", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicIIncrement", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -641,31 +528,18 @@ atomic-isub-op ::= !spv.ptr ``` """ -function AtomicISub( - pointer::Value, - value::Value; - result::IR.Type, - memory_scope, - semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value] +function AtomicISub(pointer::Value, value::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicISub", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicISub", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -702,31 +576,18 @@ atomic-or-op ::= !spv.ptr ``` """ -function AtomicOr( - pointer::Value, - value::Value; - result::IR.Type, - memory_scope, - semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value] +function AtomicOr(pointer::Value, value::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicOr", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicOr", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -764,31 +625,18 @@ atomic-smax-op ::= !spv.ptr ``` """ -function AtomicSMax( - pointer::Value, - value::Value; - result::IR.Type, - memory_scope, - semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value] +function AtomicSMax(pointer::Value, value::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicSMax", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicSMax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -826,31 +674,18 @@ atomic-smin-op ::= !spv.ptr ``` """ -function AtomicSMin( - pointer::Value, - value::Value; - result::IR.Type, - memory_scope, - semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value] +function AtomicSMin(pointer::Value, value::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicSMin", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicSMin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -888,31 +723,18 @@ atomic-umax-op ::= !spv.ptr ``` """ -function AtomicUMax( - pointer::Value, - value::Value; - result::IR.Type, - memory_scope, - semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value] +function AtomicUMax(pointer::Value, value::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicUMax", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicUMax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -950,31 +772,18 @@ atomic-umin-op ::= !spv.ptr ``` """ -function AtomicUMin( - pointer::Value, - value::Value; - result::IR.Type, - memory_scope, - semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value] +function AtomicUMin(pointer::Value, value::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicUMin", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicUMin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1012,31 +821,18 @@ atomic-xor-op ::= !spv.ptr ``` """ -function AtomicXor( - pointer::Value, - value::Value; - result::IR.Type, - memory_scope, - semantics, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, value] +function AtomicXor(pointer::Value, value::Value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicXor", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spv.AtomicXor", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1072,25 +868,19 @@ Results are computed per component. %3 = spv.BitCount %1: vector<4xi32> ``` """ -function BitCount( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function BitCount(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.BitCount", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.BitCount", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1136,30 +926,19 @@ The type of Base and Insert must be the same as Result Type. %0 = spv.BitFieldInsert %base, %insert, %offset, %count : vector<3xi32>, i8, i8 ``` """ -function BitFieldInsert( - base::Value, - insert::Value, - offset::Value, - count::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function BitFieldInsert(base::Value, insert::Value, offset::Value, count::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[base, insert, offset, count] + operands = Value[base, insert, offset, count, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.BitFieldInsert", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.BitFieldInsert", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1205,29 +984,19 @@ The type of Base must be the same as Result Type. %0 = spv.BitFieldSExtract %base, %offset, %count : vector<3xi32>, i8, i8 ``` """ -function BitFieldSExtract( - base::Value, - offset::Value, - count::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function BitFieldSExtract(base::Value, offset::Value, count::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[base, offset, count] + operands = Value[base, offset, count, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.BitFieldSExtract", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.BitFieldSExtract", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1255,29 +1024,19 @@ bitfield-extract-u-op ::= ssa-id `=` `spv.BitFieldUExtract` ssa-use %0 = spv.BitFieldUExtract %base, %offset, %count : vector<3xi32>, i8, i8 ``` """ -function BitFieldUExtract( - base::Value, - offset::Value, - count::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function BitFieldUExtract(base::Value, offset::Value, count::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[base, offset, count] + operands = Value[base, offset, count, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.BitFieldUExtract", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.BitFieldUExtract", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1309,25 +1068,19 @@ The type of Base must be the same as Result Type. %3 = spv.BitReverse %1 : vector<4xi32> ``` """ -function BitReverse( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function BitReverse(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.BitReverse", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.BitReverse", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1371,21 +1124,17 @@ bitcast-op ::= ssa-id `=` `spv.Bitcast` ssa-use ``` """ function Bitcast(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Bitcast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Bitcast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1415,28 +1164,19 @@ Results are computed per component, and within each component, per bit. %2 = spv.BitwiseAnd %0, %1 : vector<4xi32> ``` """ -function BitwiseAnd( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function BitwiseAnd(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.BitwiseAnd", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.BitwiseAnd", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1466,28 +1206,19 @@ Results are computed per component, and within each component, per bit. %2 = spv.BitwiseOr %0, %1 : vector<4xi32> ``` """ -function BitwiseOr( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function BitwiseOr(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.BitwiseOr", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.BitwiseOr", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1517,28 +1248,19 @@ Results are computed per component, and within each component, per bit. %2 = spv.BitwiseXor %0, %1 : vector<4xi32> ``` """ -function BitwiseXor( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function BitwiseXor(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.BitwiseXor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.BitwiseXor", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1576,36 +1298,20 @@ spv.BranchConditional %condition, ^true_branch, ^false_branch spv.BranchConditional %condition, ^true_branch(%0: i32), ^false_branch(%1: i32) ``` """ -function BranchConditional( - condition::Value, - trueTargetOperands::Vector{Value}, - falseTargetOperands::Vector{Value}; - branch_weights=nothing, - trueTarget::Block, - falseTarget::Block, - location=Location(), -) +function BranchConditional(condition::Value, trueTargetOperands::Vector{Value}, falseTargetOperands::Vector{Value}; branch_weights=nothing, trueTarget::Block, falseTarget::Block, location=Location()) results = IR.Type[] - operands = Value[condition, trueTargetOperands..., falseTargetOperands...] + operands = Value[condition, trueTargetOperands..., falseTargetOperands..., ] owned_regions = Region[] - successors = Block[trueTarget, falseTarget] + successors = Block[trueTarget, falseTarget, ] attributes = NamedAttribute[] - push!( - attributes, - operandsegmentsizes([1, length(trueTargetOperands), length(falseTargetOperands)]), - ) - !isnothing(branch_weights) && - push!(attributes, namedattribute("branch_weights", branch_weights)) - - return IR.create_operation( - "spv.BranchConditional", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([1, length(trueTargetOperands), length(falseTargetOperands), ])) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) + + IR.create_operation( + "spv.BranchConditional", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1631,20 +1337,16 @@ spv.Branch ^target(%0, %1: i32, f32) """ function Branch(targetOperands::Vector{Value}; target::Block, location=Location()) results = IR.Type[] - operands = Value[targetOperands...,] + operands = Value[targetOperands..., ] owned_regions = Region[] - successors = Block[target,] + successors = Block[target, ] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Branch", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Branch", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1682,24 +1384,18 @@ composite-construct-op ::= ssa-id `=` `spv.CompositeConstruct` %0 = spv.CompositeConstruct %1, %2, %3 : vector<3xf32> ``` """ -function CompositeConstruct( - constituents::Vector{Value}; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[constituents...,] +function CompositeConstruct(constituents::Vector{Value}; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[constituents..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.CompositeConstruct", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.CompositeConstruct", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1732,24 +1428,18 @@ composite-extract-op ::= ssa-id `=` `spv.CompositeExtract` ssa-use %2 = spv.CompositeExtract %1[1 : i32] : !spv.array<4x!spv.array<4xf32>> ``` """ -function CompositeExtract( - composite::Value; component::IR.Type, indices, location=Location() -) - results = IR.Type[component,] - operands = Value[composite,] +function CompositeExtract(composite::Value; component::IR.Type, indices, location=Location()) + results = IR.Type[component, ] + operands = Value[composite, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("indices", indices),] - - return IR.create_operation( - "spv.CompositeExtract", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("indices", indices), ] + + IR.create_operation( + "spv.CompositeExtract", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1782,24 +1472,18 @@ composite-insert-op ::= ssa-id `=` `spv.CompositeInsert` ssa-use, ssa-use %0 = spv.CompositeInsert %object, %composite[1 : i32] : f32 into !spv.array<4xf32> ``` """ -function CompositeInsert( - object::Value, composite::Value; result::IR.Type, indices, location=Location() -) - results = IR.Type[result,] - operands = Value[object, composite] +function CompositeInsert(object::Value, composite::Value; result::IR.Type, indices, location=Location()) + results = IR.Type[result, ] + operands = Value[object, composite, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("indices", indices),] - - return IR.create_operation( - "spv.CompositeInsert", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("indices", indices), ] + + IR.create_operation( + "spv.CompositeInsert", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1839,21 +1523,17 @@ spv.Constant-op ::= ssa-id `=` `spv.Constant` attribute-value TODO: support constant structs """ function Constant(; constant::IR.Type, value, location=Location()) - results = IR.Type[constant,] + results = IR.Type[constant, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("value", value),] - - return IR.create_operation( - "spv.Constant", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("value", value), ] + + IR.create_operation( + "spv.Constant", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1903,28 +1583,18 @@ spv.ControlBarrier \"Workgroup\", \"Device\", \"Acquire|UniformMemory\" ``` """ -function ControlBarrier(; - execution_scope, memory_scope, memory_semantics, location=Location() -) +function ControlBarrier(; execution_scope, memory_scope, memory_semantics, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("memory_scope", memory_scope), - namedattribute("memory_semantics", memory_semantics), - ] - - return IR.create_operation( - "spv.ControlBarrier", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("memory_scope", memory_scope), namedattribute("memory_semantics", memory_semantics), ] + + IR.create_operation( + "spv.ControlBarrier", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1953,21 +1623,17 @@ convert-f-to-s-op ::= ssa-id `=` `spv.ConvertFToSOp` ssa-use ``` """ function ConvertFToS(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertFToS", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ConvertFToS", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1997,21 +1663,17 @@ convert-f-to-u-op ::= ssa-id `=` `spv.ConvertFToUOp` ssa-use ``` """ function ConvertFToU(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertFToU", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ConvertFToU", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2040,21 +1702,17 @@ convert-s-to-f-op ::= ssa-id `=` `spv.ConvertSToFOp` ssa-use ``` """ function ConvertSToF(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertSToF", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ConvertSToF", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2083,21 +1741,17 @@ convert-u-to-f-op ::= ssa-id `=` `spv.ConvertUToFOp` ssa-use ``` """ function ConvertUToF(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertUToF", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ConvertUToF", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2122,25 +1776,19 @@ For example: %0 = spv.CooperativeMatrixLengthNV : !spv.coopmatrix ``` """ -function CooperativeMatrixLengthNV(; - result=nothing::Union{Nothing,IR.Type}, type, location=Location() -) +function CooperativeMatrixLengthNV(; result=nothing::Union{Nothing, IR.Type}, type, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("type", type),] + attributes = NamedAttribute[namedattribute("type", type), ] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.CooperativeMatrixLengthNV", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.CooperativeMatrixLengthNV", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2197,31 +1845,19 @@ For example: : !spv.ptr as !spv.coopmatrix ``` """ -function CooperativeMatrixLoadNV( - pointer::Value, - stride::Value, - columnmajor::Value; - result::IR.Type, - memory_access=nothing, - location=Location(), -) - results = IR.Type[result,] - operands = Value[pointer, stride, columnmajor] +function CooperativeMatrixLoadNV(pointer::Value, stride::Value, columnmajor::Value; result::IR.Type, memory_access=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[pointer, stride, columnmajor, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !isnothing(memory_access) && - push!(attributes, namedattribute("memory_access", memory_access)) - - return IR.create_operation( - "spv.CooperativeMatrixLoadNV", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + + IR.create_operation( + "spv.CooperativeMatrixLoadNV", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2272,29 +1908,19 @@ For example: !spv.coopmatrix ``` """ -function CooperativeMatrixMulAddNV( - a::Value, - b::Value, - c::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function CooperativeMatrixMulAddNV(a::Value, b::Value, c::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b, c] + operands = Value[a, b, c, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.CooperativeMatrixMulAddNV", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.CooperativeMatrixMulAddNV", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2337,31 +1963,19 @@ For example: !spv.ptr, !spv.coopmatrix ``` """ -function CooperativeMatrixStoreNV( - pointer::Value, - object::Value, - stride::Value, - columnmajor::Value; - memory_access=nothing, - location=Location(), -) +function CooperativeMatrixStoreNV(pointer::Value, object::Value, stride::Value, columnmajor::Value; memory_access=nothing, location=Location()) results = IR.Type[] - operands = Value[pointer, object, stride, columnmajor] + operands = Value[pointer, object, stride, columnmajor, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !isnothing(memory_access) && - push!(attributes, namedattribute("memory_access", memory_access)) - - return IR.create_operation( - "spv.CooperativeMatrixStoreNV", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + + IR.create_operation( + "spv.CooperativeMatrixStoreNV", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2394,37 +2008,22 @@ copy-memory-op ::= `spv.CopyMemory ` storage-class ssa-use spv.CopyMemory \"Function\" %0, \"Function\" %1 : f32 ``` """ -function CopyMemory( - target::Value, - source::Value; - memory_access=nothing, - alignment=nothing, - source_memory_access=nothing, - source_alignment=nothing, - location=Location(), -) +function CopyMemory(target::Value, source::Value; memory_access=nothing, alignment=nothing, source_memory_access=nothing, source_alignment=nothing, location=Location()) results = IR.Type[] - operands = Value[target, source] + operands = Value[target, source, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !isnothing(memory_access) && - push!(attributes, namedattribute("memory_access", memory_access)) + !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)) - - return IR.create_operation( - "spv.CopyMemory", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(source_memory_access) && push!(attributes, namedattribute("source_memory_access", source_memory_access)) + !isnothing(source_alignment) && push!(attributes, namedattribute("source_alignment", source_alignment)) + + IR.create_operation( + "spv.CopyMemory", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2474,21 +2073,13 @@ function EntryPoint(; execution_model, fn, interface, location=Location()) operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_model", execution_model), - namedattribute("fn", fn), - namedattribute("interface", interface), - ] - - return IR.create_operation( - "spv.EntryPoint", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("execution_model", execution_model), namedattribute("fn", fn), namedattribute("interface", interface), ] + + IR.create_operation( + "spv.EntryPoint", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2526,21 +2117,13 @@ function ExecutionMode(; fn, execution_mode, values, location=Location()) operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("fn", fn), - namedattribute("execution_mode", execution_mode), - namedattribute("values", values), - ] - - return IR.create_operation( - "spv.ExecutionMode", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("fn", fn), namedattribute("execution_mode", execution_mode), namedattribute("values", values), ] + + IR.create_operation( + "spv.ExecutionMode", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2568,28 +2151,19 @@ fadd-op ::= ssa-id `=` `spv.FAdd` ssa-use, ssa-use %5 = spv.FAdd %2, %3 : vector<4xf32> ``` """ -function FAdd( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function FAdd(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.FAdd", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FAdd", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2619,21 +2193,17 @@ f-convert-op ::= ssa-id `=` `spv.FConvertOp` ssa-use ``` """ function FConvert(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FConvert", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FConvert", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2663,28 +2233,19 @@ fdiv-op ::= ssa-id `=` `spv.FDiv` ssa-use, ssa-use %5 = spv.FDiv %2, %3 : vector<4xf32> ``` """ -function FDiv( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function FDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.FDiv", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FDiv", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2715,28 +2276,19 @@ fmod-op ::= ssa-id `=` `spv.FMod` ssa-use, ssa-use %5 = spv.FMod %2, %3 : vector<4xf32> ``` """ -function FMod( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function FMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.FMod", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FMod", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2766,28 +2318,19 @@ fmul-op ::= `spv.FMul` ssa-use, ssa-use %5 = spv.FMul %2, %3 : vector<4xf32> ``` """ -function FMul( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function FMul(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.FMul", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FMul", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2815,25 +2358,19 @@ fmul-op ::= `spv.FNegate` ssa-use `:` float-scalar-vector-type %3 = spv.FNegate %2 : vector<4xf32> ``` """ -function FNegate( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function FNegate(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.FNegate", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FNegate", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2864,21 +2401,17 @@ fordequal-op ::= ssa-id `=` `spv.FOrdEqual` ssa-use, ssa-use ``` """ function FOrdEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand1, operand2] + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FOrdEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2908,24 +2441,18 @@ fordgte-op ::= ssa-id `=` `spv.FOrdGreaterThanEqual` ssa-use, ssa-use %5 = spv.FOrdGreaterThanEqual %2, %3 : vector<4xf32> ``` """ -function FOrdGreaterThanEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function FOrdGreaterThanEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdGreaterThanEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FOrdGreaterThanEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2955,24 +2482,18 @@ fordgt-op ::= ssa-id `=` `spv.FOrdGreaterThan` ssa-use, ssa-use %5 = spv.FOrdGreaterThan %2, %3 : vector<4xf32> ``` """ -function FOrdGreaterThan( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function FOrdGreaterThan(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdGreaterThan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FOrdGreaterThan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3002,24 +2523,18 @@ fordlte-op ::= ssa-id `=` `spv.FOrdLessThanEqual` ssa-use, ssa-use %5 = spv.FOrdLessThanEqual %2, %3 : vector<4xf32> ``` """ -function FOrdLessThanEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function FOrdLessThanEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdLessThanEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FOrdLessThanEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3049,24 +2564,18 @@ fordlt-op ::= ssa-id `=` `spv.FOrdLessThan` ssa-use, ssa-use %5 = spv.FOrdLessThan %2, %3 : vector<4xf32> ``` """ -function FOrdLessThan( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function FOrdLessThan(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdLessThan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FOrdLessThan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3096,24 +2605,18 @@ fordneq-op ::= ssa-id `=` `spv.FOrdNotEqual` ssa-use, ssa-use %5 = spv.FOrdNotEqual %2, %3 : vector<4xf32> ``` """ -function FOrdNotEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function FOrdNotEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdNotEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FOrdNotEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3145,28 +2648,19 @@ frem-op ::= ssa-id `=` `spv.FRemOp` ssa-use, ssa-use %5 = spv.FRemOp %2, %3 : vector<4xf32> ``` """ -function FRem( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function FRem(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.FRem", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FRem", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3195,28 +2689,19 @@ fsub-op ::= ssa-id `=` `spv.FRemOp` ssa-use, ssa-use %5 = spv.FRemOp %2, %3 : vector<4xf32> ``` """ -function FSub( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function FSub(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.FSub", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FSub", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3247,21 +2732,17 @@ funordequal-op ::= ssa-id `=` `spv.FUnordEqual` ssa-use, ssa-use ``` """ function FUnordEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand1, operand2] + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FUnordEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3291,24 +2772,18 @@ funordgte-op ::= ssa-id `=` `spv.FUnordGreaterThanEqual` ssa-use, ssa-use %5 = spv.FUnordGreaterThanEqual %2, %3 : vector<4xf32> ``` """ -function FUnordGreaterThanEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function FUnordGreaterThanEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordGreaterThanEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FUnordGreaterThanEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3338,24 +2813,18 @@ funordgt-op ::= ssa-id `=` `spv.FUnordGreaterThan` ssa-use, ssa-use %5 = spv.FUnordGreaterThan %2, %3 : vector<4xf32> ``` """ -function FUnordGreaterThan( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function FUnordGreaterThan(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordGreaterThan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FUnordGreaterThan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3385,24 +2854,18 @@ funordlte-op ::= ssa-id `=` `spv.FUnordLessThanEqual` ssa-use, ssa-use %5 = spv.FUnordLessThanEqual %2, %3 : vector<4xf32> ``` """ -function FUnordLessThanEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function FUnordLessThanEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordLessThanEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FUnordLessThanEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3432,24 +2895,18 @@ funordlt-op ::= ssa-id `=` `spv.FUnordLessThan` ssa-use, ssa-use %5 = spv.FUnordLessThan %2, %3 : vector<4xf32> ``` """ -function FUnordLessThan( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function FUnordLessThan(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordLessThan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FUnordLessThan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3479,24 +2936,18 @@ funordneq-op ::= ssa-id `=` `spv.FUnordNotEqual` ssa-use, ssa-use %5 = spv.FUnordNotEqual %2, %3 : vector<4xf32> ``` """ -function FUnordNotEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function FUnordNotEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordNotEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FUnordNotEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3532,23 +2983,15 @@ spv.func @bar() -> () \"Inline|Pure\" { ... } function func(; type, sym_name, function_control, body::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] - attributes = NamedAttribute[ - namedattribute("type", type), - namedattribute("sym_name", sym_name), - namedattribute("function_control", function_control), - ] - - return IR.create_operation( - "spv.func", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("type", type), namedattribute("sym_name", sym_name), namedattribute("function_control", function_control), ] + + IR.create_operation( + "spv.func", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3582,28 +3025,19 @@ spv.FunctionCall @f_void(%arg0) : (i32) -> () %0 = spv.FunctionCall @f_iadd(%arg0, %arg1) : (i32, i32) -> i32 ``` """ -function FunctionCall( - arguments::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - callee, - location=Location(), -) +function FunctionCall(arguments::Vector{Value}; result=nothing::Union{Nothing, IR.Type}, callee, location=Location()) results = IR.Type[] - operands = Value[arguments...,] + operands = Value[arguments..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("callee", callee),] + attributes = NamedAttribute[namedattribute("callee", callee), ] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.FunctionCall", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.FunctionCall", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3637,21 +3071,17 @@ acos-op ::= ssa-id `=` `spv.GLSL.Acos` ssa-use `:` ``` """ function GLSL_Acos(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Acos", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Acos", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3685,21 +3115,17 @@ asin-op ::= ssa-id `=` `spv.GLSL.Asin` ssa-use `:` ``` """ function GLSL_Asin(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Asin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Asin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3733,21 +3159,17 @@ atan-op ::= ssa-id `=` `spv.GLSL.Atan` ssa-use `:` ``` """ function GLSL_Atan(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Atan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Atan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3778,21 +3200,17 @@ ceil-op ::= ssa-id `=` `spv.GLSL.Ceil` ssa-use `:` ``` """ function GLSL_Ceil(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Ceil", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Ceil", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3824,21 +3242,17 @@ cos-op ::= ssa-id `=` `spv.GLSL.Cos` ssa-use `:` ``` """ function GLSL_Cos(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Cos", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Cos", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3870,21 +3284,17 @@ cosh-op ::= ssa-id `=` `spv.GLSL.Cosh` ssa-use `:` ``` """ function GLSL_Cosh(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Cosh", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Cosh", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3916,21 +3326,17 @@ exp-op ::= ssa-id `=` `spv.GLSL.Exp` ssa-use `:` ``` """ function GLSL_Exp(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Exp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Exp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -3960,21 +3366,17 @@ abs-op ::= ssa-id `=` `spv.GLSL.FAbs` ssa-use `:` ``` """ function GLSL_FAbs(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.FAbs", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.FAbs", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4004,21 +3406,17 @@ fclamp-op ::= ssa-id `=` `spv.GLSL.FClamp` ssa-use, ssa-use, ssa-use `:` ``` """ function GLSL_FClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[x, y, z] + results = IR.Type[result, ] + operands = Value[x, y, z, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.FClamp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.FClamp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4049,21 +3447,17 @@ fmax-op ::= ssa-id `=` `spv.GLSL.FMax` ssa-use `:` ``` """ function GLSL_FMax(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[lhs, rhs] + results = IR.Type[result, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.FMax", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.FMax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4094,21 +3488,17 @@ fmin-op ::= ssa-id `=` `spv.GLSL.FMin` ssa-use `:` ``` """ function GLSL_FMin(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[lhs, rhs] + results = IR.Type[result, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.FMin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.FMin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4130,29 +3520,19 @@ Result Type and the type of all operands must be the same type. Results are comp %0 = spv.GLSL.FMix %x : vector<4xf32>, %y : vector<4xf32>, %a : vector<4xf32> -> vector<4xf32> ``` """ -function GLSL_FMix( - x::Value, - y::Value, - a::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function GLSL_FMix(x::Value, y::Value, a::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[x, y, a] + operands = Value[x, y, a, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.GLSL.FMix", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.FMix", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4182,21 +3562,17 @@ sign-op ::= ssa-id `=` `spv.GLSL.FSign` ssa-use `:` ``` """ function GLSL_FSign(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.FSign", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.FSign", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4227,21 +3603,17 @@ floor-op ::= ssa-id `=` `spv.GLSL.Floor` ssa-use `:` ``` """ function GLSL_Floor(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Floor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Floor", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4281,21 +3653,17 @@ fma-op ::= ssa-id `=` `spv.GLSL.Fma` ssa-use, ssa-use, ssa-use `:` ``` """ function GLSL_Fma(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[x, y, z] + results = IR.Type[result, ] + operands = Value[x, y, z, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Fma", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Fma", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4338,21 +3706,17 @@ frexpstruct-op ::= ssa-id `=` `spv.GLSL.FrexpStruct` ssa-use `:` ``` """ function GLSL_FrexpStruct(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.FrexpStruct", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.FrexpStruct", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4382,21 +3746,17 @@ rsqrt-op ::= ssa-id `=` `spv.GLSL.InverseSqrt` ssa-use `:` ``` """ function GLSL_InverseSqrt(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.InverseSqrt", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.InverseSqrt", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4434,25 +3794,19 @@ component. %y = spv.GLSL.Ldexp %x : vector<3xf32>, %exp : vector<3xi32> -> vector<3xf32> ``` """ -function GLSL_Ldexp( - x::Value, exp::Value; y=nothing::Union{Nothing,IR.Type}, location=Location() -) +function GLSL_Ldexp(x::Value, exp::Value; y=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[x, exp] + operands = Value[x, exp, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(y) && push!(results, y) - - return IR.create_operation( - "spv.GLSL.Ldexp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Ldexp", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4485,21 +3839,17 @@ log-op ::= ssa-id `=` `spv.GLSL.Log` ssa-use `:` ``` """ function GLSL_Log(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Log", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Log", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4533,21 +3883,17 @@ pow-op ::= ssa-id `=` `spv.GLSL.Pow` ssa-use `:` ``` """ function GLSL_Pow(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[lhs, rhs] + results = IR.Type[result, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Pow", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Pow", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4577,21 +3923,17 @@ floor-op ::= ssa-id `=` `spv.GLSL.Round` ssa-use `:` ``` """ function GLSL_Round(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Round", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Round", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4620,21 +3962,17 @@ abs-op ::= ssa-id `=` `spv.GLSL.SAbs` ssa-use `:` ``` """ function GLSL_SAbs(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.SAbs", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.SAbs", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4663,21 +4001,17 @@ uclamp-op ::= ssa-id `=` `spv.GLSL.UClamp` ssa-use, ssa-use, ssa-use `:` ``` """ function GLSL_SClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[x, y, z] + results = IR.Type[result, ] + operands = Value[x, y, z, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.SClamp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.SClamp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4707,21 +4041,17 @@ smax-op ::= ssa-id `=` `spv.GLSL.SMax` ssa-use `:` ``` """ function GLSL_SMax(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[lhs, rhs] + results = IR.Type[result, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.SMax", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.SMax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4751,21 +4081,17 @@ smin-op ::= ssa-id `=` `spv.GLSL.SMin` ssa-use `:` ``` """ function GLSL_SMin(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[lhs, rhs] + results = IR.Type[result, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.SMin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.SMin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4794,21 +4120,17 @@ sign-op ::= ssa-id `=` `spv.GLSL.SSign` ssa-use `:` ``` """ function GLSL_SSign(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.SSign", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.SSign", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4840,21 +4162,17 @@ sin-op ::= ssa-id `=` `spv.GLSL.Sin` ssa-use `:` ``` """ function GLSL_Sin(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Sin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Sin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4886,21 +4204,17 @@ sinh-op ::= ssa-id `=` `spv.GLSL.Sinh` ssa-use `:` ``` """ function GLSL_Sinh(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Sinh", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Sinh", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4930,21 +4244,17 @@ sqrt-op ::= ssa-id `=` `spv.GLSL.Sqrt` ssa-use `:` ``` """ function GLSL_Sqrt(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Sqrt", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Sqrt", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -4976,21 +4286,17 @@ tan-op ::= ssa-id `=` `spv.GLSL.Tan` ssa-use `:` ``` """ function GLSL_Tan(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Tan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Tan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5022,21 +4328,17 @@ tanh-op ::= ssa-id `=` `spv.GLSL.Tanh` ssa-use `:` ``` """ function GLSL_Tanh(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Tanh", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.Tanh", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5065,21 +4367,17 @@ uclamp-op ::= ssa-id `=` `spv.GLSL.UClamp` ssa-use, ssa-use, ssa-use `:` ``` """ function GLSL_UClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[x, y, z] + results = IR.Type[result, ] + operands = Value[x, y, z, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.UClamp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.UClamp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5109,21 +4407,17 @@ smax-op ::= ssa-id `=` `spv.GLSL.UMax` ssa-use `:` ``` """ function GLSL_UMax(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[lhs, rhs] + results = IR.Type[result, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.UMax", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.UMax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5153,21 +4447,17 @@ smin-op ::= ssa-id `=` `spv.GLSL.UMin` ssa-use `:` ``` """ function GLSL_UMin(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[lhs, rhs] + results = IR.Type[result, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.UMin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GLSL.UMin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5211,39 +4501,23 @@ spv.GlobalVariable @var2 bind(1, 2) : !spv.ptr spv.GlobalVariable @var3 built_in(\"GlobalInvocationId\") : !spv.ptr, Input> ``` """ -function GlobalVariable(; - type, - sym_name, - initializer=nothing, - location_=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 = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("type", type), namedattribute("sym_name", sym_name) - ] + attributes = NamedAttribute[namedattribute("type", type), namedattribute("sym_name", sym_name), ] !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(descriptorSet) && push!(attributes, namedattribute("descriptorSet", descriptorSet)) !isnothing(builtin) && push!(attributes, namedattribute("builtin", builtin)) - - return IR.create_operation( - "spv.GlobalVariable", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GlobalVariable", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5292,29 +4566,19 @@ group-broadcast-op ::= ssa-id `=` `spv.GroupBroadcast` scope ssa_use, vector<4xf32>, vector<3xi32> ``` """ -function GroupBroadcast( - value::Value, - localid::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) +function GroupBroadcast(value::Value, localid::Value; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) results = IR.Type[] - operands = Value[value, localid] + operands = Value[value, localid, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.GroupBroadcast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupBroadcast", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5347,24 +4611,18 @@ non-uniform-ballot-op ::= ssa-id `=` `spv.GroupNonUniformBallot` scope %0 = spv.GroupNonUniformBallot \"SubGroup\" %predicate : vector<4xi32> ``` """ -function GroupNonUniformBallot( - predicate::Value; result::IR.Type, execution_scope, location=Location() -) - results = IR.Type[result,] - operands = Value[predicate,] +function GroupNonUniformBallot(predicate::Value; result::IR.Type, execution_scope, location=Location()) + results = IR.Type[result, ] + operands = Value[predicate, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - - return IR.create_operation( - "spv.GroupNonUniformBallot", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + + IR.create_operation( + "spv.GroupNonUniformBallot", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5409,29 +4667,19 @@ group-non-uniform-broadcast-op ::= ssa-id `=` vector<4xf32>, i32 ``` """ -function GroupNonUniformBroadcast( - value::Value, - id::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) +function GroupNonUniformBroadcast(value::Value, id::Value; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) results = IR.Type[] - operands = Value[value, id] + operands = Value[value, id, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.GroupNonUniformBroadcast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformBroadcast", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5456,25 +4704,19 @@ non-uniform-elect-op ::= ssa-id `=` `spv.GroupNonUniformElect` scope %0 = spv.GroupNonUniformElect : i1 ``` """ -function GroupNonUniformElect(; - result=nothing::Union{Nothing,IR.Type}, execution_scope, location=Location() -) +function GroupNonUniformElect(; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.GroupNonUniformElect", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformElect", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5520,33 +4762,19 @@ non-uniform-fadd-op ::= ssa-id `=` `spv.GroupNonUniformFAdd` scope operation %1 = spv.GroupNonUniformFAdd \"Subgroup\" \"ClusteredReduce\" %vector cluster_size(%four) : vector<4xf32> ``` """ -function GroupNonUniformFAdd( - value::Value, - cluster_size=nothing::Union{Nothing,Value}; - result::IR.Type, - execution_scope, - group_operation, - location=Location(), -) - results = IR.Type[result,] - operands = Value[value,] +function GroupNonUniformFAdd(value::Value, cluster_size=nothing::Union{Nothing, Value}; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] !isnothing(cluster_size) && push!(operands, cluster_size) - - return IR.create_operation( - "spv.GroupNonUniformFAdd", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformFAdd", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5595,33 +4823,19 @@ non-uniform-fmax-op ::= ssa-id `=` `spv.GroupNonUniformFMax` scope operation %1 = spv.GroupNonUniformFMax \"Subgroup\" \"ClusteredReduce\" %vector cluster_size(%four) : vector<4xf32> ``` """ -function GroupNonUniformFMax( - value::Value, - cluster_size=nothing::Union{Nothing,Value}; - result::IR.Type, - execution_scope, - group_operation, - location=Location(), -) - results = IR.Type[result,] - operands = Value[value,] +function GroupNonUniformFMax(value::Value, cluster_size=nothing::Union{Nothing, Value}; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] !isnothing(cluster_size) && push!(operands, cluster_size) - - return IR.create_operation( - "spv.GroupNonUniformFMax", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformFMax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5670,33 +4884,19 @@ non-uniform-fmin-op ::= ssa-id `=` `spv.GroupNonUniformFMin` scope operation %1 = spv.GroupNonUniformFMin \"Subgroup\" \"ClusteredReduce\" %vector cluster_size(%four) : vector<4xf32> ``` """ -function GroupNonUniformFMin( - value::Value, - cluster_size=nothing::Union{Nothing,Value}; - result::IR.Type, - execution_scope, - group_operation, - location=Location(), -) - results = IR.Type[result,] - operands = Value[value,] +function GroupNonUniformFMin(value::Value, cluster_size=nothing::Union{Nothing, Value}; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] !isnothing(cluster_size) && push!(operands, cluster_size) - - return IR.create_operation( - "spv.GroupNonUniformFMin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformFMin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5742,33 +4942,19 @@ non-uniform-fmul-op ::= ssa-id `=` `spv.GroupNonUniformFMul` scope operation %1 = spv.GroupNonUniformFMul \"Subgroup\" \"ClusteredReduce\" %vector cluster_size(%four) : vector<4xf32> ``` """ -function GroupNonUniformFMul( - value::Value, - cluster_size=nothing::Union{Nothing,Value}; - result::IR.Type, - execution_scope, - group_operation, - location=Location(), -) - results = IR.Type[result,] - operands = Value[value,] +function GroupNonUniformFMul(value::Value, cluster_size=nothing::Union{Nothing, Value}; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] !isnothing(cluster_size) && push!(operands, cluster_size) - - return IR.create_operation( - "spv.GroupNonUniformFMul", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformFMul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5812,33 +4998,19 @@ non-uniform-iadd-op ::= ssa-id `=` `spv.GroupNonUniformIAdd` scope operation %1 = spv.GroupNonUniformIAdd \"Subgroup\" \"ClusteredReduce\" %vector cluster_size(%four) : vector<4xi32> ``` """ -function GroupNonUniformIAdd( - value::Value, - cluster_size=nothing::Union{Nothing,Value}; - result::IR.Type, - execution_scope, - group_operation, - location=Location(), -) - results = IR.Type[result,] - operands = Value[value,] +function GroupNonUniformIAdd(value::Value, cluster_size=nothing::Union{Nothing, Value}; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] !isnothing(cluster_size) && push!(operands, cluster_size) - - return IR.create_operation( - "spv.GroupNonUniformIAdd", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformIAdd", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5882,33 +5054,19 @@ non-uniform-imul-op ::= ssa-id `=` `spv.GroupNonUniformIMul` scope operation %1 = spv.GroupNonUniformIMul \"Subgroup\" \"ClusteredReduce\" %vector cluster_size(%four) : vector<4xi32> ``` """ -function GroupNonUniformIMul( - value::Value, - cluster_size=nothing::Union{Nothing,Value}; - result::IR.Type, - execution_scope, - group_operation, - location=Location(), -) - results = IR.Type[result,] - operands = Value[value,] +function GroupNonUniformIMul(value::Value, cluster_size=nothing::Union{Nothing, Value}; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] !isnothing(cluster_size) && push!(operands, cluster_size) - - return IR.create_operation( - "spv.GroupNonUniformIMul", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformIMul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -5952,33 +5110,19 @@ non-uniform-smax-op ::= ssa-id `=` `spv.GroupNonUniformSMax` scope operation %1 = spv.GroupNonUniformSMax \"Subgroup\" \"ClusteredReduce\" %vector cluster_size(%four) : vector<4xi32> ``` """ -function GroupNonUniformSMax( - value::Value, - cluster_size=nothing::Union{Nothing,Value}; - result::IR.Type, - execution_scope, - group_operation, - location=Location(), -) - results = IR.Type[result,] - operands = Value[value,] +function GroupNonUniformSMax(value::Value, cluster_size=nothing::Union{Nothing, Value}; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] !isnothing(cluster_size) && push!(operands, cluster_size) - - return IR.create_operation( - "spv.GroupNonUniformSMax", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformSMax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6022,33 +5166,19 @@ non-uniform-smin-op ::= ssa-id `=` `spv.GroupNonUniformSMin` scope operation %1 = spv.GroupNonUniformSMin \"Subgroup\" \"ClusteredReduce\" %vector cluster_size(%four) : vector<4xi32> ``` """ -function GroupNonUniformSMin( - value::Value, - cluster_size=nothing::Union{Nothing,Value}; - result::IR.Type, - execution_scope, - group_operation, - location=Location(), -) - results = IR.Type[result,] - operands = Value[value,] +function GroupNonUniformSMin(value::Value, cluster_size=nothing::Union{Nothing, Value}; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] !isnothing(cluster_size) && push!(operands, cluster_size) - - return IR.create_operation( - "spv.GroupNonUniformSMin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformSMin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6093,33 +5223,19 @@ non-uniform-umax-op ::= ssa-id `=` `spv.GroupNonUniformUMax` scope operation %1 = spv.GroupNonUniformUMax \"Subgroup\" \"ClusteredReduce\" %vector cluster_size(%four) : vector<4xi32> ``` """ -function GroupNonUniformUMax( - value::Value, - cluster_size=nothing::Union{Nothing,Value}; - result::IR.Type, - execution_scope, - group_operation, - location=Location(), -) - results = IR.Type[result,] - operands = Value[value,] +function GroupNonUniformUMax(value::Value, cluster_size=nothing::Union{Nothing, Value}; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] !isnothing(cluster_size) && push!(operands, cluster_size) - - return IR.create_operation( - "spv.GroupNonUniformUMax", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformUMax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6164,33 +5280,19 @@ non-uniform-umin-op ::= ssa-id `=` `spv.GroupNonUniformUMin` scope operation %1 = spv.GroupNonUniformUMin \"Subgroup\" \"ClusteredReduce\" %vector cluster_size(%four) : vector<4xi32> ``` """ -function GroupNonUniformUMin( - value::Value, - cluster_size=nothing::Union{Nothing,Value}; - result::IR.Type, - execution_scope, - group_operation, - location=Location(), -) - results = IR.Type[result,] - operands = Value[value,] +function GroupNonUniformUMin(value::Value, cluster_size=nothing::Union{Nothing, Value}; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] !isnothing(cluster_size) && push!(operands, cluster_size) - - return IR.create_operation( - "spv.GroupNonUniformUMin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.GroupNonUniformUMin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6225,28 +5327,19 @@ iadd-op ::= ssa-id `=` `spv.IAdd` ssa-use, ssa-use ``` """ -function IAdd( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function IAdd(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.IAdd", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.IAdd", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6277,21 +5370,17 @@ iequal-op ::= ssa-id `=` `spv.IEqual` ssa-use, ssa-use ``` """ function IEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand1, operand2] + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.IEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.IEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6326,28 +5415,19 @@ imul-op ::= ssa-id `=` `spv.IMul` ssa-use, ssa-use ``` """ -function IMul( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function IMul(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.IMul", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.IMul", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6378,21 +5458,17 @@ inot-equal-op ::= ssa-id `=` `spv.INotEqual` ssa-use, ssa-use ``` """ function INotEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand1, operand2] + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.INotEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.INotEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6427,28 +5503,19 @@ isub-op ::= `spv.ISub` ssa-use, ssa-use ``` """ -function ISub( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function ISub(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.ISub", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ISub", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6488,32 +5555,19 @@ image-operands ::= `\"None\"` | `\"Bias\"` | `\"Lod\"` | `\"Grad\"` %0 = spv.ImageDrefGather %1 : !spv.sampled_image>, %2 : vector<4xf32>, %3 : f32 [\"NonPrivateTexel\"] : f32, f32 -> vector<4xi32> ``` """ -function ImageDrefGather( - sampledimage::Value, - coordinate::Value, - dref::Value, - operand_arguments::Vector{Value}; - result::IR.Type, - imageoperands=nothing, - location=Location(), -) - results = IR.Type[result,] - operands = Value[sampledimage, coordinate, dref, operand_arguments...] +function ImageDrefGather(sampledimage::Value, coordinate::Value, dref::Value, operand_arguments::Vector{Value}; result::IR.Type, imageoperands=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[sampledimage, coordinate, dref, operand_arguments..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !isnothing(imageoperands) && - push!(attributes, namedattribute("imageoperands", imageoperands)) - - return IR.create_operation( - "spv.ImageDrefGather", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(imageoperands) && push!(attributes, namedattribute("imageoperands", imageoperands)) + + IR.create_operation( + "spv.ImageDrefGather", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6534,21 +5588,17 @@ same as Result Type. ``` """ function Image(sampledimage::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[sampledimage,] + results = IR.Type[result, ] + operands = Value[sampledimage, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Image", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Image", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6587,21 +5637,17 @@ See the client API specification for additional image type restrictions. ``` """ function ImageQuerySize(image::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[image,] + results = IR.Type[result, ] + operands = Value[image, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ImageQuerySize", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ImageQuerySize", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6627,28 +5673,18 @@ func @inbounds_ptr_access_chain(%arg0: !spv.ptr, %arg1 : i6 } ``` """ -function InBoundsPtrAccessChain( - base_ptr::Value, - element::Value, - indices::Vector{Value}; - result::IR.Type, - location=Location(), -) - results = IR.Type[result,] - operands = Value[base_ptr, element, indices...] +function InBoundsPtrAccessChain(base_ptr::Value, element::Value, indices::Vector{Value}; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[base_ptr, element, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.InBoundsPtrAccessChain", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.InBoundsPtrAccessChain", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6679,21 +5715,17 @@ isinf-op ::= ssa-id `=` `spv.IsInf` ssa-use ``` """ function IsInf(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.IsInf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.IsInf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6724,21 +5756,17 @@ isnan-op ::= ssa-id `=` `spv.IsNan` ssa-use ``` """ function IsNan(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.IsNan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.IsNan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6775,31 +5803,20 @@ load-op ::= ssa-id ` = spv.Load ` storage-class ssa-use %3 = spv.Load \"Function\" %0 [\"Aligned\", 4] : f32 ``` """ -function Load( - ptr::Value; - value::IR.Type, - memory_access=nothing, - alignment=nothing, - location=Location(), -) - results = IR.Type[value,] - operands = Value[ptr,] +function Load(ptr::Value; value::IR.Type, memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[ptr, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !isnothing(memory_access) && - push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "spv.Load", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Load", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6829,21 +5846,17 @@ logical-and ::= `spv.LogicalAnd` ssa-use `,` ssa-use ``` """ function LogicalAnd(operand1::Value, operand2::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand1, operand2] + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.LogicalAnd", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.LogicalAnd", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6872,24 +5885,18 @@ logical-equal ::= `spv.LogicalEqual` ssa-use `,` ssa-use %2 = spv.LogicalEqual %0, %1 : vector<4xi1> ``` """ -function LogicalEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function LogicalEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.LogicalEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.LogicalEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6918,24 +5925,18 @@ logical-not-equal ::= `spv.LogicalNotEqual` ssa-use `,` ssa-use %2 = spv.LogicalNotEqual %0, %1 : vector<4xi1> ``` """ -function LogicalNotEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function LogicalNotEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.LogicalNotEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.LogicalNotEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -6962,21 +5963,17 @@ logical-not ::= `spv.LogicalNot` ssa-use `:` operand-type ``` """ function LogicalNot(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.LogicalNot", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.LogicalNot", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7006,21 +6003,17 @@ logical-or ::= `spv.LogicalOr` ssa-use `,` ssa-use ``` """ function LogicalOr(operand1::Value, operand2::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand1, operand2] + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.LogicalOr", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.LogicalOr", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7054,19 +6047,15 @@ block, except the entry block, branching to the header block. function mlir_loop(; loop_control, body::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] - attributes = NamedAttribute[namedattribute("loop_control", loop_control),] - - return IR.create_operation( - "spv.mlir.loop", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("loop_control", loop_control), ] + + IR.create_operation( + "spv.mlir.loop", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7099,24 +6088,18 @@ ssa-use `:` matrix-type `,` matrix-type `->` matrix-type !spv.matrix<4 x vector<4xf32>> ``` """ -function MatrixTimesMatrix( - leftmatrix::Value, rightmatrix::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[leftmatrix, rightmatrix] +function MatrixTimesMatrix(leftmatrix::Value, rightmatrix::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[leftmatrix, rightmatrix, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.MatrixTimesMatrix", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.MatrixTimesMatrix", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7148,24 +6131,18 @@ ssa-use `:` matrix-type `,` float-type `->` matrix-type ``` """ -function MatrixTimesScalar( - matrix::Value, scalar::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[matrix, scalar] +function MatrixTimesScalar(matrix::Value, scalar::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[matrix, scalar, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.MatrixTimesScalar", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.MatrixTimesScalar", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7208,20 +6185,13 @@ function MemoryBarrier(; memory_scope, memory_semantics, location=Location()) operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), - namedattribute("memory_semantics", memory_semantics), - ] - - return IR.create_operation( - "spv.MemoryBarrier", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("memory_semantics", memory_semantics), ] + + IR.create_operation( + "spv.MemoryBarrier", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7240,16 +6210,12 @@ function mlir_merge(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.mlir.merge", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.mlir.merge", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7296,34 +6262,20 @@ spv.module Logical Vulkan } ``` """ -function module_(; - addressing_model, - memory_model, - vce_triple=nothing, - sym_name=nothing, - region_0::Region, - location=Location(), -) +function module_(; addressing_model, memory_model, vce_triple=nothing, sym_name=nothing, region_0::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[region_0,] + owned_regions = Region[region_0, ] successors = Block[] - attributes = NamedAttribute[ - namedattribute("addressing_model", addressing_model), - namedattribute("memory_model", memory_model), - ] + attributes = NamedAttribute[namedattribute("addressing_model", addressing_model), namedattribute("memory_model", memory_model), ] !isnothing(vce_triple) && push!(attributes, namedattribute("vce_triple", vce_triple)) !isnothing(sym_name) && push!(attributes, namedattribute("sym_name", sym_name)) - - return IR.create_operation( - "spv.module", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.module", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7353,23 +6305,19 @@ Results are computed per component, and within each component, per bit. %3 = spv.Not %1 : vector<4xi32> ``` """ -function Not(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function Not(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.Not", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Not", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7399,21 +6347,17 @@ ceil-op ::= ssa-id `=` `spv.OCL.ceil` ssa-use `:` ``` """ function OCL_ceil(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.ceil", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.ceil", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7443,21 +6387,17 @@ cos-op ::= ssa-id `=` `spv.OCL.cos` ssa-use `:` ``` """ function OCL_cos(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.cos", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.cos", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7487,21 +6427,17 @@ erf-op ::= ssa-id `=` `spv.OCL.erf` ssa-use `:` ``` """ function OCL_erf(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.erf", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.erf", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7531,21 +6467,17 @@ exp-op ::= ssa-id `=` `spv.OCL.exp` ssa-use `:` ``` """ function OCL_exp(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.exp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.exp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7575,21 +6507,17 @@ abs-op ::= ssa-id `=` `spv.OCL.fabs` ssa-use `:` ``` """ function OCL_fabs(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.fabs", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.fabs", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7619,21 +6547,17 @@ floor-op ::= ssa-id `=` `spv.OCL.floor` ssa-use `:` ``` """ function OCL_floor(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.floor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.floor", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7663,21 +6587,17 @@ log-op ::= ssa-id `=` `spv.OCL.log` ssa-use `:` ``` """ function OCL_log(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.log", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.log", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7708,21 +6628,17 @@ pow-op ::= ssa-id `=` `spv.OCL.pow` ssa-use `:` ``` """ function OCL_pow(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[lhs, rhs] + results = IR.Type[result, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.pow", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.pow", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7752,21 +6668,17 @@ rsqrt-op ::= ssa-id `=` `spv.OCL.rsqrt` ssa-use `:` ``` """ function OCL_rsqrt(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.rsqrt", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.rsqrt", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7796,21 +6708,17 @@ abs-op ::= ssa-id `=` `spv.OCL.s_abs` ssa-use `:` ``` """ function OCL_s_abs(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.s_abs", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.s_abs", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7840,21 +6748,17 @@ sin-op ::= ssa-id `=` `spv.OCL.sin` ssa-use `:` ``` """ function OCL_sin(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.sin", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.sin", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7884,21 +6788,17 @@ sqrt-op ::= ssa-id `=` `spv.OCL.sqrt` ssa-use `:` ``` """ function OCL_sqrt(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.sqrt", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.sqrt", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7928,21 +6828,17 @@ tanh-op ::= ssa-id `=` `spv.OCL.tanh` ssa-use `:` ``` """ function OCL_tanh(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.tanh", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.OCL.tanh", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -7974,21 +6870,17 @@ ordered-op ::= ssa-id `=` `spv.Ordered` ssa-use, ssa-use ``` """ function Ordered(operand1::Value, operand2::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand1, operand2] + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Ordered", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Ordered", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8037,28 +6929,18 @@ func @ptr_access_chain(%arg0: !spv.ptr, %arg1 : i64) -> () } ``` """ -function PtrAccessChain( - base_ptr::Value, - element::Value, - indices::Vector{Value}; - result::IR.Type, - location=Location(), -) - results = IR.Type[result,] - operands = Value[base_ptr, element, indices...] +function PtrAccessChain(base_ptr::Value, element::Value, indices::Vector{Value}; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[base_ptr, element, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.PtrAccessChain", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.PtrAccessChain", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8088,21 +6970,17 @@ spv-reference-of-op ::= ssa-id `=` `spv.mlir.referenceof` symbol-ref-id TODO Add support for composite specialization constants. """ function mlir_referenceof(; reference::IR.Type, spec_const, location=Location()) - results = IR.Type[reference,] + results = IR.Type[reference, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("spec_const", spec_const),] - - return IR.create_operation( - "spv.mlir.referenceof", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("spec_const", spec_const), ] + + IR.create_operation( + "spv.mlir.referenceof", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8123,16 +7001,12 @@ function Return(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Return", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Return", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8159,20 +7033,16 @@ spv.ReturnValue %0 : f32 """ function ReturnValue(value::Value; location=Location()) results = IR.Type[] - operands = Value[value,] + operands = Value[value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ReturnValue", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ReturnValue", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8202,21 +7072,17 @@ s-convert-op ::= ssa-id `=` `spv.SConvertOp` ssa-use ``` """ function SConvert(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SConvert", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SConvert", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8248,28 +7114,19 @@ sdiv-op ::= ssa-id `=` `spv.SDiv` ssa-use, ssa-use ``` """ -function SDiv( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function SDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.SDiv", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SDiv", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8299,24 +7156,18 @@ sgreater-than-equal-op ::= ssa-id `=` `spv.SGreaterThanEqual` ssa-use, ssa-use ``` """ -function SGreaterThanEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function SGreaterThanEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SGreaterThanEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SGreaterThanEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8346,24 +7197,18 @@ sgreater-than-op ::= ssa-id `=` `spv.SGreaterThan` ssa-use, ssa-use ``` """ -function SGreaterThan( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function SGreaterThan(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SGreaterThan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SGreaterThan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8393,24 +7238,18 @@ sless-than-equal-op ::= ssa-id `=` `spv.SLessThanEqual` ssa-use, ssa-use ``` """ -function SLessThanEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function SLessThanEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SLessThanEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SLessThanEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8441,21 +7280,17 @@ sless-than-op ::= ssa-id `=` `spv.SLessThan` ssa-use, ssa-use ``` """ function SLessThan(operand1::Value, operand2::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand1, operand2] + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SLessThan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SLessThan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8488,28 +7323,19 @@ smod-op ::= ssa-id `=` `spv.SMod` ssa-use, ssa-use ``` """ -function SMod( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function SMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.SMod", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SMod", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8533,25 +7359,19 @@ must equal the component width in Result Type. %3 = spv.SNegate %2 : vector<4xi32> ``` """ -function SNegate( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function SNegate(operand::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.SNegate", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SNegate", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8584,28 +7404,19 @@ srem-op ::= ssa-id `=` `spv.SRem` ssa-use, ssa-use ``` """ -function SRem( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function SRem(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.SRem", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SRem", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8648,29 +7459,19 @@ select-op ::= ssa-id `=` `spv.Select` ssa-use, ssa-use, ssa-use %3 = spv.Select %0, %1, %2 : vector<3xi1>, vector<3xf32> ``` """ -function Select( - condition::Value, - true_value::Value, - false_value::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function Select(condition::Value, true_value::Value, false_value::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[condition, true_value, false_value] + operands = Value[condition, true_value, false_value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.Select", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Select", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8698,19 +7499,15 @@ The merge block should only contain a `spv.mlir.merge` op. function mlir_selection(; selection_control, body::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] - attributes = NamedAttribute[namedattribute("selection_control", selection_control),] - - return IR.create_operation( - "spv.mlir.selection", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("selection_control", selection_control), ] + + IR.create_operation( + "spv.mlir.selection", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8750,24 +7547,18 @@ shift-left-logical-op ::= ssa-id `=` `spv.ShiftLeftLogical` %5 = spv.ShiftLeftLogical %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftLeftLogical( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function ShiftLeftLogical(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ShiftLeftLogical", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ShiftLeftLogical", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8804,24 +7595,18 @@ shift-right-arithmetic-op ::= ssa-id `=` `spv.ShiftRightArithmetic` %5 = spv.ShiftRightArithmetic %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftRightArithmetic( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function ShiftRightArithmetic(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ShiftRightArithmetic", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ShiftRightArithmetic", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8859,24 +7644,18 @@ shift-right-logical-op ::= ssa-id `=` `spv.ShiftRightLogical` %5 = spv.ShiftRightLogical %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftRightLogical( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function ShiftRightLogical(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ShiftRightLogical", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ShiftRightLogical", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8921,21 +7700,13 @@ function SpecConstantComposite(; type, sym_name, constituents, location=Location operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("type", type), - namedattribute("sym_name", sym_name), - namedattribute("constituents", constituents), - ] - - return IR.create_operation( - "spv.SpecConstantComposite", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("type", type), namedattribute("sym_name", sym_name), namedattribute("constituents", constituents), ] + + IR.create_operation( + "spv.SpecConstantComposite", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -8975,19 +7746,13 @@ function SpecConstant(; sym_name, default_value, location=Location()) operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("sym_name", sym_name), namedattribute("default_value", default_value) - ] - - return IR.create_operation( - "spv.SpecConstant", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("sym_name", sym_name), namedattribute("default_value", default_value), ] + + IR.create_operation( + "spv.SpecConstant", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9061,21 +7826,17 @@ TODO Add capability-specific ops when supported. ``` """ function SpecConstantOperation(; result::IR.Type, body::Region, location=Location()) - results = IR.Type[result,] + results = IR.Type[result, ] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SpecConstantOperation", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SpecConstantOperation", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9108,27 +7869,20 @@ spv.Store \"Function\" %0, %1 [\"Volatile\"] : f32 spv.Store \"Function\" %0, %1 [\"Aligned\", 4] : f32 ``` """ -function Store( - ptr::Value, value::Value; memory_access=nothing, alignment=nothing, location=Location() -) +function Store(ptr::Value, value::Value; memory_access=nothing, alignment=nothing, location=Location()) results = IR.Type[] - operands = Value[ptr, value] + operands = Value[ptr, value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !isnothing(memory_access) && - push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "spv.Store", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Store", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9163,21 +7917,17 @@ subgroup-ballot-op ::= ssa-id `=` `spv.SubgroupBallotKHR` ``` """ function SubgroupBallotKHR(predicate::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[predicate,] + results = IR.Type[result, ] + operands = Value[predicate, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SubgroupBallotKHR", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SubgroupBallotKHR", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9213,21 +7963,17 @@ subgroup-block-read-INTEL-op ::= ssa-id `=` `spv.SubgroupBlockReadINTEL` ``` """ function SubgroupBlockReadINTEL(ptr::Value; value::IR.Type, location=Location()) - results = IR.Type[value,] - operands = Value[ptr,] + results = IR.Type[value, ] + operands = Value[ptr, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SubgroupBlockReadINTEL", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SubgroupBlockReadINTEL", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9263,20 +8009,16 @@ spv.SubgroupBlockWriteINTEL \"StorageBuffer\" %ptr, %value : i32 """ function SubgroupBlockWriteINTEL(ptr::Value, value::Value; location=Location()) results = IR.Type[] - operands = Value[ptr, value] + operands = Value[ptr, value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SubgroupBlockWriteINTEL", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.SubgroupBlockWriteINTEL", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9309,21 +8051,17 @@ matrix-type ``` """ function Transpose(matrix::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[matrix,] + results = IR.Type[result, ] + operands = Value[matrix, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Transpose", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Transpose", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9354,21 +8092,17 @@ u-convert-op ::= ssa-id `=` `spv.UConvertOp` ssa-use ``` """ function UConvert(operand::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand,] + results = IR.Type[result, ] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.UConvert", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.UConvert", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9399,28 +8133,19 @@ udiv-op ::= ssa-id `=` `spv.UDiv` ssa-use, ssa-use ``` """ -function UDiv( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function UDiv(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.UDiv", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.UDiv", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9450,24 +8175,18 @@ ugreater-than-equal-op ::= ssa-id `=` `spv.UGreaterThanEqual` ssa-use, ssa-use ``` """ -function UGreaterThanEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function UGreaterThanEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.UGreaterThanEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.UGreaterThanEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9497,24 +8216,18 @@ ugreater-than-op ::= ssa-id `=` `spv.UGreaterThan` ssa-use, ssa-use ``` """ -function UGreaterThan( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function UGreaterThan(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.UGreaterThan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.UGreaterThan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9544,24 +8257,18 @@ uless-than-equal-op ::= ssa-id `=` `spv.ULessThanEqual` ssa-use, ssa-use ``` """ -function ULessThanEqual( - operand1::Value, operand2::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[operand1, operand2] +function ULessThanEqual(operand1::Value, operand2::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ULessThanEqual", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ULessThanEqual", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9592,21 +8299,17 @@ uless-than-op ::= ssa-id `=` `spv.ULessThan` ssa-use, ssa-use ``` """ function ULessThan(operand1::Value, operand2::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand1, operand2] + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ULessThan", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.ULessThan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9637,28 +8340,19 @@ umod-op ::= ssa-id `=` `spv.UMod` ssa-use, ssa-use ``` """ -function UMod( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function UMod(operand1::Value, operand2::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand1, operand2] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.UMod", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.UMod", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9685,21 +8379,17 @@ undef-op ::= `spv.Undef` `:` spirv-type ``` """ function Undef(; result::IR.Type, location=Location()) - results = IR.Type[result,] + results = IR.Type[result, ] operands = Value[] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Undef", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Undef", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9731,21 +8421,17 @@ unordered-op ::= ssa-id `=` `spv.Unordered` ssa-use, ssa-use ``` """ function Unordered(operand1::Value, operand2::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[operand1, operand2] + results = IR.Type[result, ] + operands = Value[operand1, operand2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Unordered", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Unordered", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9766,16 +8452,12 @@ function Unreachable(; location=Location()) owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Unreachable", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Unreachable", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9813,28 +8495,19 @@ where `init` specifies initializer. %2 = spv.Variable init(%0): !spv.ptr ``` """ -function Variable( - initializer=nothing::Union{Nothing,Value}; - pointer::IR.Type, - storage_class, - location=Location(), -) - results = IR.Type[pointer,] +function Variable(initializer=nothing::Union{Nothing, Value}; pointer::IR.Type, storage_class, location=Location()) + results = IR.Type[pointer, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("storage_class", storage_class),] + attributes = NamedAttribute[namedattribute("storage_class", storage_class), ] !isnothing(initializer) && push!(operands, initializer) - - return IR.create_operation( - "spv.Variable", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.Variable", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9860,24 +8533,18 @@ or equal to the number of components in Vector. %2 = spv.VectorExtractDynamic %0[%1] : vector<8xf32>, i32 ``` """ -function VectorExtractDynamic( - vector::Value, index::Value; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[vector, index] +function VectorExtractDynamic(vector::Value, index::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[vector, index, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.VectorExtractDynamic", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.VectorExtractDynamic", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -9915,29 +8582,19 @@ vector-insert-dynamic-op ::= `spv.VectorInsertDynamic ` ssa-use `,` %2 = spv.VectorInsertDynamic %scalar %0[%1] : f32, vector<8xf32>, i32 ``` """ -function VectorInsertDynamic( - vector::Value, - component::Value, - index::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function VectorInsertDynamic(vector::Value, component::Value, index::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[vector, component, index] + operands = Value[vector, component, index, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "spv.VectorInsertDynamic", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.VectorInsertDynamic", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9978,24 +8635,18 @@ operands, or using an OpUndef for one of the Vector operands. -> vector<3xf32> ``` """ -function VectorShuffle( - vector1::Value, vector2::Value; result::IR.Type, components, location=Location() -) - results = IR.Type[result,] - operands = Value[vector1, vector2] +function VectorShuffle(vector1::Value, vector2::Value; result::IR.Type, components, location=Location()) + results = IR.Type[result, ] + operands = Value[vector1, vector2, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("components", components),] - - return IR.create_operation( - "spv.VectorShuffle", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("components", components), ] + + IR.create_operation( + "spv.VectorShuffle", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -10020,20 +8671,16 @@ spv.mlir.yield %0 """ function mlir_yield(operand::Value; location=Location()) results = IR.Type[] - operands = Value[operand,] + operands = Value[operand, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "spv.mlir.yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "spv.mlir.yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Shape.jl b/src/Dialects/14/Shape.jl index a8470504..08b576f5 100644 --- a/src/Dialects/14/Shape.jl +++ b/src/Dialects/14/Shape.jl @@ -1,9 +1,8 @@ module shape -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `add` @@ -15,25 +14,19 @@ the result must be of type `size`. If error propagation is not possible because both operands are of type `index` then the result may be of type `size` or `index`. """ -function add( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function add(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.add", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.add", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -54,21 +47,17 @@ inputs have differing ranks or differ in extents of shared dimensions. ``` """ function any(inputs::Vector{Value}; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[inputs...,] + results = IR.Type[result, ] + operands = Value[inputs..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "shape.any", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.any", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -93,21 +82,17 @@ ready to execute. ``` """ function assuming_all(inputs::Vector{Value}; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[inputs...,] + results = IR.Type[result, ] + operands = Value[inputs..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming_all", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.assuming_all", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -121,24 +106,18 @@ compiler, information for dependent code to rely on (by assuming), and nothing else. They should not exist after a program is fully lowered and ready to execute. """ -function assuming( - witness::Value; results::Vector{IR.Type}, doRegion::Region, location=Location() -) - results = IR.Type[results...,] - operands = Value[witness,] - owned_regions = Region[doRegion,] +function assuming(witness::Value; results_::Vector{IR.Type}, doRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[witness, ] + owned_regions = Region[doRegion, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.assuming", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -150,22 +129,18 @@ This yield operation represents a return operation within the operands and produces no results. The operand number and types must match the number and types of parent `shape.assuming` results. """ -function assuming_yield(operands::Vector{Value}; location=Location()) +function assuming_yield(operands_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[operands...,] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming_yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.assuming_yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -192,25 +167,19 @@ value. If the result type is an extent tensor (and can therefore not hold the error value) the behavior may be undefined. The optional string attribute can be used to describe the error case. """ -function broadcast( - shapes::Vector{Value}; result::IR.Type, error=nothing, location=Location() -) - results = IR.Type[result,] - operands = Value[shapes...,] +function broadcast(shapes::Vector{Value}; result::IR.Type, error=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[shapes..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(error) && push!(attributes, namedattribute("error", error)) - - return IR.create_operation( - "shape.broadcast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.broadcast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -225,25 +194,19 @@ concat([2,3], [4,5]) -> [2,3,4,5] concat([], []) -> [] concat([], [4,5,6]) -> [4,5,6] """ -function concat( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function concat(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.concat", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.concat", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -260,23 +223,19 @@ rank. %2 = shape.const_shape [4, 5, 6] : tensor<3xindex> ``` """ -function const_shape(; result=nothing::Union{Nothing,IR.Type}, shape, location=Location()) +function const_shape(; result=nothing::Union{Nothing, IR.Type}, shape, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("shape", shape),] + attributes = NamedAttribute[namedattribute("shape", shape), ] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.const_shape", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.const_shape", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -289,23 +248,19 @@ Creates a `shape.size` type representing the constant size given by `value`. %x = shape.const_size 10 ``` """ -function const_size(; result=nothing::Union{Nothing,IR.Type}, value, location=Location()) +function const_size(; result=nothing::Union{Nothing, IR.Type}, value, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("value", value),] + attributes = NamedAttribute[namedattribute("value", value), ] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.const_size", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.const_size", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -324,25 +279,19 @@ pass. %w2 = shape.assuming_all(%w0, %w2) // Can be folded to \"const_witness true\" ``` """ -function const_witness(; - result=nothing::Union{Nothing,IR.Type}, passing, location=Location() -) +function const_witness(; result=nothing::Union{Nothing, IR.Type}, passing, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("passing", passing),] + attributes = NamedAttribute[namedattribute("passing", passing), ] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.const_witness", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.const_witness", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -361,25 +310,19 @@ shape.broadcast documents. %w1 = shape.cstr_broadcastable [2,2], [3,2] // Failure ``` """ -function cstr_broadcastable( - shapes::Vector{Value}; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function cstr_broadcastable(shapes::Vector{Value}; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[shapes...,] + operands = Value[shapes..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.cstr_broadcastable", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.cstr_broadcastable", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -396,25 +339,19 @@ Given 1 or more input shapes, determine if all shapes are the exact same. %w1 = shape.cstr_eq [2,2], [1,2] // Failure ``` """ -function cstr_eq( - shapes::Vector{Value}; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function cstr_eq(shapes::Vector{Value}; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[shapes...,] + operands = Value[shapes..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.cstr_eq", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.cstr_eq", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -437,25 +374,19 @@ Since this op can be used to express many different possible assertions (depending on whatever computation calculated `pred`), the `msg` should clarify the nature of the assertion for users. """ -function cstr_require( - pred::Value; result=nothing::Union{Nothing,IR.Type}, msg, location=Location() -) +function cstr_require(pred::Value; result=nothing::Union{Nothing, IR.Type}, msg, location=Location()) results = IR.Type[] - operands = Value[pred,] + operands = Value[pred, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("msg", msg),] + attributes = NamedAttribute[namedattribute("msg", msg), ] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.cstr_require", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.cstr_require", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -467,21 +398,17 @@ Prints the input dim or shape and passes through input. Note: This is intended for testing and debugging only. """ function debug_print(input::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "shape.debug_print", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.debug_print", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -502,25 +429,19 @@ negative infinity, i.e. floor(lhs / rhs), such that always holds. If any of the values is of type `size`, the behavior for negative value is undefined. """ -function div( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function div(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.div", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.div", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -531,25 +452,19 @@ Creates a shape from a 1D integral tensor of extents. The rank of the resulting shape equals the number of elements in the tensor, and the extents match the values of the elements. """ -function from_extent_tensor( - input::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function from_extent_tensor(input::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[input,] + operands = Value[input, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.from_extent_tensor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.from_extent_tensor", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -567,21 +482,17 @@ the shape. ``` """ function from_extents(extents::Vector{Value}; shape::IR.Type, location=Location()) - results = IR.Type[shape,] - operands = Value[extents...,] + results = IR.Type[shape, ] + operands = Value[extents..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "shape.from_extents", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.from_extents", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -607,19 +518,15 @@ shape.function_library { function function_library(; mapping, body::Region, location=Location()) results = IR.Type[] operands = Value[] - owned_regions = Region[body,] + owned_regions = Region[body, ] successors = Block[] - attributes = NamedAttribute[namedattribute("mapping", mapping),] - - return IR.create_operation( - "shape.function_library", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("mapping", mapping), ] + + IR.create_operation( + "shape.function_library", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -629,25 +536,19 @@ end Gets the extent indexed by `dim` from the `shape` operand. If the shape is an error then it returns an invalid size. """ -function get_extent( - shape::Value, dim::Value; extent=nothing::Union{Nothing,IR.Type}, location=Location() -) +function get_extent(shape::Value, dim::Value; extent=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[shape, dim] + operands = Value[shape, dim, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(extent) && push!(results, extent) - - return IR.create_operation( - "shape.get_extent", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.get_extent", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -660,25 +561,19 @@ and the shape dialect. The behavior is undefined for negative indices. """ -function index_to_size( - arg::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function index_to_size(arg::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[arg,] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.index_to_size", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.index_to_size", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -700,25 +595,19 @@ assertion failure. %false = shape.is_broadcastable [2,2], [3,2] ``` """ -function is_broadcastable( - shapes::Vector{Value}; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function is_broadcastable(shapes::Vector{Value}; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[shapes...,] + operands = Value[shapes..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.is_broadcastable", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.is_broadcastable", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -730,25 +619,19 @@ If either operand is an error, then an error will be propagated to the result. If the input types mismatch or the ranks do not match, then the result is an error. """ -function max( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function max(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.max", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.max", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -779,30 +662,20 @@ used to return an error to the user upon mismatch of dimensions. %c = shape.meet %a, %b, error=\"\" : !shape.shape, !shape.shape -> !shape.shape ``` """ -function meet( - arg0::Value, - arg1::Value; - result=nothing::Union{Nothing,IR.Type}, - error=nothing, - location=Location(), -) +function meet(arg0::Value, arg1::Value; result=nothing::Union{Nothing, IR.Type}, error=nothing, location=Location()) results = IR.Type[] - operands = Value[arg0, arg1] + operands = Value[arg0, arg1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) !isnothing(error) && push!(attributes, namedattribute("error", error)) - - return IR.create_operation( - "shape.meet", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.meet", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -814,25 +687,19 @@ If either operand is an error, then an error will be propagated to the result. If the input types mismatch or the ranks do not match, then the result is an error. """ -function min( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function min(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.min", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.min", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -846,25 +713,19 @@ the result must be of type `size`. If error propagation is not possible because both operands are of type `index` then the result may be of type `size` or `index`. """ -function mul( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function mul(lhs::Value, rhs::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[lhs, rhs] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.mul", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.mul", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -877,25 +738,19 @@ extents. If the argument is of type `shape` then the result will be of type is and extent tensor `tensor` then the result will be of type `index`. """ -function num_elements( - shape::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function num_elements(shape::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[shape,] + operands = Value[shape, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.num_elements", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.num_elements", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -904,23 +759,19 @@ end Returns the rank of the shape or extent tensor, i.e. the number of extents. """ -function rank(shape::Value; rank=nothing::Union{Nothing,IR.Type}, location=Location()) +function rank(shape::Value; rank=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[shape,] + operands = Value[shape, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(rank) && push!(results, rank) - - return IR.create_operation( - "shape.rank", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.rank", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -957,28 +808,18 @@ func @reduce(%shape : !shape.shape, %init : !shape.size) -> !shape.size { } ``` """ -function reduce( - shape::Value, - initVals::Vector{Value}; - result::Vector{IR.Type}, - region::Region, - location=Location(), -) - results = IR.Type[result...,] - operands = Value[shape, initVals...] - owned_regions = Region[region,] +function reduce(shape::Value, initVals::Vector{Value}; result::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result..., ] + operands = Value[shape, initVals..., ] + owned_regions = Region[region, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "shape.reduce", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.reduce", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -991,25 +832,19 @@ as their equivalent non-error shapes. Error shapes can be tested for equality like any other shape value, meaning that the error value is equal to itself. """ -function shape_eq( - shapes::Vector{Value}; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function shape_eq(shapes::Vector{Value}; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[shapes...,] + operands = Value[shapes..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.shape_eq", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.shape_eq", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1019,23 +854,19 @@ end The operation takes a value or a shaped operand as an argument and it returns a shape or extent tensor. """ -function shape_of(arg::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) +function shape_of(arg::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[arg,] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.shape_of", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.shape_of", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1047,25 +878,19 @@ inverse, `index_to_size`, facilitate index conversion between the standard and the shape dialect. The behavior is undefined for unknown and invalid arguments. """ -function size_to_index( - arg::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function size_to_index(arg::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[arg,] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.size_to_index", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.size_to_index", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1093,24 +918,18 @@ Examples: Requires: - `index` is in the range [-rank(operand),rank(operand)] """ -function split_at( - operand::Value, index::Value; head::IR.Type, tail::IR.Type, location=Location() -) - results = IR.Type[head, tail] - operands = Value[operand, index] +function split_at(operand::Value, index::Value; head::IR.Type, tail::IR.Type, location=Location()) + results = IR.Type[head, tail, ] + operands = Value[operand, index, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "shape.split_at", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.split_at", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1124,21 +943,17 @@ extents of the shape. If the shape represents an error, this op\'s behavior is undefined. """ function to_extent_tensor(input::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[input,] + results = IR.Type[result, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "shape.to_extent_tensor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.to_extent_tensor", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1160,21 +975,17 @@ representing sizes) then this propagages the error shape. E.g., This operation is the compliment of `shape_of` wrt ValueShape values. """ function value_as_shape(arg::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[arg,] + results = IR.Type[result, ] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "shape.value_as_shape", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.value_as_shape", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1213,28 +1024,19 @@ the result may be less specified than `operand`\'s shape as `shape` is merely used to construct the new ValueShape. If join behavior is desired then a join op should be used. """ -function with_shape( - operand::Value, - shape::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function with_shape(operand::Value, shape::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[operand, shape] + operands = Value[operand, shape, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "shape.with_shape", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.with_shape", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1242,22 +1044,18 @@ end `yield` """ -function yield(operands::Vector{Value}; location=Location()) +function yield(operands_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[operands...,] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "shape.yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "shape.yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/SparseTensor.jl b/src/Dialects/14/SparseTensor.jl index 35d2cbba..08ca29ed 100644 --- a/src/Dialects/14/SparseTensor.jl +++ b/src/Dialects/14/SparseTensor.jl @@ -1,9 +1,8 @@ module sparse_tensor -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `compress` @@ -27,30 +26,18 @@ sparse_tensor.compress %0, %1, %values, %filled, %added, %2 memref, memref, index ``` """ -function compress( - tensor::Value, - indices::Value, - values::Value, - filled::Value, - added::Value, - count::Value; - location=Location(), -) +function compress(tensor::Value, indices::Value, values::Value, filled::Value, added::Value, count::Value; location=Location()) results = IR.Type[] - operands = Value[tensor, indices, values, filled, added, count] + operands = Value[tensor, indices, values, filled, added, count, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.compress", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.compress", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -88,21 +75,17 @@ Examples: ``` """ function convert(source::Value; dest::IR.Type, location=Location()) - results = IR.Type[dest,] - operands = Value[source,] + results = IR.Type[dest, ] + operands = Value[source, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.convert", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.convert", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -138,29 +121,18 @@ may be refined over time as our sparse abstractions evolve. : tensor<4x4xf64, #CSR> to memref, memref, memref, index ``` """ -function expand( - tensor::Value; - values::IR.Type, - filled::IR.Type, - added::IR.Type, - count::IR.Type, - location=Location(), -) - results = IR.Type[values, filled, added, count] - operands = Value[tensor,] +function expand(tensor::Value; values::IR.Type, filled::IR.Type, added::IR.Type, count::IR.Type, location=Location()) + results = IR.Type[values, filled, added, count, ] + operands = Value[tensor, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.expand", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.expand", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -182,21 +154,17 @@ a subsequent operation that yields a sparse tensor as the result. ``` """ function init(sizes::Vector{Value}; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[sizes...,] + results = IR.Type[result, ] + operands = Value[sizes..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.init", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.init", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -221,20 +189,16 @@ sparse_tensor.lex_insert %tensor, %indices, %val """ function lex_insert(tensor::Value, indices::Value, value::Value; location=Location()) results = IR.Type[] - operands = Value[tensor, indices, value] + operands = Value[tensor, indices, value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.lex_insert", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.lex_insert", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -264,29 +228,20 @@ may be refined over time as our sparse abstractions evolve. %1 = sparse_tensor.load %0 : tensor<8xf64, #SV> ``` """ -function load( - tensor::Value; - result=nothing::Union{Nothing,IR.Type}, - hasInserts=nothing, - location=Location(), -) +function load(tensor::Value; result=nothing::Union{Nothing, IR.Type}, hasInserts=nothing, location=Location()) results = IR.Type[] - operands = Value[tensor,] + operands = Value[tensor, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) !isnothing(hasInserts) && push!(attributes, namedattribute("hasInserts", hasInserts)) - - return IR.create_operation( - "sparse_tensor.load", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.load", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -309,21 +264,17 @@ sparse_tensor.new %source : !Source to tensor<1024x1024xf64, #CSR> ``` """ function new(source::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[source,] + results = IR.Type[result, ] + operands = Value[source, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.new", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.new", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -345,20 +296,16 @@ sparse_tensor.out %t, %dest : tensor<1024x1024xf64, #CSR>, !Dest """ function out(tensor::Value, dest::Value; location=Location()) results = IR.Type[] - operands = Value[tensor, dest] + operands = Value[tensor, dest, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.out", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.out", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -385,20 +332,16 @@ sparse_tensor.release %tensor : tensor<1024x1024xf64, #CSR> """ function release(tensor::Value; location=Location()) results = IR.Type[] - operands = Value[tensor,] + operands = Value[tensor, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.release", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.release", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -421,21 +364,17 @@ indices array. ``` """ function indices(tensor::Value, dim::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[tensor, dim] + results = IR.Type[result, ] + operands = Value[tensor, dim, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.indices", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.indices", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -458,21 +397,17 @@ pointers array. ``` """ function pointers(tensor::Value, dim::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[tensor, dim] + results = IR.Type[result, ] + operands = Value[tensor, dim, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.pointers", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.pointers", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -494,21 +429,17 @@ values array. ``` """ function values(tensor::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[tensor,] + results = IR.Type[result, ] + operands = Value[tensor, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.values", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "sparse_tensor.values", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/StandardOps.jl b/src/Dialects/14/StandardOps.jl index 2a02c0d3..12e503c3 100644 --- a/src/Dialects/14/StandardOps.jl +++ b/src/Dialects/14/StandardOps.jl @@ -1,9 +1,8 @@ module std -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `assert` @@ -21,20 +20,16 @@ assert %b, \"Expected ... to be true\" """ function assert(arg::Value; msg, location=Location()) results = IR.Type[] - operands = Value[arg,] + operands = Value[arg, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("msg", msg),] - - return IR.create_operation( - "std.assert", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("msg", msg), ] + + IR.create_operation( + "std.assert", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -57,20 +52,16 @@ the block successor. """ function br(destOperands::Vector{Value}; dest::Block, location=Location()) results = IR.Type[] - operands = Value[destOperands...,] + operands = Value[destOperands..., ] owned_regions = Region[] - successors = Block[dest,] + successors = Block[dest, ] attributes = NamedAttribute[] - - return IR.create_operation( - "std.br", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "std.br", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -92,27 +83,18 @@ Function values can be created with the : (tensor<16xf32>, tensor<16xf32>) -> tensor<16xf32> ``` """ -function call_indirect( - callee::Value, - callee_operands::Vector{Value}; - results::Vector{IR.Type}, - location=Location(), -) - results = IR.Type[results...,] - operands = Value[callee, callee_operands...] +function call_indirect(callee::Value, callee_operands::Vector{Value}; results_::Vector{IR.Type}, location=Location()) + results = IR.Type[results_..., ] + operands = Value[callee, callee_operands..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "std.call_indirect", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "std.call_indirect", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -130,24 +112,18 @@ symbol reference attribute named \"callee\". %2 = call @my_add(%0, %1) : (f32, f32) -> f32 ``` """ -function call( - operands::Vector{Value}; result_0::Vector{IR.Type}, callee, location=Location() -) - results = IR.Type[result_0...,] - operands = Value[operands...,] +function call(operands_::Vector{Value}; result_0::Vector{IR.Type}, callee, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("callee", callee),] - - return IR.create_operation( - "std.call", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("callee", callee), ] + + IR.create_operation( + "std.call", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -179,33 +155,19 @@ func @select(%a: i32, %b: i32, %flag: i1) -> i32 { } ``` """ -function cond_br( - condition::Value, - trueDestOperands::Vector{Value}, - falseDestOperands::Vector{Value}; - trueDest::Block, - falseDest::Block, - location=Location(), -) +function cond_br(condition::Value, trueDestOperands::Vector{Value}, falseDestOperands::Vector{Value}; trueDest::Block, falseDest::Block, location=Location()) results = IR.Type[] - operands = Value[condition, trueDestOperands..., falseDestOperands...] + operands = Value[condition, trueDestOperands..., falseDestOperands..., ] owned_regions = Region[] - successors = Block[trueDest, falseDest] + successors = Block[trueDest, falseDest, ] attributes = NamedAttribute[] - push!( - attributes, - operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands)]), - ) - - return IR.create_operation( - "std.cond_br", - location; - operands, - owned_regions, - successors, - attributes, + push!(attributes, operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands), ])) + + IR.create_operation( + "std.cond_br", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -245,21 +207,17 @@ reference a function simplifies this ([rationale](../Rationale/Rationale.md#multithreading-the-compiler)). """ function constant(; result_0::IR.Type, value, location=Location()) - results = IR.Type[result_0,] + results = IR.Type[result_0, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("value", value),] - - return IR.create_operation( - "std.constant", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("value", value), ] + + IR.create_operation( + "std.constant", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -280,22 +238,18 @@ func @foo() : (i32, f8) { } ``` """ -function return_(operands::Vector{Value}; location=Location()) +function return_(operands_::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[operands...,] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "std.return", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "std.return", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -332,29 +286,19 @@ to implement `min` and `max` with signed or unsigned comparison semantics. %vx = std.select %cond, %vtrue, %vfalse : vector<42xf32> ``` """ -function select( - condition::Value, - true_value::Value, - false_value::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function select(condition::Value, true_value::Value, false_value::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[condition, true_value, false_value] + operands = Value[condition, true_value, false_value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "std.select", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "std.select", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -385,21 +329,17 @@ tensors in the same way dynamically shaped memrefs are handled. ``` """ function splat(input::Value; aggregate::IR.Type, location=Location()) - results = IR.Type[aggregate,] - operands = Value[input,] + results = IR.Type[aggregate, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "std.splat", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "std.splat", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -422,37 +362,20 @@ switch %flag : i32, [ ] ``` """ -function switch( - flag::Value, - defaultOperands::Vector{Value}, - caseOperands::Vector{Value}; - case_values=nothing, - case_operand_segments, - defaultDestination::Block, - caseDestinations::Vector{Block}, - location=Location(), -) +function switch(flag::Value, defaultOperands::Vector{Value}, caseOperands::Vector{Value}; case_values=nothing, case_operand_segments, defaultDestination::Block, caseDestinations::Vector{Block}, location=Location()) results = IR.Type[] - operands = Value[flag, defaultOperands..., caseOperands...] + operands = Value[flag, defaultOperands..., caseOperands..., ] owned_regions = Region[] - successors = Block[defaultDestination, caseDestinations...] - attributes = NamedAttribute[namedattribute( - "case_operand_segments", case_operand_segments - ),] - push!( - attributes, operandsegmentsizes([1, length(defaultOperands), length(caseOperands)]) - ) + successors = Block[defaultDestination, caseDestinations..., ] + attributes = NamedAttribute[namedattribute("case_operand_segments", case_operand_segments), ] + push!(attributes, operandsegmentsizes([1, length(defaultOperands), length(caseOperands), ])) !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) - - return IR.create_operation( - "std.switch", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "std.switch", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Tensor.jl b/src/Dialects/14/Tensor.jl index abbda690..5f5d6695 100644 --- a/src/Dialects/14/Tensor.jl +++ b/src/Dialects/14/Tensor.jl @@ -1,9 +1,8 @@ module tensor -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `cast` @@ -29,21 +28,17 @@ converting to a mismatching constant dimension. ``` """ function cast(source::Value; dest::IR.Type, location=Location()) - results = IR.Type[dest,] - operands = Value[source,] + results = IR.Type[dest, ] + operands = Value[source, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.cast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tensor.cast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -73,21 +68,17 @@ Examples: ``` """ function collapse_shape(src::Value; result::IR.Type, reassociation, location=Location()) - results = IR.Type[result,] - operands = Value[src,] + results = IR.Type[result, ] + operands = Value[src, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("reassociation", reassociation),] - - return IR.create_operation( - "tensor.collapse_shape", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "tensor.collapse_shape", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -116,25 +107,19 @@ The specified tensor type is that of the first operand. %y = \"tensor.dim\"(%A, %c1) : (memref<4x?xf32>, index) -> index ``` """ -function dim( - source::Value, index::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) +function dim(source::Value, index::Value; result=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[source, index] + operands = Value[source, index, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result) && push!(results, result) - - return IR.create_operation( - "tensor.dim", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tensor.dim", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -164,21 +149,17 @@ Examples: ``` """ function expand_shape(src::Value; result::IR.Type, reassociation, location=Location()) - results = IR.Type[result,] - operands = Value[src,] + results = IR.Type[result, ] + operands = Value[src, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("reassociation", reassociation),] - - return IR.create_operation( - "tensor.expand_shape", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "tensor.expand_shape", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -200,24 +181,18 @@ indices should all be of `index` type. %6 = tensor.extract %ut[%1, %2] : tensor<*xi32> ``` """ -function extract( - tensor::Value, indices::Vector{Value}; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[tensor, indices...] +function extract(tensor::Value, indices::Vector{Value}; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[tensor, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.extract", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tensor.extract", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -263,40 +238,19 @@ between different flavors of ops on that operate on tensors. tensor<8x16x4xf32> to tensor<1x?xf32> ``` """ -function extract_slice( - source::Value, - offsets::Vector{Value}, - sizes::Vector{Value}, - strides::Vector{Value}; - result::IR.Type, - static_offsets, - static_sizes, - static_strides, - location=Location(), -) - results = IR.Type[result,] - operands = Value[source, offsets..., sizes..., strides...] +function extract_slice(source::Value, offsets::Vector{Value}, sizes::Vector{Value}, strides::Vector{Value}; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[source, offsets..., sizes..., strides..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("static_offsets", static_offsets), - namedattribute("static_sizes", static_sizes), - namedattribute("static_strides", static_strides), - ] - push!( - attributes, - operandsegmentsizes([1, length(offsets), length(sizes), length(strides)]), - ) - - return IR.create_operation( - "tensor.extract_slice", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("static_offsets", static_offsets), namedattribute("static_sizes", static_sizes), namedattribute("static_strides", static_strides), ] + push!(attributes, operandsegmentsizes([1, length(offsets), length(sizes), length(strides), ])) + + IR.create_operation( + "tensor.extract_slice", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -319,21 +273,17 @@ will result in a tensor [%d, %e, %f]] """ function from_elements(elements::Vector{Value}; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[elements...,] + results = IR.Type[result, ] + operands = Value[elements..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.from_elements", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tensor.from_elements", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -359,24 +309,18 @@ a \"parallel map\" operation. } : tensor ``` """ -function generate( - dynamicExtents::Vector{Value}; result::IR.Type, body::Region, location=Location() -) - results = IR.Type[result,] - operands = Value[dynamicExtents...,] - owned_regions = Region[body,] +function generate(dynamicExtents::Vector{Value}; result::IR.Type, body::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[dynamicExtents..., ] + owned_regions = Region[body, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.generate", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tensor.generate", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -401,24 +345,18 @@ indices should all be of `index` type. %6 = tensor.insert %ut into %dest[%1, %2] : tensor<*xi32> ``` """ -function insert( - scalar::Value, dest::Value, indices::Vector{Value}; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[scalar, dest, indices...] +function insert(scalar::Value, dest::Value, indices::Vector{Value}; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[scalar, dest, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.insert", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tensor.insert", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -472,41 +410,19 @@ behavior of tensor.extract_slice. tensor<1x?xf32> into tensor<8x16x4xf32> ``` """ -function insert_slice( - source::Value, - dest::Value, - offsets::Vector{Value}, - sizes::Vector{Value}, - strides::Vector{Value}; - result::IR.Type, - static_offsets, - static_sizes, - static_strides, - location=Location(), -) - results = IR.Type[result,] - operands = Value[source, dest, offsets..., sizes..., strides...] +function insert_slice(source::Value, dest::Value, offsets::Vector{Value}, sizes::Vector{Value}, strides::Vector{Value}; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[source, dest, offsets..., sizes..., strides..., ] owned_regions = Region[] 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)]), - ) - - return IR.create_operation( - "tensor.insert_slice", - location; - operands, - owned_regions, - successors, - attributes, + 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), ])) + + IR.create_operation( + "tensor.insert_slice", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -582,36 +498,20 @@ Example 4: } : tensor<2x3xf32> to tensor<2x3xf32> ``` """ -function pad( - source::Value, - low::Vector{Value}, - high::Vector{Value}; - result::IR.Type, - static_low, - static_high, - nofold=nothing, - region::Region, - location=Location(), -) - results = IR.Type[result,] - operands = Value[source, low..., high...] - owned_regions = Region[region,] +function pad(source::Value, low::Vector{Value}, high::Vector{Value}; result::IR.Type, static_low, static_high, nofold=nothing, region::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[source, low..., high..., ] + owned_regions = Region[region, ] successors = Block[] - attributes = NamedAttribute[ - namedattribute("static_low", static_low), namedattribute("static_high", static_high) - ] - push!(attributes, operandsegmentsizes([1, length(low), length(high)])) + attributes = NamedAttribute[namedattribute("static_low", static_low), namedattribute("static_high", static_high), ] + push!(attributes, operandsegmentsizes([1, length(low), length(high), ])) !isnothing(nofold) && push!(attributes, namedattribute("nofold", nofold)) - - return IR.create_operation( - "tensor.pad", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tensor.pad", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -627,23 +527,19 @@ The `tensor.rank` operation takes a tensor operand and returns its rank. %1 = tensor.rank %arg1 : tensor ``` """ -function rank(tensor::Value; result_0=nothing::Union{Nothing,IR.Type}, location=Location()) +function rank(tensor::Value; result_0=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[tensor,] + operands = Value[tensor, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(result_0) && push!(results, result_0) - - return IR.create_operation( - "tensor.rank", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tensor.rank", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -682,21 +578,17 @@ Result type is unranked. ``` """ function reshape(source::Value, shape::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[source, shape] + results = IR.Type[result, ] + operands = Value[source, shape, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.reshape", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tensor.reshape", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -709,20 +601,16 @@ is used to create dynamically sized tensors """ function yield(value::Value; location=Location()) results = IR.Type[] - operands = Value[value,] + operands = Value[value, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.yield", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tensor.yield", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/Tosa.jl b/src/Dialects/14/Tosa.jl index cf274a0c..d05ac6ad 100644 --- a/src/Dialects/14/Tosa.jl +++ b/src/Dialects/14/Tosa.jl @@ -1,9 +1,8 @@ module tosa -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `abs` @@ -11,21 +10,17 @@ import ...API Elementwise absolute value operation """ function abs(input1::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1,] + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.abs", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.abs", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -36,21 +31,17 @@ Elementwise addition of input1 and input2. Axis of size 1 will be broadcast, as necessary. """ function add(input1::Value, input2::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1, input2] + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.add", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.add", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -64,29 +55,18 @@ The commonplace implementation is to use i64 operations to avoid integer overflow with target specific implementations can use native operations to avoid wider than necessary types. """ -function apply_scale( - value::Value, - multiplier::Value, - shift::Value; - output::IR.Type, - double_round, - location=Location(), -) - results = IR.Type[output,] - operands = Value[value, multiplier, shift] +function apply_scale(value::Value, multiplier::Value, shift::Value; output::IR.Type, double_round, location=Location()) + results = IR.Type[output, ] + operands = Value[value, multiplier, shift, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("double_round", double_round),] - - return IR.create_operation( - "tosa.apply_scale", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("double_round", double_round), ] + + IR.create_operation( + "tosa.apply_scale", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -97,21 +77,17 @@ This returns the index with the largest value across the given axis of the input tensor. """ function argmax(input::Value; output::IR.Type, axis, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.argmax", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.argmax", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -121,24 +97,18 @@ end Elementwise arithmetic right shift of input1 by the amount specified in input2. Axis of size 1 will be broadcast, as necessary. """ -function arithmetic_right_shift( - input1::Value, input2::Value; output::IR.Type, round, location=Location() -) - results = IR.Type[output,] - operands = Value[input1, input2] +function arithmetic_right_shift(input1::Value, input2::Value; output::IR.Type, round, location=Location()) + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("round", round),] - - return IR.create_operation( - "tosa.arithmetic_right_shift", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("round", round), ] + + IR.create_operation( + "tosa.arithmetic_right_shift", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -149,36 +119,19 @@ This performs an average pooling over the given input tensor. A sliding window of size given by is passed over the input tensor, with the mean value being placed in the output tensor. """ -function avg_pool2d( - input::Value; - output::IR.Type, - kernel, - stride, - pad, - quantization_info=nothing, - location=Location(), -) - results = IR.Type[output,] - operands = Value[input,] +function avg_pool2d(input::Value; output::IR.Type, kernel, stride, pad, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("kernel", kernel), - namedattribute("stride", stride), - namedattribute("pad", pad), - ] - !isnothing(quantization_info) && - push!(attributes, namedattribute("quantization_info", quantization_info)) - - return IR.create_operation( - "tosa.avg_pool2d", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("kernel", kernel), namedattribute("stride", stride), namedattribute("pad", pad), ] + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) + + IR.create_operation( + "tosa.avg_pool2d", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -189,21 +142,17 @@ Elementwise bitwise AND of input1 and input2. Axis of size 1 will be broadcast as necessary. """ function bitwise_and(input1::Value, input2::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1, input2] + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_and", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.bitwise_and", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -213,21 +162,17 @@ end Elementwise bitwise NOT of input tensor. """ function bitwise_not(input1::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1,] + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_not", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.bitwise_not", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -238,21 +183,17 @@ Elementwise bitwise OR of input1 and input2. Axis of size 1 will be broadcast as necessary. """ function bitwise_or(input1::Value, input2::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1, input2] + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_or", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.bitwise_or", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -263,21 +204,17 @@ Elementwise bitwise XOR of input1 and input2. Axis of size 1 will be broadcast as necessary. """ function bitwise_xor(input1::Value, input2::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1, input2] + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_xor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.bitwise_xor", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -305,21 +242,17 @@ Performs a set of permissible cast operations signed 16 to float int16 float """ function cast(input::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.cast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.cast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -329,21 +262,17 @@ end Elementwise ceiling operation """ function ceil(input1::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1,] + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.ceil", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.ceil", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -356,29 +285,18 @@ input type. No zero point subtraction is done to the values, thus to clamp to the zero point value, the zero point itself should be supplied as the minimum value. """ -function clamp( - input::Value; output::IR.Type, min_int, max_int, min_fp, max_fp, location=Location() -) - results = IR.Type[output,] - operands = Value[input,] +function clamp(input::Value; output::IR.Type, min_int, max_int, min_fp, max_fp, location=Location()) + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("min_int", min_int), - namedattribute("max_int", max_int), - namedattribute("min_fp", min_fp), - namedattribute("max_fp", max_fp), - ] - - return IR.create_operation( - "tosa.clamp", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("min_int", min_int), namedattribute("max_int", max_int), namedattribute("min_fp", min_fp), namedattribute("max_fp", max_fp), ] + + IR.create_operation( + "tosa.clamp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -388,21 +306,17 @@ end Elementwise count leading zeros operation """ function clz(input1::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1,] + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.clz", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.clz", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -413,21 +327,17 @@ Concatenate a variadic amount of tensors along a given axis. No data conversion happens during a concat operation. """ function concat(input1::Vector{Value}; output::IR.Type, axis, location=Location()) - results = IR.Type[output,] - operands = Value[input1...,] + results = IR.Type[output, ] + operands = Value[input1..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.concat", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.concat", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -437,23 +347,19 @@ end A node containing constant data for use as the input to an operation. May hold data in any of the supported data formats. """ -function const_(; output=nothing::Union{Nothing,IR.Type}, value, location=Location()) +function const_(; output=nothing::Union{Nothing, IR.Type}, value, location=Location()) results = IR.Type[] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("value", value),] + attributes = NamedAttribute[namedattribute("value", value), ] !isnothing(output) && push!(results, output) - - return IR.create_operation( - "tosa.const", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.const", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -463,38 +369,19 @@ end Performs a 2D convolution over the given tensor input, using the weight tensor. """ -function conv2d( - input::Value, - weight::Value, - bias::Value; - output::IR.Type, - pad, - stride, - dilation, - quantization_info=nothing, - location=Location(), -) - results = IR.Type[output,] - operands = Value[input, weight, bias] +function conv2d(input::Value, weight::Value, bias::Value; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[input, weight, bias, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("pad", pad), - namedattribute("stride", stride), - namedattribute("dilation", dilation), - ] - !isnothing(quantization_info) && - push!(attributes, namedattribute("quantization_info", quantization_info)) - - return IR.create_operation( - "tosa.conv2d", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) + + IR.create_operation( + "tosa.conv2d", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -503,38 +390,19 @@ end Performs a 3D convolution over the given input tensor. """ -function conv3d( - input::Value, - weight::Value, - bias::Value; - output::IR.Type, - pad, - stride, - dilation, - quantization_info=nothing, - location=Location(), -) - results = IR.Type[output,] - operands = Value[input, weight, bias] +function conv3d(input::Value, weight::Value, bias::Value; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[input, weight, bias, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("pad", pad), - namedattribute("stride", stride), - namedattribute("dilation", dilation), - ] - !isnothing(quantization_info) && - push!(attributes, namedattribute("quantization_info", quantization_info)) - - return IR.create_operation( - "tosa.conv3d", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) + + IR.create_operation( + "tosa.conv3d", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -546,24 +414,18 @@ that are not expressed in the existing TOSA operations. These operators are not expected to be portable across TOSA implementations. The input and output signatures must be expressed in the corresponding TOSA node. """ -function custom( - inputs::Vector{Value}; outputs::Vector{IR.Type}, identifier, location=Location() -) - results = IR.Type[outputs...,] - operands = Value[inputs...,] +function custom(inputs::Vector{Value}; outputs::Vector{IR.Type}, identifier, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[inputs..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("identifier", identifier),] - - return IR.create_operation( - "tosa.custom", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("identifier", identifier), ] + + IR.create_operation( + "tosa.custom", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -573,38 +435,19 @@ end Performs 2D convolutions separately over each channel of the given tensor input, using the weight tensor. """ -function depthwise_conv2d( - input::Value, - weight::Value, - bias::Value; - output::IR.Type, - pad, - stride, - dilation, - quantization_info=nothing, - location=Location(), -) - results = IR.Type[output,] - operands = Value[input, weight, bias] +function depthwise_conv2d(input::Value, weight::Value, bias::Value; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[input, weight, bias, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("pad", pad), - namedattribute("stride", stride), - namedattribute("dilation", dilation), - ] - !isnothing(quantization_info) && - push!(attributes, namedattribute("quantization_info", quantization_info)) - - return IR.create_operation( - "tosa.depthwise_conv2d", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("pad", pad), namedattribute("stride", stride), namedattribute("dilation", dilation), ] + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) + + IR.create_operation( + "tosa.depthwise_conv2d", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -615,21 +458,17 @@ Elementwise integer divide operator of input1 by input2. Axis of size 1 will be broadcast, as necessary. """ function div(input1::Value, input2::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1, input2] + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.div", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.div", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -639,21 +478,17 @@ end Elementwise comparison operation """ function equal(input1::Value, input2::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1, input2] + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.equal", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.equal", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -663,21 +498,17 @@ end Elementwise e to the x operation """ function exp(input1::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1,] + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.exp", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.exp", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -687,21 +518,17 @@ end Elementwise floor operation """ function floor(input1::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1,] + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.floor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.floor", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -710,31 +537,19 @@ end Performs a fully connected network. """ -function fully_connected( - input::Value, - weight::Value, - bias::Value; - output::IR.Type, - quantization_info=nothing, - location=Location(), -) - results = IR.Type[output,] - operands = Value[input, weight, bias] +function fully_connected(input::Value, weight::Value, bias::Value; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[input, weight, bias, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !isnothing(quantization_info) && - push!(attributes, namedattribute("quantization_info", quantization_info)) - - return IR.create_operation( - "tosa.fully_connected", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) + + IR.create_operation( + "tosa.fully_connected", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -745,21 +560,17 @@ Generate a tensor for which each element in the output is a slice of the values tensor based on the value of indices. """ function gather(values::Value, indices::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[values, indices] + results = IR.Type[output, ] + operands = Value[values, indices, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.gather", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.gather", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -769,21 +580,17 @@ end Elementwise comparison operation """ function greater_equal(input1::Value, input2::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1, input2] + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.greater_equal", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.greater_equal", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -793,21 +600,17 @@ end Elementwise greater than comparison operation """ function greater(input1::Value, input2::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1, input2] + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.greater", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.greater", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -818,21 +621,17 @@ Returns a tensor with the same shape, size, type and content as the input. """ function identity(input1::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1,] + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.identity", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.identity", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -842,29 +641,18 @@ end Evaluates a Boolean condition and then takes one of two distinct execution paths. This implements the semantic If-then-else structure. """ -function cond_if( - cond::Value, - inputs::Vector{Value}; - output::Vector{IR.Type}, - then_branch::Region, - else_branch::Region, - location=Location(), -) - results = IR.Type[output...,] - operands = Value[cond, inputs...] - owned_regions = Region[then_branch, else_branch] +function cond_if(cond::Value, inputs::Vector{Value}; output::Vector{IR.Type}, then_branch::Region, else_branch::Region, location=Location()) + results = IR.Type[output..., ] + operands = Value[cond, inputs..., ] + owned_regions = Region[then_branch, else_branch, ] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.cond_if", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.cond_if", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -874,21 +662,17 @@ end Elementwise natural logarithm operation """ function log(input1::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1,] + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.log", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.log", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -899,21 +683,17 @@ Elementwise logical AND of input1 and input2. Axis of size 1 will be broadcast, as necessary. """ function logical_and(input1::Value, input2::Value; z::IR.Type, location=Location()) - results = IR.Type[z,] - operands = Value[input1, input2] + results = IR.Type[z, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_and", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.logical_and", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -923,24 +703,18 @@ end Elementwise left shift of input1 and input2. Axis of size 1 will be broadcast, as necessary. """ -function logical_left_shift( - input1::Value, input2::Value; output::IR.Type, location=Location() -) - results = IR.Type[output,] - operands = Value[input1, input2] +function logical_left_shift(input1::Value, input2::Value; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_left_shift", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.logical_left_shift", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -950,21 +724,17 @@ end Elementwise logical NOT of input. """ function logical_not(input1::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1,] + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_not", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.logical_not", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -975,21 +745,17 @@ Elementwise logical OR of input1 and input2. Axis of size 1 will be broadcast as necessary. """ function logical_or(input1::Value, input2::Value; z::IR.Type, location=Location()) - results = IR.Type[z,] - operands = Value[input1, input2] + results = IR.Type[z, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_or", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.logical_or", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -999,24 +765,18 @@ end Elementwise logical right shift of input1 by the amount specified in input2. Axis of size 1 will be broadcast, as necessary. """ -function logical_right_shift( - input1::Value, input2::Value; output::IR.Type, location=Location() -) - results = IR.Type[output,] - operands = Value[input1, input2] +function logical_right_shift(input1::Value, input2::Value; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_right_shift", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.logical_right_shift", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1027,21 +787,17 @@ Elementwise logical XOR of input1 and input2. Axis of size 1 will be broadcast as necessary. """ function logical_xor(input1::Value, input2::Value; z::IR.Type, location=Location()) - results = IR.Type[z,] - operands = Value[input1, input2] + results = IR.Type[z, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_xor", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.logical_xor", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1052,26 +808,19 @@ Performs a two dimensional matrix multiplication. This allows both inputs to be activations, rather than reserving weights as an attribute in the FULLY_CONNECTED operator. """ -function matmul( - a::Value, b::Value; c::IR.Type, quantization_info=nothing, location=Location() -) - results = IR.Type[c,] - operands = Value[a, b] +function matmul(a::Value, b::Value; c::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[c, ] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !isnothing(quantization_info) && - push!(attributes, namedattribute("quantization_info", quantization_info)) - - return IR.create_operation( - "tosa.matmul", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) + + IR.create_operation( + "tosa.matmul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1084,25 +833,17 @@ maximum value being placed in the output tensor. """ function max_pool2d(input::Value; output::IR.Type, kernel, stride, pad, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("kernel", kernel), - namedattribute("stride", stride), - namedattribute("pad", pad), - ] - - return IR.create_operation( - "tosa.max_pool2d", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("kernel", kernel), namedattribute("stride", stride), namedattribute("pad", pad), ] + + IR.create_operation( + "tosa.max_pool2d", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1113,21 +854,17 @@ Elementwise max of input1 and input2. Axis of size 1 will be broadcast, as necessary. """ function maximum(input1::Value, input2::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1, input2] + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.maximum", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.maximum", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1138,21 +875,17 @@ Elementwise minimum of input1 and input2. Axis of size 1 will be broadcast, as necessary. """ function minimum(input1::Value, input2::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1, input2] + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.minimum", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.minimum", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1163,21 +896,17 @@ Elementwise multiplication (Hadamard product) of input1 and input2. Axis of size 1 will be broadcast, as necessary. """ function mul(input1::Value, input2::Value; output::IR.Type, shift, location=Location()) - results = IR.Type[output,] - operands = Value[input1, input2] + results = IR.Type[output, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("shift", shift),] - - return IR.create_operation( - "tosa.mul", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("shift", shift), ] + + IR.create_operation( + "tosa.mul", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1186,26 +915,19 @@ end Elementwise negation operation """ -function negate( - input1::Value; output::IR.Type, quantization_info=nothing, location=Location() -) - results = IR.Type[output,] - operands = Value[input1,] +function negate(input1::Value; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - !isnothing(quantization_info) && - push!(attributes, namedattribute("quantization_info", quantization_info)) - - return IR.create_operation( - "tosa.negate", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) + + IR.create_operation( + "tosa.negate", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1214,32 +936,20 @@ end Pads a tensor along borders of each dimension with pad_value. """ -function pad( - input1::Value, - padding::Value, - pad_const=nothing::Union{Nothing,Value}; - output::IR.Type, - quantization_info=nothing, - location=Location(), -) - results = IR.Type[output,] - operands = Value[input1, padding] +function pad(input1::Value, padding::Value, pad_const=nothing::Union{Nothing, Value}; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[input1, padding, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(pad_const) && push!(operands, pad_const) - !isnothing(quantization_info) && - push!(attributes, namedattribute("quantization_info", quantization_info)) - - return IR.create_operation( - "tosa.pad", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) + + IR.create_operation( + "tosa.pad", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1250,21 +960,17 @@ Elementwise input1 raised to the power of input2. Axis of size 1 will be broadcast, as necessary. """ function pow(input1::Value, input2::Value; z::IR.Type, location=Location()) - results = IR.Type[z,] - operands = Value[input1, input2] + results = IR.Type[z, ] + operands = Value[input1, input2, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.pow", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.pow", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1275,21 +981,17 @@ Elementwise reciprocal operation. For integer operation, a TABLE should be used with the appropriate ranges. """ function reciprocal(input1::Value; output::IR.Type, location=Location()) - results = IR.Type[output,] - operands = Value[input1,] + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.reciprocal", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "tosa.reciprocal", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1299,21 +1001,17 @@ end Reduce a tensor along the given axis with a logical AND operation """ function reduce_all(input::Value; output::IR.Type, axis, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_all", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_all", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1323,21 +1021,17 @@ end Reduce a tensor along the given axis with a logical OR operation """ function reduce_any(input::Value; output::IR.Type, axis, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_any", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_any", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1347,21 +1041,17 @@ end Reduce a tensor along the given axis with a maximum operation """ function reduce_max(input::Value; output::IR.Type, axis, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_max", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_max", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1371,21 +1061,17 @@ end Reduce a tensor along the given axis with a minimum operation """ function reduce_min(input::Value; output::IR.Type, axis, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_min", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_min", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1395,21 +1081,17 @@ end Reduce a tensor along the given axis by computing the product of the axis. """ function reduce_prod(input::Value; output::IR.Type, axis, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_prod", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_prod", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1419,21 +1101,17 @@ end Reduce a tensor along the given axis by computing the sum of the axis. """ function reduce_sum(input::Value; output::IR.Type, axis, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_sum", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_sum", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1443,23 +1121,17 @@ end ReLU with a scalar maximum value. """ function reluN(input::Value; output::IR.Type, max_int, max_fp, location=Location()) - results = IR.Type[output,] - operands = Value[input,] + results = IR.Type[output, ] + operands = Value[input, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("max_int", max_int), namedattribute("max_fp", max_fp) - ] - - return IR.create_operation( - "tosa.reluN", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("max_int", max_int), namedattribute("max_fp", max_fp), ] + + IR.create_operation( + "tosa.reluN", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1483,41 +1155,18 @@ signed 48 to 32 int48 int32 unsigned 8 to signed 8 uint8 int8 signed 8 to unsigned 8 int8 uint8 """ -function rescale( - input::Value; - output::IR.Type, - input_zp, - output_zp, - multiplier, - shift, - scale32, - double_round, - per_channel, - location=Location(), -) - results = IR.Type[output,] - operands = Value[input,] - owned_regions = Region[] - successors = Block[] - attributes = NamedAttribute[ - namedattribute("input_zp", input_zp), - namedattribute("output_zp", output_zp), - namedattribute("multiplier", multiplier), - namedattribute("shift", shift), - namedattribute("scale32", scale32), - namedattribute("double_round", double_round), - namedattribute("per_channel", per_channel), - ] - - return IR.create_operation( - "tosa.rescale", - location; - operands, - owned_regions, - successors, - attributes, - results=results, - result_inference=false, +function rescale(input::Value; output::IR.Type, input_zp, output_zp, multiplier, shift, scale32, double_round, per_channel, location=Location()) + results = IR.Type[output, ] + operands = Value[input, ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("input_zp", input_zp), namedattribute("output_zp", output_zp), namedattribute("multiplier", multiplier), namedattribute("shift", shift), namedattribute("scale32", scale32), namedattribute("double_round", double_round), namedattribute("per_channel", per_channel), ] + + IR.create_operation( + "tosa.rescale", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1529,21 +1178,17 @@ specified by the shape argument. Reshape may operate on tensors of any rank. No data conversion happens during a reshape operation. """ function reshape(input1::Value; output::IR.Type, new_shape, location=Location()) - results = IR.Type[output,] - operands = Value[input1,] + results = IR.Type[output, ] + operands = Value[input1, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("new_shape", new_shape),] - - return IR.create_operation( - "tosa.reshape", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("new_shape", new_shape), ] + + IR.create_operation( + "tosa.reshape", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1555,41 +1200,18 @@ expected use, stride_y is approximately (IH<, vector<16xi1>, vector<16xf32> ``` """ -function compressstore( - base::Value, - indices::Vector{Value}, - mask::Value, - valueToStore::Value; - location=Location(), -) +function compressstore(base::Value, indices::Vector{Value}, mask::Value, valueToStore::Value; location=Location()) results = IR.Type[] - operands = Value[base, indices..., mask, valueToStore] + operands = Value[base, indices..., mask, valueToStore, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.compressstore", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.compressstore", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -219,21 +196,17 @@ print %1 ``` """ function constant_mask(; result_0::IR.Type, mask_dim_sizes, location=Location()) - results = IR.Type[result_0,] + results = IR.Type[result_0, ] operands = Value[] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("mask_dim_sizes", mask_dim_sizes),] - - return IR.create_operation( - "vector.constant_mask", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("mask_dim_sizes", mask_dim_sizes), ] + + IR.create_operation( + "vector.constant_mask", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -354,36 +327,19 @@ int only. The default is \"add\". : vector<10xf32>, vector<10xf32> into f32 ``` """ -function contract( - lhs::Value, - rhs::Value, - acc::Value, - masks::Vector{Value}; - result_0::IR.Type, - indexing_maps, - iterator_types, - kind=nothing, - location=Location(), -) - results = IR.Type[result_0,] - operands = Value[lhs, rhs, acc, masks...] +function contract(lhs::Value, rhs::Value, acc::Value, masks::Vector{Value}; result_0::IR.Type, indexing_maps, iterator_types, kind=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[lhs, rhs, acc, masks..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("indexing_maps", indexing_maps), - namedattribute("iterator_types", iterator_types), - ] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) - - return IR.create_operation( - "vector.contract", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.contract", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -417,22 +373,18 @@ print %1 3 | 0 0 0 ``` """ -function create_mask(operands::Vector{Value}; result_0::IR.Type, location=Location()) - results = IR.Type[result_0,] - operands = Value[operands...,] +function create_mask(operands_::Vector{Value}; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[operands_..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.create_mask", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.create_mask", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -467,29 +419,18 @@ Examples: : memref, vector<16xi1>, vector<16xf32> into vector<16xf32> ``` """ -function expandload( - base::Value, - indices::Vector{Value}, - mask::Value, - pass_thru::Value; - result::IR.Type, - location=Location(), -) - results = IR.Type[result,] - operands = Value[base, indices..., mask, pass_thru] +function expandload(base::Value, indices::Vector{Value}, mask::Value, pass_thru::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[base, indices..., mask, pass_thru, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.expandload", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.expandload", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -515,28 +456,19 @@ https://llvm.org/docs/LangRef.html#extractelement-instruction %2 = vector.extractelement %z[]: vector ``` """ -function extractelement( - vector::Value, - position=nothing::Union{Nothing,Value}; - result::IR.Type, - location=Location(), -) - results = IR.Type[result,] - operands = Value[vector,] +function extractelement(vector::Value, position=nothing::Union{Nothing, Value}; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[vector, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(position) && push!(operands, position) - - return IR.create_operation( - "vector.extractelement", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.extractelement", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -584,24 +516,18 @@ For instance: to vector<4x4x2xf32> ``` """ -function extract_map( - vector::Value, ids::Vector{Value}; result_0::IR.Type, location=Location() -) - results = IR.Type[result_0,] - operands = Value[vector, ids...] +function extract_map(vector::Value, ids::Vector{Value}; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[vector, ids..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.extract_map", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.extract_map", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -619,21 +545,17 @@ the proper position. Degenerates to an element type in the 0-D case. ``` """ function extract(vector::Value; result_0::IR.Type, position, location=Location()) - results = IR.Type[result_0,] - operands = Value[vector,] + results = IR.Type[result_0, ] + operands = Value[vector, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("position", position),] - - return IR.create_operation( - "vector.extract", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "vector.extract", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -663,28 +585,18 @@ attribute. The returned subvector contains the elements starting at offset vector<4x8x16xf32> to vector<2x4x16xf32> ``` """ -function extract_strided_slice( - vector::Value; result_0::IR.Type, offsets, sizes, strides, location=Location() -) - results = IR.Type[result_0,] - operands = Value[vector,] +function extract_strided_slice(vector::Value; result_0::IR.Type, offsets, sizes, strides, location=Location()) + results = IR.Type[result_0, ] + operands = Value[vector, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("offsets", offsets), - namedattribute("sizes", sizes), - namedattribute("strides", strides), - ] - - return IR.create_operation( - "vector.extract_strided_slice", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("offsets", offsets), namedattribute("sizes", sizes), namedattribute("strides", strides), ] + + IR.create_operation( + "vector.extract_strided_slice", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -706,21 +618,17 @@ to the `llvm.fma.*` intrinsic. ``` """ function fma(lhs::Value, rhs::Value, acc::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[lhs, rhs, acc] + results = IR.Type[result, ] + operands = Value[lhs, rhs, acc, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.fma", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.fma", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -750,23 +658,17 @@ http://llvm.org/docs/LangRef.html#llvm-matrix-transpose-intrinsic ``` """ function flat_transpose(matrix::Value; res::IR.Type, rows, columns, location=Location()) - results = IR.Type[res,] - operands = Value[matrix,] + results = IR.Type[res, ] + operands = Value[matrix, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("rows", rows), namedattribute("columns", columns) - ] - - return IR.create_operation( - "vector.flat_transpose", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("rows", rows), namedattribute("columns", columns), ] + + IR.create_operation( + "vector.flat_transpose", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -801,30 +703,18 @@ Examples: : memref<16x16xf32>, vector<16xi32>, vector<16xi1>, vector<16xf32> into vector<16xf32> ``` """ -function gather( - base::Value, - indices::Vector{Value}, - index_vec::Value, - mask::Value, - pass_thru::Value; - result::IR.Type, - location=Location(), -) - results = IR.Type[result,] - operands = Value[base, indices..., index_vec, mask, pass_thru] +function gather(base::Value, indices::Vector{Value}, index_vec::Value, mask::Value, pass_thru::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[base, indices..., index_vec, mask, pass_thru, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.gather", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.gather", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -849,29 +739,19 @@ https://llvm.org/docs/LangRef.html#insertelement-instruction %2 = vector.insertelement %f, %z[]: vector ``` """ -function insertelement( - source::Value, - dest::Value, - position=nothing::Union{Nothing,Value}; - result::IR.Type, - location=Location(), -) - results = IR.Type[result,] - operands = Value[source, dest] +function insertelement(source::Value, dest::Value, position=nothing::Union{Nothing, Value}; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[source, dest, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(position) && push!(operands, position) - - return IR.create_operation( - "vector.insertelement", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.insertelement", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -921,24 +801,18 @@ For instance: into vector<64x4x32xf32> ``` """ -function insert_map( - vector::Value, dest::Value, ids::Vector{Value}; result::IR.Type, location=Location() -) - results = IR.Type[result,] - operands = Value[vector, dest, ids...] +function insert_map(vector::Value, dest::Value, ids::Vector{Value}; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[vector, dest, ids..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.insert_map", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.insert_map", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -957,21 +831,17 @@ position. Degenerates to a scalar source type when n = 0. ``` """ function insert(source::Value, dest::Value; res::IR.Type, position, location=Location()) - results = IR.Type[res,] - operands = Value[source, dest] + results = IR.Type[res, ] + operands = Value[source, dest, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("position", position),] - - return IR.create_operation( - "vector.insert", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "vector.insert", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -997,26 +867,18 @@ the proper location as specified by the offsets. vector<2x4xf32> into vector<16x4x8xf32> ``` """ -function insert_strided_slice( - source::Value, dest::Value; res::IR.Type, offsets, strides, location=Location() -) - results = IR.Type[res,] - operands = Value[source, dest] +function insert_strided_slice(source::Value, dest::Value; res::IR.Type, offsets, strides, location=Location()) + results = IR.Type[res, ] + operands = Value[source, dest, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("offsets", offsets), namedattribute("strides", strides) - ] - - return IR.create_operation( - "vector.insert_strided_slice", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("offsets", offsets), namedattribute("strides", strides), ] + + IR.create_operation( + "vector.insert_strided_slice", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1077,21 +939,17 @@ Example 6: Explicit out-of-bound vector load. ``` """ function load(base::Value, indices::Vector{Value}; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[base, indices...] + results = IR.Type[result, ] + operands = Value[base, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.load", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.load", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1123,29 +981,18 @@ Examples: : memref, vector<16xi1>, vector<16xf32> into vector<16xf32> ``` """ -function maskedload( - base::Value, - indices::Vector{Value}, - mask::Value, - pass_thru::Value; - result::IR.Type, - location=Location(), -) - results = IR.Type[result,] - operands = Value[base, indices..., mask, pass_thru] +function maskedload(base::Value, indices::Vector{Value}, mask::Value, pass_thru::Value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[base, indices..., mask, pass_thru, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.maskedload", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.maskedload", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1177,28 +1024,18 @@ vector.maskedstore %base[%i, %j], %mask, %value : memref, vector<16xi1>, vector<16xf32> ``` """ -function maskedstore( - base::Value, - indices::Vector{Value}, - mask::Value, - valueToStore::Value; - location=Location(), -) +function maskedstore(base::Value, indices::Vector{Value}, mask::Value, valueToStore::Value; location=Location()) results = IR.Type[] - operands = Value[base, indices..., mask, valueToStore] + operands = Value[base, indices..., mask, valueToStore, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.maskedstore", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.maskedstore", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1229,34 +1066,18 @@ http://llvm.org/docs/LangRef.html#llvm-matrix-multiply-intrinsic (vector<64xf64>, vector<48xf64>) -> vector<12xf64> ``` """ -function matrix_multiply( - lhs::Value, - rhs::Value; - res::IR.Type, - lhs_rows, - lhs_columns, - rhs_columns, - location=Location(), -) - results = IR.Type[res,] - operands = Value[lhs, rhs] +function matrix_multiply(lhs::Value, rhs::Value; res::IR.Type, lhs_rows, lhs_columns, rhs_columns, location=Location()) + results = IR.Type[res, ] + operands = Value[lhs, rhs, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("lhs_rows", lhs_rows), - namedattribute("lhs_columns", lhs_columns), - namedattribute("rhs_columns", rhs_columns), - ] - - return IR.create_operation( - "vector.matrix_multiply", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("lhs_rows", lhs_rows), namedattribute("lhs_columns", lhs_columns), namedattribute("rhs_columns", rhs_columns), ] + + IR.create_operation( + "vector.matrix_multiply", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1276,26 +1097,18 @@ int only). vector<4x16xf32> into f32 ``` """ -function multi_reduction( - source::Value; dest::IR.Type, kind, reduction_dims, location=Location() -) - results = IR.Type[dest,] - operands = Value[source,] +function multi_reduction(source::Value; dest::IR.Type, kind, reduction_dims, location=Location()) + results = IR.Type[dest, ] + operands = Value[source, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("kind", kind), namedattribute("reduction_dims", reduction_dims) - ] - - return IR.create_operation( - "vector.multi_reduction", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dims", reduction_dims), ] + + IR.create_operation( + "vector.multi_reduction", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1349,30 +1162,19 @@ return %6: vector<10xf32> ``` """ -function outerproduct( - lhs::Value, - rhs::Value, - acc::Vector{Value}; - result_0::IR.Type, - kind=nothing, - location=Location(), -) - results = IR.Type[result_0,] - operands = Value[lhs, rhs, acc...] +function outerproduct(lhs::Value, rhs::Value, acc::Vector{Value}; result_0::IR.Type, kind=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[lhs, rhs, acc..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) - - return IR.create_operation( - "vector.outerproduct", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.outerproduct", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1402,20 +1204,16 @@ newline). """ function print(source::Value; location=Location()) results = IR.Type[] - operands = Value[source,] + operands = Value[source, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.print", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.print", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1442,24 +1240,18 @@ http://llvm.org/docs/LangRef.html#vector-reduction-intrinsics %4 = vector.reduction \"mul\", %0, %1 : vector<16xf32> into f32 ``` """ -function reduction( - vector::Value, acc::Vector{Value}; dest::IR.Type, kind, location=Location() -) - results = IR.Type[dest,] - operands = Value[vector, acc...] +function reduction(vector::Value, acc::Vector{Value}; dest::IR.Type, kind, location=Location()) + results = IR.Type[dest, ] + operands = Value[vector, acc..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("kind", kind),] - - return IR.create_operation( - "vector.reduction", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("kind", kind), ] + + IR.create_operation( + "vector.reduction", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1547,30 +1339,19 @@ Example [n, o, p, q], [r, -, -, -]]] """ -function reshape( - vector::Value, - input_shape::Vector{Value}, - output_shape::Vector{Value}; - result::IR.Type, - fixed_vector_sizes, - location=Location(), -) - results = IR.Type[result,] - operands = Value[vector, input_shape..., output_shape...] +function reshape(vector::Value, input_shape::Vector{Value}, output_shape::Vector{Value}; result::IR.Type, fixed_vector_sizes, location=Location()) + results = IR.Type[result, ] + operands = Value[vector, input_shape..., output_shape..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("fixed_vector_sizes", fixed_vector_sizes),] - push!(attributes, operandsegmentsizes([1, length(input_shape), length(output_shape)])) - - return IR.create_operation( - "vector.reshape", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("fixed_vector_sizes", fixed_vector_sizes), ] + push!(attributes, operandsegmentsizes([1, length(input_shape), length(output_shape), ])) + + IR.create_operation( + "vector.reshape", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1591,35 +1372,18 @@ reduction in the scan. vector<4x8x16x32xf32>, vector<4x16x32xf32> ``` """ -function scan( - source::Value, - initial_value::Value; - dest::IR.Type, - accumulated_value::IR.Type, - kind, - reduction_dim, - inclusive, - location=Location(), -) - results = IR.Type[dest, accumulated_value] - operands = Value[source, initial_value] +function scan(source::Value, initial_value::Value; dest::IR.Type, accumulated_value::IR.Type, kind, reduction_dim, inclusive, location=Location()) + results = IR.Type[dest, accumulated_value, ] + operands = Value[source, initial_value, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[ - namedattribute("kind", kind), - namedattribute("reduction_dim", reduction_dim), - namedattribute("inclusive", inclusive), - ] - - return IR.create_operation( - "vector.scan", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dim", reduction_dim), namedattribute("inclusive", inclusive), ] + + IR.create_operation( + "vector.scan", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1656,29 +1420,18 @@ vector.scatter %base[%i, %j][%v], %mask, %value : memref<16x16xf32>, vector<16xi32>, vector<16xi1>, vector<16xf32> ``` """ -function scatter( - base::Value, - indices::Vector{Value}, - index_vec::Value, - mask::Value, - valueToStore::Value; - location=Location(), -) +function scatter(base::Value, indices::Vector{Value}, index_vec::Value, mask::Value, valueToStore::Value; location=Location()) results = IR.Type[] - operands = Value[base, indices..., index_vec, mask, valueToStore] + operands = Value[base, indices..., index_vec, mask, valueToStore, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.scatter", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.scatter", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1718,21 +1471,17 @@ is supported in that particular case, for now. ``` """ function shape_cast(source::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[source,] + results = IR.Type[result, ] + operands = Value[source, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.shape_cast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.shape_cast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1768,21 +1517,17 @@ according to the given mask. The legality rules are: ``` """ function shuffle(v1::Value, v2::Value; vector::IR.Type, mask, location=Location()) - results = IR.Type[vector,] - operands = Value[v1, v2] + results = IR.Type[vector, ] + operands = Value[v1, v2, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("mask", mask),] - - return IR.create_operation( - "vector.shuffle", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("mask", mask), ] + + IR.create_operation( + "vector.shuffle", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -1840,24 +1585,18 @@ Example 6: Explicit out-of-bounds vector store. vector.store %valueToStore, %memref[%c0] : memref<7xf32>, vector<8xf32> ``` """ -function store( - valueToStore::Value, base::Value, indices::Vector{Value}; location=Location() -) +function store(valueToStore::Value, base::Value, indices::Vector{Value}; location=Location()) results = IR.Type[] - operands = Value[valueToStore, base, indices...] + operands = Value[valueToStore, base, indices..., ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.store", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.store", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2021,36 +1760,21 @@ for %i0 = 0 to %0 { tensor, vector<1xf32> ``` """ -function transfer_read( - source::Value, - indices::Vector{Value}, - padding::Value, - mask=nothing::Union{Nothing,Value}; - vector::IR.Type, - permutation_map, - in_bounds=nothing, - location=Location(), -) - results = IR.Type[vector,] - operands = Value[source, indices..., padding] +function transfer_read(source::Value, indices::Vector{Value}, padding::Value, mask=nothing::Union{Nothing, Value}; vector::IR.Type, permutation_map, in_bounds=nothing, location=Location()) + results = IR.Type[vector, ] + operands = Value[source, indices..., padding, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("permutation_map", permutation_map),] + attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] !isnothing(mask) && push!(operands, mask) - push!( - attributes, operandsegmentsizes([1, length(indices), 1, (mask == nothing) ? 0 : 1]) - ) + push!(attributes, operandsegmentsizes([1, length(indices), 1, (mask==nothing) ? 0 : 1])) !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) - - return IR.create_operation( - "vector.transfer_read", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.transfer_read", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2144,37 +1868,22 @@ vector.transfer_write %4, %arg1[%c3, %c3] vector<1xf32>, tensor ``` """ -function transfer_write( - vector::Value, - source::Value, - indices::Vector{Value}, - mask=nothing::Union{Nothing,Value}; - result=nothing::Union{Nothing,IR.Type}, - permutation_map, - in_bounds=nothing, - location=Location(), -) +function transfer_write(vector::Value, source::Value, indices::Vector{Value}, mask=nothing::Union{Nothing, Value}; result=nothing::Union{Nothing, IR.Type}, permutation_map, in_bounds=nothing, location=Location()) results = IR.Type[] - operands = Value[vector, source, indices...] + operands = Value[vector, source, indices..., ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("permutation_map", permutation_map),] + attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] !isnothing(mask) && push!(operands, mask) - push!( - attributes, operandsegmentsizes([1, 1, length(indices), (mask == nothing) ? 0 : 1]) - ) + push!(attributes, operandsegmentsizes([1, 1, length(indices), (mask==nothing) ? 0 : 1])) !isnothing(result) && push!(results, result) !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) - - return IR.create_operation( - "vector.transfer_write", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.transfer_write", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2204,21 +1913,17 @@ the transp array [i_1, .., i_n] must be a permutation of [0, .., n-1]. ``` """ function transpose(vector::Value; result::IR.Type, transp, location=Location()) - results = IR.Type[result,] - operands = Value[vector,] + results = IR.Type[result, ] + operands = Value[vector, ] owned_regions = Region[] successors = Block[] - attributes = NamedAttribute[namedattribute("transp", transp),] - - return IR.create_operation( - "vector.transpose", - location; - operands, - owned_regions, - successors, - attributes, + attributes = NamedAttribute[namedattribute("transp", transp), ] + + IR.create_operation( + "vector.transpose", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -2245,21 +1950,17 @@ operation ::= `vector.type_cast` ssa-use : memref-type to memref-type ``` """ function type_cast(memref::Value; result::IR.Type, location=Location()) - results = IR.Type[result,] - operands = Value[memref,] + results = IR.Type[result, ] + operands = Value[memref, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "vector.type_cast", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "vector.type_cast", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end diff --git a/src/Dialects/14/X86Vector.jl b/src/Dialects/14/X86Vector.jl index 46ebe6eb..f6792ec2 100644 --- a/src/Dialects/14/X86Vector.jl +++ b/src/Dialects/14/X86Vector.jl @@ -1,33 +1,26 @@ module x86vector -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes -import ...API + """ `avx_intr_dp_ps_256` """ -function avx_intr_dp_ps_256( - a::Value, b::Value, c::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function avx_intr_dp_ps_256(a::Value, b::Value, c::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b, c] + operands = Value[a, b, c, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "x86vector.avx.intr.dp.ps.256", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx.intr.dp.ps.256", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -49,25 +42,19 @@ dot product of the two source vectors. %d = arith.addf %1, %2 : f32 ``` """ -function avx_intr_dot( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function avx_intr_dot(a::Value, b::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, b] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "x86vector.avx.intr.dot", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx.intr.dot", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -75,25 +62,19 @@ end `avx512_intr_mask_compress` """ -function avx512_intr_mask_compress( - a::Value, src::Value, k::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function avx512_intr_mask_compress(a::Value, src::Value, k::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a, src, k] + operands = Value[a, src, k, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "x86vector.avx512.intr.mask.compress", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx512.intr.mask.compress", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -112,33 +93,21 @@ Contiguously store the active integer/floating-point elements in `a` (those with their respective bit set in writemask `k`) to `dst`, and pass through the remaining elements from `src`. """ -function avx512_mask_compress( - k::Value, - a::Value, - src=nothing::Union{Nothing,Value}; - dst=nothing::Union{Nothing,IR.Type}, - constant_src=nothing, - location=Location(), -) +function avx512_mask_compress(k::Value, a::Value, src=nothing::Union{Nothing, Value}; dst=nothing::Union{Nothing, IR.Type}, constant_src=nothing, location=Location()) results = IR.Type[] - operands = Value[k, a] + operands = Value[k, a, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(src) && push!(operands, src) !isnothing(dst) && push!(results, dst) - !isnothing(constant_src) && - push!(attributes, namedattribute("constant_src", constant_src)) - - return IR.create_operation( - "x86vector.avx512.mask.compress", - location; - operands, - owned_regions, - successors, - attributes, + !isnothing(constant_src) && push!(attributes, namedattribute("constant_src", constant_src)) + + IR.create_operation( + "x86vector.avx512.mask.compress", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -156,31 +125,19 @@ Round packed floating-point elements in `a` to the number of fraction bits specified by `imm`, and store the results in `dst` using writemask `k` (elements are copied from src when the corresponding mask bit is not set). """ -function avx512_mask_rndscale( - src::Value, - k::Value, - a::Value, - imm::Value, - rounding::Value; - dst=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function avx512_mask_rndscale(src::Value, k::Value, a::Value, imm::Value, rounding::Value; dst=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[src, k, a, imm, rounding] + operands = Value[src, k, a, imm, rounding, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(dst) && push!(results, dst) - - return IR.create_operation( - "x86vector.avx512.mask.rndscale", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx512.mask.rndscale", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -188,31 +145,19 @@ end `avx512_intr_mask_rndscale_pd_512` """ -function avx512_intr_mask_rndscale_pd_512( - src::Value, - k::Value, - a::Value, - imm::Value, - rounding::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function avx512_intr_mask_rndscale_pd_512(src::Value, k::Value, a::Value, imm::Value, rounding::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[src, k, a, imm, rounding] + operands = Value[src, k, a, imm, rounding, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "x86vector.avx512.intr.mask.rndscale.pd.512", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx512.intr.mask.rndscale.pd.512", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -220,31 +165,19 @@ end `avx512_intr_mask_rndscale_ps_512` """ -function avx512_intr_mask_rndscale_ps_512( - src::Value, - k::Value, - a::Value, - imm::Value, - rounding::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function avx512_intr_mask_rndscale_ps_512(src::Value, k::Value, a::Value, imm::Value, rounding::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[src, k, a, imm, rounding] + operands = Value[src, k, a, imm, rounding, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "x86vector.avx512.intr.mask.rndscale.ps.512", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx512.intr.mask.rndscale.ps.512", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -262,31 +195,19 @@ Scale the packed floating-point elements in `a` using values from `b`, and store the results in `dst` using writemask `k` (elements are copied from src when the corresponding mask bit is not set). """ -function avx512_mask_scalef( - src::Value, - a::Value, - b::Value, - k::Value, - rounding::Value; - dst=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function avx512_mask_scalef(src::Value, a::Value, b::Value, k::Value, rounding::Value; dst=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[src, a, b, k, rounding] + operands = Value[src, a, b, k, rounding, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(dst) && push!(results, dst) - - return IR.create_operation( - "x86vector.avx512.mask.scalef", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx512.mask.scalef", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -294,31 +215,19 @@ end `avx512_intr_mask_scalef_pd_512` """ -function avx512_intr_mask_scalef_pd_512( - src::Value, - a::Value, - b::Value, - k::Value, - rounding::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function avx512_intr_mask_scalef_pd_512(src::Value, a::Value, b::Value, k::Value, rounding::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[src, a, b, k, rounding] + operands = Value[src, a, b, k, rounding, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "x86vector.avx512.intr.mask.scalef.pd.512", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx512.intr.mask.scalef.pd.512", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -326,31 +235,19 @@ end `avx512_intr_mask_scalef_ps_512` """ -function avx512_intr_mask_scalef_ps_512( - src::Value, - a::Value, - b::Value, - k::Value, - rounding::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) +function avx512_intr_mask_scalef_ps_512(src::Value, a::Value, b::Value, k::Value, rounding::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[src, a, b, k, rounding] + operands = Value[src, a, b, k, rounding, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "x86vector.avx512.intr.mask.scalef.ps.512", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx512.intr.mask.scalef.ps.512", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -358,25 +255,19 @@ end `avx_intr_rsqrt_ps_256` """ -function avx_intr_rsqrt_ps_256( - a::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) +function avx_intr_rsqrt_ps_256(a::Value; res=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a,] + operands = Value[a, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(res) && push!(results, res) - - return IR.create_operation( - "x86vector.avx.intr.rsqrt.ps.256", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx.intr.rsqrt.ps.256", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -384,23 +275,19 @@ end `avx_rsqrt` """ -function avx_rsqrt(a::Value; b=nothing::Union{Nothing,IR.Type}, location=Location()) +function avx_rsqrt(a::Value; b=nothing::Union{Nothing, IR.Type}, location=Location()) results = IR.Type[] - operands = Value[a,] + operands = Value[a, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] !isnothing(b) && push!(results, b) - - return IR.create_operation( - "x86vector.avx.rsqrt", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx.rsqrt", location; + operands, owned_regions, successors, attributes, results=(length(results) == 0 ? nothing : results), - result_inference=(length(results) == 0 ? true : false), + result_inference=(length(results) == 0 ? true : false) ) end @@ -408,24 +295,18 @@ end `avx512_intr_vp2intersect_d_512` """ -function avx512_intr_vp2intersect_d_512( - a::Value, b::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[a, b] +function avx512_intr_vp2intersect_d_512(a::Value, b::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.intr.vp2intersect.d.512", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx512.intr.vp2intersect.d.512", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -445,24 +326,18 @@ specified by `k1` and `k2`. A match in corresponding elements of `a` and `b` is indicated by a set bit in the corresponding bit of the mask registers. """ -function avx512_vp2intersect( - a::Value, b::Value; k1::IR.Type, k2::IR.Type, location=Location() -) - results = IR.Type[k1, k2] - operands = Value[a, b] +function avx512_vp2intersect(a::Value, b::Value; k1::IR.Type, k2::IR.Type, location=Location()) + results = IR.Type[k1, k2, ] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.vp2intersect", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx512.vp2intersect", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end @@ -470,24 +345,18 @@ end `avx512_intr_vp2intersect_q_512` """ -function avx512_intr_vp2intersect_q_512( - a::Value, b::Value; res::IR.Type, location=Location() -) - results = IR.Type[res,] - operands = Value[a, b] +function avx512_intr_vp2intersect_q_512(a::Value, b::Value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[a, b, ] owned_regions = Region[] successors = Block[] attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.intr.vp2intersect.q.512", - location; - operands, - owned_regions, - successors, - attributes, + + IR.create_operation( + "x86vector.avx512.intr.vp2intersect.q.512", location; + operands, owned_regions, successors, attributes, results=results, - result_inference=false, + result_inference=false ) end