diff --git a/Project.toml b/Project.toml index 8048fe4e..17869ec6 100644 --- a/Project.toml +++ b/Project.toml @@ -6,12 +6,16 @@ version = "0.1.0" CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" MLIR_jll = "a70bccb4-a5c0-5e2e-a329-e731972457e8" +MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" Preferences = "21216c6a-2e73-6563-6e65-726566657250" ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63" +TaskLocalValues = "ed4db957-447d-4319-bfb6-7fa9ae7ecf34" [compat] CEnum = "0.4" -MLIR_jll = "14,15,16,17,18" +MLIR_jll = "14,15,16,17" +MacroTools = "0.5.13" Preferences = "1" ScopedValues = "1" +TaskLocalValues = "0.1.1" julia = "1.9" diff --git a/deps/tblgen/jl-generators.cc b/deps/tblgen/jl-generators.cc index 75f5d502..f66c28ce 100644 --- a/deps/tblgen/jl-generators.cc +++ b/deps/tblgen/jl-generators.cc @@ -176,12 +176,12 @@ bool emitOpTableDefs(const llvm::RecordKeeper &recordKeeper, const char *imports; if (isExternal) { - imports = R"(import MLIR.IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType + imports = R"(import MLIR.IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import MLIR.Dialects: namedattribute, operandsegmentsizes)"; } else { - imports = R"(import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType + imports = R"(import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes)"; } @@ -268,23 +268,15 @@ end } operandname = sanitizeName(operandname); - std::string type = "Value"; - bool optional = named_operand.isOptional(); bool variadic = named_operand.isVariadic(); - if (variadic) - { - type = "Vector{" + type + "}"; - } - std::string separator = ", "; if (optional) { - optionals += llvm::formatv(R"(!isnothing({0}) && push!(_operands, {0}{1}) + optionals += llvm::formatv(R"(!isnothing({0}) && push!(operands, value{2}({0}){1}) )", - operandname, (variadic ? "..." : "")); - type = "Union{Nothing, " + type + "}"; + operandname, (variadic ? "..." : ""), (variadic ? "." : "")); defaultvalue = "=nothing"; if (!alreadykeyword) { @@ -294,11 +286,11 @@ end } else { - operandcontainer += operandname + (variadic ? "..." : "") + ", "; + operandcontainer += llvm::formatv(R"(value{0}({1}){2}, )", (variadic ? "." : ""), operandname, (variadic ? "..." : "")); separator = (!alreadykeyword && i == op.getNumOperands() - 1) ? "; " : ", "; } - operandarguments += operandname + defaultvalue + "::" + type + separator; + operandarguments += operandname + defaultvalue + separator; } if (operandarguments == "") { operandarguments = "; "; diff --git a/examples/generate/definitions.jl b/examples/generate/definitions.jl new file mode 100644 index 00000000..b0f90065 --- /dev/null +++ b/examples/generate/definitions.jl @@ -0,0 +1,190 @@ +# EXCLUDE FROM TESTING + +import MLIR.IR +using MLIR.IR: Value, Attribute, result, Operation, Convertible, context, IndexType, ValueTrait +import MLIR.Dialects +using MLIR.API: mlirMemRefTypeGet, mlirStridedLayoutAttrGet, mlirRankedTensorTypeGet, mlirIntegerTypeGet, mlirShapedTypeGetDynamicSize, mlirF64TypeGet, mlirF32TypeGet, mlirF16TypeGet +import MLIR.Generate +import MLIR.Generate: @intrinsic, BoolTrait + +### int ### +struct MLIRInteger{N} <: Integer + value::Value + MLIRInteger{N}(i::Value) where {N} = new(i) +end +ValueTrait(::Type{<:MLIRInteger}) = Convertible() +IR.Type(::Type{MLIRInteger{N}}) where {N} = IR.Type(mlirIntegerTypeGet(context(), N)) + +const i1 = MLIRInteger{1} +BoolTrait(::Type{i1}) = Generate.Boollike() + +const i8 = MLIRInteger{8} +const i16 = MLIRInteger{16} +const i32 = MLIRInteger{32} +const i64 = MLIRInteger{64} + +@intrinsic Base.:+(a::T, b::T) where {T<:MLIRInteger} = T(Dialects.arith.addi(a, b)|>result) +@intrinsic Base.:-(a::T, b::T) where {T<:MLIRInteger} = T(Dialects.arith.subi(a, b)|>result) +@intrinsic Base.:*(a::T, b::T) where {T<:MLIRInteger} = T(Dialects.arith.muli(a, b)|>result) +@intrinsic Base.:/(a::T, b::T) where {T<:MLIRInteger} = T(Dialects.arith.divi(a, b)|>result) + +@intrinsic Base.:>(a::T, b::T) where {T<:MLIRInteger} = i1(Dialects.arith.cmpi(a, b, result=IR.Type(i1), predicate=4)) +@intrinsic Base.:>=(a::T, b::T) where {T<:MLIRInteger} = i1(Dialects.arith.cmpi(a, b, result=IR.Type(i1), predicate=5)) +@intrinsic Base.:<(a::T, b::T) where {T<:MLIRInteger} = i1(Dialects.arith.cmpi(a, b, result=IR.Type(i1), predicate=2)) +@intrinsic Base.:<=(a::T, b::T) where {T<:MLIRInteger} = i1(Dialects.arith.cmpi(a, b, result=IR.Type(i1), predicate=3)) + + +# promote constant julia integers to int +@intrinsic i64(x::Integer) = i64(Dialects.arith.constant(value=Attribute(Int64(x)), result=IR.Type(i64))|>result) +@intrinsic i32(x::Integer) = i32(Dialects.arith.constant(value=Attribute(Int32(x)), result=IR.Type(i32))|>result) +@intrinsic i16(x::Integer) = i16(Dialects.arith.constant(value=Attribute(Int16(x)), result=IR.Type(i16))|>result) +@intrinsic i8(x::Integer) = i8(Dialects.arith.constant(value=Attribute(Int8(x)), result=IR.Type(i8))|>result) + +Base.promote_rule(::Type{T}, ::Type{I}) where {T<:MLIRInteger, I<:Integer} = T +Base.convert(::Type{T}, x::T) where {T <: MLIRInteger} = x +@intrinsic function Base.convert(::Type{T}, x::Integer)::T where {T<:MLIRInteger} + op = Dialects.arith.constant(value=Attribute(x), result=IR.Type(T)) + T(result(op)) +end + +### float ### +abstract type MLIRFloat <: AbstractFloat end +ValueTrait(::Type{<:MLIRFloat}) = Convertible() + +struct MLIRF64 <: MLIRFloat + value::Value +end +struct MLIRF32 <: MLIRFloat + value::Value +end +struct MLIRF16 <: MLIRFloat + value::Value +end + +const f64 = MLIRF64 +const f32 = MLIRF32 +const f16 = MLIRF16 + +IR.Type(::Type{MLIRF64}) = IR.Type(mlirF64TypeGet(context())) +IR.Type(::Type{MLIRF32}) = IR.Type(mlirF32TypeGet(context())) +IR.Type(::Type{MLIRF16}) = IR.Type(mlirF16TypeGet(context())) + +@intrinsic (Base.:+(a::T, b::T)::T) where {T<:MLIRFloat} = T(Dialects.arith.addf(a, b)|>result) +@intrinsic (Base.:-(a::T, b::T)::T) where {T<:MLIRFloat} = T(Dialects.arith.subf(a, b)|>result) +@intrinsic (Base.:*(a::T, b::T)::T) where {T<:MLIRFloat} = T(Dialects.arith.mulf(a, b)|>result) +@intrinsic (Base.:/(a::T, b::T)::T) where {T<:MLIRFloat} = T(Dialects.arith.divf(a, b)|>result) + +# TODO: +# @intrinsic Base.:>(a::T, b::T)::i1 where {T<:MLIRFloat} = i1(Dialects.arith.cmpf(a, b, predicate=...)) +# @intrinsic Base.:>=(a::T, b::T)::i1 where {T<:MLIRFloat} = i1(Dialects.arith.cmpf(a, b, predicate=...)) +# @intrinsic Base.:<(a::T, b::T)::i1 where {T<:MLIRFloat} = i1(Dialects.arith.cmpf(a, b, predicate=...)) +# @intrinsic Base.:<=(a::T, b::T)::i1 where {T<:MLIRFloat} = i1(Dialects.arith.cmpf(a, b, predicate=...)) + +f32(x::f32) = x +@intrinsic f32(x::Real) = f32(Dialects.arith.constant(value=IR.Attribute(Float32(x)), result=IR.Type(f32)) |> result) +Base.convert(::Type{f32}, x::Real) = f32(x) +Base.promote_rule(::Type{f32}, ::Type{<:Real}) = f32 + +### index ### +struct MLIRIndex <: Integer + value::Value +end +const index = MLIRIndex +IR.Type(::Type{MLIRIndex}) = IndexType() +ValueTrait(::Type{<:MLIRIndex}) = Convertible() + +@intrinsic Base.:+(a::index, b::index)::index = index(Dialects.index.add(a, b)|>result) +@intrinsic Base.:-(a::index, b::index)::index = index(Dialects.index.sub(a, b)|>result) +@intrinsic Base.:*(a::index, b::index)::index = index(Dialects.index.mul(a, b)|>result) +@intrinsic Base.:/(a::index, b::index)::index = index(Dialects.index.divs(a, b)|>result) + +# TODO: +# @intrinsic Base.:>(a::index, b::index)::i1 = i1(Dialects.index.cmp(a, b, predicate=...)|>result) +# @intrinsic Base.:>=(a::index, b::index)::i1 = i1(Dialects.index.cmp(a, b, predicate=...)|>result) +# @intrinsic Base.:<(a::index, b::index)::i1 = i1(Dialects.index.cmp(a, b, predicate=...)|>result) +# @intrinsic Base.:<=(a::index, b::index)::i1 = i1(Dialects.index.cmp(a, b, predicate=...)|>result) + +# promote constant julia integers to index +@intrinsic index(x::Integer) = index(Dialects.index.constant(value=Attribute(x, IR.Type(index)), result=IR.Type(index))|>result) +Base.promote_rule(::Type{index}, ::Type{I}) where {I<:Integer} = index +function Base.convert(::Type{index}, x::Integer)::index + index(x) +end + +@intrinsic i64(x::index) = i64(Dialects.index.casts(x, output=IR.Type(i64))|>result) +@intrinsic index(x::i64) = index(Dialects.index.casts(x, output=IR.Type(index))|>result) + +### abstract type for array-like types ### +abstract type MLIRArrayLike{T, N} <: AbstractArray{T, N} end + +ValueTrait(::Type{<:MLIRArrayLike}) = Convertible() +Base.show(io::IO, a::A) where {A<:MLIRArrayLike{T, N}} where {T, N} = print(io, "$A[...]") +Base.show(io::IO, ::MIME{Symbol("text/plain")}, a::A) where {A<:MLIRArrayLike{T, N}} where {T, N} = print(io, "$A[...]") + +### memref ### +struct MLIRMemref{T, N, Shape, Memspace, Stride, Offset} <: MLIRArrayLike{T, N} + value::Value +end +function IR.Type(::Type{MLIRMemref{T, N, Shape, Memspace, Stride, Offset}}) where {T, N, Shape, Memspace, Stride, Offset} + memspace(a::Attribute) = a + memspace(::Nothing) = Attribute() + memspace(i::Integer) = Attribute(i) + + shape(::Nothing) = Int[mlirShapedTypeGetDynamicSize() for _ in 1:N] + shape(s) = Int[s.parameters...] + + # default to column-major layout + stride(::Nothing) = Int[1, [mlirShapedTypeGetDynamicSize() for _ in 2:N]...] + stride(s) = shape(s) + + offset(::Nothing) = mlirShapedTypeGetDynamicSize() + offset(i::Integer) = i + + IR.Type(mlirMemRefTypeGet( + IR.Type(T), + N, + shape(Shape), + Attribute(mlirStridedLayoutAttrGet( + context().context, + offset(Offset), + N, + stride(Stride))), + memspace(Memspace) + )) + +end +const memref{T, N} = MLIRMemref{T, N, nothing, nothing, nothing, 0} + +Base.size(A::MLIRMemref{T, N, Shape}) where {T, N, Shape} = Tuple(Shape.parameters) + +@intrinsic function Base.getindex(A::MLIRMemref{T, 1}, i::index)::T where T + oneoff = Dialects.index.constant(; value=Attribute(1, IndexType())) |> result + new_index = Dialects.index.sub(i, oneoff) |> result + T(Dialects.memref.load(A, [new_index]) |> result) +end +function Base.getindex(A::MLIRMemref{T}, i::Int)::T where T + A[index(i)] +end + +@intrinsic function Base.setindex!(A::MLIRMemref{T, 1}, v::T, i::index)::T where T + oneoff = Dialects.index.constant(; value=Attribute(1, IndexType())) |> result + new_index = Dialects.index.sub(i, oneoff) |> IR.result + Dialects.memref.store(v, A, [new_index]) + return v +end +@intrinsic function Base.setindex!(A::MLIRMemref{T, 1}, v, i::Int)::T where {T} + # this method can only be called with constant i since we assume arguments to `code_mlir` to be MLIR types, not Julia types. + i = index(Dialects.index.constant(; value=Attribute(i, IndexType())) |> result) + A[i] = v +end + +### tensor ### +struct MLIRTensor{T, N} <: MLIRArrayLike{T, N} + value::Value +end +IR.Type(::Type{MLIRTensor{T, N}}) where {T, N} = mlirRankedTensorTypeGet( + N, + Int[mlirShapedTypeGetDynamicSize() for _ in 1:N], + IR.Type(T), + Attribute()) |> IR.Type +const tensor = MLIRTensor diff --git a/examples/generate/main.jl b/examples/generate/main.jl new file mode 100644 index 00000000..b120b252 --- /dev/null +++ b/examples/generate/main.jl @@ -0,0 +1,184 @@ +using Test +@warn "Running MLIR code generation tests. This can take a few minutes." + +# include type and intrinsic function definitions: +include("definitions.jl"); + +import MLIR: IR, Generate, Dialects, API +import MLIR.IR: Value, Operation, result, Convertible, context, ValueTrait + +# administrative duties +function registerAllDialects!() + ctx = IR.context() + registry = API.mlirDialectRegistryCreate() + API.mlirRegisterAllDialects(registry) + API.mlirContextAppendDialectRegistry(ctx, registry) + API.mlirDialectRegistryDestroy(registry) + + API.mlirContextLoadAllAvailableDialects(ctx) + return registry +end +ctx = IR.Context() +registerAllDialects!(); +API.mlirRegisterAllPasses() +API.mlirRegisterAllLLVMTranslations(ctx.context) + +function compare_generated(generated::IR.Module, expected::String) + # Don't directly compare expected with generated. + # Parse first to ensure the same SSA value names are used. + expected = parse(IR.Module, expected) + + expected = string.(IR.OperationIterator(IR.body(expected))) + generated = string.(IR.OperationIterator(IR.body(generated))) + + return Set(expected) == Set(generated) +end + +# A codegen context is used to specify how Julia IR is converted to MLIR. +cg = Generate.CodegenContext() + +f1(a, b) = a+b + +op1 = cg(f1, Tuple{i64,i64}) + +@test compare_generated( + op1, + """ +func.func private @"$(Generate.name(cg, Generate.get_mi(f1, Tuple{i64,i64})))"(%a: i64, %b: i64) -> i64 { + %sum = arith.addi %a, %b : i64 + return %sum : i64 +} +""", +) + +# isbitstype structs can be used as arguments or return types. +# They will be unpacked into their constituent fields that are convertible to MLIR types. +# e.g. a function `Point{i64}` taking and returning a point, will be converted to a MLIR +# function that takes two `i64` arguments and returns two `i64` values. +struct Point{T} + x::T + y::T +end + +struct Line{T} + p1::Point{T} + p2::Point{T} +end + +@noinline sq_distance(l::Line) = (l.p1.x - l.p2.x)^2 + (l.p1.y - l.p2.y)^2 + +function f2(a::Point{i64}, b::Point{i64}) + l = Line(a, b) + d_2 = sq_distance(l) + + Point(((a.x, a.y) .- d_2)...) +end + +@time op2 = cg(f2, Tuple{Point{i64},Point{i64}}) + +# Note the large number of basic blocks generated. +# Simplification passes in MLIR can be used to clean these up. +@test compare_generated( + op2, + """ + func.func private @"$(Generate.name(cg, Generate.get_mi(f2, Tuple{Point{i64},Point{i64}})))"(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> (i64, i64) { + %0 = call @"$(Generate.name(cg, Generate.get_mi(sq_distance, Tuple{Line{i64}})))"(%arg0, %arg1, %arg2, %arg3) : (i64, i64, i64, i64) -> i64 + cf.br ^bb1 + ^bb1: // pred: ^bb0 + cf.br ^bb2 + ^bb2: // pred: ^bb1 + cf.br ^bb3 + ^bb3: // pred: ^bb2 + cf.br ^bb4 + ^bb4: // pred: ^bb3 + cf.br ^bb5 + ^bb5: // pred: ^bb4 + %1 = arith.subi %arg0, %0 : i64 + cf.br ^bb6 + ^bb6: // pred: ^bb5 + cf.br ^bb7 + ^bb7: // pred: ^bb6 + cf.br ^bb8 + ^bb8: // pred: ^bb7 + cf.br ^bb9 + ^bb9: // pred: ^bb8 + cf.br ^bb10 + ^bb10: // pred: ^bb9 + cf.br ^bb11 + ^bb11: // pred: ^bb10 + cf.br ^bb12 + ^bb12: // pred: ^bb11 + %2 = arith.subi %arg1, %0 : i64 + cf.br ^bb13 + ^bb13: // pred: ^bb12 + cf.br ^bb14 + ^bb14: // pred: ^bb13 + cf.br ^bb15 + ^bb15: // pred: ^bb14 + cf.br ^bb16 + ^bb16: // pred: ^bb15 + cf.br ^bb17 + ^bb17: // pred: ^bb16 + return %1, %2 : i64, i64 + } + func.func private @"$(Generate.name(cg, Generate.get_mi(sq_distance, Tuple{Line{i64}})))"(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i64 { + %0 = arith.subi %arg0, %arg2 : i64 + %1 = arith.muli %0, %0 : i64 + %2 = arith.subi %arg1, %arg3 : i64 + %3 = arith.muli %2, %2 : i64 + %4 = arith.addi %1, %3 : i64 + return %4 : i64 + } + """ +) + +# To customize how goto's or return statements are converted to MLIR, we can specialize +# particular methods for a new type. +# In this case, we create a codegen context that will generate `scf.yield` for return +# statements in Julia SSA IR. +# We also change the behaviour of `generate_function` to return the generated region +# instead of wrapping it in a `func.func` operation, as we want to nest it inside a +# `scf.for` operation. +import MLIR.Generate: generate_return, generate_function, aggregate_funcs +abstract type LoopBody end +function generate_return(cg::Generate.CodegenContext{LoopBody}, values; location) + return Dialects.scf.yield(values) +end +generate_function(cg::Generate.CodegenContext{LoopBody}, argtypes, rettypes, reg; kwargs...) = reg +aggregate_funcs(cg::Generate.CodegenContext{LoopBody}, funcs) = only(funcs) + +# This intrinsic function creates an operation containing a region. +# The region body is generated by the `body` function, which is passed the intrinsic function +# as an argument. +Generate.@intrinsic function scf_for( + body, initial_value::T, start::index, stop::index, step::index +) where {T} + region = Generate.CodegenContext{LoopBody}()(body, Tuple{index,T}) + op = Dialects.scf.for_( + start, stop, step, [initial_value]; results_=IR.Type[IR.Type(T)], region + ) + return T(IR.result(op)) +end + +function f3(N) + val = i64(0) + scf_for(val, index(0), N, index(1)) do i, val + val + i64(i) + end +end + +op3 = cg(f3, Tuple{index}) + +@test compare_generated(op3, """ + func.func private @"$(Generate.name(cg, Generate.get_mi(f3, Tuple{index})))"(%arg0: index) -> i64 { + %c0_i64 = arith.constant 0 : i64 + %idx0 = index.constant 0 + %idx1 = index.constant 1 + %0 = scf.for %arg1 = %idx0 to %arg0 step %idx1 iter_args(%arg2 = %c0_i64) -> (i64) { + %1 = index.casts %arg1 : index to i64 + %2 = arith.addi %arg2, %1 : i64 + scf.yield %2 : i64 + } + return %0 : i64 + } +""") diff --git a/src/Dialects/14/AMX.jl b/src/Dialects/14/AMX.jl index 4df6ab3e..67b68f6a 100644 --- a/src/Dialects/14/AMX.jl +++ b/src/Dialects/14/AMX.jl @@ -1,38 +1,24 @@ module amx -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbf16ps", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbf16ps(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbf16ps", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -40,31 +26,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbssd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbssd(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbssd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -72,31 +45,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbsud", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbsud(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbsud", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -104,31 +64,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbusd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbusd(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbusd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -136,31 +83,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbuud", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbuud(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbuud", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -168,29 +102,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tileloadd64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tileloadd64(operand_0, operand_1, operand_2, operand_3; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tileloadd64", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -198,29 +121,18 @@ end `tilestored64` """ -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tilestored64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tilestored64(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tilestored64", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -228,22 +140,18 @@ end `tilezero` """ -function tilezero(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( - "amx.tilezero", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tilezero(operand_0, operand_1; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tilezero", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -261,22 +169,18 @@ corresponding tile configuration. %0 = amx.tile_load %arg0[%c0, %c0] : memref into vector<16x64xi8> ``` """ -function tile_load(base::Value, indices::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_load(base, indices; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -295,22 +199,18 @@ pairs of \"bf16\"). The operation is eventually lowered into the : vector<16x32xbf16>, vector<16x32xbf16>, vector<16x16xf32> ``` """ -function tile_mulf(lhs::Value, rhs::Value, acc::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_mulf(lhs, rhs, acc; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_mulf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -332,32 +232,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_muli(lhs, rhs, acc; res::IR.Type, isZextLhs=nothing, isZextRhs=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(isZextLhs) && push!(attributes, namedattribute("isZextLhs", isZextLhs)) + !isnothing(isZextRhs) && push!(attributes, namedattribute("isZextRhs", isZextRhs)) + + IR.create_operation( + "amx.tile_muli", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -375,22 +263,18 @@ corresponding tile configuration. amx.tile_store %arg1[%c0, %c0], %0 : memref, vector<16x64xi8> ``` """ -function tile_store(base::Value, indices::Vector{Value}, val::Value; location=Location()) - _results = IR.Type[] - _operands = Value[base, indices..., val] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_store(base, indices, val; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(val), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/Affine.jl b/src/Dialects/14/Affine.jl index 504fad04..2a5744c0 100644 --- a/src/Dialects/14/Affine.jl +++ b/src/Dialects/14/Affine.jl @@ -1,7 +1,6 @@ module affine -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -26,22 +25,18 @@ have ‘index’ type. %2 = affine.apply affine_map<(i)[s0] -> (i+s0)> (%42)[%n] ``` """ -function apply(mapOperands::Vector{Value}; result_0::IR.Type, map, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply(mapOperands; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(mapOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.apply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -152,24 +147,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function for_(operand_0; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -243,28 +232,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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.if", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function if_(operand_0; results_::Vector{IR.Type}, thenRegion::Region, elseRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[thenRegion, elseRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -290,22 +269,18 @@ Example 2: Uses \'symbol\' keyword for symbols \'%n\' and \'%m\'. %1 = affine.load %0[%i0 + symbol(%n), %i1 + symbol(%m)] : memref<100x100xf32> ``` """ -function 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.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(memref, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -321,22 +296,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map", map),] - - return IR.create_operation( - "affine.max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function max(operands_; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -362,22 +333,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map", map),] - - return IR.create_operation( - "affine.min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function min(operands_; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -446,40 +413,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(mapOperands; results_::Vector{IR.Type}, reductions, lowerBoundsMap, lowerBoundsGroups, upperBoundsMap, upperBoundsGroups, steps, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[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), ] + + IR.create_operation( + "affine.parallel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -501,33 +446,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function prefetch(memref, indices; isWrite, localityHint, isDataCache, location=Location()) + results = IR.Type[] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -553,22 +483,18 @@ Example 2: Uses \'symbol\' keyword for symbols \'%n\' and \'%m\'. 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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, memref, indices; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -611,24 +537,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.vector_load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vector_load(memref, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.vector_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -673,24 +593,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() -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.vector_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vector_store(value, memref, indices; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.vector_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -708,22 +622,18 @@ Otherwise, it has to be present in the syntax to indicate which values are yielded. ``` """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/Arithmetic.jl b/src/Dialects/14/Arithmetic.jl index e974eca4..379a3999 100644 --- a/src/Dialects/14/Arithmetic.jl +++ b/src/Dialects/14/Arithmetic.jl @@ -1,7 +1,6 @@ module arith -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -28,25 +27,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.addf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function addf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.addf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -71,25 +64,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.addi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function addi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.addi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -114,25 +101,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.andi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function andi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.andi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -154,22 +135,18 @@ endianness for the source and target types (e.g. float is big-endian and 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -188,25 +165,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ceildivsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ceildivsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -227,25 +198,19 @@ behavior. %a = arith.ceildivui %b, %c : i64 ``` """ -function ceildivui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ceildivui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ceildivui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -276,22 +241,18 @@ attribute by the parser. %r3 = \"arith.cmpf\"(%0, %1) {predicate: 0} : (f8, f8) -> i1 ``` """ -function cmpf(lhs::Value, rhs::Value; result::IR.Type, predicate, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cmpf(lhs, rhs; result::IR.Type, predicate, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "arith.cmpf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -360,22 +321,18 @@ complement or large positives : (vector<4xi64>, vector<4xi64>) -> vector<4xi1> ``` """ -function cmpi(lhs::Value, rhs::Value; result::IR.Type, predicate, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cmpi(lhs, rhs; result::IR.Type, predicate, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "arith.cmpi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -419,25 +376,19 @@ end `divf` """ -function divf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.divf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.divf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -463,25 +414,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.divsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.divsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -508,25 +453,19 @@ behavior. %x = arith.divui %y, %z : tensor<4x?xi8> ``` """ -function divui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.divui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.divui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -537,22 +476,18 @@ Cast a floating-point value to a larger floating-point-typed value. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extf(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -576,22 +511,18 @@ of the most-significant bit of the input. %5 = arith.extsi %0 : vector<2 x i32> to vector<2 x i64> ``` """ -function extsi(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extsi(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extsi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -614,22 +545,18 @@ The top-most (N - M) bits of the output are filled with zeros. %5 = arith.extui %0 : vector<2 x i32> to vector<2 x i64> ``` """ -function extui(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extui(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -640,22 +567,18 @@ Cast from a value interpreted as floating-point to the nearest (rounding 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.fptosi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptosi(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.fptosi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -666,22 +589,18 @@ Cast from a value interpreted as floating-point to the nearest (rounding 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.fptoui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptoui(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.fptoui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -701,25 +620,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.floordivsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function floordivsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.floordivsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -731,22 +644,18 @@ vectors. Index is an integer of platform-specific bit width. If casting to 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.index_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function index_cast(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.index_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -769,25 +678,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.maxf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.maxf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -795,25 +698,19 @@ end `maxsi` """ -function maxsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.maxsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.maxsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -821,25 +718,19 @@ end `maxui` """ -function maxui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.maxui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.maxui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -862,25 +753,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.minf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.minf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -888,25 +773,19 @@ end `minsi` """ -function minsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.minsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.minsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -914,25 +793,19 @@ end `minui` """ -function minui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.minui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.minui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -960,25 +833,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.mulf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mulf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.mulf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -986,25 +853,19 @@ end `muli` """ -function muli( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.muli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function muli(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.muli", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1029,23 +890,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.negf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function negf(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.negf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1070,25 +927,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ori", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ori(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ori", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1096,25 +947,19 @@ end `remf` """ -function remf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.remf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.remf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1140,25 +985,19 @@ behavior. %x = arith.remsi %y, %z : tensor<4x?xi8> ``` """ -function remsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.remsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.remsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1184,25 +1023,19 @@ behavior. %x = arith.remui %y, %z : tensor<4x?xi8> ``` """ -function remui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.remui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.remui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1214,22 +1047,18 @@ floating-point value. If the value cannot be exactly represented, it is 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.sitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sitofp(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.sitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1247,25 +1076,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shli(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shli", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1287,25 +1110,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shrsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shrsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shrsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1324,25 +1141,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shrui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shrui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shrui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1370,25 +1181,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.subf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.subf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1396,25 +1201,19 @@ end `subi` """ -function subi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.subi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.subi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1426,22 +1225,18 @@ The destination type must be strictly narrower than the source type. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.truncf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function truncf(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.truncf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1463,22 +1258,18 @@ The top-most (N - M) bits of the input are discarded. %5 = arith.trunci %0 : vector<2 x i32> to vector<2 x i16> ``` """ -function trunci(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.trunci", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function trunci(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.trunci", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1490,22 +1281,18 @@ floating-point value. If the value cannot be exactly represented, it is 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.uitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function uitofp(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.uitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1530,25 +1317,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.xori", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function xori(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.xori", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/14/ArmNeon.jl b/src/Dialects/14/ArmNeon.jl index d7f5eb0b..53a93149 100644 --- a/src/Dialects/14/ArmNeon.jl +++ b/src/Dialects/14/ArmNeon.jl @@ -1,7 +1,6 @@ module arm_neon -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -15,22 +14,18 @@ vector to the destination SIMD&FP register. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.intr.smull", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_smull(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.intr.smull", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -46,22 +41,18 @@ corresponding entry of `a`: 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.2d.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function _2d_sdot(a, b, c; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.2d.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -75,22 +66,18 @@ where vector operands are partitioned into groups of four elements. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.intr.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdot(a, b, c; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.intr.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/ArmSVE.jl b/src/Dialects/14/ArmSVE.jl index 3dee6dd7..9b6f7da5 100644 --- a/src/Dialects/14/ArmSVE.jl +++ b/src/Dialects/14/ArmSVE.jl @@ -1,31 +1,24 @@ module arm_sve -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fadd(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fadd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -36,24 +29,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.addf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_addf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.addf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -61,24 +48,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_add(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.add", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -89,24 +70,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.addi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_addi(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.addi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -114,24 +89,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fdiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fdiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -142,24 +111,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -167,24 +130,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fmul(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -195,24 +152,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.mulf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_mulf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.mulf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -220,24 +171,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_mul(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.mul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -248,24 +193,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.muli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_muli(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.muli", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -273,24 +212,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sdiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -301,24 +234,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divi_signed", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divi_signed(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divi_signed", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -326,24 +253,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fsub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fsub(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fsub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -354,24 +275,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.subf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_subf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.subf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -379,24 +294,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sub(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -407,24 +316,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.subi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_subi(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.subi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -432,24 +335,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.udiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_udiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.udiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -460,24 +357,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divi_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divi_unsigned(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divi_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -485,24 +376,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdot(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -520,22 +405,18 @@ to the overlapping element of the first vector input. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sdot(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -543,24 +424,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.smmla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_smmla(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.smmla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -581,22 +456,18 @@ the result to the first input using modular arithmetic. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.smmla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function smmla(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.smmla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -604,24 +475,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.udot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_udot(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.udot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -639,22 +504,18 @@ to the overlapping element of the first vector input. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.udot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function udot(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.udot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -662,24 +523,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.ummla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ummla(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.ummla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -700,22 +555,18 @@ the result to the first input using modular arithmetic. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.ummla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ummla(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.ummla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/Async.jl b/src/Dialects/14/Async.jl index 180f463d..6c252911 100644 --- a/src/Dialects/14/Async.jl +++ b/src/Dialects/14/Async.jl @@ -1,7 +1,6 @@ module async -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -19,25 +18,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add_to_group(operand, group; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(group), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + 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) ) end @@ -61,22 +54,18 @@ group become ready. async.await_all %0 ``` """ -function await_all(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.await_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function await_all(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.await_all", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -96,23 +85,19 @@ async.await %0 : !async.token %2 = async.await %1 : !async.value ``` """ -function await(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "async.await", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function await(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "async.await", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -122,23 +107,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()) - _results = IR.Type[] - _operands = Value[id,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(handle) && push!(_results, handle) - - return IR.create_operation( - "async.coro.begin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function coro_begin(id; handle=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(id), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(handle) && push!(results, handle) + + 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) ) end @@ -149,22 +130,18 @@ The `async.coro.end` marks the point where a coroutine needs to return control back to the caller if it is not an initial invocation of the 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.end", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_end(handle; location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.end", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -174,22 +151,18 @@ end The `async.coro.free` deallocates the coroutine frame created by the async.coro.begin operation. """ -function coro_free(id::Value, handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[id, handle] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.free", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_free(id, handle; location=Location()) + results = IR.Type[] + operands = Value[value(id), value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.free", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -223,25 +196,19 @@ end The `async.coro.saves` saves the coroutine state. """ -function coro_save( - handle::Value; state=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(state) && push!(_results, state) - - return IR.create_operation( - "async.coro.save", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function coro_save(handle; state=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(state) && push!(results, state) + + 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) ) end @@ -257,28 +224,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(), -) - _results = IR.Type[] - _operands = Value[state,] - _owned_regions = Region[] - _successors = Block[suspendDest, resumeDest, cleanupDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.suspend", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_suspend(state; suspendDest::Block, resumeDest::Block, cleanupDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(state), ] + owned_regions = Region[] + successors = Block[suspendDest, resumeDest, cleanupDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.suspend", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -299,25 +256,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() -) - _results = IR.Type[] - _operands = Value[size,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "async.create_group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function create_group(size; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(size), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -362,30 +313,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dependencies), length(operands)])) - - return IR.create_operation( - "async.execute", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function execute(dependencies, operands_; token::IR.Type, results_::Vector{IR.Type}, body::Region, location=Location()) + results = IR.Type[token, results_..., ] + operands = Value[value.(dependencies)..., value.(operands_)..., ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dependencies), length(operands), ])) + + IR.create_operation( + "async.execute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -395,22 +335,18 @@ end The `async.runtime.add_ref` operation adds a reference(s) to async value (token, value or group). """ -function runtime_add_ref(operand::Value; count, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("count", count),] - - return IR.create_operation( - "async.runtime.add_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_add_ref(operand; count, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("count", count), ] + + IR.create_operation( + "async.runtime.add_ref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -420,25 +356,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_add_to_group(operand, group; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(group), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + 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) ) end @@ -449,22 +379,18 @@ The `async.runtime.await_and_resume` operation awaits for the operand to become available or error and resumes the coroutine on a thread managed by the runtime. """ -function runtime_await_and_resume(operand::Value, handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand, handle] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.await_and_resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_await_and_resume(operand, handle; location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.await_and_resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -474,22 +400,18 @@ end The `async.runtime.await` operation blocks the caller thread until the operand becomes available or error. """ -function runtime_await(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.await", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_await(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.await", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -499,25 +421,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_create_group(size; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(size), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -552,22 +468,18 @@ end The `async.runtime.drop_ref` operation drops a reference(s) to async value (token, value or group). """ -function runtime_drop_ref(operand::Value; count, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("count", count),] - - return IR.create_operation( - "async.runtime.drop_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_drop_ref(operand; count, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("count", count), ] + + IR.create_operation( + "async.runtime.drop_ref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -579,25 +491,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_is_error(operand; is_error=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(is_error) && push!(results, is_error) + + 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) ) end @@ -607,22 +513,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_load(storage; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(storage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -660,22 +562,18 @@ end The `async.runtime.resume` operation resumes the coroutine on a thread managed by the runtime. """ -function runtime_resume(handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_resume(handle; location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -685,22 +583,18 @@ end The `async.runtime.set_available` operation switches async token or value state to available. """ -function runtime_set_available(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.set_available", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_set_available(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.set_available", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -710,22 +604,18 @@ end The `async.runtime.set_error` operation switches async token or value state to error. """ -function runtime_set_error(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.set_error", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_set_error(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.set_error", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -735,22 +625,18 @@ end The `async.runtime.store` operation stores the value into the runtime async.value storage. """ -function runtime_store(value::Value, storage::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value, storage] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_store(value, storage; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(storage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -760,22 +646,18 @@ end The `async.yield` is a special terminator operation for the block inside `async.execute` operation. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/Bufferization.jl b/src/Dialects/14/Bufferization.jl index bfa30ff9..7aff74d2 100644 --- a/src/Dialects/14/Bufferization.jl +++ b/src/Dialects/14/Bufferization.jl @@ -1,7 +1,6 @@ module bufferization -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -20,22 +19,18 @@ views or create an actual copy. Mutating the source or result 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.clone", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clone(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.clone", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -56,22 +51,18 @@ This operation is a specialized variant of the built-in 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.to_memref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function to_memref(tensor; memref::IR.Type, location=Location()) + results = IR.Type[memref, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.to_memref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -96,22 +87,18 @@ involving tensors and memrefs. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.to_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function to_tensor(memref; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.to_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/Builtin.jl b/src/Dialects/14/Builtin.jl index 9f664dbe..558c2c3f 100644 --- a/src/Dialects/14/Builtin.jl +++ b/src/Dialects/14/Builtin.jl @@ -1,7 +1,6 @@ module builtin -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -143,24 +142,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "builtin.unrealized_conversion_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function unrealized_conversion_cast(inputs; outputs::Vector{IR.Type}, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "builtin.unrealized_conversion_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/Complex.jl b/src/Dialects/14/Complex.jl index c80a6301..7cb943ab 100644 --- a/src/Dialects/14/Complex.jl +++ b/src/Dialects/14/Complex.jl @@ -1,7 +1,6 @@ module complex -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -15,22 +14,18 @@ The `abs` op takes a single complex number and computes its absolute value. %a = complex.abs %b : complex ``` """ -function abs(complex::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function abs(complex; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.abs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -45,25 +40,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -110,22 +99,18 @@ floating-point operands, the real and the imaginary part. %a = complex.create %b, %c : complex ``` """ -function create(real::Value, imaginary::Value; complex::IR.Type, location=Location()) - _results = IR.Type[complex,] - _operands = Value[real, imaginary] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.create", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create(real, imaginary; complex::IR.Type, location=Location()) + results = IR.Type[complex, ] + operands = Value[value(real), value(imaginary), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.create", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -139,25 +124,19 @@ division: %a = complex.div %b, %c : complex ``` """ -function div( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function div(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.div", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -172,25 +151,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function eq(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.eq", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -207,23 +180,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -238,22 +207,18 @@ The `im` op takes a single complex number and extracts the imaginary part. %a = complex.im %b : complex ``` """ -function im(complex::Value; imaginary::IR.Type, location=Location()) - _results = IR.Type[imaginary,] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.im", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function im(complex; imaginary::IR.Type, location=Location()) + results = IR.Type[imaginary, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.im", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -271,23 +236,19 @@ approximately equal to 2.718281. %a = complex.log1p %b : complex ``` """ -function log1p(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.log1p", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log1p(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.log1p", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -304,23 +265,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -333,25 +290,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -366,23 +317,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.neg", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function neg(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.neg", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -398,25 +345,19 @@ equal. %a = complex.neq %b, %c : complex ``` """ -function neq( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.neq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function neq(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.neq", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -431,22 +372,18 @@ The `re` op takes a single complex number and extracts the real part. %a = complex.re %b : complex ``` """ -function re(complex::Value; real::IR.Type, location=Location()) - _results = IR.Type[real,] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.re", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function re(complex; real::IR.Type, location=Location()) + results = IR.Type[real, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.re", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -462,23 +399,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sign(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -493,25 +426,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sub(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/14/EmitC.jl b/src/Dialects/14/EmitC.jl index f8b0604a..55237550 100644 --- a/src/Dialects/14/EmitC.jl +++ b/src/Dialects/14/EmitC.jl @@ -1,7 +1,6 @@ module emitc -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -22,22 +21,18 @@ can be applied to a single operand. ``` """ -function apply(operand::Value; result::IR.Type, applicableOperator, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply(operand; result::IR.Type, applicableOperator, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("applicableOperator", applicableOperator), ] + + IR.create_operation( + "emitc.apply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -60,32 +55,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...,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operands_; result_0::Vector{IR.Type}, callee, args=nothing, template_args=nothing, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + !isnothing(args) && push!(attributes, namedattribute("args", args)) + !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 ) end diff --git a/src/Dialects/14/GPU.jl b/src/Dialects/14/GPU.jl index 4d9e217e..b0746a50 100644 --- a/src/Dialects/14/GPU.jl +++ b/src/Dialects/14/GPU.jl @@ -1,7 +1,6 @@ module gpu -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -29,30 +28,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function all_reduce(value; result_0=nothing::Union{Nothing, IR.Type}, op=nothing, body::Region, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result_0) && push!(results, result_0) + !isnothing(op) && push!(attributes, namedattribute("op", op)) + + 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) ) end @@ -75,36 +64,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - length(asyncDependencies), length(dynamicSizes), length(symbolOperands) - ]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.alloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloc(asyncDependencies, dynamicSizes, symbolOperands; memref::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(asyncDependencies)..., value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(asyncDependencies), length(dynamicSizes), length(symbolOperands), ])) + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.alloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -234,28 +207,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(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies..., memref] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.dealloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dealloc(asyncDependencies, memref; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.dealloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -428,22 +392,18 @@ Writes from the host are guaranteed to be visible to device kernels that are launched afterwards. Writes from the device are guaranteed to be visible on the host after synchronizing with the device kernel completion. """ -function host_register(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.host_register", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function host_register(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.host_register", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -528,60 +488,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(), -) - _results = IR.Type[] - _operands = Value[ - asyncDependencies..., - gridSizeX, - gridSizeY, - gridSizeZ, - blockSizeX, - blockSizeY, - blockSizeZ, - operands..., - ] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kernel", kernel),] - !isnothing(dynamicSharedMemorySize) && push!(_operands, dynamicSharedMemorySize) - push!( - _attributes, - operandsegmentsizes([ - length(asyncDependencies), - 1, - 1, - 1, - 1, - 1, - 1, - isnothing(dynamicSharedMemorySize) ? 0 : 1, - length(operands), - ]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.launch_func", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function launch_func(asyncDependencies, gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ, dynamicSharedMemorySize=nothing; operands_, asyncToken=nothing::Union{Nothing, IR.Type}, kernel, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(gridSizeX), value(gridSizeY), value(gridSizeZ), value(blockSizeX), value(blockSizeY), value(blockSizeZ), value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kernel", kernel), ] + !isnothing(dynamicSharedMemorySize) && push!(operands, value(dynamicSharedMemorySize)) + push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1length(operands), ])) + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.launch_func", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -653,33 +574,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function launch(gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ, dynamicSharedMemorySize=nothing; body::Region, location=Location()) + results = IR.Type[] + operands = Value[value(gridSizeX), value(gridSizeY), value(gridSizeZ), value(blockSizeX), value(blockSizeY), value(blockSizeZ), ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dynamicSharedMemorySize) && push!(operands, value(dynamicSharedMemorySize)) + + IR.create_operation( + "gpu.launch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -701,29 +608,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function memcpy(asyncDependencies, dst, src; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(dst), value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.memcpy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -745,29 +642,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function memset(asyncDependencies, dst, value; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(dst), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.memset", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -835,22 +722,18 @@ scalar arguments that should be printed. The format string is a C-style printf string, subject to any restrictions imposed by one\'s target platform. """ -function printf(args::Vector{Value}; format, location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("format", format),] - - return IR.create_operation( - "gpu.printf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function printf(args; format, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("format", format), ] + + IR.create_operation( + "gpu.printf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -861,22 +744,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -901,32 +780,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(), -) - _results = IR.Type[] - _operands = Value[value, offset, width] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mode", mode),] - !isnothing(result) && push!(_results, result) - !isnothing(valid) && push!(_results, valid) - - return IR.create_operation( - "gpu.shuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shuffle(value, offset, width; result=nothing::Union{Nothing, IR.Type}, valid=nothing::Union{Nothing, IR.Type}, mode, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(offset), value(width), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mode", mode), ] + !isnothing(result) && push!(results, result) + !isnothing(valid) && push!(results, valid) + + IR.create_operation( + "gpu.shuffle", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -984,29 +851,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subgroup_mma_compute(opA, opB, opC; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(opA), value(opB), value(opC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -1033,22 +890,18 @@ This op is meant to be used along with `gpu.subgroup_mma_compute`. !gpu.mma_matrix<16x16xf32, \"COp\"> ``` """ -function subgroup_mma_constant_matrix(value::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_constant_matrix(value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.subgroup_mma_constant_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1072,24 +925,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("operation", operation),] - - return IR.create_operation( - "gpu.subgroup_mma_elementwise", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_elementwise(args; res::IR.Type, operation, location=Location()) + results = IR.Type[res, ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("operation", operation), ] + + IR.create_operation( + "gpu.subgroup_mma_elementwise", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1117,28 +964,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("leadDimension", leadDimension),] - - return IR.create_operation( - "gpu.subgroup_mma_load_matrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_load_matrix(srcMemref, indices; res::IR.Type, leadDimension, location=Location()) + results = IR.Type[res, ] + operands = Value[value(srcMemref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] + + IR.create_operation( + "gpu.subgroup_mma_load_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1164,24 +1001,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_store_matrix(src, dstMemref, indices; leadDimension, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(dstMemref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] + + IR.create_operation( + "gpu.subgroup_mma_store_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1309,27 +1140,19 @@ once this op completes. Example usage: gpu.wait [%t0, %t1] ``` """ -function wait( - asyncDependencies::Vector{Value}; - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wait(asyncDependencies; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1345,22 +1168,18 @@ in gpu ops. It returns values to the immediately enclosing gpu op. gpu.yield %f0, %f1 : f32, f32 ``` """ -function yield(values::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[values...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(values; location=Location()) + results = IR.Type[] + operands = Value[value.(values)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/LLVMIR.jl b/src/Dialects/14/LLVMIR.jl index 0fe6ab67..bf7353d1 100644 --- a/src/Dialects/14/LLVMIR.jl +++ b/src/Dialects/14/LLVMIR.jl @@ -1,32 +1,25 @@ module llvm -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `ashr` """ -function ashr( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.ashr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ashr(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.ashr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -65,25 +58,19 @@ end `add` """ -function add( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -91,22 +78,18 @@ end `addrspacecast` """ -function addrspacecast(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.addrspacecast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function addrspacecast(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.addrspacecast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -247,23 +230,19 @@ end `alloca` """ -function alloca(arraySize::Value; res::IR.Type, alignment=nothing, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca(arraySize; res::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arraySize), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "llvm.alloca", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -271,25 +250,19 @@ end `and` """ -function and( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function and(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.and", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -297,22 +270,18 @@ end `intr_assume` """ -function intr_assume(cond::Value; location=Location()) - _results = IR.Type[] - _operands = Value[cond,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.assume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_assume(cond; location=Location()) + results = IR.Type[] + operands = Value[value(cond), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.assume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -320,33 +289,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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cmpxchg(ptr, cmp, val; res::IR.Type, success_ordering, failure_ordering, location=Location()) + results = IR.Type[res, ] + operands = Value[value(ptr), value(cmp), value(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 ) end @@ -354,26 +308,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("bin_op", bin_op), namedattribute("ordering", ordering) - ] - - return IR.create_operation( - "llvm.atomicrmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomicrmw(ptr, val; res::IR.Type, bin_op, ordering, location=Location()) + results = IR.Type[res, ] + operands = Value[value(ptr), value(val), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -381,25 +327,19 @@ end `intr_bitreverse` """ -function intr_bitreverse( - in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.bitreverse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_bitreverse(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -407,22 +347,18 @@ end `bitcast` """ -function bitcast(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -430,22 +366,18 @@ end `br` """ -function br(destOperands::Vector{Value}; dest::Block, location=Location()) - _results = IR.Type[] - _operands = Value[destOperands...,] - _owned_regions = Region[] - _successors = Block[dest,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function br(destOperands; dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(destOperands)..., ] + owned_regions = Region[] + successors = Block[dest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -479,31 +411,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...,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operand_0; result_0::Vector{IR.Type}, callee=nothing, fastmathFlags=nothing, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + + IR.create_operation( + "llvm.call", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -511,36 +432,20 @@ end `cond_br` """ -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...] - _owned_regions = Region[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cond_br(condition, trueDestOperands, falseDestOperands; branch_weights=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueDestOperands)..., value.(falseDestOperands)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + 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 ) end @@ -597,25 +502,19 @@ end `intr_copysign` """ -function intr_copysign( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_copysign(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -646,22 +545,18 @@ end `intr_coro_begin` """ -function intr_coro_begin(token::Value, mem::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_coro_begin(token, mem; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(token), value(mem), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.coro.begin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -669,22 +564,18 @@ end `intr_coro_end` """ -function intr_coro_end(handle::Value, unwind::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_coro_end(handle, unwind; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(handle), value(unwind), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.coro.end", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -692,22 +583,18 @@ end `intr_coro_free` """ -function intr_coro_free(id::Value, handle::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_coro_free(id, handle; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(id), value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.coro.free", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -715,91 +602,72 @@ end `intr_coro_id` """ -function intr_coro_id( - align::Value, - promise::Value, - coroaddr::Value, - fnaddrs::Value; - res::IR.Type, - location=Location(), -) +function intr_coro_id(align, promise, coroaddr, fnaddrs; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(align), value(promise), value(coroaddr), value(fnaddrs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.coro.id", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`intr_coro_resume` + +""" +function intr_coro_resume(handle; location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.coro.resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`intr_coro_save` + +""" +function intr_coro_save(handle; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.coro.save", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +""" +`intr_coro_size` + +""" +function intr_coro_size(; res::IR.Type, location=Location()) _results = IR.Type[res,] - _operands = Value[align, promise, coroaddr, fnaddrs] + _operands = Value[] _owned_regions = Region[] _successors = Block[] _attributes = NamedAttribute[] return IR.create_operation( - "llvm.intr.coro.id", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_resume` - -""" -function intr_coro_resume(handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_save` - -""" -function intr_coro_save(handle::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.save", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_size` - -""" -function intr_coro_size(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.size", + "llvm.intr.coro.size", location; operands=_operands, owned_regions=_owned_regions, @@ -814,22 +682,18 @@ end `intr_coro_suspend` """ -function intr_coro_suspend(save::Value, final::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_coro_suspend(save, final; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(save), value(final), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.coro.suspend", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -837,23 +701,19 @@ end `intr_cos` """ -function intr_cos(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_cos(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -861,22 +721,18 @@ end `intr_ctlz` """ -function intr_ctlz(in::Value, zero_undefined::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ctlz(in, zero_undefined; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(in), value(zero_undefined), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.ctlz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -884,22 +740,18 @@ end `intr_cttz` """ -function intr_cttz(in::Value, zero_undefined::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_cttz(in, zero_undefined; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(in), value(zero_undefined), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.cttz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -907,23 +759,19 @@ end `intr_ctpop` """ -function intr_ctpop(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.ctpop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_ctpop(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -931,22 +779,18 @@ end `intr_eh_typeid_for` """ -function intr_eh_typeid_for(type_info::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_eh_typeid_for(type_info; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(type_info), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.eh.typeid.for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -954,23 +798,19 @@ end `intr_exp2` """ -function intr_exp2(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.exp2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_exp2(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -978,23 +818,19 @@ end `intr_exp` """ -function intr_exp(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_exp(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -1002,22 +838,18 @@ end `extractelement` """ -function extractelement(vector::Value, position::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[vector, position] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.extractelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extractelement(vector, position; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(vector), value(position), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.extractelement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1025,22 +857,18 @@ end `extractvalue` """ -function extractvalue(container::Value; res::IR.Type, position, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extractvalue(container; res::IR.Type, position, location=Location()) + results = IR.Type[res, ] + operands = Value[value(container), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "llvm.extractvalue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1048,23 +876,19 @@ end `intr_fabs` """ -function intr_fabs(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.fabs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_fabs(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -1072,31 +896,20 @@ end `fadd` """ -function fadd( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fadd(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -1104,23 +917,19 @@ end `intr_ceil` """ -function intr_ceil(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_ceil(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -1128,31 +937,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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fcmp(lhs, rhs; res::IR.Type, predicate, fastmathFlags=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(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 ) end @@ -1160,31 +957,20 @@ end `fdiv` """ -function fdiv( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fdiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -1192,23 +978,19 @@ end `intr_floor` """ -function intr_floor(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_floor(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -1216,25 +998,19 @@ end `intr_fma` """ -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_fma(a, b, c; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -1242,25 +1018,19 @@ end `intr_fmuladd` """ -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.fmuladd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_fmuladd(a, b, c; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -1268,31 +1038,20 @@ end `fmul` """ -function fmul( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fmul(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -1300,30 +1059,20 @@ end `fneg` """ -function fneg( - operand::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fneg(operand; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -1331,22 +1080,18 @@ end `fpext` """ -function fpext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fpext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fpext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fpext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1354,22 +1099,18 @@ end `fptosi` """ -function fptosi(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptosi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptosi(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptosi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1377,22 +1118,18 @@ end `fptoui` """ -function fptoui(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptoui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptoui(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptoui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1400,22 +1137,18 @@ end `fptrunc` """ -function fptrunc(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptrunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptrunc(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptrunc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1423,31 +1156,20 @@ end `frem` """ -function frem( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function frem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -1455,31 +1177,20 @@ end `fsub` """ -function fsub( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fsub(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -1512,23 +1223,19 @@ end `freeze` """ -function freeze(val::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[val,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.freeze", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function freeze(val; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(val), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.freeze", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1536,24 +1243,18 @@ end `getelementptr` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function getelementptr(base, indices; res::IR.Type, structIndices, location=Location()) + results = IR.Type[res, ] + operands = Value[value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("structIndices", structIndices), ] + + IR.create_operation( + "llvm.getelementptr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1561,22 +1262,18 @@ end `intr_get_active_lane_mask` """ -function intr_get_active_lane_mask(base::Value, n::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_get_active_lane_mask(base, n; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(base), value(n), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.get.active.lane.mask", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1808,22 +1505,18 @@ end `icmp` """ -function icmp(lhs::Value, rhs::Value; res::IR.Type, predicate, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function icmp(lhs, rhs; res::IR.Type, predicate, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "llvm.icmp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1837,43 +1530,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(), -) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function inline_asm(operands_; 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[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + 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(asm_dialect) && push!(attributes, namedattribute("asm_dialect", asm_dialect)) + !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 ) end @@ -1881,49 +1554,37 @@ end `insertelement` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function insertelement(vector, value, position; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(vector), value(value), value(position), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.insertelement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -""" -`insertvalue` - -""" -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +""" +`insertvalue` + +""" +function insertvalue(container, value; res::IR.Type, position, location=Location()) + results = IR.Type[res, ] + operands = Value[value(container), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "llvm.insertvalue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1931,22 +1592,18 @@ end `inttoptr` """ -function inttoptr(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.inttoptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function inttoptr(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.inttoptr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1954,38 +1611,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] - _attributes = NamedAttribute[] - 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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function invoke(callee_operands, normalDestOperands, unwindDestOperands; result_0::Vector{IR.Type}, callee=nothing, normalDest::Block, unwindDest::Block, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(callee_operands)..., value.(normalDestOperands)..., value.(unwindDestOperands)..., ] + owned_regions = Region[] + successors = Block[normalDest, unwindDest, ] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(callee_operands), length(normalDestOperands), length(unwindDestOperands), ])) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + + IR.create_operation( + "llvm.invoke", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2054,25 +1693,19 @@ end `lshr` """ -function lshr( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.lshr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function lshr(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.lshr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2080,25 +1713,19 @@ end `landingpad` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function landingpad(operand_0; res::IR.Type, cleanup=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(cleanup) && push!(attributes, namedattribute("cleanup", cleanup)) + + IR.create_operation( + "llvm.landingpad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2106,42 +1733,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,] - _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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(addr; 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[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(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) + + IR.create_operation( + "llvm.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2149,23 +1758,19 @@ end `intr_log10` """ -function intr_log10(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.log10", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_log10(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -2173,23 +1778,19 @@ end `intr_log2` """ -function intr_log2(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.log2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_log2(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -2197,23 +1798,19 @@ end `intr_log` """ -function intr_log(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_log(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -2221,29 +1818,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_masked_load(data, mask, pass_thru; res::IR.Type, alignment, location=Location()) + results = IR.Type[res, ] + operands = Value[value(data), value(mask), value.(pass_thru)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "llvm.intr.masked.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2251,24 +1837,18 @@ end `intr_masked_store` """ -function intr_masked_store( - value::Value, data::Value, mask::Value; alignment, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_masked_store(value, data, mask; alignment, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(data), value(mask), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "llvm.intr.masked.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2276,28 +1856,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_matrix_column_major_load(data, stride; res::IR.Type, isVolatile, rows, columns, location=Location()) + results = IR.Type[res, ] + operands = Value[value(data), value(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.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2305,34 +1875,18 @@ end `intr_matrix_column_major_store` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_matrix_column_major_store(matrix, data, stride; isVolatile, rows, columns, location=Location()) + results = IR.Type[] + operands = Value[value(matrix), value(data), value(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 ) end @@ -2340,34 +1894,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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_matrix_multiply(lhs, rhs; res::IR.Type, lhs_rows, lhs_columns, rhs_columns, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(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 ) end @@ -2375,26 +1913,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("rows", rows), namedattribute("columns", columns) - ] - - return IR.create_operation( - "llvm.intr.matrix.transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_matrix_transpose(matrix; res::IR.Type, rows, columns, location=Location()) + results = IR.Type[res, ] + operands = Value[value(matrix), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -2402,25 +1932,19 @@ end `intr_maxnum` """ -function intr_maxnum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_maxnum(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -2428,25 +1952,19 @@ end `intr_maximum` """ -function intr_maximum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_maximum(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -2454,49 +1972,37 @@ end `intr_memcpy_inline` """ -function intr_memcpy_inline( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, src, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memcpy.inline", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_memcpy_inline(dst, src, len, isVolatile; location=Location()) + results = IR.Type[] + operands = Value[value(dst), value(src), value(len), value(isVolatile), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.memcpy.inline", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end """ -`intr_memcpy` - -""" -function intr_memcpy( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, src, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memcpy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +`intr_memcpy` + +""" +function intr_memcpy(dst, src, len, isVolatile; location=Location()) + results = IR.Type[] + operands = Value[value(dst), value(src), value(len), value(isVolatile), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.memcpy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2504,24 +2010,18 @@ end `intr_memmove` """ -function intr_memmove( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, src, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memmove", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_memmove(dst, src, len, isVolatile; location=Location()) + results = IR.Type[] + operands = Value[value(dst), value(src), value(len), value(isVolatile), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.memmove", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2529,24 +2029,18 @@ end `intr_memset` """ -function intr_memset( - dst::Value, val::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, val, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memset", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_memset(dst, val, len, isVolatile; location=Location()) + results = IR.Type[] + operands = Value[value(dst), value(val), value(len), value(isVolatile), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.memset", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2585,25 +2079,19 @@ end `intr_minnum` """ -function intr_minnum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_minnum(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -2611,25 +2099,19 @@ end `intr_minimum` """ -function intr_minimum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_minimum(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -2637,25 +2119,19 @@ end `mul` """ -function mul( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2700,25 +2176,19 @@ end `or` """ -function or( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function or(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.or", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2726,22 +2196,18 @@ end `intr_powi` """ -function intr_powi(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( - "llvm.intr.powi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_powi(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.powi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2749,25 +2215,19 @@ end `intr_pow` """ -function intr_pow( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_pow(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -2775,24 +2235,18 @@ end `intr_prefetch` """ -function intr_prefetch( - addr::Value, rw::Value, hint::Value, cache::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[addr, rw, hint, cache] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.prefetch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_prefetch(addr, rw, hint, cache; location=Location()) + results = IR.Type[] + operands = Value[value(addr), value(rw), value(hint), value(cache), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.prefetch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2800,22 +2254,18 @@ end `ptrtoint` """ -function ptrtoint(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.ptrtoint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ptrtoint(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.ptrtoint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2823,22 +2273,18 @@ end `resume` """ -function resume(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function resume(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2846,22 +2292,18 @@ end `return_` """ -function return_(args::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(args; location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2869,24 +2311,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.sadd.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sadd_with_overflow(operand_0, operand_1; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.sadd.with.overflow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2894,25 +2330,19 @@ end `sdiv` """ -function sdiv( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.sdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sdiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.sdiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2920,22 +2350,18 @@ end `sext` """ -function sext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.sext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.sext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2943,22 +2369,18 @@ end `sitofp` """ -function sitofp(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.sitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sitofp(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.sitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2966,25 +2388,19 @@ end `intr_smax` """ -function intr_smax( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_smax(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -2992,25 +2408,19 @@ end `intr_smin` """ -function intr_smin( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_smin(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -3018,50 +2428,38 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.smul.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_smul_with_overflow(operand_0, operand_1; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.smul.with.overflow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end """ -`srem` - -""" -function srem( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) +`srem` - return IR.create_operation( - "llvm.srem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +""" +function srem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.srem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3069,24 +2467,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.ssub.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ssub_with_overflow(operand_0, operand_1; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.ssub.with.overflow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3094,29 +2486,19 @@ end `select` """ -function select( - condition::Value, - trueValue::Value, - falseValue::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function select(condition, trueValue, falseValue; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(trueValue), value(falseValue), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3124,25 +2506,19 @@ end `shl` """ -function shl( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.shl", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shl(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.shl", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3150,22 +2526,18 @@ end `shufflevector` """ -function shufflevector(v1::Value, v2::Value; res::IR.Type, mask, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shufflevector(v1, v2; res::IR.Type, mask, location=Location()) + results = IR.Type[res, ] + operands = Value[value(v1), value(v2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mask", mask), ] + + IR.create_operation( + "llvm.shufflevector", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3173,23 +2545,19 @@ end `intr_sin` """ -function intr_sin(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_sin(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -3197,23 +2565,19 @@ end `intr_sqrt` """ -function intr_sqrt(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_sqrt(in; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -3221,22 +2585,18 @@ end `intr_stackrestore` """ -function intr_stackrestore(ptr::Value; location=Location()) - _results = IR.Type[] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.stackrestore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_stackrestore(ptr; location=Location()) + results = IR.Type[] + operands = Value[value(ptr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.stackrestore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3267,42 +2627,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(), -) - _results = IR.Type[] - _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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, addr; access_groups=nothing, alias_scopes=nothing, noalias_scopes=nothing, alignment=nothing, volatile_=nothing, nontemporal=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(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(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) + + IR.create_operation( + "llvm.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3310,25 +2652,19 @@ end `sub` """ -function sub( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sub(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.sub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3336,41 +2672,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(), -) - _results = IR.Type[] - _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)]) - ) - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch(value, defaultOperands, caseOperands; case_values=nothing, case_operand_segments, branch_weights=nothing, defaultDestination::Block, caseDestinations::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), value.(defaultOperands)..., value.(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), ])) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) + !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 ) end @@ -3378,22 +2694,18 @@ end `trunc` """ -function trunc(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.trunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function trunc(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.trunc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3401,24 +2713,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.uadd.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_uadd_with_overflow(operand_0, operand_1; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.uadd.with.overflow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3426,25 +2732,19 @@ end `udiv` """ -function udiv( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.udiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function udiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.udiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3452,22 +2752,18 @@ end `uitofp` """ -function uitofp(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.uitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function uitofp(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.uitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3475,25 +2771,19 @@ end `intr_umax` """ -function intr_umax( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_umax(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -3501,25 +2791,19 @@ end `intr_umin` """ -function intr_umin( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function intr_umin(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -3527,24 +2811,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.umul.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_umul_with_overflow(operand_0, operand_1; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.umul.with.overflow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3552,50 +2830,38 @@ end `urem` """ -function urem( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.urem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function urem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.urem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.usub.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +""" +`intr_usub_with_overflow` + +""" +function intr_usub_with_overflow(operand_0, operand_1; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.usub.with.overflow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3660,25 +2926,19 @@ end `xor` """ -function xor( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function xor(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.xor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3686,22 +2946,18 @@ end `zext` """ -function zext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.zext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function zext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.zext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3709,24 +2965,18 @@ end `intr_masked_compressstore` """ -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.masked.compressstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_masked_compressstore(operand_0, operand_1, operand_2; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.masked.compressstore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3734,24 +2984,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.masked.expandload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_masked_expandload(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.masked.expandload", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3759,29 +3003,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_masked_gather(ptrs, mask, pass_thru; res::IR.Type, alignment, location=Location()) + results = IR.Type[res, ] + operands = Value[value(ptrs), value(mask), value.(pass_thru)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "llvm.intr.masked.gather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3789,24 +3022,18 @@ end `intr_masked_scatter` """ -function intr_masked_scatter( - value::Value, ptrs::Value, mask::Value; alignment, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_masked_scatter(value, ptrs, mask; alignment, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(ptrs), value(mask), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "llvm.intr.masked.scatter", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3814,22 +3041,18 @@ end `intr_vector_reduce_add` """ -function intr_vector_reduce_add(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_add(operand_0; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.vector.reduce.add", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3837,22 +3060,18 @@ end `intr_vector_reduce_and` """ -function intr_vector_reduce_and(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_and(operand_0; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.vector.reduce.and", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3860,25 +3079,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_fadd(operand_0, operand_1; res::IR.Type, reassoc=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(reassoc) && push!(attributes, namedattribute("reassoc", reassoc)) + + IR.create_operation( + "llvm.intr.vector.reduce.fadd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3886,22 +3099,18 @@ end `intr_vector_reduce_fmax` """ -function intr_vector_reduce_fmax(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_fmax(operand_0; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.vector.reduce.fmax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3909,22 +3118,18 @@ end `intr_vector_reduce_fmin` """ -function intr_vector_reduce_fmin(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_fmin(operand_0; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.vector.reduce.fmin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3932,25 +3137,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_fmul(operand_0, operand_1; res::IR.Type, reassoc=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(reassoc) && push!(attributes, namedattribute("reassoc", reassoc)) + + IR.create_operation( + "llvm.intr.vector.reduce.fmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3958,22 +3157,18 @@ end `intr_vector_reduce_mul` """ -function intr_vector_reduce_mul(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_mul(operand_0; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.vector.reduce.mul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3981,22 +3176,18 @@ end `intr_vector_reduce_or` """ -function intr_vector_reduce_or(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_or(operand_0; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.vector.reduce.or", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4004,22 +3195,18 @@ end `intr_vector_reduce_smax` """ -function intr_vector_reduce_smax(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_smax(operand_0; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.vector.reduce.smax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4027,22 +3214,18 @@ end `intr_vector_reduce_smin` """ -function intr_vector_reduce_smin(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_smin(operand_0; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.vector.reduce.smin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4050,22 +3233,18 @@ end `intr_vector_reduce_umax` """ -function intr_vector_reduce_umax(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_umax(operand_0; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.vector.reduce.umax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4073,22 +3252,18 @@ end `intr_vector_reduce_umin` """ -function intr_vector_reduce_umin(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_umin(operand_0; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.vector.reduce.umin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4096,22 +3271,18 @@ end `intr_vector_reduce_xor` """ -function intr_vector_reduce_xor(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_vector_reduce_xor(operand_0; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.intr.vector.reduce.xor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/Linalg.jl b/src/Dialects/14/Linalg.jl index 0edb6af6..03d93233 100644 --- a/src/Dialects/14/Linalg.jl +++ b/src/Dialects/14/Linalg.jl @@ -1,7 +1,6 @@ module linalg -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -67,24 +66,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("static_sizes", static_sizes),] - - return IR.create_operation( - "linalg.init_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function init_tensor(sizes; result::IR.Type, static_sizes, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("static_sizes", static_sizes), ] + + IR.create_operation( + "linalg.init_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -157,45 +150,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tiled_loop(lowerBound, upperBound, step, inputs, outputs; results_::Vector{IR.Type}, iterator_types, distribution_types=nothing, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(inputs)..., value.(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)) + + IR.create_operation( + "linalg.tiled_loop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -212,27 +180,22 @@ in `linalg` generic ops. It returns values to the immediately enclosing linalg.yield %f0, %f1 : f32, f32 ``` """ -function yield(values::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[values...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "linalg.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(values; location=Location()) + results = IR.Type[] + operands = Value[value.(values)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "linalg.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -241,29 +204,19 @@ import ..Dialects: namedattribute, operandsegmentsizes 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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.batch_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -273,29 +226,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.batch_matvec", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_matvec(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -305,33 +248,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_1d_nwc_wcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -341,29 +270,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_1d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_1d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_1d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -377,33 +296,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nchw_fchw(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -417,33 +322,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nhwc_hwcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -458,33 +349,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nhwc_hwcf_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -494,29 +371,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -526,33 +393,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_3d_ndhwc_dhwcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -562,29 +415,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_3d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_3d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_3d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -595,33 +438,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_1d_nwc_wc(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -632,33 +461,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwc(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -668,33 +483,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwc_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -704,33 +505,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwcm(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -740,33 +527,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwcm_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -776,29 +549,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.dot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dot(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.dot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -806,29 +569,19 @@ end `fill` """ -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,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "linalg.fill", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fill(value, output; result=nothing::Union{Nothing, IR.Type}, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(output), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "linalg.fill", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -843,29 +596,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.fill_rng_2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fill_rng_2d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -968,39 +711,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,] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("indexing_maps", indexing_maps), - namedattribute("iterator_types", iterator_types), - ] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - !isnothing(doc) && push!(_attributes, namedattribute("doc", doc)) - !isnothing(library_call) && - push!(_attributes, namedattribute("library_call", library_call)) - - return IR.create_operation( - "linalg.generic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generic(inputs, outputs; 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[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(doc) && push!(attributes, namedattribute("doc", doc)) + !isnothing(library_call) && push!(attributes, namedattribute("library_call", library_call)) + + IR.create_operation( + "linalg.generic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1010,29 +735,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1042,29 +757,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matmul_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matmul_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1074,29 +779,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matvec", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matvec(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1111,29 +806,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.mmt4d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mmt4d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.mmt4d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1143,33 +828,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nchw_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -1179,33 +850,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -1215,33 +872,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_min(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -1251,33 +894,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -1287,33 +916,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -1323,33 +938,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_max_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -1359,33 +960,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_min(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -1395,33 +982,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_min_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -1431,33 +1004,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides, dilations, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + 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 ) end @@ -1469,29 +1028,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.quantized_batch_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function quantized_batch_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -1503,29 +1052,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.quantized_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function quantized_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.quantized_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1535,29 +1074,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.soft_plus_2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function soft_plus_2d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -1567,29 +1096,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.vecmat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vecmat(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.vecmat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/Math.jl b/src/Dialects/14/Math.jl index 8126859c..bc014a2d 100644 --- a/src/Dialects/14/Math.jl +++ b/src/Dialects/14/Math.jl @@ -1,7 +1,6 @@ module math -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -24,23 +23,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function abs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.abs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -78,25 +73,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.atan2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atan2(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.atan2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -127,23 +116,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.atan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atan(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.atan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -174,23 +159,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceil(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ceil", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -222,25 +203,19 @@ attributes. %x = math.copysign %y, %z : tensor<4x?xf8> ``` """ -function copysign( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.copysign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function copysign(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.copysign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -271,23 +246,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cos(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -309,23 +280,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ctlz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ctlz(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ctlz", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -347,23 +314,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.cttz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cttz(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.cttz", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -385,23 +348,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ctpop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ctpop(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ctpop", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -432,23 +391,19 @@ no standard attributes. %x = math.erf %y : tensor<4x?xf8> ``` """ -function erf(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.erf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function erf(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.erf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -478,23 +433,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.exp2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp2(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.exp2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -526,23 +477,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.expm1", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function expm1(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.expm1", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -572,23 +519,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -619,23 +562,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function floor(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.floor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -671,29 +610,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fma(a, b, c; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.fma", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -709,23 +638,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.log10", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log10(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.log10", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -743,23 +668,19 @@ log1p(x) := log(1 + x) %y = math.log1p %x : f64 ``` """ -function log1p(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.log1p", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log1p(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.log1p", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -775,23 +696,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.log2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log2(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.log2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -807,23 +724,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -854,25 +767,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.powf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function powf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.powf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -884,23 +791,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rsqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.rsqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -931,23 +834,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sin(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -970,23 +869,19 @@ attributes. %x = math.sqrt %y : tensor<4x?xf32> ``` """ -function sqrt(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1017,23 +912,19 @@ no standard attributes. %x = math.tanh %y : tensor<4x?xf8> ``` """ -function tanh(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tanh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/14/MemRef.jl b/src/Dialects/14/MemRef.jl index 4e85cff4..74a92aad 100644 --- a/src/Dialects/14/MemRef.jl +++ b/src/Dialects/14/MemRef.jl @@ -1,7 +1,6 @@ module memref -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -14,22 +13,18 @@ the buffer isn\'t aligned to the given alignment, the behavior is undefined. This operation doesn\'t affect the semantics of a correct program. It\'s for optimization only, and the optimization is best-effort. """ -function assume_alignment(memref::Value; alignment, location=Location()) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "memref.assume_alignment", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assume_alignment(memref; alignment, location=Location()) + results = IR.Type[] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "memref.assume_alignment", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -50,29 +45,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - - return IR.create_operation( - "memref.atomic_rmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_rmw(value, memref, indices; result::IR.Type, kind, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), ] + + IR.create_operation( + "memref.atomic_rmw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -82,22 +66,18 @@ end \"memref.atomic_yield\" yields an SSA value from a GenericAtomicRMWOp region. """ -function atomic_yield(result::Value; location=Location()) - _results = IR.Type[] - _operands = Value[result,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.atomic_yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_yield(result; location=Location()) + results = IR.Type[] + operands = Value[value(result), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.atomic_yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -115,22 +95,18 @@ memref.copy %arg0, %arg1 : memref to memref Source and destination are expected to have the same element type and shape. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function copy(source, target; location=Location()) + results = IR.Type[] + operands = Value[value(source), value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.copy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -158,28 +134,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.generic_atomic_rmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generic_atomic_rmw(memref, indices; result::IR.Type, atomic_body::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[atomic_body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.generic_atomic_rmw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -221,22 +187,18 @@ techniques. This is possible because of the [restrictions on dimensions and symbols](Affine.md/#restrictions-on-dimensions-and-symbols) in these contexts. """ -function 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( - "memref.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(memref, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -281,30 +243,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands)])) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.alloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloc(dynamicSizes, symbolOperands; memref::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "memref.alloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -345,30 +297,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands)])) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.alloca", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca(dynamicSizes, symbolOperands; memref::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "memref.alloca", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -437,22 +379,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()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.alloca_scope.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca_scope_return(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.alloca_scope.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -512,22 +450,18 @@ Erase rank information. %5 = memref.cast %1 : memref<4x?xf32> to memref<*xf32> ``` """ -function cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -565,22 +499,18 @@ Examples: memref into memref ``` """ -function collapse_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function collapse_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "memref.collapse_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -599,22 +529,18 @@ alloc\'d memref (e.g. memrefs returned by `view` operations). memref.dealloc %0 : memref<8x64xf32, affine_map<(d0, d1) -> (d0, d1), 1>> ``` """ -function dealloc(memref::Value; location=Location()) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dealloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dealloc(memref; location=Location()) + results = IR.Type[] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dealloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -643,22 +569,18 @@ The specified memref type is that of the first operand. %y = \"memref.dim\"(%A, %c1) : (memref<4 x ? x f32>, index) -> index ``` """ -function dim(source::Value, index::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dim", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dim(source, index; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dim", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -709,22 +631,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dma_start", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dma_start(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dma_start", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -748,24 +666,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() -) - _results = IR.Type[] - _operands = Value[tagMemRef, tagIndices..., numElements] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dma_wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dma_wait(tagMemRef, tagIndices, numElements; location=Location()) + results = IR.Type[] + operands = Value[value(tagMemRef), value.(tagIndices)..., value(numElements), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dma_wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -803,22 +715,18 @@ smaller rank. memref into memref ``` """ -function expand_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "memref.expand_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -946,33 +854,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function prefetch(memref, indices; isWrite, localityHint, isDataCache, location=Location()) + results = IR.Type[] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -988,22 +881,18 @@ The `memref.rank` operation takes a memref operand and returns its rank. %1 = memref.rank %arg1 : memref ``` """ -function rank(memref::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.rank", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rank(memref; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.rank", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1027,40 +916,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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reinterpret_cast(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "memref.reinterpret_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1099,22 +967,18 @@ Result type is unranked. : (memref<*xf32>, memref) to memref<*xf32> ``` """ -function reshape(source::Value, shape::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source, shape] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(source, shape; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1148,22 +1012,18 @@ techniques. This is possible because of the [restrictions on dimensions and symbols](Affine.md/#restrictions-on-dimensions-and-symbols) in these contexts. """ -function store(value::Value, memref::Value, indices::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, memref, indices; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1180,22 +1040,18 @@ transformation. %1 = memref.transpose %0 (i, j) -> (j, i) : memref to memref (d1 * s0 + d0)>> ``` """ -function transpose(in::Value; result_0::IR.Type, permutation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(in; result_0::IR.Type, permutation, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation", permutation), ] + + IR.create_operation( + "memref.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1237,28 +1093,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.view", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function view(source, byte_shift, sizes; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(source), value(byte_shift), value.(sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.view", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1397,40 +1243,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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subview(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "memref.subview", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1449,22 +1274,18 @@ element types of these must match, and are specified by the memref type. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.tensor_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tensor_store(tensor, memref; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.tensor_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/OpenACC.jl b/src/Dialects/14/OpenACC.jl index 0779ee39..36131c44 100644 --- a/src/Dialects/14/OpenACC.jl +++ b/src/Dialects/14/OpenACC.jl @@ -1,7 +1,6 @@ module acc -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -22,70 +21,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function data(ifCond=nothing; copyOperands, copyinOperands, copyinReadonlyOperands, copyoutOperands, copyoutZeroOperands, createOperands, createZeroOperands, noCreateOperands, presentOperands, deviceptrOperands, attachOperands, defaultAttr=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(copyOperands)..., value.(copyinOperands)..., value.(copyinReadonlyOperands)..., value.(copyoutOperands)..., value.(copyoutZeroOperands)..., value.(createOperands)..., value.(createZeroOperands)..., value.(noCreateOperands)..., value.(presentOperands)..., value.(deviceptrOperands)..., value.(attachOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(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), ])) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + + IR.create_operation( + "acc.data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -100,58 +50,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function enter_data(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, copyinOperands, createOperands, createZeroOperands, attachOperands, async=nothing, wait=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(copyinOperands)..., value.(createOperands)..., value.(createZeroOperands)..., value.(attachOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(copyinOperands), length(createOperands), length(createZeroOperands), length(attachOperands), ])) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + + IR.create_operation( + "acc.enter_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -166,54 +82,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function exit_data(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, copyoutOperands, deleteOperands, detachOperands, async=nothing, wait=nothing, finalize=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(copyoutOperands)..., value.(deleteOperands)..., value.(detachOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + 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)) + + IR.create_operation( + "acc.exit_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -230,37 +117,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(), -) - _results = IR.Type[] - _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), - isnothing(deviceNumOperand) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - - return IR.create_operation( - "acc.init", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function init(deviceTypeOperands, deviceNumOperand=nothing; ifCond=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(deviceTypeOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(deviceNumOperand) && push!(operands, value(deviceNumOperand)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + 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 ) end @@ -284,64 +155,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,] - _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([ - isnothing(gangNum) ? 0 : 1, - isnothing(gangStatic) ? 0 : 1, - isnothing(workerNum) ? 0 : 1, - isnothing(vectorLength) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop(gangNum=nothing; gangStatic=nothing, workerNum=nothing, vectorLength=nothing, tileOperands, privateOperands, reductionOperands, 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[value.(tileOperands)..., value.(privateOperands)..., value.(reductionOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(gangNum) && push!(operands, value(gangNum)) + !isnothing(gangStatic) && push!(operands, value(gangStatic)) + !isnothing(workerNum) && push!(operands, value(workerNum)) + !isnothing(vectorLength) && push!(operands, value(vectorLength)) + push!(attributes, operandsegmentsizes([(gangNum==nothing) ? 0 : 1(gangStatic==nothing) ? 0 : 1(workerNum==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1length(tileOperands), length(privateOperands), length(reductionOperands), ])) + !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)) + + IR.create_operation( + "acc.loop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -360,106 +196,30 @@ 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(), -) - _results = IR.Type[] - _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) - !isnothing(numGangs) && push!(_operands, numGangs) - !isnothing(numWorkers) && push!(_operands, numWorkers) - !isnothing(vectorLength) && push!(_operands, vectorLength) - !isnothing(ifCond) && push!(_operands, ifCond) - !isnothing(selfCond) && push!(_operands, selfCond) - push!( - _attributes, - operandsegmentsizes([ - isnothing(async) ? 0 : 1, - length(waitOperands), - isnothing(numGangs) ? 0 : 1, - isnothing(numWorkers) ? 0 : 1, - isnothing(vectorLength) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - isnothing(selfCond) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(async=nothing; waitOperands, numGangs=nothing, numWorkers=nothing, vectorLength=nothing, ifCond=nothing, selfCond=nothing, reductionOperands, copyOperands, copyinOperands, copyinReadonlyOperands, copyoutOperands, copyoutZeroOperands, createOperands, createZeroOperands, noCreateOperands, presentOperands, devicePtrOperands, attachOperands, gangPrivateOperands, gangFirstPrivateOperands, asyncAttr=nothing, waitAttr=nothing, selfAttr=nothing, reductionOp=nothing, defaultAttr=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(reductionOperands)..., value.(copyOperands)..., value.(copyinOperands)..., value.(copyinReadonlyOperands)..., value.(copyoutOperands)..., value.(copyoutZeroOperands)..., value.(createOperands)..., value.(createZeroOperands)..., value.(noCreateOperands)..., value.(presentOperands)..., value.(devicePtrOperands)..., value.(attachOperands)..., value.(gangPrivateOperands)..., value.(gangFirstPrivateOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(async) && push!(operands, value(async)) + !isnothing(numGangs) && push!(operands, value(numGangs)) + !isnothing(numWorkers) && push!(operands, value(numWorkers)) + !isnothing(vectorLength) && push!(operands, value(vectorLength)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(selfCond) && push!(operands, value(selfCond)) + push!(attributes, operandsegmentsizes([(async==nothing) ? 0 : 1length(waitOperands), (numGangs==nothing) ? 0 : 1(numWorkers==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1(selfCond==nothing) ? 0 : 1length(reductionOperands), length(copyOperands), length(copyinOperands), length(copyinReadonlyOperands), length(copyoutOperands), length(copyoutZeroOperands), length(createOperands), length(createZeroOperands), length(noCreateOperands), length(presentOperands), length(devicePtrOperands), length(attachOperands), length(gangPrivateOperands), length(gangFirstPrivateOperands), ])) + !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)) + + IR.create_operation( + "acc.parallel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -476,37 +236,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(), -) - _results = IR.Type[] - _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), - isnothing(deviceNumOperand) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - - return IR.create_operation( - "acc.shutdown", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shutdown(deviceTypeOperands, deviceNumOperand=nothing; ifCond=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(deviceTypeOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(deviceNumOperand) && push!(operands, value(deviceNumOperand)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + 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 ) end @@ -551,54 +295,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function update(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, deviceTypeOperands, hostOperands, deviceOperands, async=nothing, wait=nothing, ifPresent=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(deviceTypeOperands)..., value.(hostOperands)..., value.(deviceOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + 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)) + + IR.create_operation( + "acc.update", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -615,42 +330,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(), -) - _results = IR.Type[] - _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), - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - !isnothing(async) && push!(_attributes, namedattribute("async", async)) - - return IR.create_operation( - "acc.wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wait(waitOperands, asyncOperand=nothing; waitDevnum=nothing, ifCond=nothing, async=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + push!(attributes, operandsegmentsizes([length(waitOperands), (asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + + IR.create_operation( + "acc.wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -661,22 +357,18 @@ end acc ops (parallel and loop). It returns values to the immediately enclosing acc op. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "acc.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "acc.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/OpenMP.jl b/src/Dialects/14/OpenMP.jl index 4154f865..29ecb24a 100644 --- a/src/Dialects/14/OpenMP.jl +++ b/src/Dialects/14/OpenMP.jl @@ -1,7 +1,6 @@ module omp -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -76,27 +75,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_read(x, v; hint=nothing, memory_order=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(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)) + + IR.create_operation( + "omp.atomic.read", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -124,35 +116,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(), -) - _results = IR.Type[] - _operands = Value[x, expr] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_update(x, expr; isXBinopExpr=nothing, binop, hint=nothing, memory_order=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(expr), ] + owned_regions = Region[] + successors = Block[] + 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)) + + IR.create_operation( + "omp.atomic.update", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -173,27 +151,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_write(address, value; hint=nothing, memory_order=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(address), value(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)) + + IR.create_operation( + "omp.atomic.write", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -283,22 +254,18 @@ makes a thread’s temporary view of memory consistent with memory and enforces an order on the memory operations of the variables explicitly specified or implied. """ -function flush(varList::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[varList...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.flush", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function flush(varList; location=Location()) + results = IR.Type[] + operands = Value[value.(varList)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.flush", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -345,31 +312,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ordered(depend_vec_vars; depend_type_val=nothing, num_loops_val=nothing, location=Location()) + results = IR.Type[] + operands = Value[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)) + + IR.create_operation( + "omp.ordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -432,61 +388,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(), -) - _results = IR.Type[] - _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([ - isnothing(if_expr_var) ? 0 : 1, - isnothing(num_threads_var) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(if_expr_var=nothing; num_threads_var=nothing, private_vars, firstprivate_vars, shared_vars, copyin_vars, allocate_vars, allocators_vars, default_val=nothing, proc_bind_val=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(private_vars)..., value.(firstprivate_vars)..., value.(shared_vars)..., value.(copyin_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr_var) && push!(operands, value(if_expr_var)) + !isnothing(num_threads_var) && push!(operands, value(num_threads_var)) + push!(attributes, operandsegmentsizes([(if_expr_var==nothing) ? 0 : 1(num_threads_var==nothing) ? 0 : 1length(private_vars), length(firstprivate_vars), length(shared_vars), length(copyin_vars), length(allocate_vars), length(allocators_vars), ])) + !isnothing(default_val) && push!(attributes, namedattribute("default_val", default_val)) + !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 ) end @@ -548,22 +466,18 @@ entity for a reduction requested in some ancestor. The reduction is identified by the accumulator, but the value of the accumulator may not be updated immediately. """ -function reduction(operand::Value, accumulator::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand, accumulator] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduction(operand, accumulator; location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(accumulator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -624,53 +538,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(), -) - _results = IR.Type[] - _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), - ]), - ) - !isnothing(reductions) && push!(_attributes, namedattribute("reductions", reductions)) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.sections", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sections(private_vars, firstprivate_vars, lastprivate_vars, reduction_vars, allocate_vars, allocators_vars; reductions=nothing, nowait=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(private_vars)..., value.(firstprivate_vars)..., value.(lastprivate_vars)..., value.(reduction_vars)..., value.(allocate_vars)..., value.(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), ])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.sections", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -694,41 +576,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(), -) - _results = IR.Type[] - _operands = Value[] - _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([ - isnothing(if_expr) ? 0 : 1, - isnothing(device) ? 0 : 1, - isnothing(thread_limit) ? 0 : 1, - ]), - ) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.target", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function target(if_expr=nothing; device=nothing, thread_limit=nothing, nowait=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(device) && push!(operands, value(device)) + !isnothing(thread_limit) && push!(operands, value(thread_limit)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1(thread_limit==nothing) ? 0 : 1])) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.target", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -869,84 +733,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(), -) - _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,] - _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), - isnothing(schedule_chunk_var) ? 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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wsloop(lowerBound, upperBound, step, private_vars, firstprivate_vars, lastprivate_vars, linear_vars, linear_step_vars, reduction_vars, schedule_chunk_var=nothing; 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[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(private_vars)..., value.(firstprivate_vars)..., value.(lastprivate_vars)..., value.(linear_vars)..., value.(linear_step_vars)..., value.(reduction_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(schedule_chunk_var) && push!(operands, value(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])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(schedule_val) && push!(attributes, namedattribute("schedule_val", schedule_val)) + !isnothing(schedule_modifier) && push!(attributes, namedattribute("schedule_modifier", schedule_modifier)) + !isnothing(simd_modifier) && push!(attributes, namedattribute("simd_modifier", simd_modifier)) + !isnothing(collapse_val) && push!(attributes, namedattribute("collapse_val", collapse_val)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(ordered_val) && push!(attributes, namedattribute("ordered_val", ordered_val)) + !isnothing(order_val) && push!(attributes, namedattribute("order_val", order_val)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + + IR.create_operation( + "omp.wsloop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -959,22 +768,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()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/PDL.jl b/src/Dialects/14/PDL.jl index 2f6d8733..9505c334 100644 --- a/src/Dialects/14/PDL.jl +++ b/src/Dialects/14/PDL.jl @@ -1,7 +1,6 @@ module pdl -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -21,26 +20,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() -) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - !isnothing(constParams) && - push!(_attributes, namedattribute("constParams", constParams)) - - return IR.create_operation( - "pdl.apply_native_constraint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_native_constraint(args; name, constParams=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) + + IR.create_operation( + "pdl.apply_native_constraint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -80,30 +72,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - !isnothing(constParams) && - push!(_attributes, namedattribute("constParams", constParams)) - - return IR.create_operation( - "pdl.apply_native_rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_native_rewrite(args; results_::Vector{IR.Type}, name, constParams=nothing, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) + + IR.create_operation( + "pdl.apply_native_rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -132,26 +113,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function attribute(type=nothing; attr::IR.Type, value=nothing, location=Location()) + results = IR.Type[attr, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(type) && push!(operands, value(type)) + !isnothing(value) && push!(attributes, namedattribute("value", value)) + + IR.create_operation( + "pdl.attribute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -168,22 +143,18 @@ operation correspond with the `eraseOp` method on a `PatternRewriter`. pdl.erase %root ``` """ -function erase(operation::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operation,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl.erase", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function erase(operation; location=Location()) + results = IR.Type[] + operands = Value[value(operation), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl.erase", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -208,23 +179,19 @@ 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,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(type) && push!(_operands, type) - - return IR.create_operation( - "pdl.operand", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operand(type=nothing; val::IR.Type, location=Location()) + results = IR.Type[val, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(type) && push!(operands, value(type)) + + IR.create_operation( + "pdl.operand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -249,23 +216,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,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(type) && push!(_operands, type) - - return IR.create_operation( - "pdl.operands", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operands_(type=nothing; val::IR.Type, location=Location()) + results = IR.Type[val, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(type) && push!(operands, value(type)) + + IR.create_operation( + "pdl.operands", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -366,35 +329,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...] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operation(operands_, attributes_, types; op::IR.Type, name=nothing, attributeNames, location=Location()) + results = IR.Type[op, ] + operands = Value[value.(operands_)..., value.(attributes_)..., value.(types)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("attributeNames", attributeNames), ] + push!(attributes, operandsegmentsizes([length(operands), length(attributes), length(types), ])) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "pdl.operation", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -467,32 +415,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(), -) - _results = IR.Type[] - _operands = Value[operation, replValues...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(replOperation) && push!(_operands, replOperation) - push!( - _attributes, - operandsegmentsizes([1, isnothing(replOperation) ? 0 : 1, length(replValues)]), - ) - - return IR.create_operation( - "pdl.replace", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function replace(operation, replOperation=nothing; replValues, location=Location()) + results = IR.Type[] + operands = Value[value(operation), value.(replValues)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(replOperation) && push!(operands, value(replOperation)) + 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 ) end @@ -518,22 +454,18 @@ as defined by the ODS definition of the operation. // the IR snippet, `%pdl_result` would correspond to `%result_1`. ``` """ -function result(parent::Value; val::IR.Type, index, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function result(parent; val::IR.Type, index, location=Location()) + results = IR.Type[val, ] + operands = Value[value(parent), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl.result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -566,23 +498,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(index) && push!(_attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl.results", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function results_(parent; val::IR.Type, index=nothing, location=Location()) + results = IR.Type[val, ] + operands = Value[value(parent), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl.results", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -626,34 +554,22 @@ pdl.rewrite { } ``` """ -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,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(root) && push!(_operands, root) - push!(_attributes, operandsegmentsizes([isnothing(root) ? 0 : 1, length(externalArgs)])) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - !isnothing(externalConstParams) && - push!(_attributes, namedattribute("externalConstParams", externalConstParams)) - - return IR.create_operation( - "pdl.rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rewrite(root=nothing; externalArgs, name=nothing, externalConstParams=nothing, body::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(externalArgs)..., ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(root) && push!(operands, value(root)) + push!(attributes, operandsegmentsizes([(root==nothing) ? 0 : 1length(externalArgs), ])) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + !isnothing(externalConstParams) && push!(attributes, namedattribute("externalConstParams", externalConstParams)) + + IR.create_operation( + "pdl.rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/PDLInterp.jl b/src/Dialects/14/PDLInterp.jl index 9992a775..3c6a207e 100644 --- a/src/Dialects/14/PDLInterp.jl +++ b/src/Dialects/14/PDLInterp.jl @@ -1,7 +1,6 @@ module pdl_interp -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -21,31 +20,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(), -) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_constraint(args; name, constParams=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[namedattribute("name", name), ] + !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) + + IR.create_operation( + "pdl_interp.apply_constraint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -76,30 +63,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - !isnothing(constParams) && - push!(_attributes, namedattribute("constParams", constParams)) - - return IR.create_operation( - "pdl_interp.apply_rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_rewrite(args; results_::Vector{IR.Type}, name, constParams=nothing, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + !isnothing(constParams) && push!(attributes, namedattribute("constParams", constParams)) + + IR.create_operation( + "pdl_interp.apply_rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -116,24 +92,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.are_equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function are_equal(lhs, rhs; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.are_equal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -182,24 +152,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_attribute(attribute; constantValue, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(attribute), ] + owned_regions = Region[] + 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 ) end @@ -222,31 +186,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_operand_count(operation; count, compareAtLeast=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(operation), ] + owned_regions = Region[] + 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 ) end @@ -263,24 +215,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_operation_name(operation; name, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(operation), ] + owned_regions = Region[] + 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 ) end @@ -303,31 +249,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_result_count(operation; count, compareAtLeast=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(operation), ] + owned_regions = Region[] + 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 ) end @@ -344,24 +278,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_type(value; type, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -378,24 +306,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_types(value; types, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -477,36 +399,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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_operation(operands_, attributes_, types; operation::IR.Type, name, attributeNames, location=Location()) + results = IR.Type[operation, ] + operands = Value[value.(operands_)..., value.(attributes_)..., value.(types)..., ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -585,22 +490,18 @@ marked as erased. The semantics of this operation correspond with the pdl_interp.erase %root ``` """ -function erase(operation::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operation,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.erase", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function erase(operation; location=Location()) + results = IR.Type[] + operands = Value[value(operation), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.erase", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -617,22 +518,18 @@ at the specified index. If the index is out of range, returns null. %ops = pdl_interp.extract 1 of %values : !pdl.value ``` """ -function extract(range::Value; result::IR.Type, index, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract(range; result::IR.Type, index, location=Location()) + results = IR.Type[result, ] + operands = Value[value(range), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.extract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -686,22 +583,18 @@ pdl_interp.foreach %op : !pdl.operation in %ops { } -> ^next ``` """ -function foreach(values::Value; region::Region, successor::Block, location=Location()) - _results = IR.Type[] - _operands = Value[values,] - _owned_regions = Region[region,] - _successors = Block[successor,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.foreach", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach(values; region::Region, successor::Block, location=Location()) + results = IR.Type[] + operands = Value[value(values), ] + owned_regions = Region[region, ] + successors = Block[successor, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.foreach", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -718,22 +611,18 @@ returned. %attr = pdl_interp.get_attribute \"attr\" of %op ``` """ -function get_attribute(operation::Value; attribute::IR.Type, name, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_attribute(operation; attribute::IR.Type, name, location=Location()) + results = IR.Type[attribute, ] + operands = Value[value(operation), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.get_attribute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -749,22 +638,18 @@ specific attribute. %type = pdl_interp.get_attribute_type of %attr ``` """ -function get_attribute_type(value::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_attribute_type(value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_attribute_type", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -782,22 +667,18 @@ or range of operand results, null is returned. %op = pdl_interp.get_defining_op of %value : !pdl.value ``` """ -function get_defining_op(value::Value; operation::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_defining_op(value; operation::IR.Type, location=Location()) + results = IR.Type[operation, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_defining_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -814,22 +695,18 @@ null value is returned. %operand = pdl_interp.get_operand 1 of %op ``` """ -function get_operand(operation::Value; value::IR.Type, index, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_operand(operation; value::IR.Type, index, location=Location()) + results = IR.Type[value, ] + operands = Value[value(operation), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.get_operand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -856,23 +733,19 @@ the returned operand group corresponds to all operands of the operation. %operands = pdl_interp.get_operands of %op : !pdl.range ``` """ -function get_operands(operation::Value; value::IR.Type, index=nothing, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_operands(operation; value::IR.Type, index=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(operation), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl_interp.get_operands", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -889,22 +762,18 @@ null value is returned. %result = pdl_interp.get_result 1 of %op ``` """ -function get_result(operation::Value; value::IR.Type, index, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_result(operation; value::IR.Type, index, location=Location()) + results = IR.Type[value, ] + operands = Value[value(operation), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.get_result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -931,23 +800,19 @@ the returned operand group corresponds to all results of the operation. %results = pdl_interp.get_results of %op : !pdl.range ``` """ -function get_results(operation::Value; value::IR.Type, index=nothing, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_results(operation; value::IR.Type, index=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(operation), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl_interp.get_results", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -968,22 +833,18 @@ similarly to ResultRange::getUsers. %ops = pdl_interp.get_users of %values : !pdl.range ``` """ -function get_users(value::Value; operations::IR.Type, location=Location()) - _results = IR.Type[operations,] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.get_users", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_users(value; operations::IR.Type, location=Location()) + results = IR.Type[operations, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_users", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1003,22 +864,18 @@ value or range thereof. %type = pdl_interp.get_value_type of %values : !pdl.range ``` """ -function get_value_type(value::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_value_type(value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_value_type", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1068,22 +925,18 @@ false destination is taken. 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,] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.is_not_null", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function is_not_null(value; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.is_not_null", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1102,37 +955,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(), -) - _results = IR.Type[] - _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)])) - !isnothing(rootKind) && push!(_attributes, namedattribute("rootKind", rootKind)) - !isnothing(generatedOps) && - push!(_attributes, namedattribute("generatedOps", generatedOps)) - - return IR.create_operation( - "pdl_interp.record_match", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function record_match(inputs, matchedOps; rewriter, rootKind=nothing, generatedOps=nothing, benefit, dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(inputs)..., value.(matchedOps)..., ] + owned_regions = Region[] + 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)) + + IR.create_operation( + "pdl_interp.record_match", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1151,22 +988,18 @@ values must match the number of results specified by the operation. 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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.replace", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function replace(operation, replValues; location=Location()) + results = IR.Type[] + operands = Value[value(operation), value.(replValues)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.replace", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1184,28 +1017,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_attribute(attribute; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(attribute), ] + owned_regions = Region[] + 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 ) end @@ -1223,28 +1046,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_operand_count(operation; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(operation), ] + owned_regions = Region[] + 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 ) end @@ -1262,28 +1075,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_operation_name(operation; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(operation), ] + owned_regions = Region[] + 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 ) end @@ -1301,28 +1104,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_result_count(operation; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(operation), ] + owned_regions = Region[] + 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 ) end @@ -1340,24 +1133,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_type(value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -1375,24 +1162,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_types(value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end diff --git a/src/Dialects/14/Quant.jl b/src/Dialects/14/Quant.jl index 42ad32e2..716f005d 100644 --- a/src/Dialects/14/Quant.jl +++ b/src/Dialects/14/Quant.jl @@ -1,7 +1,6 @@ module quant -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -12,39 +11,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(), -) - _results = IR.Type[] - _operands = Value[inputs,] - _owned_regions = Region[] - _successors = Block[] - _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(is_signed) && push!(_attributes, namedattribute("is_signed", is_signed)) - - return IR.create_operation( - "quant.const_fake_quant", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function const_fake_quant(inputs; outputs=nothing::Union{Nothing, IR.Type}, min, max, num_bits, narrow_range=nothing, is_signed=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(inputs), ] + owned_regions = Region[] + successors = Block[] + 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(is_signed) && push!(attributes, namedattribute("is_signed", is_signed)) + + 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) ) end @@ -57,41 +38,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(), -) - _results = IR.Type[] - _operands = Value[inputs,] - _owned_regions = Region[] - _successors = Block[] - _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(is_signed) && push!(_attributes, namedattribute("is_signed", is_signed)) - - return IR.create_operation( - "quant.const_fake_quant_per_axis", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function const_fake_quant_per_axis(inputs; outputs=nothing::Union{Nothing, IR.Type}, min, max, axis, num_bits, narrow_range=nothing, is_signed=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(inputs), ] + owned_regions = Region[] + successors = Block[] + 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(is_signed) && push!(attributes, namedattribute("is_signed", is_signed)) + + 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) ) end @@ -105,25 +66,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() -) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("coupledKey", coupledKey),] - !isnothing(result_0) && push!(_results, result_0) - - return IR.create_operation( - "quant.coupled_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function coupled_ref(arg; result_0=nothing::Union{Nothing, IR.Type}, coupledKey, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("coupledKey", coupledKey), ] + !isnothing(result_0) && push!(results, result_0) + + 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) ) end @@ -131,22 +86,18 @@ end `dcast` """ -function dcast(arg::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.dcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dcast(arg; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.dcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -154,22 +105,18 @@ end `qcast` """ -function qcast(arg::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.qcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function qcast(arg; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.qcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -177,34 +124,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function region(inputs; outputs::Vector{IR.Type}, input_specs, output_specs, logical_kernel, body::Region, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[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), ] + + IR.create_operation( + "quant.region", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -212,22 +143,18 @@ end `return_` """ -function return_(results::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -251,32 +178,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(), -) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function stats(arg; result_0=nothing::Union{Nothing, IR.Type}, layerStats, axisStats=nothing, axis=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + 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)) + + IR.create_operation( + "quant.stats", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -289,25 +205,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() -) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("statsKey", statsKey),] - !isnothing(result_0) && push!(_results, result_0) - - return IR.create_operation( - "quant.stats_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function stats_ref(arg; result_0=nothing::Union{Nothing, IR.Type}, statsKey, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("statsKey", statsKey), ] + !isnothing(result_0) && push!(results, result_0) + + 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) ) end @@ -315,22 +225,18 @@ end `scast` """ -function scast(arg::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.scast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scast(arg; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.scast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/SCF.jl b/src/Dialects/14/SCF.jl index bee5367d..8dcf6317 100644 --- a/src/Dialects/14/SCF.jl +++ b/src/Dialects/14/SCF.jl @@ -1,7 +1,6 @@ module scf -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -12,22 +11,18 @@ of the `scf.while` construct. If its first argument is true, the \"after\" region of `scf.while` is executed, with the remaining arguments forwarded 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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.condition", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function condition(condition, args; location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.condition", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -180,30 +175,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function for_(lowerBound, upperBound, step, initArgs; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(lowerBound), value(upperBound), value(step), value.(initArgs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -253,28 +236,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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.if", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function if_(condition; results_::Vector{IR.Type}, thenRegion::Region, elseRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(condition), ] + owned_regions = Region[thenRegion, elseRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -324,36 +297,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - length(lowerBound), length(upperBound), length(step), length(initVals) - ]), - ) - - return IR.create_operation( - "scf.parallel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(lowerBound, upperBound, step, initVals; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(initVals)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -393,22 +349,18 @@ scf.reduce(%operand) : f32 { } ``` """ -function reduce(operand::Value; reductionOperator::Region, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[reductionOperator,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce(operand; reductionOperator::Region, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[reductionOperator, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.reduce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -423,22 +375,18 @@ the operand of \"scf.reduce\". Example for the custom format: scf.reduce.return %res : f32 ``` """ -function reduce_return(result::Value; location=Location()) - _results = IR.Type[] - _operands = Value[result,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.reduce.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_return(result; location=Location()) + results = IR.Type[] + operands = Value[value(result), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.reduce.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -556,28 +504,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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.while", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function while_(inits; results_::Vector{IR.Type}, before::Region, after::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(inits)..., ] + owned_regions = Region[before, after, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.while", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -594,22 +532,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()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/SPIRV.jl b/src/Dialects/14/SPIRV.jl index bb35e77b..a84b18b8 100644 --- a/src/Dialects/14/SPIRV.jl +++ b/src/Dialects/14/SPIRV.jl @@ -1,7 +1,6 @@ module spv -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -46,24 +45,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.AccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AccessChain(base_ptr, indices; component_ptr::IR.Type, location=Location()) + results = IR.Type[component_ptr, ] + operands = Value[value(base_ptr), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.AccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -147,31 +140,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicAnd(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -221,35 +201,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicCompareExchange(pointer, value, comparator; result::IR.Type, memory_scope, equal_semantics, unequal_semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), value(comparator), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -277,35 +240,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicCompareExchangeWeak(pointer, value, comparator; result::IR.Type, memory_scope, equal_semantics, unequal_semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), value(comparator), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -342,31 +288,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicExchange", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicExchange(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -408,31 +341,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicFAddEXT", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicFAddEXT(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -469,31 +389,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicIAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIAdd(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -529,26 +436,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicIDecrement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIDecrement(pointer; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -583,26 +482,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicIIncrement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIIncrement(pointer; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -640,31 +531,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicISub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicISub(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -701,31 +579,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicOr(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -763,31 +628,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicSMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicSMax(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -825,31 +677,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicSMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicSMin(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -887,31 +726,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicUMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicUMax(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -949,31 +775,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicUMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicUMin(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1011,31 +824,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicXor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicXor(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1071,25 +871,19 @@ Results are computed per component. %3 = spv.BitCount %1: vector<4xi32> ``` """ -function BitCount( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.BitCount", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitCount(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitCount", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1135,30 +929,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldInsert(base, insert, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(insert), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitFieldInsert", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1204,29 +987,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldSExtract(base, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitFieldSExtract", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1254,29 +1027,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldUExtract(base, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitFieldUExtract", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1308,25 +1071,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() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.BitReverse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitReverse(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitReverse", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1369,22 +1126,18 @@ bitcast-op ::= ssa-id `=` `spv.Bitcast` ssa-use %1 = spv.Bitcast %0 : !spv.ptr to !spv.ptr ``` """ -function Bitcast(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Bitcast(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1414,28 +1167,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.BitwiseAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseAnd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitwiseAnd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1465,28 +1209,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.BitwiseOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseOr(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitwiseOr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1516,28 +1251,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.BitwiseXor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseXor(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitwiseXor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1575,36 +1301,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(), -) - _results = IR.Type[] - _operands = Value[condition, trueTargetOperands..., falseTargetOperands...] - _owned_regions = Region[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function BranchConditional(condition, trueTargetOperands, falseTargetOperands; branch_weights=nothing, trueTarget::Block, falseTarget::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueTargetOperands)..., value.(falseTargetOperands)..., ] + owned_regions = Region[] + successors = Block[trueTarget, falseTarget, ] + attributes = NamedAttribute[] + 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 ) end @@ -1628,22 +1338,18 @@ spv.Branch ^target spv.Branch ^target(%0, %1: i32, f32) ``` """ -function Branch(targetOperands::Vector{Value}; target::Block, location=Location()) - _results = IR.Type[] - _operands = Value[targetOperands...,] - _owned_regions = Region[] - _successors = Block[target,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Branch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Branch(targetOperands; target::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(targetOperands)..., ] + owned_regions = Region[] + successors = Block[target, ] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Branch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1681,24 +1387,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.CompositeConstruct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CompositeConstruct(constituents; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(constituents)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.CompositeConstruct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1731,24 +1431,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("indices", indices),] - - return IR.create_operation( - "spv.CompositeExtract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CompositeExtract(composite; component::IR.Type, indices, location=Location()) + results = IR.Type[component, ] + operands = Value[value(composite), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indices", indices), ] + + IR.create_operation( + "spv.CompositeExtract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1781,24 +1475,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("indices", indices),] - - return IR.create_operation( - "spv.CompositeInsert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CompositeInsert(object, composite; result::IR.Type, indices, location=Location()) + results = IR.Type[result, ] + operands = Value[value(object), value(composite), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indices", indices), ] + + IR.create_operation( + "spv.CompositeInsert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1951,22 +1639,18 @@ convert-f-to-s-op ::= ssa-id `=` `spv.ConvertFToSOp` ssa-use %3 = spv.ConvertFToS %2 : vector<3xf32> to vector<3xi32> ``` """ -function ConvertFToS(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertFToS", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertFToS(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ConvertFToS", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1995,22 +1679,18 @@ convert-f-to-u-op ::= ssa-id `=` `spv.ConvertFToUOp` ssa-use %3 = spv.ConvertFToU %2 : vector<3xf32> to vector<3xi32> ``` """ -function ConvertFToU(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertFToU", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertFToU(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ConvertFToU", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2038,22 +1718,18 @@ convert-s-to-f-op ::= ssa-id `=` `spv.ConvertSToFOp` ssa-use %3 = spv.ConvertSToF %2 : vector<3xi32> to vector<3xf32> ``` """ -function ConvertSToF(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertSToF", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertSToF(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ConvertSToF", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2081,22 +1757,18 @@ convert-u-to-f-op ::= ssa-id `=` `spv.ConvertUToFOp` ssa-use %3 = spv.ConvertUToF %2 : vector<3xi32> to vector<3xf32> ``` """ -function ConvertUToF(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertUToF", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertUToF(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ConvertUToF", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2196,31 +1868,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CooperativeMatrixLoadNV(pointer, stride, columnmajor; result::IR.Type, memory_access=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(stride), value(columnmajor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -2271,29 +1931,19 @@ For example: !spv.coopmatrix ``` """ -function CooperativeMatrixMulAddNV( - a::Value, - b::Value, - c::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CooperativeMatrixMulAddNV(a, b, c; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CooperativeMatrixMulAddNV", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2336,31 +1986,19 @@ For example: !spv.ptr, !spv.coopmatrix ``` """ -function CooperativeMatrixStoreNV( - pointer::Value, - object::Value, - stride::Value, - columnmajor::Value; - memory_access=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CooperativeMatrixStoreNV(pointer, object, stride, columnmajor; memory_access=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(pointer), value(object), value(stride), value(columnmajor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -2393,37 +2031,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(), -) - _results = IR.Type[] - _operands = Value[target, source] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CopyMemory(target, source; memory_access=nothing, alignment=nothing, source_memory_access=nothing, source_alignment=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(target), value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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)) + + IR.create_operation( + "spv.CopyMemory", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2567,28 +2190,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FAdd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2617,22 +2231,18 @@ f-convert-op ::= ssa-id `=` `spv.FConvertOp` ssa-use %3 = spv.FConvertOp %2 : vector<3xf32> to vector<3xf64> ``` """ -function FConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2662,28 +2272,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2714,28 +2315,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2765,28 +2357,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FMul(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2814,25 +2397,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() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FNegate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FNegate(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FNegate", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2862,22 +2439,18 @@ fordequal-op ::= ssa-id `=` `spv.FOrdEqual` ssa-use, ssa-use %5 = spv.FOrdEqual %2, %3 : vector<4xf32> ``` """ -function FOrdEqual(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.FOrdEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2907,24 +2480,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2954,24 +2521,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3001,24 +2562,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3048,24 +2603,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3095,24 +2644,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3144,28 +2687,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FRem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FRem(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FRem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3194,28 +2728,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FSub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FSub(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FSub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3245,22 +2770,18 @@ funordequal-op ::= ssa-id `=` `spv.FUnordEqual` ssa-use, ssa-use %5 = spv.FUnordEqual %2, %3 : vector<4xf32> ``` """ -function FUnordEqual(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.FUnordEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FUnordEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3290,24 +2811,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FUnordGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3337,24 +2852,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FUnordGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3384,24 +2893,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FUnordLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3431,24 +2934,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FUnordLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3478,24 +2975,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FUnordNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3581,28 +3072,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(), -) - _results = IR.Type[] - _operands = Value[arguments...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("callee", callee),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FunctionCall", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FunctionCall(arguments; result=nothing::Union{Nothing, IR.Type}, callee, location=Location()) + results = IR.Type[] + operands = Value[value.(arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FunctionCall", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3635,22 +3117,18 @@ acos-op ::= ssa-id `=` `spv.GLSL.Acos` ssa-use `:` %3 = spv.GLSL.Acos %1 : vector<3xf16> ``` """ -function GLSL_Acos(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Acos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Acos(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Acos", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3683,22 +3161,18 @@ asin-op ::= ssa-id `=` `spv.GLSL.Asin` ssa-use `:` %3 = spv.GLSL.Asin %1 : vector<3xf16> ``` """ -function GLSL_Asin(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Asin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Asin(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Asin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3731,22 +3205,18 @@ atan-op ::= ssa-id `=` `spv.GLSL.Atan` ssa-use `:` %3 = spv.GLSL.Atan %1 : vector<3xf16> ``` """ -function GLSL_Atan(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Atan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Atan(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Atan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3776,22 +3246,18 @@ ceil-op ::= ssa-id `=` `spv.GLSL.Ceil` ssa-use `:` %3 = spv.GLSL.Ceil %1 : vector<3xf16> ``` """ -function GLSL_Ceil(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Ceil(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Ceil", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3822,22 +3288,18 @@ cos-op ::= ssa-id `=` `spv.GLSL.Cos` ssa-use `:` %3 = spv.GLSL.Cos %1 : vector<3xf16> ``` """ -function GLSL_Cos(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Cos(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Cos", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3868,22 +3330,18 @@ cosh-op ::= ssa-id `=` `spv.GLSL.Cosh` ssa-use `:` %3 = spv.GLSL.Cosh %1 : vector<3xf16> ``` """ -function GLSL_Cosh(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Cosh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Cosh(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Cosh", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3914,22 +3372,18 @@ exp-op ::= ssa-id `=` `spv.GLSL.Exp` ssa-use `:` %3 = spv.GLSL.Exp %1 : vector<3xf16> ``` """ -function GLSL_Exp(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Exp(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Exp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3958,22 +3412,18 @@ abs-op ::= ssa-id `=` `spv.GLSL.FAbs` ssa-use `:` %3 = spv.GLSL.FAbs %1 : vector<3xf16> ``` """ -function GLSL_FAbs(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.FAbs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_FAbs(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.FAbs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4002,22 +3452,18 @@ fclamp-op ::= ssa-id `=` `spv.GLSL.FClamp` ssa-use, ssa-use, ssa-use `:` %3 = spv.GLSL.FClamp %x, %min, %max : vector<3xf16> ``` """ -function GLSL_FClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_FClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.FClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4047,22 +3493,18 @@ fmax-op ::= ssa-id `=` `spv.GLSL.FMax` ssa-use `:` %3 = spv.GLSL.FMax %0, %1 : vector<3xf16> ``` """ -function GLSL_FMax(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.FMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_FMax(lhs, rhs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.FMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4092,22 +3534,18 @@ fmin-op ::= ssa-id `=` `spv.GLSL.FMin` ssa-use `:` %3 = spv.GLSL.FMin %0, %1 : vector<3xf16> ``` """ -function GLSL_FMin(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.FMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_FMin(lhs, rhs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.FMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4129,29 +3567,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GLSL_FMix(x, y, a; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(y), value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -4180,22 +3608,18 @@ sign-op ::= ssa-id `=` `spv.GLSL.FSign` ssa-use `:` %3 = spv.GLSL.FSign %1 : vector<3xf16> ``` """ -function GLSL_FSign(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.FSign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_FSign(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.FSign", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4225,22 +3649,18 @@ floor-op ::= ssa-id `=` `spv.GLSL.Floor` ssa-use `:` %3 = spv.GLSL.Floor %1 : vector<3xf16> ``` """ -function GLSL_Floor(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Floor(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Floor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4279,22 +3699,18 @@ fma-op ::= ssa-id `=` `spv.GLSL.Fma` ssa-use, ssa-use, ssa-use `:` %1 = spv.GLSL.Fma %a, %b, %c : vector<3xf16> ``` """ -function GLSL_Fma(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Fma(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Fma", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4336,22 +3752,18 @@ frexpstruct-op ::= ssa-id `=` `spv.GLSL.FrexpStruct` ssa-use `:` %3 = spv.GLSL.FrexpStruct %0 : vector<3xf32> -> !spv.struct, vector<3xi32>> ``` """ -function GLSL_FrexpStruct(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.FrexpStruct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_FrexpStruct(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.FrexpStruct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4380,22 +3792,18 @@ rsqrt-op ::= ssa-id `=` `spv.GLSL.InverseSqrt` ssa-use `:` %3 = spv.GLSL.InverseSqrt %1 : vector<3xf16> ``` """ -function GLSL_InverseSqrt(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.InverseSqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_InverseSqrt(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.InverseSqrt", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4433,25 +3841,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GLSL_Ldexp(x, exp; y=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(exp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(y) && push!(results, y) + + 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) ) end @@ -4483,22 +3885,18 @@ log-op ::= ssa-id `=` `spv.GLSL.Log` ssa-use `:` %3 = spv.GLSL.Log %1 : vector<3xf16> ``` """ -function GLSL_Log(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Log(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Log", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4531,22 +3929,18 @@ pow-op ::= ssa-id `=` `spv.GLSL.Pow` ssa-use `:` %3 = spv.GLSL.Pow %0, %1 : vector<3xf16> ``` """ -function GLSL_Pow(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Pow(lhs, rhs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Pow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4575,22 +3969,18 @@ floor-op ::= ssa-id `=` `spv.GLSL.Round` ssa-use `:` %3 = spv.GLSL.Round %1 : vector<3xf16> ``` """ -function GLSL_Round(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Round(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Round", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4618,22 +4008,18 @@ abs-op ::= ssa-id `=` `spv.GLSL.SAbs` ssa-use `:` %3 = spv.GLSL.SAbs %1 : vector<3xi16> ``` """ -function GLSL_SAbs(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.SAbs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_SAbs(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.SAbs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4661,22 +4047,18 @@ uclamp-op ::= ssa-id `=` `spv.GLSL.UClamp` ssa-use, ssa-use, ssa-use `:` %3 = spv.GLSL.SClamp %x, %min, %max : vector<3xsi16> ``` """ -function GLSL_SClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_SClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.SClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4705,22 +4087,18 @@ smax-op ::= ssa-id `=` `spv.GLSL.SMax` ssa-use `:` %3 = spv.GLSL.SMax %0, %1 : vector<3xi16> ``` """ -function GLSL_SMax(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.SMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_SMax(lhs, rhs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.SMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4749,22 +4127,18 @@ smin-op ::= ssa-id `=` `spv.GLSL.SMin` ssa-use `:` %3 = spv.GLSL.SMin %0, %1 : vector<3xi16> ``` """ -function GLSL_SMin(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.SMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_SMin(lhs, rhs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.SMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4792,22 +4166,18 @@ sign-op ::= ssa-id `=` `spv.GLSL.SSign` ssa-use `:` %3 = spv.GLSL.SSign %1 : vector<3xi16> ``` """ -function GLSL_SSign(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.SSign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_SSign(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.SSign", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4838,22 +4208,18 @@ sin-op ::= ssa-id `=` `spv.GLSL.Sin` ssa-use `:` %3 = spv.GLSL.Sin %1 : vector<3xf16> ``` """ -function GLSL_Sin(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Sin(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Sin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4884,22 +4250,18 @@ sinh-op ::= ssa-id `=` `spv.GLSL.Sinh` ssa-use `:` %3 = spv.GLSL.Sinh %1 : vector<3xf16> ``` """ -function GLSL_Sinh(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Sinh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Sinh(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Sinh", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4928,22 +4290,18 @@ sqrt-op ::= ssa-id `=` `spv.GLSL.Sqrt` ssa-use `:` %3 = spv.GLSL.Sqrt %1 : vector<3xf16> ``` """ -function GLSL_Sqrt(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Sqrt(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Sqrt", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4974,22 +4332,18 @@ tan-op ::= ssa-id `=` `spv.GLSL.Tan` ssa-use `:` %3 = spv.GLSL.Tan %1 : vector<3xf16> ``` """ -function GLSL_Tan(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Tan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_Tan(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Tan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5020,24 +4374,20 @@ tanh-op ::= ssa-id `=` `spv.GLSL.Tanh` ssa-use `:` %3 = spv.GLSL.Tanh %1 : vector<3xf16> ``` """ -function GLSL_Tanh(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.Tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end +function GLSL_Tanh(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.Tanh", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `GLSL_UClamp` @@ -5063,22 +4413,18 @@ uclamp-op ::= ssa-id `=` `spv.GLSL.UClamp` ssa-use, ssa-use, ssa-use `:` %3 = spv.GLSL.UClamp %x, %min, %max : vector<3xui16> ``` """ -function GLSL_UClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_UClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.UClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5107,22 +4453,18 @@ smax-op ::= ssa-id `=` `spv.GLSL.UMax` ssa-use `:` %3 = spv.GLSL.UMax %0, %1 : vector<3xi16> ``` """ -function GLSL_UMax(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.UMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_UMax(lhs, rhs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.UMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5151,22 +4493,18 @@ smin-op ::= ssa-id `=` `spv.GLSL.UMin` ssa-use `:` %3 = spv.GLSL.UMin %0, %1 : vector<3xi16> ``` """ -function GLSL_UMin(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GLSL.UMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GLSL_UMin(lhs, rhs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GLSL.UMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5292,29 +4630,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(), -) - _results = IR.Type[] - _operands = Value[value, localid] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GroupBroadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupBroadcast(value, localid; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(localid), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GroupBroadcast", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5347,24 +4675,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - - return IR.create_operation( - "spv.GroupNonUniformBallot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformBallot(predicate; result::IR.Type, execution_scope, location=Location()) + results = IR.Type[result, ] + operands = Value[value(predicate), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + + IR.create_operation( + "spv.GroupNonUniformBallot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5409,29 +4731,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(), -) - _results = IR.Type[] - _operands = Value[value, id] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GroupNonUniformBroadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupNonUniformBroadcast(value, id; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(id), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GroupNonUniformBroadcast", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5520,33 +4832,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFAdd(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformFAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5595,33 +4893,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformFMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5670,33 +4954,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformFMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5742,33 +5012,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMul(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformFMul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5812,33 +5068,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformIAdd(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformIAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5882,33 +5124,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformIMul(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformIMul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5952,33 +5180,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformSMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformSMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6022,33 +5236,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformSMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformSMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6093,33 +5293,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformUMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformUMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6164,33 +5350,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformUMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformUMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6225,28 +5397,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.IAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IAdd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.IAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6276,22 +5439,18 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.IEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function IEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.IEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6326,28 +5485,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.IMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IMul(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.IMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6377,22 +5527,18 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.INotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function INotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.INotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6427,28 +5573,19 @@ isub-op ::= `spv.ISub` ssa-use, ssa-use ``` """ -function ISub( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.ISub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ISub(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.ISub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6488,32 +5625,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(imageoperands) && - push!(_attributes, namedattribute("imageoperands", imageoperands)) - - return IR.create_operation( - "spv.ImageDrefGather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ImageDrefGather(sampledimage, coordinate, dref, operand_arguments; result::IR.Type, imageoperands=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(sampledimage), value(coordinate), value(dref), value.(operand_arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(imageoperands) && push!(attributes, namedattribute("imageoperands", imageoperands)) + + IR.create_operation( + "spv.ImageDrefGather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6533,22 +5657,18 @@ same as Result Type. %0 = spv.Image %1 : !spv.sampled_image> ``` """ -function Image(sampledimage::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[sampledimage,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Image", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Image(sampledimage; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(sampledimage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Image", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6586,22 +5706,18 @@ See the client API specification for additional image type restrictions. %5 = spv.ImageQuerySize %2 : !spv.image -> vector<3xi32> ``` """ -function ImageQuerySize(image::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[image,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ImageQuerySize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ImageQuerySize(image; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(image), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ImageQuerySize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6627,28 +5743,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.InBoundsPtrAccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function InBoundsPtrAccessChain(base_ptr, element, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base_ptr), value(element), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.InBoundsPtrAccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6678,22 +5784,18 @@ isinf-op ::= ssa-id `=` `spv.IsInf` ssa-use %3 = spv.IsInf %1: vector<4xi32> ``` """ -function IsInf(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.IsInf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function IsInf(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.IsInf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6723,22 +5825,18 @@ isnan-op ::= ssa-id `=` `spv.IsNan` ssa-use %3 = spv.IsNan %1: vector<4xi32> ``` """ -function IsNan(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.IsNan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function IsNan(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.IsNan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6775,31 +5873,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Load(ptr; value::IR.Type, memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(ptr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spv.Load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6828,22 +5915,18 @@ logical-and ::= `spv.LogicalAnd` ssa-use `,` ssa-use %2 = spv.LogicalAnd %0, %1 : vector<4xi1> ``` """ -function LogicalAnd(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.LogicalAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function LogicalAnd(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.LogicalAnd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6860,36 +5943,30 @@ Result Type must be a scalar or vector of Boolean type. -``` -logical-equal ::= `spv.LogicalEqual` ssa-use `,` ssa-use - `:` operand-type -``` - -#### Example: - -```mlir -%2 = spv.LogicalEqual %0, %1 : i1 -%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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.LogicalEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +``` +logical-equal ::= `spv.LogicalEqual` ssa-use `,` ssa-use + `:` operand-type +``` + +#### Example: + +```mlir +%2 = spv.LogicalEqual %0, %1 : i1 +%2 = spv.LogicalEqual %0, %1 : vector<4xi1> +``` +""" +function LogicalEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.LogicalEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6918,24 +5995,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.LogicalNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function LogicalNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.LogicalNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6961,22 +6032,18 @@ logical-not ::= `spv.LogicalNot` ssa-use `:` operand-type %2 = spv.LogicalNot %0 : vector<4xi1> ``` """ -function LogicalNot(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.LogicalNot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function LogicalNot(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.LogicalNot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7005,22 +6072,18 @@ logical-or ::= `spv.LogicalOr` ssa-use `,` ssa-use %2 = spv.LogicalOr %0, %1 : vector<4xi1> ``` """ -function LogicalOr(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.LogicalOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function LogicalOr(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.LogicalOr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7099,24 +6162,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.MatrixTimesMatrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function MatrixTimesMatrix(leftmatrix, rightmatrix; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(leftmatrix), value(rightmatrix), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.MatrixTimesMatrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7148,24 +6205,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.MatrixTimesScalar", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function MatrixTimesScalar(matrix, scalar; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(matrix), value(scalar), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.MatrixTimesScalar", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7353,23 +6404,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.Not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Not(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.Not", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7398,22 +6445,18 @@ ceil-op ::= ssa-id `=` `spv.OCL.ceil` ssa-use `:` %3 = spv.OCL.ceil %1 : vector<3xf16> ``` """ -function OCL_ceil(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_ceil(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.ceil", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7442,22 +6485,18 @@ cos-op ::= ssa-id `=` `spv.OCL.cos` ssa-use `:` %3 = spv.OCL.cos %1 : vector<3xf16> ``` """ -function OCL_cos(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_cos(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.cos", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7486,22 +6525,18 @@ erf-op ::= ssa-id `=` `spv.OCL.erf` ssa-use `:` %3 = spv.OCL.erf %1 : vector<3xf16> ``` """ -function OCL_erf(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.erf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_erf(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.erf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7530,22 +6565,18 @@ exp-op ::= ssa-id `=` `spv.OCL.exp` ssa-use `:` %3 = spv.OCL.exp %1 : vector<3xf16> ``` """ -function OCL_exp(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_exp(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.exp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7574,22 +6605,18 @@ abs-op ::= ssa-id `=` `spv.OCL.fabs` ssa-use `:` %3 = spv.OCL.fabs %1 : vector<3xf16> ``` """ -function OCL_fabs(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.fabs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_fabs(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.fabs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7618,22 +6645,18 @@ floor-op ::= ssa-id `=` `spv.OCL.floor` ssa-use `:` %3 = spv.OCL.ceifloorl %1 : vector<3xf16> ``` """ -function OCL_floor(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_floor(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.floor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7662,22 +6685,18 @@ log-op ::= ssa-id `=` `spv.OCL.log` ssa-use `:` %3 = spv.OCL.log %1 : vector<3xf16> ``` """ -function OCL_log(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_log(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.log", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7707,22 +6726,18 @@ pow-op ::= ssa-id `=` `spv.OCL.pow` ssa-use `:` %3 = spv.OCL.pow %0, %1 : vector<3xf16> ``` """ -function OCL_pow(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_pow(lhs, rhs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.pow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7751,22 +6766,18 @@ rsqrt-op ::= ssa-id `=` `spv.OCL.rsqrt` ssa-use `:` %3 = spv.OCL.rsqrt %1 : vector<3xf16> ``` """ -function OCL_rsqrt(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_rsqrt(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.rsqrt", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7795,22 +6806,18 @@ abs-op ::= ssa-id `=` `spv.OCL.s_abs` ssa-use `:` %3 = spv.OCL.s_abs %1 : vector<3xi16> ``` """ -function OCL_s_abs(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.s_abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_s_abs(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.s_abs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7839,22 +6846,18 @@ sin-op ::= ssa-id `=` `spv.OCL.sin` ssa-use `:` %3 = spv.OCL.sin %1 : vector<3xf16> ``` """ -function OCL_sin(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_sin(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.sin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7877,28 +6880,24 @@ sqrt-op ::= ssa-id `=` `spv.OCL.sqrt` ssa-use `:` ```mlir #### Example: - -``` -%2 = spv.OCL.sqrt %0 : f32 -%3 = spv.OCL.sqrt %1 : vector<3xf16> -``` -""" -function OCL_sqrt(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, + +``` +%2 = spv.OCL.sqrt %0 : f32 +%3 = spv.OCL.sqrt %1 : vector<3xf16> +``` +""" +function OCL_sqrt(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.sqrt", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7927,22 +6926,18 @@ tanh-op ::= ssa-id `=` `spv.OCL.tanh` ssa-use `:` %3 = spv.OCL.tanh %1 : vector<3xf16> ``` """ -function OCL_tanh(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.OCL.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function OCL_tanh(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.OCL.tanh", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7973,22 +6968,18 @@ ordered-op ::= ssa-id `=` `spv.Ordered` ssa-use, ssa-use %5 = spv.Ordered %2, %3 : vector<4xf32> ``` """ -function Ordered(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.Ordered", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Ordered(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Ordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8037,28 +7028,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.PtrAccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function PtrAccessChain(base_ptr, element, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base_ptr), value(element), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.PtrAccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8157,22 +7138,18 @@ return-value-op ::= `spv.ReturnValue` ssa-use `:` spirv-type spv.ReturnValue %0 : f32 ``` """ -function ReturnValue(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ReturnValue", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ReturnValue(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ReturnValue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8201,22 +7178,18 @@ s-convert-op ::= ssa-id `=` `spv.SConvertOp` ssa-use %3 = spv.SConvertOp %2 : vector<3xi32> to vector<3xi64> ``` """ -function SConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8248,28 +7221,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.SDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.SDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8299,24 +7263,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8346,24 +7304,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8393,24 +7345,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8440,22 +7386,18 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8488,28 +7430,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.SMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.SMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8533,25 +7466,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() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.SNegate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SNegate(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.SNegate", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8584,28 +7511,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.SRem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SRem(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.SRem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8648,29 +7566,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Select(condition, true_value, false_value; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(true_value), value(false_value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.Select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8750,24 +7658,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ShiftLeftLogical", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ShiftLeftLogical(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ShiftLeftLogical", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8804,24 +7706,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ShiftRightArithmetic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ShiftRightArithmetic(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ShiftRightArithmetic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8852,31 +7748,25 @@ shift-right-logical-op ::= ssa-id `=` `spv.ShiftRightLogical` integer-scalar-vector-type ``` -#### Example: - -```mlir -%2 = spv.ShiftRightLogical %0, %1 : i32, i16 -%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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ShiftRightLogical", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +#### Example: + +```mlir +%2 = spv.ShiftRightLogical %0, %1 : i32, i16 +%5 = spv.ShiftRightLogical %3, %4 : vector<3xi32>, vector<3xi16> +``` +""" +function ShiftRightLogical(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ShiftRightLogical", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9108,27 +7998,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() -) - _results = IR.Type[] - _operands = Value[ptr, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Store(ptr, value; memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(ptr), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spv.Store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9162,22 +8045,18 @@ subgroup-ballot-op ::= ssa-id `=` `spv.SubgroupBallotKHR` %0 = spv.SubgroupBallotKHR %predicate : vector<4xi32> ``` """ -function SubgroupBallotKHR(predicate::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[predicate,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SubgroupBallotKHR", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SubgroupBallotKHR(predicate; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(predicate), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SubgroupBallotKHR", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9212,22 +8091,18 @@ subgroup-block-read-INTEL-op ::= ssa-id `=` `spv.SubgroupBlockReadINTEL` %0 = spv.SubgroupBlockReadINTEL \"StorageBuffer\" %ptr : i32 ``` """ -function SubgroupBlockReadINTEL(ptr::Value; value::IR.Type, location=Location()) - _results = IR.Type[value,] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SubgroupBlockReadINTEL", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SubgroupBlockReadINTEL(ptr; value::IR.Type, location=Location()) + results = IR.Type[value, ] + operands = Value[value(ptr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SubgroupBlockReadINTEL", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9261,22 +8136,18 @@ subgroup-block-write-INTEL-op ::= ssa-id `=` `spv.SubgroupBlockWriteINTEL` spv.SubgroupBlockWriteINTEL \"StorageBuffer\" %ptr, %value : i32 ``` """ -function SubgroupBlockWriteINTEL(ptr::Value, value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[ptr, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SubgroupBlockWriteINTEL", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SubgroupBlockWriteINTEL(ptr, value; location=Location()) + results = IR.Type[] + operands = Value[value(ptr), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SubgroupBlockWriteINTEL", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9308,22 +8179,18 @@ matrix-type ``` """ -function Transpose(matrix::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[matrix,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Transpose(matrix; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(matrix), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9353,22 +8220,18 @@ u-convert-op ::= ssa-id `=` `spv.UConvertOp` ssa-use %3 = spv.UConvertOp %2 : vector<3xi32> to vector<3xi64> ``` """ -function UConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.UConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.UConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9399,28 +8262,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.UDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.UDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9450,24 +8304,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.UGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.UGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9497,24 +8345,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.UGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.UGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9544,24 +8386,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ULessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ULessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ULessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9591,22 +8427,18 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ULessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ULessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ULessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9637,28 +8469,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.UMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.UMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9730,22 +8553,18 @@ unordered-op ::= ssa-id `=` `spv.Unordered` ssa-use, ssa-use %5 = spv.Unordered %2, %3 : vector<4xf32> ``` """ -function Unordered(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.Unordered", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Unordered(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Unordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9813,28 +8632,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,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("storage_class", storage_class),] - !isnothing(initializer) && push!(_operands, initializer) - - return IR.create_operation( - "spv.Variable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Variable(initializer=nothing; 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), ] + !isnothing(initializer) && push!(operands, value(initializer)) + + IR.create_operation( + "spv.Variable", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9860,24 +8670,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.VectorExtractDynamic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function VectorExtractDynamic(vector, index; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.VectorExtractDynamic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9915,29 +8719,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function VectorInsertDynamic(vector, component, index; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(vector), value(component), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.VectorInsertDynamic", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9978,24 +8772,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("components", components),] - - return IR.create_operation( - "spv.VectorShuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function VectorShuffle(vector1, vector2; result::IR.Type, components, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("components", components), ] + + IR.create_operation( + "spv.VectorShuffle", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10018,22 +8806,18 @@ spv.mlir.yield ::= `spv.mlir.yield` ssa-id : spirv-type spv.mlir.yield %0 ``` """ -function mlir_yield(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.mlir.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mlir_yield(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.mlir.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/Shape.jl b/src/Dialects/14/Shape.jl index b8a3edd7..20817c3b 100644 --- a/src/Dialects/14/Shape.jl +++ b/src/Dialects/14/Shape.jl @@ -1,7 +1,6 @@ module shape -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -14,25 +13,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -52,22 +45,18 @@ inputs have differing ranks or differ in extents of shared dimensions. %s1 = shape.any [?,?], [1,2] // [1,2] ``` """ -function any(inputs::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.any", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function any(inputs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.any", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -91,22 +80,18 @@ ready to execute. %wt = shape.assuming_all %w0, %w2 // Passing ``` """ -function assuming_all(inputs::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assuming_all(inputs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.assuming_all", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -120,24 +105,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assuming(witness; results_::Vector{IR.Type}, doRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(witness), ] + owned_regions = Region[doRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.assuming", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -149,22 +128,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming_yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assuming_yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.assuming_yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -191,25 +166,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(error) && push!(_attributes, namedattribute("error", error)) - - return IR.create_operation( - "shape.broadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function broadcast(shapes; result::IR.Type, error=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(error) && push!(attributes, namedattribute("error", error)) + + IR.create_operation( + "shape.broadcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -224,25 +193,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.concat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function concat(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.concat", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -360,25 +323,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_broadcastable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_broadcastable(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -395,25 +352,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_eq(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -436,25 +387,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() -) - _results = IR.Type[] - _operands = Value[pred,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("msg", msg),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_require", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_require(pred; result=nothing::Union{Nothing, IR.Type}, msg, location=Location()) + results = IR.Type[] + operands = Value[value(pred), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("msg", msg), ] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -465,22 +410,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.debug_print", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function debug_print(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.debug_print", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -501,25 +442,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function div(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.div", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -530,25 +465,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function from_extent_tensor(input; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -565,22 +494,18 @@ the shape. %s1 = shape.from_extents ``` """ -function from_extents(extents::Vector{Value}; shape::IR.Type, location=Location()) - _results = IR.Type[shape,] - _operands = Value[extents...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.from_extents", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function from_extents(extents; shape::IR.Type, location=Location()) + results = IR.Type[shape, ] + operands = Value[value.(extents)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.from_extents", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -628,25 +553,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function get_extent(shape, dim; extent=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), value(dim), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(extent) && push!(results, extent) + + 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) ) end @@ -659,25 +578,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function index_to_size(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -699,25 +612,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.is_broadcastable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function is_broadcastable(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -729,25 +636,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function max(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.max", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -778,30 +679,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function meet(arg0, arg1; result=nothing::Union{Nothing, IR.Type}, error=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(arg0), value(arg1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(error) && push!(attributes, namedattribute("error", error)) + + IR.create_operation( + "shape.meet", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -813,25 +704,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function min(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.min", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -845,25 +730,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -876,25 +755,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() -) - _results = IR.Type[] - _operands = Value[shape,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.num_elements", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function num_elements(shape; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -903,23 +776,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()) - _results = IR.Type[] - _operands = Value[shape,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(rank) && push!(_results, rank) - - return IR.create_operation( - "shape.rank", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rank(shape; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + IR.create_operation( + "shape.rank", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -956,28 +825,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce(shape, initVals; result::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result..., ] + operands = Value[value(shape), value.(initVals)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.reduce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -990,25 +849,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.shape_eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shape_eq(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1018,23 +871,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()) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.shape_of", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shape_of(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1046,25 +895,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function size_to_index(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1092,24 +935,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.split_at", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function split_at(operand, index; head::IR.Type, tail::IR.Type, location=Location()) + results = IR.Type[head, tail, ] + operands = Value[value(operand), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.split_at", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1122,22 +959,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.to_extent_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function to_extent_tensor(input; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.to_extent_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1158,22 +991,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.value_as_shape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function value_as_shape(arg; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.value_as_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1212,28 +1041,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function with_shape(operand, shape; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1241,22 +1061,18 @@ end `yield` """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/SparseTensor.jl b/src/Dialects/14/SparseTensor.jl index 450264de..b6ca0a6a 100644 --- a/src/Dialects/14/SparseTensor.jl +++ b/src/Dialects/14/SparseTensor.jl @@ -1,7 +1,6 @@ module sparse_tensor -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -26,30 +25,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(), -) - _results = IR.Type[] - _operands = Value[tensor, indices, values, filled, added, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.compress", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function compress(tensor, indices, values, filled, added, count; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(indices), value(values), value(filled), value(added), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.compress", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -86,22 +73,18 @@ Examples: %4 = sparse_tensor.convert %d : tensor to tensor<100xf64, #SV> ``` """ -function convert(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.convert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function convert(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.convert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -137,29 +120,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.expand", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand(tensor; values::IR.Type, filled::IR.Type, added::IR.Type, count::IR.Type, location=Location()) + results = IR.Type[values, filled, added, count, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.expand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -180,22 +152,18 @@ a subsequent operation that yields a sparse tensor as the result. outs(%c: tensor) -> tensor ``` """ -function init(sizes::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[sizes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.init", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function init(sizes; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.init", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -218,22 +186,18 @@ sparse_tensor.lex_insert %tensor, %indices, %val : tensor<1024x1024xf64, #CSR>, memref, f64 ``` """ -function lex_insert(tensor::Value, indices::Value, value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[tensor, indices, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.lex_insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function lex_insert(tensor, indices, value; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(indices), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.lex_insert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -263,29 +227,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function load(tensor; result=nothing::Union{Nothing, IR.Type}, hasInserts=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(hasInserts) && push!(attributes, namedattribute("hasInserts", hasInserts)) + + 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) ) end @@ -307,22 +262,18 @@ typed sparse tensor with inital contents into a computation. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.new", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function new(source; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.new", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -342,22 +293,18 @@ a buffer defined by a pointer. sparse_tensor.out %t, %dest : tensor<1024x1024xf64, #CSR>, !Dest ``` """ -function out(tensor::Value, dest::Value; location=Location()) - _results = IR.Type[] - _operands = Value[tensor, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.out", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function out(tensor, dest; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.out", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -382,22 +329,18 @@ may be refined over time as our sparse abstractions evolve. sparse_tensor.release %tensor : tensor<1024x1024xf64, #CSR> ``` """ -function release(tensor::Value; location=Location()) - _results = IR.Type[] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.release", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function release(tensor; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.release", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -419,22 +362,18 @@ indices array. : tensor<64x64xf64, #CSR> to memref ``` """ -function indices(tensor::Value, dim::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor, dim] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.indices", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function indices(tensor, dim; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), value(dim), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.indices", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -456,22 +395,18 @@ pointers array. : tensor<64x64xf64, #CSR> to memref ``` """ -function pointers(tensor::Value, dim::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor, dim] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.pointers", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pointers(tensor, dim; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), value(dim), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.pointers", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -492,22 +427,18 @@ values array. %1 = sparse_tensor.values %0 : tensor<64x64xf64, #CSR> to memref ``` """ -function values(tensor::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.values", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function values(tensor; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.values", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/StandardOps.jl b/src/Dialects/14/StandardOps.jl index 4b16f870..60782742 100644 --- a/src/Dialects/14/StandardOps.jl +++ b/src/Dialects/14/StandardOps.jl @@ -1,7 +1,6 @@ module std -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,22 +17,18 @@ runtime to propagate the error to the user. assert %b, \"Expected ... to be true\" ``` """ -function assert(arg::Value; msg, location=Location()) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("msg", msg),] - - return IR.create_operation( - "std.assert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assert(arg; msg, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("msg", msg), ] + + IR.create_operation( + "std.assert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -54,22 +49,18 @@ the block successor. ^bb3(%3: tensor<*xf32>): ``` """ -function br(destOperands::Vector{Value}; dest::Block, location=Location()) - _results = IR.Type[] - _operands = Value[destOperands...,] - _owned_regions = Region[] - _successors = Block[dest,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "std.br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function br(destOperands; dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(destOperands)..., ] + owned_regions = Region[] + successors = Block[dest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "std.br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -91,27 +82,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "std.call_indirect", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call_indirect(callee, callee_operands; results_::Vector{IR.Type}, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(callee), value.(callee_operands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "std.call_indirect", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -129,24 +111,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("callee", callee),] - - return IR.create_operation( - "std.call", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operands_; result_0::Vector{IR.Type}, callee, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + + IR.create_operation( + "std.call", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -178,33 +154,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(), -) - _results = IR.Type[] - _operands = Value[condition, trueDestOperands..., falseDestOperands...] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands)]), - ) - - return IR.create_operation( - "std.cond_br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cond_br(condition, trueDestOperands, falseDestOperands; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueDestOperands)..., value.(falseDestOperands)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + 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 ) end @@ -279,22 +241,18 @@ func @foo() : (i32, f8) { } ``` """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "std.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "std.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -331,29 +289,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function select(condition, true_value, false_value; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(true_value), value(false_value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "std.select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -383,22 +331,18 @@ tensors in the same way dynamically shaped memrefs are handled. %t = splat %s [%m, %n] : tensor ``` """ -function splat(input::Value; aggregate::IR.Type, location=Location()) - _results = IR.Type[aggregate,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "std.splat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function splat(input; aggregate::IR.Type, location=Location()) + results = IR.Type[aggregate, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "std.splat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -421,38 +365,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(), -) - _results = IR.Type[] - _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)]) - ) - !isnothing(case_values) && - push!(_attributes, namedattribute("case_values", case_values)) - - return IR.create_operation( - "std.switch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch(flag, defaultOperands, caseOperands; case_values=nothing, case_operand_segments, defaultDestination::Block, caseDestinations::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(flag), value.(defaultOperands)..., value.(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), ])) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) + + IR.create_operation( + "std.switch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/Tensor.jl b/src/Dialects/14/Tensor.jl index df21ec9b..a2a1443a 100644 --- a/src/Dialects/14/Tensor.jl +++ b/src/Dialects/14/Tensor.jl @@ -1,7 +1,6 @@ module tensor -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -27,22 +26,18 @@ converting to a mismatching constant dimension. %5 = tensor.cast %4 : tensor to tensor<*xf32> ``` """ -function cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -71,22 +66,18 @@ Examples: : tensor into tensor ``` """ -function collapse_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function collapse_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "tensor.collapse_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -115,25 +106,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() -) - _results = IR.Type[] - _operands = Value[source, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "tensor.dim", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function dim(source, index; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "tensor.dim", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -162,22 +147,18 @@ Examples: : tensor into tensor ``` """ -function expand_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "tensor.expand_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -199,24 +180,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract(tensor, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.extract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -262,40 +237,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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract_slice(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "tensor.extract_slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -317,22 +271,18 @@ will result in a tensor [[%a, %b, %c] [%d, %e, %f]] """ -function from_elements(elements::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[elements...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.from_elements", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function from_elements(elements; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(elements)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.from_elements", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -358,24 +308,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.generate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generate(dynamicExtents; result::IR.Type, body::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(dynamicExtents)..., ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.generate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -400,24 +344,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function insert(scalar, dest, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(scalar), value(dest), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.insert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -471,41 +409,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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function insert_slice(source, dest, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(dest), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "tensor.insert_slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -581,36 +497,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,] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pad(source, low, high; result::IR.Type, static_low, static_high, nofold=nothing, region::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(low)..., value.(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), ])) + !isnothing(nofold) && push!(attributes, namedattribute("nofold", nofold)) + + IR.create_operation( + "tensor.pad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -626,23 +526,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()) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rank(tensor; result_0=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result_0) && push!(results, result_0) + + IR.create_operation( + "tensor.rank", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -680,22 +576,18 @@ Result type is unranked. : (tensor<*xf32>, tensor) -> tensor<*xf32> ``` """ -function reshape(source::Value, shape::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source, shape] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(source, shape; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -706,22 +598,18 @@ This operation is used to yield a single value from a within a region. It is used to create dynamically sized tensors (see `tensor.generate` and `tensor.pad` ops). """ -function yield(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/Tosa.jl b/src/Dialects/14/Tosa.jl index c2976a44..a81403d9 100644 --- a/src/Dialects/14/Tosa.jl +++ b/src/Dialects/14/Tosa.jl @@ -1,7 +1,6 @@ module tosa -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -9,22 +8,18 @@ import ..Dialects: namedattribute, operandsegmentsizes Elementwise absolute value operation """ -function abs(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function abs(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.abs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -34,22 +29,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function add(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.add", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -63,29 +54,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("double_round", double_round),] - - return IR.create_operation( - "tosa.apply_scale", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_scale(value, multiplier, shift; output::IR.Type, double_round, location=Location()) + results = IR.Type[output, ] + operands = Value[value(value), value(multiplier), value(shift), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("double_round", double_round), ] + + IR.create_operation( + "tosa.apply_scale", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -95,22 +75,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.argmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function argmax(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.argmax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -120,24 +96,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("round", round),] - - return IR.create_operation( - "tosa.arithmetic_right_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function arithmetic_right_shift(input1, input2; output::IR.Type, round, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("round", round), ] + + IR.create_operation( + "tosa.arithmetic_right_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -148,36 +118,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avg_pool2d(input; output::IR.Type, kernel, stride, pad, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[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)) + + IR.create_operation( + "tosa.avg_pool2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -187,22 +140,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_and(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_and", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -211,22 +160,18 @@ end Elementwise bitwise NOT of input tensor. """ -function bitwise_not(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_not(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_not", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -236,22 +181,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_or(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_or", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -261,22 +202,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_xor(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_xor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -303,22 +240,18 @@ Performs a set of permissible cast operations signed 8 to float int8 float signed 16 to float int16 float """ -function cast(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -327,22 +260,18 @@ end Elementwise ceiling operation """ -function ceil(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ceil(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.ceil", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -355,29 +284,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clamp(input; output::IR.Type, min_int, max_int, min_fp, max_fp, location=Location()) + results = IR.Type[output, ] + operands = Value[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), ] + + IR.create_operation( + "tosa.clamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -386,22 +304,18 @@ end Elementwise count leading zeros operation """ -function clz(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.clz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clz(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.clz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -411,22 +325,18 @@ end 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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.concat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function concat(input1; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value.(input1)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.concat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -462,38 +372,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv2d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.conv2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -502,38 +393,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv3d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.conv3d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -545,24 +417,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("identifier", identifier),] - - return IR.create_operation( - "tosa.custom", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function custom(inputs; outputs::Vector{IR.Type}, identifier, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("identifier", identifier), ] + + IR.create_operation( + "tosa.custom", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -572,38 +438,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv2d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.depthwise_conv2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -613,22 +460,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function div(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.div", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -637,22 +480,18 @@ end Elementwise comparison operation """ -function equal(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.equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function equal(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.equal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -661,22 +500,18 @@ end Elementwise e to the x operation """ -function exp(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function exp(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.exp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -685,22 +520,18 @@ end Elementwise floor operation """ -function floor(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function floor(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.floor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -709,31 +540,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fully_connected(input, weight, bias; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(bias), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -743,22 +562,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gather(values, indices; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(values), value(indices), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.gather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -767,22 +582,18 @@ end Elementwise comparison operation """ -function greater_equal(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.greater_equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function greater_equal(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.greater_equal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -791,22 +602,18 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.greater", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function greater(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.greater", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -816,22 +623,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.identity", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function identity(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.identity", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -841,53 +644,38 @@ 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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.cond_if", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end +function cond_if(cond, inputs; output::Vector{IR.Type}, then_branch::Region, else_branch::Region, location=Location()) + results = IR.Type[output..., ] + operands = Value[value(cond), value.(inputs)..., ] + owned_regions = Region[then_branch, else_branch, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.cond_if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `log` Elementwise natural logarithm operation """ -function log(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function log(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.log", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -897,22 +685,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_and(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_and", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -922,24 +706,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_left_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_left_shift(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_left_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -948,22 +726,18 @@ end Elementwise logical NOT of input. """ -function logical_not(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_not(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_not", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -973,22 +747,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_or(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_or", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -998,24 +768,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_right_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_right_shift(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_right_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1025,22 +789,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_xor(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_xor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1051,26 +811,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul(a, b; c::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[c, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -1082,26 +835,18 @@ size given by is passed over the input tensor, with the 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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function max_pool2d(input; output::IR.Type, kernel, stride, pad, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1111,22 +856,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.maximum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maximum(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.maximum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1136,22 +877,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.minimum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function minimum(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.minimum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1161,22 +898,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("shift", shift),] - - return IR.create_operation( - "tosa.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mul(input1, input2; output::IR.Type, shift, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("shift", shift), ] + + IR.create_operation( + "tosa.mul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1185,26 +918,19 @@ end Elementwise negation operation """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function negate(input1; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -1213,32 +939,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pad(input1, padding, pad_const=nothing; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(padding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(pad_const) && push!(operands, value(pad_const)) + !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 ) end @@ -1248,22 +962,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pow(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.pow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1273,22 +983,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.reciprocal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reciprocal(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.reciprocal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1297,22 +1003,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_all(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_all", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1321,22 +1023,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_any", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_any(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_any", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1345,22 +1043,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_max(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1369,22 +1063,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_min(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1393,22 +1083,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_prod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_prod(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_prod", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1417,22 +1103,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_sum(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1441,24 +1123,18 @@ 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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reluN(input; output::IR.Type, max_int, max_fp, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1482,41 +1158,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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rescale(input; output::IR.Type, input_zp, output_zp, multiplier, shift, scale32, double_round, per_channel, location=Location()) + results = IR.Type[output, ] + operands = Value[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 @@ -1527,22 +1180,18 @@ Returns a tensor with the same type/values as the input, with a new shape 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("new_shape", new_shape),] - - return IR.create_operation( - "tosa.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(input1; output::IR.Type, new_shape, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("new_shape", new_shape), ] + + IR.create_operation( + "tosa.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1554,41 +1203,18 @@ expected use, stride_y is approximately (IH< to vector ``` """ -function bitcast(source::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(source; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -111,22 +106,18 @@ shaped vector with the same element type is always legal. %2 = vector.broadcast %1 : vector<16xf32> to vector<4x16xf32> ``` """ -function broadcast(source::Value; vector::IR.Type, location=Location()) - _results = IR.Type[vector,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.broadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function broadcast(source; vector::IR.Type, location=Location()) + results = IR.Type[vector, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.broadcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -161,28 +152,18 @@ vector.compressstore %base[%i, %j], %mask, %value : memref, vector<16xi1>, vector<16xf32> ``` """ -function compressstore( - base::Value, - indices::Vector{Value}, - mask::Value, - valueToStore::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[base, indices..., mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.compressstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function compressstore(base, indices, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.compressstore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -353,36 +334,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...] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function contract(lhs, rhs, acc, masks; result_0::IR.Type, indexing_maps, iterator_types, kind=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(lhs), value(rhs), value(acc), value.(masks)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) + + IR.create_operation( + "vector.contract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -416,22 +380,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.create_mask", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_mask(operands_; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.create_mask", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -466,29 +426,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.expandload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expandload(base, indices, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.expandload", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -514,28 +463,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(position) && push!(_operands, position) - - return IR.create_operation( - "vector.extractelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extractelement(vector, position=nothing; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(position) && push!(operands, value(position)) + + IR.create_operation( + "vector.extractelement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -583,24 +523,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.extract_map", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract_map(vector, ids; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(vector), value.(ids)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.extract_map", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -617,22 +551,18 @@ the proper position. Degenerates to an element type in the 0-D case. %2 = vector.extract %0[3, 3, 3]: vector<4x8x16xf32> ``` """ -function extract(vector::Value; result_0::IR.Type, position, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract(vector; result_0::IR.Type, position, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "vector.extract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -662,28 +592,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract_strided_slice(vector; result_0::IR.Type, offsets, sizes, strides, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -704,22 +624,18 @@ to the `llvm.fma.*` intrinsic. %3 = vector.fma %0, %1, %2: vector<8x16xf32> ``` """ -function fma(lhs::Value, rhs::Value, acc::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs, acc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fma(lhs, rhs, acc; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.fma", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -748,24 +664,18 @@ http://llvm.org/docs/LangRef.html#llvm-matrix-transpose-intrinsic : (vector<16xf32>) -> vector<16xf32> ``` """ -function flat_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( - "vector.flat_transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function flat_transpose(matrix; res::IR.Type, rows, columns, location=Location()) + results = IR.Type[res, ] + operands = Value[value(matrix), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -800,30 +710,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gather(base, indices, index_vec, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(index_vec), value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.gather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -848,29 +746,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(position) && push!(_operands, position) - - return IR.create_operation( - "vector.insertelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function insertelement(source, dest, position=nothing; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(position) && push!(operands, value(position)) + + IR.create_operation( + "vector.insertelement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -920,24 +808,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.insert_map", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function insert_map(vector, dest, ids; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value(dest), value.(ids)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.insert_map", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -955,22 +837,18 @@ position. Degenerates to a scalar source type when n = 0. %5 = vector.insert %3, %4[3, 3, 3] : f32 into vector<4x8x16xf32> ``` """ -function insert(source::Value, dest::Value; res::IR.Type, position, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function insert(source, dest; res::IR.Type, position, location=Location()) + results = IR.Type[res, ] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "vector.insert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -996,26 +874,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("offsets", offsets), namedattribute("strides", strides) - ] - - return IR.create_operation( - "vector.insert_strided_slice", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function insert_strided_slice(source, dest; res::IR.Type, offsets, strides, location=Location()) + results = IR.Type[res, ] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1075,22 +945,18 @@ Example 6: Explicit out-of-bound vector load. %result = vector.load %memref[%c0] : memref<7xf32>, vector<8xf32> ``` """ -function load(base::Value, indices::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(base, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1122,29 +988,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.maskedload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maskedload(base, indices, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.maskedload", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1176,28 +1031,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(), -) - _results = IR.Type[] - _operands = Value[base, indices..., mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.maskedstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maskedstore(base, indices, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.maskedstore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1228,34 +1073,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matrix_multiply(lhs, rhs; res::IR.Type, lhs_rows, lhs_columns, rhs_columns, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(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( + "vector.matrix_multiply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1275,26 +1104,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("kind", kind), namedattribute("reduction_dims", reduction_dims) - ] - - return IR.create_operation( - "vector.multi_reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function multi_reduction(source; dest::IR.Type, kind, reduction_dims, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1348,30 +1169,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(kind) && push!(_attributes, namedattribute("kind", kind)) - - return IR.create_operation( - "vector.outerproduct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function outerproduct(lhs, rhs, acc; result_0::IR.Type, kind=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(lhs), value(rhs), value.(acc)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) + + IR.create_operation( + "vector.outerproduct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1399,22 +1209,18 @@ value for all data types, opening/closing bracket, comma, newline). ``` """ -function print(source::Value; location=Location()) - _results = IR.Type[] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.print", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function print(source; location=Location()) + results = IR.Type[] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.print", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1441,24 +1247,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - - return IR.create_operation( - "vector.reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduction(vector, acc; dest::IR.Type, kind, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(vector), value.(acc)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), ] + + IR.create_operation( + "vector.reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1546,30 +1346,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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(vector, input_shape, output_shape; result::IR.Type, fixed_vector_sizes, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value.(input_shape)..., value.(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), ])) + + IR.create_operation( + "vector.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1590,35 +1379,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scan(source, initial_value; dest::IR.Type, accumulated_value::IR.Type, kind, reduction_dim, inclusive, location=Location()) + results = IR.Type[dest, accumulated_value, ] + operands = Value[value(source), value(initial_value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1655,29 +1427,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(), -) - _results = IR.Type[] - _operands = Value[base, indices..., index_vec, mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.scatter", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scatter(base, indices, index_vec, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(index_vec), value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.scatter", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1716,22 +1477,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.shape_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shape_cast(source; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.shape_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1766,22 +1523,18 @@ according to the given mask. The legality rules are: : vector<2xf32>, vector<2xf32> ; yields vector<4xf32> ``` """ -function shuffle(v1::Value, v2::Value; vector::IR.Type, mask, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shuffle(v1, v2; vector::IR.Type, mask, location=Location()) + results = IR.Type[vector, ] + operands = Value[value(v1), value(v2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mask", mask), ] + + IR.create_operation( + "vector.shuffle", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1839,24 +1592,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() -) - _results = IR.Type[] - _operands = Value[valueToStore, base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(valueToStore, base, indices; location=Location()) + results = IR.Type[] + operands = Value[value(valueToStore), value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2020,36 +1767,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("permutation_map", permutation_map),] - !isnothing(mask) && push!(_operands, mask) - push!( - _attributes, operandsegmentsizes([1, length(indices), 1, isnothing(mask) ? 0 : 1]) - ) - !isnothing(in_bounds) && push!(_attributes, namedattribute("in_bounds", in_bounds)) - - return IR.create_operation( - "vector.transfer_read", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transfer_read(source, indices, padding, mask=nothing; vector::IR.Type, permutation_map, in_bounds=nothing, location=Location()) + results = IR.Type[vector, ] + operands = Value[value(source), value.(indices)..., value(padding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] + !isnothing(mask) && push!(operands, value(mask)) + push!(attributes, operandsegmentsizes([1, length(indices), 1, (mask==nothing) ? 0 : 1])) + !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) + + IR.create_operation( + "vector.transfer_read", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2143,37 +1875,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(), -) - _results = IR.Type[] - _operands = Value[vector, source, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("permutation_map", permutation_map),] - !isnothing(mask) && push!(_operands, mask) - push!( - _attributes, operandsegmentsizes([1, 1, length(indices), isnothing(mask) ? 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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transfer_write(vector, source, indices, mask=nothing; result=nothing::Union{Nothing, IR.Type}, permutation_map, in_bounds=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(vector), value(source), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] + !isnothing(mask) && push!(operands, value(mask)) + 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)) + + IR.create_operation( + "vector.transfer_write", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2202,22 +1919,18 @@ the transp array [i_1, .., i_n] must be a permutation of [0, .., n-1]. [c, f] ] ``` """ -function transpose(vector::Value; result::IR.Type, transp, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(vector; result::IR.Type, transp, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("transp", transp), ] + + IR.create_operation( + "vector.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2243,22 +1956,18 @@ operation ::= `vector.type_cast` ssa-use : memref-type to memref-type %VA = vector.type_cast %A : memref<5x4x3xf32> to memref> ``` """ -function type_cast(memref::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.type_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function type_cast(memref; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.type_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/14/X86Vector.jl b/src/Dialects/14/X86Vector.jl index 61bc575b..2c2d5665 100644 --- a/src/Dialects/14/X86Vector.jl +++ b/src/Dialects/14/X86Vector.jl @@ -1,32 +1,25 @@ module x86vector -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_dp_ps_256(a, b, c; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -48,25 +41,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_dot(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -74,25 +61,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_compress(a, src, k; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(src), value(k), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -111,33 +92,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_compress(k, a, src=nothing; dst=nothing::Union{Nothing, IR.Type}, constant_src=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(k), value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(src) && push!(operands, value(src)) + !isnothing(dst) && push!(results, dst) + !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) ) end @@ -155,31 +124,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_rndscale(src, k, a, imm, rounding; dst=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dst) && push!(results, dst) + + 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) ) end @@ -187,31 +144,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_rndscale_pd_512(src, k, a, imm, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -219,31 +164,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_rndscale_ps_512(src, k, a, imm, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -261,31 +194,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_scalef(src, a, b, k, rounding; dst=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dst) && push!(results, dst) + + 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) ) end @@ -293,31 +214,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_scalef_pd_512(src, a, b, k, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -325,31 +234,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_scalef_ps_512(src, a, b, k, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -357,25 +254,19 @@ end `avx_intr_rsqrt_ps_256` """ -function avx_intr_rsqrt_ps_256( - a::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_rsqrt_ps_256(a; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -383,23 +274,19 @@ end `avx_rsqrt` """ -function avx_rsqrt(a::Value; b=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[a,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(b) && push!(_results, b) - - return IR.create_operation( - "x86vector.avx.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_rsqrt(a; b=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(b) && push!(results, b) + + 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) ) end @@ -407,24 +294,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.intr.vp2intersect.d.512", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avx512_intr_vp2intersect_d_512(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.intr.vp2intersect.d.512", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -444,24 +325,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.vp2intersect", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avx512_vp2intersect(a, b; k1::IR.Type, k2::IR.Type, location=Location()) + results = IR.Type[k1, k2, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.vp2intersect", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -469,24 +344,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.intr.vp2intersect.q.512", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avx512_intr_vp2intersect_q_512(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.intr.vp2intersect.q.512", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/AMDGPU.jl b/src/Dialects/15/AMDGPU.jl index 4a158860..ad40ec1d 100644 --- a/src/Dialects/15/AMDGPU.jl +++ b/src/Dialects/15/AMDGPU.jl @@ -1,7 +1,6 @@ module amdgpu -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -58,39 +57,22 @@ Out of bounds atomic operations are ignored in hardware. See `amdgpu.raw_buffer_load` for a description of how the underlying instruction is constructed. """ -function raw_buffer_atomic_fadd( - value::Value, - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, 1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_atomic_fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_atomic_fadd(value, memref, indices, sgprOffset=nothing; boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_atomic_fadd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -126,39 +108,22 @@ are translated to intrinsic arguments as follows: to 2 to disable bounds checks, otherwise it is 3 - The cache coherency bits are off """ -function raw_buffer_load( - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - value::IR.Type, - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[value,] - _operands = Value[memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_load(memref, indices, sgprOffset=nothing; value::IR.Type, boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -182,39 +147,22 @@ components is partically completed is chipset-dependent. See `amdgpu.raw_buffer_load` for a description of how the underlying instruction is constructed. """ -function raw_buffer_store( - value::Value, - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, 1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_store(value, memref, indices, sgprOffset=nothing; boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/AMX.jl b/src/Dialects/15/AMX.jl index 4df6ab3e..67b68f6a 100644 --- a/src/Dialects/15/AMX.jl +++ b/src/Dialects/15/AMX.jl @@ -1,38 +1,24 @@ module amx -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbf16ps", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbf16ps(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbf16ps", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -40,31 +26,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbssd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbssd(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbssd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -72,31 +45,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbsud", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbsud(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbsud", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -104,31 +64,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbusd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbusd(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbusd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -136,31 +83,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbuud", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbuud(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbuud", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -168,29 +102,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tileloadd64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tileloadd64(operand_0, operand_1, operand_2, operand_3; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tileloadd64", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -198,29 +121,18 @@ end `tilestored64` """ -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tilestored64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tilestored64(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tilestored64", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -228,22 +140,18 @@ end `tilezero` """ -function tilezero(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( - "amx.tilezero", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tilezero(operand_0, operand_1; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tilezero", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -261,22 +169,18 @@ corresponding tile configuration. %0 = amx.tile_load %arg0[%c0, %c0] : memref into vector<16x64xi8> ``` """ -function tile_load(base::Value, indices::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_load(base, indices; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -295,22 +199,18 @@ pairs of \"bf16\"). The operation is eventually lowered into the : vector<16x32xbf16>, vector<16x32xbf16>, vector<16x16xf32> ``` """ -function tile_mulf(lhs::Value, rhs::Value, acc::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_mulf(lhs, rhs, acc; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_mulf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -332,32 +232,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_muli(lhs, rhs, acc; res::IR.Type, isZextLhs=nothing, isZextRhs=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(isZextLhs) && push!(attributes, namedattribute("isZextLhs", isZextLhs)) + !isnothing(isZextRhs) && push!(attributes, namedattribute("isZextRhs", isZextRhs)) + + IR.create_operation( + "amx.tile_muli", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -375,22 +263,18 @@ corresponding tile configuration. amx.tile_store %arg1[%c0, %c0], %0 : memref, vector<16x64xi8> ``` """ -function tile_store(base::Value, indices::Vector{Value}, val::Value; location=Location()) - _results = IR.Type[] - _operands = Value[base, indices..., val] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_store(base, indices, val; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(val), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Affine.jl b/src/Dialects/15/Affine.jl index 57e134a9..5848a733 100644 --- a/src/Dialects/15/Affine.jl +++ b/src/Dialects/15/Affine.jl @@ -1,7 +1,6 @@ module affine -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -26,22 +25,18 @@ have ‘index’ type. %2 = affine.apply affine_map<(i)[s0] -> (i+s0)> (%42)[%n] ``` """ -function apply(mapOperands::Vector{Value}; result_0::IR.Type, map, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply(mapOperands; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(mapOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.apply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -152,24 +147,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function for_(operand_0; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -243,28 +232,18 @@ func.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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.if", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function if_(operand_0; results_::Vector{IR.Type}, thenRegion::Region, elseRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[thenRegion, elseRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -290,22 +269,18 @@ Example 2: Uses \'symbol\' keyword for symbols \'%n\' and \'%m\'. %1 = affine.load %0[%i0 + symbol(%n), %i1 + symbol(%m)] : memref<100x100xf32> ``` """ -function 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.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(memref, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -321,22 +296,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map", map),] - - return IR.create_operation( - "affine.max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function max(operands_; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -362,22 +333,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map", map),] - - return IR.create_operation( - "affine.min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function min(operands_; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -446,40 +413,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(mapOperands; results_::Vector{IR.Type}, reductions, lowerBoundsMap, lowerBoundsGroups, upperBoundsMap, upperBoundsGroups, steps, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[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), ] + + IR.create_operation( + "affine.parallel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -501,33 +446,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function prefetch(memref, indices; isWrite, localityHint, isDataCache, location=Location()) + results = IR.Type[] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -553,22 +483,18 @@ Example 2: Uses \'symbol\' keyword for symbols \'%n\' and \'%m\'. 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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, memref, indices; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -611,24 +537,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.vector_load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vector_load(memref, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.vector_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -673,24 +593,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() -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.vector_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vector_store(value, memref, indices; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.vector_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -708,22 +622,18 @@ Otherwise, it has to be present in the syntax to indicate which values are yielded. ``` """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Arithmetic.jl b/src/Dialects/15/Arithmetic.jl index 6a9f95ae..61ce8a77 100644 --- a/src/Dialects/15/Arithmetic.jl +++ b/src/Dialects/15/Arithmetic.jl @@ -1,7 +1,6 @@ module arith -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -28,25 +27,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.addf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function addf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.addf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -71,25 +64,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.addi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function addi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.addi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -114,25 +101,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.andi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function andi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.andi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -154,22 +135,18 @@ endianness for the source and target types (e.g. float is big-endian and 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -188,25 +165,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ceildivsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ceildivsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -227,25 +198,19 @@ behavior. %a = arith.ceildivui %b, %c : i64 ``` """ -function ceildivui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ceildivui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ceildivui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -276,22 +241,18 @@ attribute by the parser. %r3 = \"arith.cmpf\"(%0, %1) {predicate: 0} : (f8, f8) -> i1 ``` """ -function cmpf(lhs::Value, rhs::Value; result::IR.Type, predicate, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cmpf(lhs, rhs; result::IR.Type, predicate, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "arith.cmpf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -360,22 +321,18 @@ complement or large positives : (vector<4xi64>, vector<4xi64>) -> vector<4xi1> ``` """ -function cmpi(lhs::Value, rhs::Value; result::IR.Type, predicate, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cmpi(lhs, rhs; result::IR.Type, predicate, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "arith.cmpi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -420,25 +377,19 @@ end `divf` """ -function divf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.divf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.divf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -464,25 +415,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.divsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.divsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -509,25 +454,19 @@ behavior. %x = arith.divui %y, %z : tensor<4x?xi8> ``` """ -function divui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.divui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.divui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -538,22 +477,18 @@ Cast a floating-point value to a larger floating-point-typed value. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extf(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -577,22 +512,18 @@ of the most-significant bit of the input. %5 = arith.extsi %0 : vector<2 x i32> to vector<2 x i64> ``` """ -function extsi(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extsi(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extsi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -615,22 +546,18 @@ The top-most (N - M) bits of the output are filled with zeros. %5 = arith.extui %0 : vector<2 x i32> to vector<2 x i64> ``` """ -function extui(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extui(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -641,22 +568,18 @@ Cast from a value interpreted as floating-point to the nearest (rounding 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.fptosi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptosi(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.fptosi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -667,22 +590,18 @@ Cast from a value interpreted as floating-point to the nearest (rounding 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.fptoui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptoui(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.fptoui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -702,25 +621,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.floordivsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function floordivsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.floordivsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -732,22 +645,18 @@ vectors. Index is an integer of platform-specific bit width. If casting to 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.index_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function index_cast(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.index_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -770,25 +679,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.maxf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.maxf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -796,25 +699,19 @@ end `maxsi` """ -function maxsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.maxsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.maxsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -822,25 +719,19 @@ end `maxui` """ -function maxui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.maxui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.maxui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -863,25 +754,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.minf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.minf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -889,25 +774,19 @@ end `minsi` """ -function minsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.minsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.minsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -915,25 +794,19 @@ end `minui` """ -function minui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.minui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.minui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -961,25 +834,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.mulf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mulf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.mulf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -987,25 +854,19 @@ end `muli` """ -function muli( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.muli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function muli(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.muli", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1030,23 +891,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.negf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function negf(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.negf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1071,25 +928,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ori", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ori(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ori", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1097,25 +948,19 @@ end `remf` """ -function remf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.remf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.remf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1141,25 +986,19 @@ behavior. %x = arith.remsi %y, %z : tensor<4x?xi8> ``` """ -function remsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.remsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.remsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1185,25 +1024,19 @@ behavior. %x = arith.remui %y, %z : tensor<4x?xi8> ``` """ -function remui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.remui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.remui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1215,22 +1048,18 @@ floating-point value. If the value cannot be exactly represented, it is 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.sitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sitofp(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.sitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1248,25 +1077,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shli(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shli", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1288,25 +1111,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shrsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shrsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shrsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1325,25 +1142,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shrui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shrui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shrui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1371,25 +1182,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.subf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.subf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1397,25 +1202,19 @@ end `subi` """ -function subi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.subi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.subi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1427,22 +1226,18 @@ The destination type must be strictly narrower than the source type. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.truncf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function truncf(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.truncf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1464,22 +1259,18 @@ The top-most (N - M) bits of the input are discarded. %5 = arith.trunci %0 : vector<2 x i32> to vector<2 x i16> ``` """ -function trunci(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.trunci", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function trunci(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.trunci", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1491,22 +1282,18 @@ floating-point value. If the value cannot be exactly represented, it is 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.uitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function uitofp(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.uitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1531,25 +1318,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.xori", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function xori(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.xori", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1583,29 +1364,19 @@ or tensor is chosen. %vx = arith.select %cond, %vtrue, %vfalse : vector<42xf32> ``` """ -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function select(condition, true_value, false_value; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(true_value), value(false_value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/15/ArmNeon.jl b/src/Dialects/15/ArmNeon.jl index d7f5eb0b..53a93149 100644 --- a/src/Dialects/15/ArmNeon.jl +++ b/src/Dialects/15/ArmNeon.jl @@ -1,7 +1,6 @@ module arm_neon -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -15,22 +14,18 @@ vector to the destination SIMD&FP register. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.intr.smull", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_smull(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.intr.smull", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -46,22 +41,18 @@ corresponding entry of `a`: 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.2d.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function _2d_sdot(a, b, c; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.2d.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -75,22 +66,18 @@ where vector operands are partitioned into groups of four elements. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.intr.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdot(a, b, c; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.intr.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/ArmSVE.jl b/src/Dialects/15/ArmSVE.jl index 3dee6dd7..9b6f7da5 100644 --- a/src/Dialects/15/ArmSVE.jl +++ b/src/Dialects/15/ArmSVE.jl @@ -1,31 +1,24 @@ module arm_sve -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fadd(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fadd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -36,24 +29,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.addf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_addf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.addf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -61,24 +48,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_add(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.add", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -89,24 +70,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.addi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_addi(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.addi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -114,24 +89,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fdiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fdiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -142,24 +111,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -167,24 +130,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fmul(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -195,24 +152,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.mulf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_mulf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.mulf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -220,24 +171,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_mul(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.mul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -248,24 +193,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.muli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_muli(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.muli", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -273,24 +212,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sdiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -301,24 +234,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divi_signed", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divi_signed(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divi_signed", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -326,24 +253,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fsub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fsub(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fsub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -354,24 +275,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.subf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_subf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.subf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -379,24 +294,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sub(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -407,24 +316,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.subi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_subi(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.subi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -432,24 +335,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.udiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_udiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.udiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -460,24 +357,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divi_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divi_unsigned(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divi_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -485,24 +376,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdot(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -520,22 +405,18 @@ to the overlapping element of the first vector input. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sdot(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -543,24 +424,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.smmla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_smmla(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.smmla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -581,22 +456,18 @@ the result to the first input using modular arithmetic. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.smmla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function smmla(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.smmla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -604,24 +475,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.udot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_udot(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.udot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -639,22 +504,18 @@ to the overlapping element of the first vector input. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.udot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function udot(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.udot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -662,24 +523,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.ummla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ummla(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.ummla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -700,22 +555,18 @@ the result to the first input using modular arithmetic. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.ummla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ummla(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.ummla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Async.jl b/src/Dialects/15/Async.jl index 180f463d..6c252911 100644 --- a/src/Dialects/15/Async.jl +++ b/src/Dialects/15/Async.jl @@ -1,7 +1,6 @@ module async -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -19,25 +18,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add_to_group(operand, group; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(group), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + 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) ) end @@ -61,22 +54,18 @@ group become ready. async.await_all %0 ``` """ -function await_all(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.await_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function await_all(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.await_all", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -96,23 +85,19 @@ async.await %0 : !async.token %2 = async.await %1 : !async.value ``` """ -function await(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "async.await", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function await(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "async.await", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -122,23 +107,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()) - _results = IR.Type[] - _operands = Value[id,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(handle) && push!(_results, handle) - - return IR.create_operation( - "async.coro.begin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function coro_begin(id; handle=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(id), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(handle) && push!(results, handle) + + 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) ) end @@ -149,22 +130,18 @@ The `async.coro.end` marks the point where a coroutine needs to return control back to the caller if it is not an initial invocation of the 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.end", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_end(handle; location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.end", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -174,22 +151,18 @@ end The `async.coro.free` deallocates the coroutine frame created by the async.coro.begin operation. """ -function coro_free(id::Value, handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[id, handle] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.free", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_free(id, handle; location=Location()) + results = IR.Type[] + operands = Value[value(id), value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.free", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -223,25 +196,19 @@ end The `async.coro.saves` saves the coroutine state. """ -function coro_save( - handle::Value; state=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(state) && push!(_results, state) - - return IR.create_operation( - "async.coro.save", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function coro_save(handle; state=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(state) && push!(results, state) + + 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) ) end @@ -257,28 +224,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(), -) - _results = IR.Type[] - _operands = Value[state,] - _owned_regions = Region[] - _successors = Block[suspendDest, resumeDest, cleanupDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.suspend", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_suspend(state; suspendDest::Block, resumeDest::Block, cleanupDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(state), ] + owned_regions = Region[] + successors = Block[suspendDest, resumeDest, cleanupDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.suspend", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -299,25 +256,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() -) - _results = IR.Type[] - _operands = Value[size,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "async.create_group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function create_group(size; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(size), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -362,30 +313,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dependencies), length(operands)])) - - return IR.create_operation( - "async.execute", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function execute(dependencies, operands_; token::IR.Type, results_::Vector{IR.Type}, body::Region, location=Location()) + results = IR.Type[token, results_..., ] + operands = Value[value.(dependencies)..., value.(operands_)..., ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dependencies), length(operands), ])) + + IR.create_operation( + "async.execute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -395,22 +335,18 @@ end The `async.runtime.add_ref` operation adds a reference(s) to async value (token, value or group). """ -function runtime_add_ref(operand::Value; count, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("count", count),] - - return IR.create_operation( - "async.runtime.add_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_add_ref(operand; count, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("count", count), ] + + IR.create_operation( + "async.runtime.add_ref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -420,25 +356,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_add_to_group(operand, group; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(group), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + 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) ) end @@ -449,22 +379,18 @@ The `async.runtime.await_and_resume` operation awaits for the operand to become available or error and resumes the coroutine on a thread managed by the runtime. """ -function runtime_await_and_resume(operand::Value, handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand, handle] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.await_and_resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_await_and_resume(operand, handle; location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.await_and_resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -474,22 +400,18 @@ end The `async.runtime.await` operation blocks the caller thread until the operand becomes available or error. """ -function runtime_await(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.await", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_await(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.await", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -499,25 +421,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_create_group(size; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(size), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -552,22 +468,18 @@ end The `async.runtime.drop_ref` operation drops a reference(s) to async value (token, value or group). """ -function runtime_drop_ref(operand::Value; count, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("count", count),] - - return IR.create_operation( - "async.runtime.drop_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_drop_ref(operand; count, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("count", count), ] + + IR.create_operation( + "async.runtime.drop_ref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -579,25 +491,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_is_error(operand; is_error=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(is_error) && push!(results, is_error) + + 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) ) end @@ -607,22 +513,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_load(storage; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(storage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -660,22 +562,18 @@ end The `async.runtime.resume` operation resumes the coroutine on a thread managed by the runtime. """ -function runtime_resume(handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_resume(handle; location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -685,22 +583,18 @@ end The `async.runtime.set_available` operation switches async token or value state to available. """ -function runtime_set_available(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.set_available", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_set_available(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.set_available", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -710,22 +604,18 @@ end The `async.runtime.set_error` operation switches async token or value state to error. """ -function runtime_set_error(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.set_error", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_set_error(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.set_error", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -735,22 +625,18 @@ end The `async.runtime.store` operation stores the value into the runtime async.value storage. """ -function runtime_store(value::Value, storage::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value, storage] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_store(value, storage; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(storage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -760,22 +646,18 @@ end The `async.yield` is a special terminator operation for the block inside `async.execute` operation. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Bufferization.jl b/src/Dialects/15/Bufferization.jl index 27d0c515..d8514b5b 100644 --- a/src/Dialects/15/Bufferization.jl +++ b/src/Dialects/15/Bufferization.jl @@ -1,7 +1,6 @@ module bufferization -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -45,34 +44,21 @@ construction operation and never escape the function boundary directly. return %0 : tensor ``` """ -function alloc_tensor( - dynamic_sizes::Vector{Value}, - copy=nothing::Union{Nothing,Value}; - result::IR.Type, - memory_space=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[dynamic_sizes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(copy) && push!(_operands, copy) - push!( - _attributes, operandsegmentsizes([length(dynamic_sizes), isnothing(copy) ? 0 : 1]) - ) - !isnothing(memory_space) && - push!(_attributes, namedattribute("memory_space", memory_space)) - - return IR.create_operation( - "bufferization.alloc_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloc_tensor(dynamic_sizes, copy=nothing; result::IR.Type, memory_space=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(dynamic_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(copy) && push!(operands, value(copy)) + push!(attributes, operandsegmentsizes([length(dynamic_sizes), (copy==nothing) ? 0 : 1])) + !isnothing(memory_space) && push!(attributes, namedattribute("memory_space", memory_space)) + + IR.create_operation( + "bufferization.alloc_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -92,22 +78,18 @@ views or create an actual copy. Mutating the source or result 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.clone", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clone(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.clone", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -137,22 +119,18 @@ tensor returns undefined results. bufferization.dealloc_tensor %tensor : tensor<1024x1024xf64, #CSR> ``` """ -function dealloc_tensor(tensor::Value; location=Location()) - _results = IR.Type[] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.dealloc_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dealloc_tensor(tensor; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.dealloc_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -173,22 +151,18 @@ This operation is a specialized variant of the built-in `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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.to_memref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function to_memref(tensor; memref::IR.Type, location=Location()) + results = IR.Type[memref, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.to_memref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -213,22 +187,18 @@ involving tensors and memrefs. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.to_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function to_tensor(memref; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.to_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Builtin.jl b/src/Dialects/15/Builtin.jl index 2ac242d8..5991a853 100644 --- a/src/Dialects/15/Builtin.jl +++ b/src/Dialects/15/Builtin.jl @@ -1,7 +1,6 @@ module builtin -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -81,24 +80,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "builtin.unrealized_conversion_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function unrealized_conversion_cast(inputs; outputs::Vector{IR.Type}, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "builtin.unrealized_conversion_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Complex.jl b/src/Dialects/15/Complex.jl index bd121db8..3ac0c312 100644 --- a/src/Dialects/15/Complex.jl +++ b/src/Dialects/15/Complex.jl @@ -1,7 +1,6 @@ module complex -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -15,22 +14,18 @@ The `abs` op takes a single complex number and computes its absolute value. %a = complex.abs %b : complex ``` """ -function abs(complex::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function abs(complex; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.abs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -45,25 +40,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -78,22 +67,18 @@ The `angle` op takes a single complex number and computes its argument value wit %a = complex.angle %b : complex ``` """ -function angle(complex::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.angle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function angle(complex; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.angle", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -109,25 +94,19 @@ atan2(y, x) = -i * log((x + i * y) / sqrt(x**2 + y**2)) %a = complex.atan2 %b, %c : complex ``` """ -function atan2( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.atan2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atan2(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.atan2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -143,23 +122,19 @@ complex conjugate. %a = complex.conj %b: complex ``` """ -function conj(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.conj", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function conj(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.conj", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -206,23 +181,19 @@ it, i.e. `cos(x)`, where `x` is the input value. %a = complex.cos %b : complex ``` """ -function cos(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cos(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -238,22 +209,18 @@ floating-point operands, the real and the imaginary part. %a = complex.create %b, %c : complex ``` """ -function create(real::Value, imaginary::Value; complex::IR.Type, location=Location()) - _results = IR.Type[complex,] - _operands = Value[real, imaginary] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.create", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create(real, imaginary; complex::IR.Type, location=Location()) + results = IR.Type[complex, ] + operands = Value[value(real), value(imaginary), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.create", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -267,25 +234,19 @@ division: %a = complex.div %b, %c : complex ``` """ -function div( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function div(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.div", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -300,25 +261,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function eq(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.eq", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -335,23 +290,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -372,23 +323,19 @@ complex.expm1(x) := complex.exp(x) - 1 %a = complex.expm1 %b : complex ``` """ -function expm1(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.expm1", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function expm1(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.expm1", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -403,22 +350,18 @@ The `im` op takes a single complex number and extracts the imaginary part. %a = complex.im %b : complex ``` """ -function im(complex::Value; imaginary::IR.Type, location=Location()) - _results = IR.Type[imaginary,] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.im", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function im(complex; imaginary::IR.Type, location=Location()) + results = IR.Type[imaginary, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.im", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -436,23 +379,19 @@ approximately equal to 2.718281. %a = complex.log1p %b : complex ``` """ -function log1p(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.log1p", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log1p(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.log1p", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -469,23 +408,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -498,25 +433,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -531,23 +460,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.neg", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function neg(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.neg", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -563,25 +488,19 @@ equal. %a = complex.neq %b, %c : complex ``` """ -function neq( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.neq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function neq(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.neq", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -597,25 +516,19 @@ exponent. %a = complex.pow %b, %c : complex ``` """ -function pow( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function pow(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.pow", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -630,22 +543,18 @@ The `re` op takes a single complex number and extracts the real part. %a = complex.re %b : complex ``` """ -function re(complex::Value; real::IR.Type, location=Location()) - _results = IR.Type[real,] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.re", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function re(complex; real::IR.Type, location=Location()) + results = IR.Type[real, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.re", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -660,23 +569,19 @@ The `rsqrt` operation computes reciprocal of square root. %a = complex.rsqrt %b : complex ``` """ -function rsqrt(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rsqrt(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.rsqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -692,23 +597,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sign(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -724,23 +625,19 @@ it, i.e. `sin(x)`, where `x` is the input value. %a = complex.sin %b : complex ``` """ -function sin(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sin(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -755,23 +652,19 @@ The `sqrt` operation takes a complex number and returns its square root. %a = complex.sqrt %b : complex ``` """ -function sqrt(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sqrt(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -786,25 +679,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sub(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -820,23 +707,19 @@ it, i.e. `tan(x)`, where `x` is the input value. %a = complex.tan %b : complex ``` """ -function tan(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.tan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tan(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.tan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -852,23 +735,19 @@ tangent. %a = complex.tanh %b : complex ``` """ -function tanh(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tanh(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/15/ControlFlow.jl b/src/Dialects/15/ControlFlow.jl index 23faa5a7..c4177c61 100644 --- a/src/Dialects/15/ControlFlow.jl +++ b/src/Dialects/15/ControlFlow.jl @@ -1,7 +1,6 @@ module cf -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,22 +17,18 @@ runtime to propagate the error to the user. assert %b, \"Expected ... to be true\" ``` """ -function assert(arg::Value; msg, location=Location()) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("msg", msg),] - - return IR.create_operation( - "cf.assert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assert(arg; msg, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("msg", msg), ] + + IR.create_operation( + "cf.assert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -54,22 +49,18 @@ target block. ^bb3(%3: tensor<*xf32>): ``` """ -function br(destOperands::Vector{Value}; dest::Block, location=Location()) - _results = IR.Type[] - _operands = Value[destOperands...,] - _owned_regions = Region[] - _successors = Block[dest,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "cf.br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function br(destOperands; dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(destOperands)..., ] + owned_regions = Region[] + successors = Block[dest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "cf.br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -101,33 +92,19 @@ func.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(), -) - _results = IR.Type[] - _operands = Value[condition, trueDestOperands..., falseDestOperands...] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands)]), - ) - - return IR.create_operation( - "cf.cond_br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cond_br(condition, trueDestOperands, falseDestOperands; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueDestOperands)..., value.(falseDestOperands)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands), ])) + + IR.create_operation( + "cf.cond_br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -150,38 +127,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(), -) - _results = IR.Type[] - _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)]) - ) - !isnothing(case_values) && - push!(_attributes, namedattribute("case_values", case_values)) - - return IR.create_operation( - "cf.switch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch(flag, defaultOperands, caseOperands; case_values=nothing, case_operand_segments, defaultDestination::Block, caseDestinations::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(flag), value.(defaultOperands)..., value.(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), ])) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) + + IR.create_operation( + "cf.switch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/EmitC.jl b/src/Dialects/15/EmitC.jl index 58124247..401d3cb7 100644 --- a/src/Dialects/15/EmitC.jl +++ b/src/Dialects/15/EmitC.jl @@ -1,7 +1,6 @@ module emitc -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -22,22 +21,18 @@ can be applied to a single operand. ``` """ -function apply(operand::Value; result::IR.Type, applicableOperator, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply(operand; result::IR.Type, applicableOperator, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("applicableOperator", applicableOperator), ] + + IR.create_operation( + "emitc.apply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -60,32 +55,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...,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operands_; result_0::Vector{IR.Type}, callee, args=nothing, template_args=nothing, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + !isnothing(args) && push!(attributes, namedattribute("args", args)) + !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 ) end @@ -107,22 +90,18 @@ and EmitC types. !emitc.ptr> to !emitc.ptr ``` """ -function cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "emitc.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "emitc.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Func.jl b/src/Dialects/15/Func.jl index 6e7ac218..784afc59 100644 --- a/src/Dialects/15/Func.jl +++ b/src/Dialects/15/Func.jl @@ -1,7 +1,6 @@ module func -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -21,27 +20,18 @@ Function values can be created with the %result = func.call_indirect %func(%0, %1) : (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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "func.call_indirect", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call_indirect(callee, callee_operands; results_::Vector{IR.Type}, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(callee), value.(callee_operands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "func.call_indirect", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -59,24 +49,18 @@ symbol reference attribute named \"callee\". %2 = func.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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("callee", callee),] - - return IR.create_operation( - "func.call", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operands_; result_0::Vector{IR.Type}, callee, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + + IR.create_operation( + "func.call", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -201,22 +185,18 @@ func.func @foo() : (i32, f8) { } ``` """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "func.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "func.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/GPU.jl b/src/Dialects/15/GPU.jl index 50334a79..034f0b5e 100644 --- a/src/Dialects/15/GPU.jl +++ b/src/Dialects/15/GPU.jl @@ -1,7 +1,6 @@ module gpu -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -29,30 +28,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function all_reduce(value; result_0=nothing::Union{Nothing, IR.Type}, op=nothing, body::Region, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result_0) && push!(results, result_0) + !isnothing(op) && push!(attributes, namedattribute("op", op)) + + 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) ) end @@ -75,36 +64,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - length(asyncDependencies), length(dynamicSizes), length(symbolOperands) - ]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.alloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloc(asyncDependencies, dynamicSizes, symbolOperands; memref::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(asyncDependencies)..., value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(asyncDependencies), length(dynamicSizes), length(symbolOperands), ])) + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.alloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -234,28 +207,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(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies..., memref] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.dealloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dealloc(asyncDependencies, memref; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.dealloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -463,22 +427,18 @@ Writes from the host are guaranteed to be visible to device kernels that are launched afterwards. Writes from the device are guaranteed to be visible on the host after synchronizing with the device kernel completion. """ -function host_register(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.host_register", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function host_register(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.host_register", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -593,60 +553,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(), -) - _results = IR.Type[] - _operands = Value[ - asyncDependencies..., - gridSizeX, - gridSizeY, - gridSizeZ, - blockSizeX, - blockSizeY, - blockSizeZ, - operands..., - ] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kernel", kernel),] - !isnothing(dynamicSharedMemorySize) && push!(_operands, dynamicSharedMemorySize) - push!( - _attributes, - operandsegmentsizes([ - length(asyncDependencies), - 1, - 1, - 1, - 1, - 1, - 1, - isnothing(dynamicSharedMemorySize) ? 0 : 1, - length(operands), - ]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.launch_func", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function launch_func(asyncDependencies, gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ, dynamicSharedMemorySize=nothing; operands_, asyncToken=nothing::Union{Nothing, IR.Type}, kernel, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(gridSizeX), value(gridSizeY), value(gridSizeZ), value(blockSizeX), value(blockSizeY), value(blockSizeZ), value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kernel", kernel), ] + !isnothing(dynamicSharedMemorySize) && push!(operands, value(dynamicSharedMemorySize)) + push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1length(operands), ])) + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.launch_func", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -724,57 +645,21 @@ 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( - asyncDependencies::Vector{Value}, - gridSizeX::Value, - gridSizeY::Value, - gridSizeZ::Value, - blockSizeX::Value, - blockSizeY::Value, - blockSizeZ::Value, - dynamicSharedMemorySize=nothing::Union{Nothing,Value}; - asyncToken=nothing::Union{Nothing,IR.Type}, - body::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - asyncDependencies..., - gridSizeX, - gridSizeY, - gridSizeZ, - blockSizeX, - blockSizeY, - blockSizeZ, - ] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(dynamicSharedMemorySize) && push!(_operands, dynamicSharedMemorySize) - push!( - _attributes, - operandsegmentsizes([ - length(asyncDependencies), - 1, - 1, - 1, - 1, - 1, - 1, - isnothing(dynamicSharedMemorySize) ? 0 : 1, - ]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.launch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function launch(asyncDependencies, gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ, dynamicSharedMemorySize=nothing; asyncToken=nothing::Union{Nothing, IR.Type}, body::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(gridSizeX), value(gridSizeY), value(gridSizeZ), value(blockSizeX), value(blockSizeY), value(blockSizeZ), ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dynamicSharedMemorySize) && push!(operands, value(dynamicSharedMemorySize)) + push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1])) + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.launch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -796,29 +681,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function memcpy(asyncDependencies, dst, src; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(dst), value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.memcpy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -840,29 +715,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function memset(asyncDependencies, dst, value; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(dst), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.memset", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -930,22 +795,18 @@ scalar arguments that should be printed. The format string is a C-style printf string, subject to any restrictions imposed by one\'s target platform. """ -function printf(args::Vector{Value}; format, location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("format", format),] - - return IR.create_operation( - "gpu.printf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function printf(args; format, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("format", format), ] + + IR.create_operation( + "gpu.printf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -956,22 +817,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -982,22 +839,18 @@ Operation that sets the current default GPU, using a zero-based index into the set of GPUs on the system. The default GPU setting may be thread-local. """ -function set_default_device(devIndex::Value; location=Location()) - _results = IR.Type[] - _operands = Value[devIndex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.set_default_device", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function set_default_device(devIndex; location=Location()) + results = IR.Type[] + operands = Value[value(devIndex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.set_default_device", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1022,32 +875,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(), -) - _results = IR.Type[] - _operands = Value[value, offset, width] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mode", mode),] - !isnothing(result) && push!(_results, result) - !isnothing(valid) && push!(_results, valid) - - return IR.create_operation( - "gpu.shuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shuffle(value, offset, width; result=nothing::Union{Nothing, IR.Type}, valid=nothing::Union{Nothing, IR.Type}, mode, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(offset), value(width), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mode", mode), ] + !isnothing(result) && push!(results, result) + !isnothing(valid) && push!(results, valid) + + IR.create_operation( + "gpu.shuffle", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1105,29 +946,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subgroup_mma_compute(opA, opB, opC; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(opA), value(opB), value(opC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -1154,22 +985,18 @@ This op is meant to be used along with `gpu.subgroup_mma_compute`. !gpu.mma_matrix<16x16xf32, \"COp\"> ``` """ -function subgroup_mma_constant_matrix(value::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_constant_matrix(value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.subgroup_mma_constant_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1193,24 +1020,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("operation", operation),] - - return IR.create_operation( - "gpu.subgroup_mma_elementwise", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_elementwise(args; res::IR.Type, operation, location=Location()) + results = IR.Type[res, ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("operation", operation), ] + + IR.create_operation( + "gpu.subgroup_mma_elementwise", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1238,28 +1059,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("leadDimension", leadDimension),] - - return IR.create_operation( - "gpu.subgroup_mma_load_matrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_load_matrix(srcMemref, indices; res::IR.Type, leadDimension, location=Location()) + results = IR.Type[res, ] + operands = Value[value(srcMemref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] + + IR.create_operation( + "gpu.subgroup_mma_load_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1285,24 +1096,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_store_matrix(src, dstMemref, indices; leadDimension, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(dstMemref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] + + IR.create_operation( + "gpu.subgroup_mma_store_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1430,27 +1235,19 @@ once this op completes. Example usage: gpu.wait [%t0, %t1] ``` """ -function wait( - asyncDependencies::Vector{Value}; - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wait(asyncDependencies; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1466,22 +1263,18 @@ in gpu ops. It returns values to the immediately enclosing gpu op. gpu.yield %f0, %f1 : f32, f32 ``` """ -function yield(values::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[values...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(values; location=Location()) + results = IR.Type[] + operands = Value[value.(values)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/LLVMIR.jl b/src/Dialects/15/LLVMIR.jl index 1ec7ce1e..2bec5522 100644 --- a/src/Dialects/15/LLVMIR.jl +++ b/src/Dialects/15/LLVMIR.jl @@ -1,32 +1,25 @@ module llvm -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `ashr` """ -function ashr( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.ashr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ashr(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.ashr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -65,25 +58,19 @@ end `add` """ -function add( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -91,22 +78,18 @@ end `addrspacecast` """ -function addrspacecast(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.addrspacecast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function addrspacecast(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.addrspacecast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -247,30 +230,20 @@ end `alloca` """ -function alloca( - arraySize::Value; - res::IR.Type, - alignment=nothing, - elem_type=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[arraySize,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - !isnothing(elem_type) && push!(_attributes, namedattribute("elem_type", elem_type)) - - return IR.create_operation( - "llvm.alloca", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca(arraySize; res::IR.Type, alignment=nothing, elem_type=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arraySize), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(elem_type) && push!(attributes, namedattribute("elem_type", elem_type)) + + IR.create_operation( + "llvm.alloca", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -278,25 +251,19 @@ end `and` """ -function and( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function and(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.and", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -304,33 +271,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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cmpxchg(ptr, cmp, val; res::IR.Type, success_ordering, failure_ordering, location=Location()) + results = IR.Type[res, ] + operands = Value[value(ptr), value(cmp), value(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 ) end @@ -338,26 +290,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("bin_op", bin_op), namedattribute("ordering", ordering) - ] - - return IR.create_operation( - "llvm.atomicrmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomicrmw(ptr, val; res::IR.Type, bin_op, ordering, location=Location()) + results = IR.Type[res, ] + operands = Value[value(ptr), value(val), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -365,22 +309,18 @@ end `bitcast` """ -function bitcast(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -388,22 +328,18 @@ end `br` """ -function br(destOperands::Vector{Value}; dest::Block, location=Location()) - _results = IR.Type[] - _operands = Value[destOperands...,] - _owned_regions = Region[] - _successors = Block[dest,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function br(destOperands; dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(destOperands)..., ] + owned_regions = Region[] + successors = Block[dest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -437,31 +373,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...,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operand_0; result_0::Vector{IR.Type}, callee=nothing, fastmathFlags=nothing, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + + IR.create_operation( + "llvm.call", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -469,36 +394,20 @@ end `cond_br` """ -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...] - _owned_regions = Region[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cond_br(condition, trueDestOperands, falseDestOperands; branch_weights=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueDestOperands)..., value.(falseDestOperands)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + 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 ) end @@ -555,22 +464,18 @@ end `extractelement` """ -function extractelement(vector::Value, position::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[vector, position] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.extractelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extractelement(vector, position; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(vector), value(position), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.extractelement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -578,22 +483,18 @@ end `extractvalue` """ -function extractvalue(container::Value; res::IR.Type, position, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extractvalue(container; res::IR.Type, position, location=Location()) + results = IR.Type[res, ] + operands = Value[value(container), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "llvm.extractvalue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -601,31 +502,20 @@ end `fadd` """ -function fadd( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fadd(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -633,31 +523,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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fcmp(lhs, rhs; res::IR.Type, predicate, fastmathFlags=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(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 ) end @@ -665,31 +543,20 @@ end `fdiv` """ -function fdiv( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fdiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -697,31 +564,20 @@ end `fmul` """ -function fmul( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fmul(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -729,30 +585,20 @@ end `fneg` """ -function fneg( - operand::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fneg(operand; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -760,22 +606,18 @@ end `fpext` """ -function fpext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fpext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fpext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fpext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -783,22 +625,18 @@ end `fptosi` """ -function fptosi(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptosi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptosi(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptosi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -806,22 +644,18 @@ end `fptoui` """ -function fptoui(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptoui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptoui(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptoui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -829,22 +663,18 @@ end `fptrunc` """ -function fptrunc(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptrunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptrunc(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptrunc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -852,31 +682,20 @@ end `frem` """ -function frem( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function frem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -884,31 +703,20 @@ end `fsub` """ -function fsub( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fsub(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -941,23 +749,19 @@ end `freeze` """ -function freeze(val::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[val,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.freeze", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function freeze(val; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(val), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.freeze", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -965,30 +769,19 @@ end `getelementptr` """ -function getelementptr( - base::Value, - indices::Vector{Value}; - res::IR.Type, - structIndices, - elem_type=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("structIndices", structIndices),] - !isnothing(elem_type) && push!(_attributes, namedattribute("elem_type", elem_type)) - - return IR.create_operation( - "llvm.getelementptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function getelementptr(base, indices; res::IR.Type, structIndices, elem_type=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("structIndices", structIndices), ] + !isnothing(elem_type) && push!(attributes, namedattribute("elem_type", elem_type)) + + IR.create_operation( + "llvm.getelementptr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1223,22 +1016,18 @@ end `icmp` """ -function icmp(lhs::Value, rhs::Value; res::IR.Type, predicate, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function icmp(lhs, rhs; res::IR.Type, predicate, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "llvm.icmp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1252,43 +1041,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(), -) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function inline_asm(operands_; 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[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + 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(asm_dialect) && push!(attributes, namedattribute("asm_dialect", asm_dialect)) + !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 ) end @@ -1296,24 +1065,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.insertelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function insertelement(vector, value, position; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(vector), value(value), value(position), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.insertelement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1321,24 +1084,18 @@ end `insertvalue` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function insertvalue(container, value; res::IR.Type, position, location=Location()) + results = IR.Type[res, ] + operands = Value[value(container), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "llvm.insertvalue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1346,22 +1103,18 @@ end `inttoptr` """ -function inttoptr(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.inttoptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function inttoptr(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.inttoptr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1369,38 +1122,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] - _attributes = NamedAttribute[] - 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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function invoke(callee_operands, normalDestOperands, unwindDestOperands; result_0::Vector{IR.Type}, callee=nothing, normalDest::Block, unwindDest::Block, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(callee_operands)..., value.(normalDestOperands)..., value.(unwindDestOperands)..., ] + owned_regions = Region[] + successors = Block[normalDest, unwindDest, ] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(callee_operands), length(normalDestOperands), length(unwindDestOperands), ])) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + + IR.create_operation( + "llvm.invoke", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1475,25 +1210,19 @@ end `lshr` """ -function lshr( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.lshr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function lshr(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.lshr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1501,25 +1230,19 @@ end `landingpad` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function landingpad(operand_0; res::IR.Type, cleanup=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(cleanup) && push!(attributes, namedattribute("cleanup", cleanup)) + + IR.create_operation( + "llvm.landingpad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1527,42 +1250,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,] - _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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(addr; 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[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(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) + + IR.create_operation( + "llvm.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1601,25 +1306,19 @@ end `mul` """ -function mul( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1664,25 +1363,19 @@ end `or` """ -function or( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function or(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.or", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1690,22 +1383,18 @@ end `ptrtoint` """ -function ptrtoint(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.ptrtoint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ptrtoint(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.ptrtoint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1713,22 +1402,18 @@ end `resume` """ -function resume(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function resume(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1736,22 +1421,18 @@ end `return_` """ -function return_(args::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(args; location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1759,25 +1440,19 @@ end `sdiv` """ -function sdiv( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.sdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sdiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.sdiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1785,22 +1460,18 @@ end `sext` """ -function sext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.sext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.sext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1808,22 +1479,18 @@ end `sitofp` """ -function sitofp(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.sitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sitofp(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.sitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1831,25 +1498,19 @@ end `srem` """ -function srem( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.srem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function srem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.srem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1857,29 +1518,19 @@ end `select` """ -function select( - condition::Value, - trueValue::Value, - falseValue::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function select(condition, trueValue, falseValue; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(trueValue), value(falseValue), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1887,25 +1538,19 @@ end `shl` """ -function shl( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.shl", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shl(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.shl", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1913,22 +1558,18 @@ end `shufflevector` """ -function shufflevector(v1::Value, v2::Value; res::IR.Type, mask, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shufflevector(v1, v2; res::IR.Type, mask, location=Location()) + results = IR.Type[res, ] + operands = Value[value(v1), value(v2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mask", mask), ] + + IR.create_operation( + "llvm.shufflevector", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1936,42 +1577,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(), -) - _results = IR.Type[] - _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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, addr; access_groups=nothing, alias_scopes=nothing, noalias_scopes=nothing, alignment=nothing, volatile_=nothing, nontemporal=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(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(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) + + IR.create_operation( + "llvm.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1979,25 +1602,19 @@ end `sub` """ -function sub( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sub(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.sub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2005,41 +1622,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(), -) - _results = IR.Type[] - _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)]) - ) - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch(value, defaultOperands, caseOperands; case_values=nothing, case_operand_segments, branch_weights=nothing, defaultDestination::Block, caseDestinations::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), value.(defaultOperands)..., value.(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), ])) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) + !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 ) end @@ -2047,22 +1644,18 @@ end `trunc` """ -function trunc(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.trunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function trunc(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.trunc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2070,25 +1663,19 @@ end `udiv` """ -function udiv( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.udiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function udiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.udiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2096,22 +1683,18 @@ end `uitofp` """ -function uitofp(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.uitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function uitofp(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.uitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2119,25 +1702,19 @@ end `urem` """ -function urem( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.urem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function urem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.urem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2202,25 +1779,19 @@ end `xor` """ -function xor( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function xor(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.xor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2228,5368 +1799,18 @@ end `zext` """ -function zext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.zext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType -import ..Dialects: namedattribute, operandsegmentsizes - -""" -`intr_assume` - -""" -function intr_assume(cond::Value; location=Location()) - _results = IR.Type[] - _operands = Value[cond,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.assume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_bitreverse` - -""" -function intr_bitreverse( - in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.bitreverse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_copysign` - -""" -function intr_copysign( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_coro_align` - -""" -function intr_coro_align(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.align", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_begin` - -""" -function intr_coro_begin(token::Value, mem::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_end` - -""" -function intr_coro_end(handle::Value, unwind::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_free` - -""" -function intr_coro_free(id::Value, handle::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.id", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_resume` - -""" -function intr_coro_resume(handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_save` - -""" -function intr_coro_save(handle::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.save", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_size` - -""" -function intr_coro_size(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.size", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_suspend` - -""" -function intr_coro_suspend(save::Value, final::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_cos` - -""" -function intr_cos(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_ctlz` - -""" -function intr_ctlz(in::Value, zero_undefined::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_cttz` - -""" -function intr_cttz(in::Value, zero_undefined::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_ctpop` - -""" -function intr_ctpop(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.ctpop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_eh_typeid_for` - -""" -function intr_eh_typeid_for(type_info::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_exp2` - -""" -function intr_exp2(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.exp2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_exp` - -""" -function intr_exp(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_fabs` - -""" -function intr_fabs(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.fabs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_ceil` - -""" -function intr_ceil(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_floor` - -""" -function intr_floor(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_fma` - -""" -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_fmuladd` - -""" -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.fmuladd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_get_active_lane_mask` - -""" -function intr_get_active_lane_mask(base::Value, n::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_log10` - -""" -function intr_log10(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.log10", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_log2` - -""" -function intr_log2(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.log2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_log` - -""" -function intr_log(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_masked_store` - -""" -function intr_masked_store( - value::Value, data::Value, mask::Value; alignment, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_matrix_column_major_store` - -""" -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_matrix_transpose` - -""" -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_maxnum` - -""" -function intr_maxnum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_maximum` - -""" -function intr_maximum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_memcpy_inline` - -""" -function intr_memcpy_inline( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, src, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memcpy.inline", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_memcpy` - -""" -function intr_memcpy( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, src, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memcpy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_memmove` - -""" -function intr_memmove( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, src, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memmove", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_memset` - -""" -function intr_memset( - dst::Value, val::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, val, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memset", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_minnum` - -""" -function intr_minnum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_minimum` - -""" -function intr_minimum( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_powi` - -""" -function intr_powi(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( - "llvm.intr.powi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_pow` - -""" -function intr_pow( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_prefetch` - -""" -function intr_prefetch( - addr::Value, rw::Value, hint::Value, cache::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[addr, rw, hint, cache] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.prefetch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_round` - -""" -function intr_round(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.sadd.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_smax` - -""" -function intr_smax( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_smin` - -""" -function intr_smin( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.smul.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.ssub.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_sin` - -""" -function intr_sin(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_sqrt` - -""" -function intr_sqrt(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_stackrestore` - -""" -function intr_stackrestore(ptr::Value; location=Location()) - _results = IR.Type[] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.stackrestore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_stacksave` - -""" -function intr_stacksave(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.stacksave", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_experimental_stepvector` - -""" -function intr_experimental_stepvector(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.experimental.stepvector", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.uadd.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_umax` - -""" -function intr_umax( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_umin` - -""" -function intr_umin( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.umul.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.usub.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_ashr` - -""" -function intr_vp_ashr( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.ashr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_add` - -""" -function intr_vp_add( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_and` - -""" -function intr_vp_and( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fadd` - -""" -function intr_vp_fadd( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fdiv` - -""" -function intr_vp_fdiv( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fmul` - -""" -function intr_vp_fmul( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fneg` - -""" -function intr_vp_fneg(op::Value, mask::Value, evl::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[op, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fneg", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fpext` - -""" -function intr_vp_fpext( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fpext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fptosi` - -""" -function intr_vp_fptosi( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fptosi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fptoui` - -""" -function intr_vp_fptoui( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fptoui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fptrunc` - -""" -function intr_vp_fptrunc( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fptrunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_frem` - -""" -function intr_vp_frem( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.frem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fsub` - -""" -function intr_vp_fsub( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fsub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fma` - -""" -function intr_vp_fma( - op1::Value, - op2::Value, - op3::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[op1, op2, op3, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_inttoptr` - -""" -function intr_vp_inttoptr( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.inttoptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_lshr` - -""" -function intr_vp_lshr( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.lshr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_load` - -""" -function intr_vp_load( - ptr::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[ptr, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_merge` - -""" -function intr_vp_merge( - cond::Value, - true_val::Value, - false_val::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[cond, true_val, false_val, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.merge", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_mul` - -""" -function intr_vp_mul( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_or` - -""" -function intr_vp_or( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_ptrtoint` - -""" -function intr_vp_ptrtoint( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.ptrtoint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_add` - -""" -function intr_vp_reduce_add( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_and` - -""" -function intr_vp_reduce_and( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fadd` - -""" -function intr_vp_reduce_fadd( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fmax` - -""" -function intr_vp_reduce_fmax( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fmin` - -""" -function intr_vp_reduce_fmin( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fmin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fmul` - -""" -function intr_vp_reduce_fmul( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_mul` - -""" -function intr_vp_reduce_mul( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_or` - -""" -function intr_vp_reduce_or( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_smax` - -""" -function intr_vp_reduce_smax( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.smax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_smin` - -""" -function intr_vp_reduce_smin( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.smin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_umax` - -""" -function intr_vp_reduce_umax( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.umax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_umin` - -""" -function intr_vp_reduce_umin( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.umin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_xor` - -""" -function intr_vp_reduce_xor( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sdiv` - -""" -function intr_vp_sdiv( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sext` - -""" -function intr_vp_sext( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sitofp` - -""" -function intr_vp_sitofp( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_srem` - -""" -function intr_vp_srem( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.srem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_select` - -""" -function intr_vp_select( - cond::Value, - true_val::Value, - false_val::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[cond, true_val, false_val, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_shl` - -""" -function intr_vp_shl( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.shl", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_store` - -""" -function intr_vp_store(val::Value, ptr::Value, mask::Value, evl::Value; location=Location()) - _results = IR.Type[] - _operands = Value[val, ptr, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_experimental_vp_strided_load` - -""" -function intr_experimental_vp_strided_load( - ptr::Value, stride::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[ptr, stride, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.experimental.vp.strided.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_experimental_vp_strided_store` - -""" -function intr_experimental_vp_strided_store( - val::Value, ptr::Value, stride::Value, mask::Value, evl::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[val, ptr, stride, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.experimental.vp.strided.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sub` - -""" -function intr_vp_sub( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_trunc` - -""" -function intr_vp_trunc( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.trunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_udiv` - -""" -function intr_vp_udiv( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.udiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_uitofp` - -""" -function intr_vp_uitofp( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.uitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_urem` - -""" -function intr_vp_urem( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.urem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_xor` - -""" -function intr_vp_xor( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_zext` - -""" -function intr_vp_zext( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.zext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vacopy` - -""" -function intr_vacopy(dest_list::Value, src_list::Value; location=Location()) - _results = IR.Type[] - _operands = Value[dest_list, src_list] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vacopy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vaend` - -""" -function intr_vaend(arg_list::Value; location=Location()) - _results = IR.Type[] - _operands = Value[arg_list,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vaend", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vastart` - -""" -function intr_vastart(arg_list::Value; location=Location()) - _results = IR.Type[] - _operands = Value[arg_list,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vastart", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_masked_compressstore` - -""" -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.masked.compressstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.masked.expandload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_masked_scatter` - -""" -function intr_masked_scatter( - value::Value, ptrs::Value, mask::Value; alignment, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_extract` - -""" -function intr_vector_extract(srcvec::Value; res::IR.Type, pos, location=Location()) - _results = IR.Type[res,] - _operands = Value[srcvec,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pos", pos),] - - return IR.create_operation( - "llvm.intr.vector.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_insert` - -""" -function intr_vector_insert( - srcvec::Value, - dstvec::Value; - res=nothing::Union{Nothing,IR.Type}, - pos, - location=Location(), -) - _results = IR.Type[] - _operands = Value[srcvec, dstvec] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pos", pos),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.vector.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_vector_reduce_add` - -""" -function intr_vector_reduce_add(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_and` - -""" -function intr_vector_reduce_and(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fmax` - -""" -function intr_vector_reduce_fmax(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fmin` - -""" -function intr_vector_reduce_fmin(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_mul` - -""" -function intr_vector_reduce_mul(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_or` - -""" -function intr_vector_reduce_or(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_smax` - -""" -function intr_vector_reduce_smax(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_smin` - -""" -function intr_vector_reduce_smin(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_umax` - -""" -function intr_vector_reduce_umax(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_umin` - -""" -function intr_vector_reduce_umin(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_xor` - -""" -function intr_vector_reduce_xor(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vscale` - -""" -function intr_vscale(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vscale", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType -import ..Dialects: namedattribute, operandsegmentsizes - -""" -`barrier0` - -""" -function barrier0(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.barrier0", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ntid_x` - -""" -function read_ptx_sreg_ntid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ntid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ntid_y` - -""" -function read_ptx_sreg_ntid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ntid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ntid_z` - -""" -function read_ptx_sreg_ntid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ntid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ctaid_x` - -""" -function read_ptx_sreg_ctaid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ctaid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ctaid_y` - -""" -function read_ptx_sreg_ctaid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ctaid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ctaid_z` - -""" -function read_ptx_sreg_ctaid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ctaid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`cp_async_commit_group` - -""" -function cp_async_commit_group(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.cp.async.commit.group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`cp_async_shared_global` - -""" -function cp_async_shared_global( - dst::Value, src::Value; size, bypass_l1=nothing, location=Location() -) - _results = IR.Type[] - _operands = Value[dst, src] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("size", size),] - !isnothing(bypass_l1) && push!(_attributes, namedattribute("bypass_l1", bypass_l1)) - - return IR.create_operation( - "nvvm.cp.async.shared.global", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`cp_async_wait_group` - -""" -function cp_async_wait_group(; n, location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("n", n),] - - return IR.create_operation( - "nvvm.cp.async.wait.group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_nctaid_x` - -""" -function read_ptx_sreg_nctaid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.nctaid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_nctaid_y` - -""" -function read_ptx_sreg_nctaid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.nctaid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_nctaid_z` - -""" -function read_ptx_sreg_nctaid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.nctaid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_laneid` - -""" -function read_ptx_sreg_laneid(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.laneid", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`ldmatrix` - -""" -function ldmatrix(ptr::Value; res::IR.Type, num, layout, location=Location()) - _results = IR.Type[res,] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("num", num), namedattribute("layout", layout) - ] - - return IR.create_operation( - "nvvm.ldmatrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mma_sync` - -The `nvvm.mma.sync` operation collectively performs the operation -`D = matmul(A, B) + C` using all threads in a warp. - -All the threads in the warp must execute the same `mma.sync` operation. - -For each possible multiplicand PTX data type, there are one or more possible -instruction shapes given as \"mMnNkK\". The below table describes the posssibilities -as well as the types required for the operands. Note that the data type for -C (the accumulator) and D (the result) can vary independently when there are -multiple possibilities in the \"C/D Type\" column. - -When an optional attribute cannot be immediately inferred from the types of -the operands and the result during parsing or validation, an error will be -raised. - -`b1Op` is only relevant when the binary (b1) type is given to -`multiplicandDataType`. It specifies how the multiply-and-acumulate is -performed and is either `xor_popc` or `and_poc`. The default is `xor_popc`. - -`intOverflowBehavior` is only relevant when the `multiplicandType` attribute -is one of `u8, s8, u4, s4`, this attribute describes how overflow is handled -in the accumulator. When the attribute is `satfinite`, the accumulator values -are clamped in the int32 range on overflow. This is the default behavior. -Alternatively, accumulator behavior `wrapped` can also be specified, in -which case overflow wraps from one end of the range to the other. - -`layoutA` and `layoutB` are required and should generally be set to -`#nvvm.mma_layout` and `#nvvm.mma_layout` respectively, but other -combinations are possible for certain layouts according to the table below. - -``` -| A/B Type | Shape | ALayout | BLayout | A Type | B Type | C/D Type | -|----------|-----------|---------|---------|----------|----------|-------------------| -| f64 | .m8n8k4 | row | col | 1x f64 | 1x f64 | 2x f64 | -| f16 | .m8n8k4 | row/col | row/col | 2x f16x2 | 2x f16x2 | 4x f16x2 or 8xf32 | -| | .m16n8k8 | row | col | 2x f16x2 | 1x f16x2 | 2x f16x2 or 4 f32 | -| | .m16n8k16 | row | col | 4x f16x2 | 2x f16x2 | 2x f16x2 or 4 f32 | -| bf16 | .m16n8k8 | row | col | 2x f16x2 | 1x f16x2 | 2x f16x2 or 4 f32 | -| | .m16n8k16 | row | col | 4x f16x2 | 2x f16x2 | 2x f16x2 or 4 f32 | -| tf32 | .m16n8k4 | row | col | 2x i32 | 1x i32 | 4x f32 | -| | .m16n8k8 | row | col | 4x i32 | 2x i32 | 2x f16x2 or 4 f32 | -| u8/s8 | .m8n8k16 | row | col | 1x i32 | 1x i32 | 2x i32 | -| | .m16n8k16 | row | col | 2x i32 | 1x i32 | 4x i32 | -| | .m16n8k32 | row | col | 4x i32 | 2x i32 | 4x i32 | -| u4/s4 | .m8n8k32 | row | col | 1x i32 | 1x i32 | 2x i32 | -| | m16n8k32 | row | col | 2x i32 | 1x i32 | 4x i32 | -| | m16n8k64 | row | col | 4x i32 | 2x i32 | 4x i32 | -| b1 | m8n8k128 | row | col | 1x i32 | 1x i32 | 2x i32 | -| | m16n8k128 | row | col | 2x i32 | 1x i32 | 4x i32 | -``` - - -# Example -```mlir - -%128 = nvvm.mma.sync A[%120, %121, %122, %123] - B[%124, %125] - C[%126, %127] - {layoutA = #nvvm.mma_layout, - layoutB = #nvvm.mma_layout, - shape = {k = 16 : i32, m = 16 : i32, n = 8 : i32}} - : (vector<2xf16>, vector<2xf16>, vector<2xf16>) - -> !llvm.struct<(vector<2xf16>, vector<2xf16>)> -``` -""" -function mma_sync( - operandA::Vector{Value}, - operandB::Vector{Value}, - operandC::Vector{Value}; - res::IR.Type, - shape, - b1Op=nothing, - intOverflowBehavior=nothing, - layoutA, - layoutB, - multiplicandAPtxType=nothing, - multiplicandBPtxType=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[operandA..., operandB..., operandC...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("shape", shape), - namedattribute("layoutA", layoutA), - namedattribute("layoutB", layoutB), - ] - push!( - _attributes, - operandsegmentsizes([length(operandA), length(operandB), length(operandC)]), - ) - !isnothing(b1Op) && push!(_attributes, namedattribute("b1Op", b1Op)) - !isnothing(intOverflowBehavior) && - push!(_attributes, namedattribute("intOverflowBehavior", intOverflowBehavior)) - !isnothing(multiplicandAPtxType) && - push!(_attributes, namedattribute("multiplicandAPtxType", multiplicandAPtxType)) - !isnothing(multiplicandBPtxType) && - push!(_attributes, namedattribute("multiplicandBPtxType", multiplicandBPtxType)) - - return IR.create_operation( - "nvvm.mma.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`rcp_approx_ftz_f` - -""" -function rcp_approx_ftz_f(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.rcp.approx.ftz.f", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`shfl_sync` - -""" -function shfl_sync( - dst::Value, - val::Value, - offset::Value, - mask_and_clamp::Value; - res::IR.Type, - kind, - return_value_and_is_valid=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[dst, val, offset, mask_and_clamp] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - !isnothing(return_value_and_is_valid) && push!( - _attributes, - namedattribute("return_value_and_is_valid", return_value_and_is_valid), - ) - - return IR.create_operation( - "nvvm.shfl.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_tid_x` - -""" -function read_ptx_sreg_tid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.tid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_tid_y` - -""" -function read_ptx_sreg_tid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.tid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_tid_z` - -""" -function read_ptx_sreg_tid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.tid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`vote_ballot_sync` - -""" -function vote_ballot_sync(mask::Value, pred::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[mask, pred] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.vote.ballot.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_load` - -""" -function wmma_load( - ptr::Value, - stride::Value; - res::IR.Type, - m, - n, - k, - layout, - eltype, - frag, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[ptr, stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("m", m), - namedattribute("n", n), - namedattribute("k", k), - namedattribute("layout", layout), - namedattribute("eltype", eltype), - namedattribute("frag", frag), - ] - - return IR.create_operation( - "nvvm.wmma.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_mma` - -""" -function wmma_mma( - args::Vector{Value}; - res::IR.Type, - m, - n, - k, - layoutA, - layoutB, - eltypeA, - eltypeB, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("m", m), - namedattribute("n", n), - namedattribute("k", k), - namedattribute("layoutA", layoutA), - namedattribute("layoutB", layoutB), - namedattribute("eltypeA", eltypeA), - namedattribute("eltypeB", eltypeB), - ] - - return IR.create_operation( - "nvvm.wmma.mma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_store` - -""" -function wmma_store( - ptr::Value, - args::Vector{Value}, - stride::Value; - m, - n, - k, - layout, - eltype, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ptr, args..., stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("m", m), - namedattribute("n", n), - namedattribute("k", k), - namedattribute("layout", layout), - namedattribute("eltype", eltype), - ] - - return IR.create_operation( - "nvvm.wmma.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_warpsize` - -""" -function read_ptx_sreg_warpsize(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.warpsize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType -import ..Dialects: namedattribute, operandsegmentsizes - -""" -`barrier` - -""" -function barrier(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.barrier", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_dim_x` - -""" -function workgroup_dim_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.dim.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_dim_y` - -""" -function workgroup_dim_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.dim.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_dim_z` - -""" -function workgroup_dim_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.dim.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_id_x` - -""" -function workgroup_id_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.id.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_id_y` - -""" -function workgroup_id_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.id.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_id_z` - -""" -function workgroup_id_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.id.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`grid_dim_x` - -""" -function grid_dim_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.grid.dim.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`grid_dim_y` - -""" -function grid_dim_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.grid.dim.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`grid_dim_z` - -""" -function grid_dim_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.grid.dim.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`buffer_load` - -""" -function buffer_load( - rsrc::Value, - vindex::Value, - offset::Value, - glc::Value, - slc::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[rsrc, vindex, offset, glc, slc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.buffer.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`buffer_store` - -""" -function buffer_store( - vdata::Value, - rsrc::Value, - vindex::Value, - offset::Value, - glc::Value, - slc::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, vindex, offset, glc, slc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.buffer.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_atomic_fadd` - -""" -function raw_buffer_atomic_fadd( - vdata::Value, - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.atomic.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_load` - -""" -function raw_buffer_load( - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_store` - -""" -function raw_buffer_store( - vdata::Value, - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workitem_id_x` - -""" -function workitem_id_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workitem.id.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workitem_id_y` - -""" -function workitem_id_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workitem.id.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workitem_id_z` - -""" -function workitem_id_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workitem.id.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x16bf16_1k` - -""" -function mfma_f32_16x16x16bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x16bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x16f16` - -""" -function mfma_f32_16x16x16f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x16f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x1f32` - -""" -function mfma_f32_16x16x1f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x1f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x2bf16` - -""" -function mfma_f32_16x16x2bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x2bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x4bf16_1k` - -""" -function mfma_f32_16x16x4bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x4bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x4f16` - -""" -function mfma_f32_16x16x4f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x4f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x4f32` - -""" -function mfma_f32_16x16x4f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x4f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x8_xf32` - -""" -function mfma_f32_16x16x8_xf32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x8.xf32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x8bf16` - -""" -function mfma_f32_16x16x8bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x8bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x1f32` - -""" -function mfma_f32_32x32x1f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x1f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x2bf16` - -""" -function mfma_f32_32x32x2bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x2bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x2f32` - -""" -function mfma_f32_32x32x2f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x2f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4_xf32` - -""" -function mfma_f32_32x32x4_xf32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4.xf32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4bf16` - -""" -function mfma_f32_32x32x4bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4bf16_1k` - -""" -function mfma_f32_32x32x4bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4f16` - -""" -function mfma_f32_32x32x4f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x8bf16_1k` - -""" -function mfma_f32_32x32x8bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x8bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x8f16` - -""" -function mfma_f32_32x32x8f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x8f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x1f32` - -""" -function mfma_f32_4x4x1f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x1f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x2bf16` - -""" -function mfma_f32_4x4x2bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x2bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x4bf16_1k` - -""" -function mfma_f32_4x4x4bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x4bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x4f16` - -""" -function mfma_f32_4x4x4f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x4f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f64_16x16x4f64` - -""" -function mfma_f64_16x16x4f64(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f64.16x16x4f64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f64_4x4x4f64` - -""" -function mfma_f64_4x4x4f64(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f64.4x4x4f64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_16x16x16i8` - -""" -function mfma_i32_16x16x16i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.16x16x16i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_16x16x32_i8` - -""" -function mfma_i32_16x16x32_i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.16x16x32.i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_16x16x4i8` - -""" -function mfma_i32_16x16x4i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.16x16x4i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_32x32x16_i8` - -""" -function mfma_i32_32x32x16_i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.32x32x16.i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_32x32x4i8` - -""" -function mfma_i32_32x32x4i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.32x32x4i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_32x32x8i8` - -""" -function mfma_i32_32x32x8i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.32x32x8i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_4x4x4i8` - -""" -function mfma_i32_4x4x4i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.4x4x4i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function zext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.zext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Linalg.jl b/src/Dialects/15/Linalg.jl index 3866c31f..99b14a05 100644 --- a/src/Dialects/15/Linalg.jl +++ b/src/Dialects/15/Linalg.jl @@ -1,7 +1,6 @@ module linalg -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -72,24 +71,18 @@ specified shape in IR and make it available to other transformations. Note: This op can be lowered to a `bufferization.alloc_tensor`, at which point it turns into an explicit buffer allocation. """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function init_tensor(sizes; result::IR.Type, static_sizes, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("static_sizes", static_sizes), ] + + IR.create_operation( + "linalg.init_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -106,27 +99,22 @@ in `linalg` generic ops. It returns values to the immediately enclosing linalg.yield %f0, %f1 : f32, f32 ``` """ -function yield(values::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[values...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "linalg.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(values; location=Location()) + results = IR.Type[] + operands = Value[value.(values)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "linalg.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -135,29 +123,19 @@ import ..Dialects: namedattribute, operandsegmentsizes 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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.batch_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -167,29 +145,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.batch_matvec", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_matvec(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -199,33 +167,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_1d_nwc_wcf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_1d_nwc_wcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_1d_nwc_wcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -235,29 +191,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_1d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_1d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_1d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -271,33 +217,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nchw_fchw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nchw_fchw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nchw_fchw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -311,33 +245,21 @@ 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_ngchw_fgchw( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_ngchw_fgchw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_ngchw_fgchw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_ngchw_fgchw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -351,33 +273,21 @@ 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_fhwc( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nhwc_fhwc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nhwc_fhwc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nhwc_fhwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -391,33 +301,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nhwc_hwcf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nhwc_hwcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nhwc_hwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -432,33 +330,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nhwc_hwcf_q", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nhwc_hwcf_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nhwc_hwcf_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -468,29 +354,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -500,33 +376,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_3d_ndhwc_dhwcf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_3d_ndhwc_dhwcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_3d_ndhwc_dhwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -536,29 +400,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_3d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_3d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_3d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -568,31 +422,20 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function copy( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - cast=nothing, - 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)])) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function copy(inputs, outputs; result_tensors::Vector{IR.Type}, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.copy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -603,33 +446,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_1d_nwc_wc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_1d_nwc_wc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_1d_nwc_wc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -639,33 +470,21 @@ 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_1d_nwc_wcm( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_1d_nwc_wcm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_1d_nwc_wcm(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_1d_nwc_wcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -676,33 +495,21 @@ Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions. """ -function depthwise_conv_2d_nchw_chw( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nchw_chw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nchw_chw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nchw_chw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -713,33 +520,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -749,33 +544,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwc_q", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwc_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -785,33 +568,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwcm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwcm(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -821,33 +592,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwcm_q", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwcm_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -858,33 +617,21 @@ Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions. """ -function depthwise_conv_3d_ndhwc_dhwc( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_3d_ndhwc_dhwc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_3d_ndhwc_dhwc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_3d_ndhwc_dhwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -894,33 +641,21 @@ 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_3d_ndhwc_dhwcm( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_3d_ndhwc_dhwcm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_3d_ndhwc_dhwcm(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_3d_ndhwc_dhwcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -930,29 +665,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.dot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dot(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.dot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -962,33 +687,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function elemwise_binary( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - fun=nothing, - cast=nothing, - 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)])) - !isnothing(fun) && push!(_attributes, namedattribute("fun", fun)) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.elemwise_binary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function elemwise_binary(inputs, outputs; result_tensors::Vector{IR.Type}, fun=nothing, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(fun) && push!(attributes, namedattribute("fun", fun)) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.elemwise_binary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -998,33 +711,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function elemwise_unary( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - fun=nothing, - cast=nothing, - 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)])) - !isnothing(fun) && push!(_attributes, namedattribute("fun", fun)) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.elemwise_unary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function elemwise_unary(inputs, outputs; result_tensors::Vector{IR.Type}, fun=nothing, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(fun) && push!(attributes, namedattribute("fun", fun)) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.elemwise_unary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1035,29 +736,19 @@ Works for arbitrary ranked output tensors since the operation performs scalar accesses only and is thus rank polymorphic. Numeric casting is performed on the value operand, promoting it to the same data type as the output. """ -function fill( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{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", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fill(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.fill", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1072,29 +763,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.fill_rng_2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fill_rng_2d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -1197,39 +878,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,] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("indexing_maps", indexing_maps), - namedattribute("iterator_types", iterator_types), - ] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - !isnothing(doc) && push!(_attributes, namedattribute("doc", doc)) - !isnothing(library_call) && - push!(_attributes, namedattribute("library_call", library_call)) - - return IR.create_operation( - "linalg.generic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generic(inputs, outputs; 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[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(doc) && push!(attributes, namedattribute("doc", doc)) + !isnothing(library_call) && push!(attributes, namedattribute("library_call", library_call)) + + IR.create_operation( + "linalg.generic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1239,31 +902,20 @@ 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}, - cast=nothing, - 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)])) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul(inputs, outputs; result_tensors::Vector{IR.Type}, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1273,29 +925,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matmul_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matmul_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1305,29 +947,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matvec", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matvec(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1342,29 +974,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.mmt4d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mmt4d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.mmt4d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1374,33 +996,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nchw_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nchw_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nchw_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1414,33 +1024,21 @@ Layout: Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nchw_sum( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nchw_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nchw_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nchw_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1450,33 +1048,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ndhwc_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ndhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1486,33 +1072,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ndhwc_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_min(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ndhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1522,33 +1096,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ndhwc_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ndhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1558,33 +1120,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1594,33 +1144,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_max_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_max_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_max_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1630,33 +1168,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_min(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1666,33 +1192,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_min_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_min_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_min_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1706,33 +1220,21 @@ Layout: 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1744,29 +1246,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.quantized_batch_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function quantized_batch_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -1778,29 +1270,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.quantized_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function quantized_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.quantized_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1810,29 +1292,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.vecmat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vecmat(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.vecmat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/MLProgram.jl b/src/Dialects/15/MLProgram.jl index c6f713db..dbc7c5ac 100644 --- a/src/Dialects/15/MLProgram.jl +++ b/src/Dialects/15/MLProgram.jl @@ -1,7 +1,6 @@ module ml_program -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -102,28 +101,18 @@ without additional consideration to evaluation order constraints. ordering (%token -> !ml_program.token) : tensor ``` """ -function global_load_graph( - consumeTokens::Vector{Value}; - result::IR.Type, - produceToken::IR.Type, - global_, - location=Location(), -) - _results = IR.Type[result, produceToken] - _operands = Value[consumeTokens...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("global", global_),] - - return IR.create_operation( - "ml_program.global_load_graph", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function global_load_graph(consumeTokens; result::IR.Type, produceToken::IR.Type, global_, location=Location()) + results = IR.Type[result, produceToken, ] + operands = Value[value.(consumeTokens)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] + + IR.create_operation( + "ml_program.global_load_graph", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -248,28 +237,18 @@ without additional consideration to evaluation order constraints. ordering (%in_token -> !ml_program.token) : tensor ``` """ -function global_store_graph( - value::Value, - consumeTokens::Vector{Value}; - produceToken::IR.Type, - global_, - location=Location(), -) - _results = IR.Type[produceToken,] - _operands = Value[value, consumeTokens...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("global", global_),] - - return IR.create_operation( - "ml_program.global_store_graph", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function global_store_graph(value, consumeTokens; produceToken::IR.Type, global_, location=Location()) + results = IR.Type[produceToken, ] + operands = Value[value(value), value.(consumeTokens)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] + + IR.create_operation( + "ml_program.global_store_graph", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -293,22 +272,18 @@ without additional consideration to evaluation order constraints. See ml_program.global_store @foobar = %0 : tensor ``` """ -function global_store(value::Value; global_, location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("global", global_),] - - return IR.create_operation( - "ml_program.global_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function global_store(value; global_, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] + + IR.create_operation( + "ml_program.global_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -321,22 +296,18 @@ The operation takes variable number of operands and produces no results. The operand number and types must match the signature of the function that contains the operation. """ -function output(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "ml_program.output", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function output(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "ml_program.output", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -349,22 +320,18 @@ The operation takes variable number of operands and produces no results. The operand number and types must match the signature of the function that contains the operation. """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "ml_program.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "ml_program.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Math.jl b/src/Dialects/15/Math.jl index a9e48471..8a681598 100644 --- a/src/Dialects/15/Math.jl +++ b/src/Dialects/15/Math.jl @@ -1,7 +1,6 @@ module math -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,23 +17,19 @@ the same type. %a = math.abs %b : f64 ``` """ -function abs(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function abs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.abs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -65,25 +60,19 @@ See also https://en.wikipedia.org/wiki/Atan2 %a = math.atan2 %b, %c : f32 ``` """ -function atan2( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.atan2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atan2(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.atan2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -107,23 +96,19 @@ one result of the same type. It has no standard attributes. %a = math.atan %b : f64 ``` """ -function atan(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.atan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atan(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.atan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -147,23 +132,19 @@ result of the same type. It has no standard attributes. %a = math.ceil %b : f64 ``` """ -function ceil(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceil(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ceil", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -188,25 +169,19 @@ tensor or vector). It has no standard attributes. %a = math.copysign %b, %c : f64 ``` """ -function copysign( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.copysign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function copysign(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.copysign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -230,23 +205,19 @@ result of the same type. It has no standard attributes. %a = math.cos %b : f64 ``` """ -function cos(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cos(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -263,23 +234,19 @@ It operates on scalar, tensor or vector. %a = math.ctlz %b : i32 ``` """ -function ctlz(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ctlz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ctlz(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ctlz", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -296,23 +263,19 @@ It operates on scalar, tensor or vector. %a = math.cttz %b : i32 ``` """ -function cttz(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.cttz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cttz(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.cttz", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -329,23 +292,19 @@ It operates on scalar, tensor or vector. %a = math.ctpop %b : i32 ``` """ -function ctpop(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ctpop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ctpop(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ctpop", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -369,23 +328,19 @@ the same type. It has no standard attributes. %a = math.erf %b : f64 ``` """ -function erf(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.erf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function erf(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.erf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -409,23 +364,19 @@ attributes. %a = math.exp2 %b : f64 ``` """ -function exp2(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.exp2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp2(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.exp2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -451,23 +402,19 @@ standard attributes. %a = math.expm1 %b : f64 ``` """ -function expm1(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.expm1", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function expm1(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.expm1", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -491,23 +438,19 @@ attributes. %a = math.exp %b : f64 ``` """ -function exp(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -531,23 +474,19 @@ result of the same type. It has no standard attributes. %a = math.floor %b : f64 ``` """ -function floor(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function floor(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.floor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -576,29 +515,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fma(a, b, c; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.fma", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -616,23 +545,19 @@ the same type. %y = math.log10 %x : f64 ``` """ -function log10(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.log10", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log10(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.log10", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -652,23 +577,19 @@ log1p(x) := log(1 + x) %y = math.log1p %x : f64 ``` """ -function log1p(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.log1p", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log1p(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.log1p", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -686,23 +607,19 @@ the same type. %y = math.log2 %x : f64 ``` """ -function log2(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.log2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log2(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.log2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -720,23 +637,19 @@ the same type. %y = math.log %x : f64 ``` """ -function log(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -760,25 +673,19 @@ must have the same type. %a = math.powf %b, %c : f64 ``` """ -function powf( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.powf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function powf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.powf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -805,23 +712,19 @@ rounding direction. %a = math.round %b : f64 ``` """ -function round(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function round(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.round", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -839,23 +742,19 @@ one result of the same type. It has no standard attributes. %a = math.rsqrt %b : f64 ``` """ -function rsqrt(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rsqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.rsqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -879,23 +778,19 @@ result of the same type. It has no standard attributes. %a = math.sin %b : f64 ``` """ -function sin(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sin(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -913,23 +808,19 @@ the same type. It has no standard attributes. %a = math.sqrt %b : f64 ``` """ -function sqrt(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -947,23 +838,19 @@ result of the same type. It has no standard attributes. %a = math.tan %b : f64 ``` """ -function tan(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.tan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tan(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.tan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -981,23 +868,19 @@ result of the same type. It has no standard attributes. %a = math.tanh %b : f64 ``` """ -function tanh(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tanh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/15/MemRef.jl b/src/Dialects/15/MemRef.jl index f27fd854..4ce51b51 100644 --- a/src/Dialects/15/MemRef.jl +++ b/src/Dialects/15/MemRef.jl @@ -1,7 +1,6 @@ module memref -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -14,22 +13,18 @@ the buffer isn\'t aligned to the given alignment, the behavior is undefined. This operation doesn\'t affect the semantics of a correct program. It\'s for optimization only, and the optimization is best-effort. """ -function assume_alignment(memref::Value; alignment, location=Location()) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "memref.assume_alignment", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assume_alignment(memref; alignment, location=Location()) + results = IR.Type[] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "memref.assume_alignment", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -50,29 +45,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - - return IR.create_operation( - "memref.atomic_rmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_rmw(value, memref, indices; result::IR.Type, kind, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), ] + + IR.create_operation( + "memref.atomic_rmw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -82,22 +66,18 @@ end \"memref.atomic_yield\" yields an SSA value from a GenericAtomicRMWOp region. """ -function atomic_yield(result::Value; location=Location()) - _results = IR.Type[] - _operands = Value[result,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.atomic_yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_yield(result; location=Location()) + results = IR.Type[] + operands = Value[value(result), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.atomic_yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -115,22 +95,18 @@ memref.copy %arg0, %arg1 : memref to memref Source and destination are expected to have the same element type and shape. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function copy(source, target; location=Location()) + results = IR.Type[] + operands = Value[value(source), value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.copy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -158,28 +134,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.generic_atomic_rmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generic_atomic_rmw(memref, indices; result::IR.Type, atomic_body::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[atomic_body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.generic_atomic_rmw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -221,22 +187,18 @@ techniques. This is possible because of the [restrictions on dimensions and symbols](Affine.md/#restrictions-on-dimensions-and-symbols) in these contexts. """ -function 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( - "memref.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(memref, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -281,30 +243,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands)])) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.alloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloc(dynamicSizes, symbolOperands; memref::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "memref.alloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -345,30 +297,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands)])) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.alloca", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca(dynamicSizes, symbolOperands; memref::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "memref.alloca", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -437,22 +379,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()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.alloca_scope.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca_scope_return(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.alloca_scope.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -512,22 +450,18 @@ Erase rank information. %5 = memref.cast %1 : memref<4x?xf32> to memref<*xf32> ``` """ -function cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -574,22 +508,18 @@ only if the corresponding start dimension in the source type is dynamic. Note: This op currently assumes that the inner strides are of the source/result layout map are the faster-varying ones. """ -function collapse_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function collapse_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "memref.collapse_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -608,22 +538,18 @@ alloc\'d memref (e.g. memrefs returned by `view` operations). memref.dealloc %0 : memref<8x64xf32, affine_map<(d0, d1) -> (d0, d1), 1>> ``` """ -function dealloc(memref::Value; location=Location()) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dealloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dealloc(memref; location=Location()) + results = IR.Type[] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dealloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -652,22 +578,18 @@ The specified memref type is that of the first operand. %y = \"memref.dim\"(%A, %c1) : (memref<4 x ? x f32>, index) -> index ``` """ -function dim(source::Value, index::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dim", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dim(source, index; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dim", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -718,22 +640,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dma_start", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dma_start(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dma_start", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -757,24 +675,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() -) - _results = IR.Type[] - _operands = Value[tagMemRef, tagIndices..., numElements] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dma_wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dma_wait(tagMemRef, tagIndices, numElements; location=Location()) + results = IR.Type[] + operands = Value[value(tagMemRef), value.(tagIndices)..., value(numElements), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dma_wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -820,22 +732,18 @@ group. Same for strides. Note: This op currently assumes that the inner strides are of the source/result layout map are the faster-varying ones. """ -function expand_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "memref.expand_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -963,33 +871,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function prefetch(memref, indices; isWrite, localityHint, isDataCache, location=Location()) + results = IR.Type[] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1005,22 +898,18 @@ The `memref.rank` operation takes a memref operand and returns its rank. %1 = memref.rank %arg1 : memref ``` """ -function rank(memref::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.rank", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rank(memref; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.rank", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1044,40 +933,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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reinterpret_cast(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "memref.reinterpret_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1116,22 +984,18 @@ Result type is unranked. : (memref<*xf32>, memref) to memref<*xf32> ``` """ -function reshape(source::Value, shape::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source, shape] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(source, shape; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1165,22 +1029,18 @@ techniques. This is possible because of the [restrictions on dimensions and symbols](Affine.md/#restrictions-on-dimensions-and-symbols) in these contexts. """ -function store(value::Value, memref::Value, indices::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, memref, indices; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1197,22 +1057,18 @@ transformation. %1 = memref.transpose %0 (i, j) -> (j, i) : memref to memref (d1 * s0 + d0)>> ``` """ -function transpose(in::Value; result_0::IR.Type, permutation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(in; result_0::IR.Type, permutation, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation", permutation), ] + + IR.create_operation( + "memref.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1254,28 +1110,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.view", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function view(source, byte_shift, sizes; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(source), value(byte_shift), value.(sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.view", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1414,40 +1260,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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subview(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "memref.subview", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1466,22 +1291,18 @@ element types of these must match, and are specified by the memref type. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.tensor_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tensor_store(tensor, memref; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.tensor_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/NVGPU.jl b/src/Dialects/15/NVGPU.jl index 142c6dd4..2c19f188 100644 --- a/src/Dialects/15/NVGPU.jl +++ b/src/Dialects/15/NVGPU.jl @@ -1,7 +1,6 @@ module nvgpu -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -46,33 +45,20 @@ gpu.device_async_wait %token2 memref<4x5xf32> to memref<2x7x5xf32, 3> ``` """ -function device_async_copy( - dst::Value, - dstIndices::Vector{Value}, - src::Value, - srcIndices::Vector{Value}; - asyncToken::IR.Type, - numElements, - bypassL1=nothing, - location=Location(), -) - _results = IR.Type[asyncToken,] - _operands = Value[dst, dstIndices..., src, srcIndices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("numElements", numElements),] - push!(_attributes, operandsegmentsizes([1, length(dstIndices), 1, length(srcIndices)])) - !isnothing(bypassL1) && push!(_attributes, namedattribute("bypassL1", bypassL1)) - - return IR.create_operation( - "nvgpu.device_async_copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function device_async_copy(dst, dstIndices, src, srcIndices; asyncToken::IR.Type, numElements, bypassL1=nothing, location=Location()) + results = IR.Type[asyncToken, ] + operands = Value[value(dst), value.(dstIndices)..., value(src), value.(srcIndices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("numElements", numElements), ] + push!(attributes, operandsegmentsizes([1, length(dstIndices), 1, length(srcIndices), ])) + !isnothing(bypassL1) && push!(attributes, namedattribute("bypassL1", bypassL1)) + + IR.create_operation( + "nvgpu.device_async_copy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -96,24 +82,18 @@ Groups are executed in the order they are created. %0 = gpu.device_async_create_group ``` """ -function device_async_create_group( - inputTokens::Vector{Value}; asyncToken::IR.Type, location=Location() -) - _results = IR.Type[asyncToken,] - _operands = Value[inputTokens...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvgpu.device_async_create_group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function device_async_create_group(inputTokens; asyncToken::IR.Type, location=Location()) + results = IR.Type[asyncToken, ] + operands = Value[value.(inputTokens)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "nvgpu.device_async_create_group", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -131,23 +111,19 @@ associated with the source token is fully completed. gpu.device_async_wait %0 ``` """ -function device_async_wait(asyncDependencies::Value; numGroups=nothing, location=Location()) - _results = IR.Type[] - _operands = Value[asyncDependencies,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(numGroups) && push!(_attributes, namedattribute("numGroups", numGroups)) - - return IR.create_operation( - "nvgpu.device_async_wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function device_async_wait(asyncDependencies; numGroups=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(asyncDependencies), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(numGroups) && push!(attributes, namedattribute("numGroups", numGroups)) + + IR.create_operation( + "nvgpu.device_async_wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -169,31 +145,18 @@ https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-mat memref -> vector<4x2xf16> ``` """ -function ldmatrix( - srcMemref::Value, - indices::Vector{Value}; - res::IR.Type, - transpose, - numTiles, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[srcMemref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("transpose", transpose), namedattribute("numTiles", numTiles) - ] - - return IR.create_operation( - "nvgpu.ldmatrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ldmatrix(srcMemref, indices; res::IR.Type, transpose, numTiles, location=Location()) + results = IR.Type[res, ] + operands = Value[value(srcMemref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("transpose", transpose), namedattribute("numTiles", numTiles), ] + + IR.create_operation( + "nvgpu.ldmatrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -220,29 +183,18 @@ nvgpu.mma.sync (%a, %b, %c) : (vector<4x2xf16>, vector<2x2xf16>, vector<2x2xf16>) -> vector<2x2xf16> ``` """ -function mma_sync( - matrixA::Value, - matrixB::Value, - matrixC::Value; - res::IR.Type, - mmaShape, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[matrixA, matrixB, matrixC] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mmaShape", mmaShape),] - - return IR.create_operation( - "nvgpu.mma.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mma_sync(matrixA, matrixB, matrixC; res::IR.Type, mmaShape, location=Location()) + results = IR.Type[res, ] + operands = Value[value(matrixA), value(matrixB), value(matrixC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mmaShape", mmaShape), ] + + IR.create_operation( + "nvgpu.mma.sync", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/OpenACC.jl b/src/Dialects/15/OpenACC.jl index 0779ee39..36131c44 100644 --- a/src/Dialects/15/OpenACC.jl +++ b/src/Dialects/15/OpenACC.jl @@ -1,7 +1,6 @@ module acc -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -22,70 +21,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function data(ifCond=nothing; copyOperands, copyinOperands, copyinReadonlyOperands, copyoutOperands, copyoutZeroOperands, createOperands, createZeroOperands, noCreateOperands, presentOperands, deviceptrOperands, attachOperands, defaultAttr=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(copyOperands)..., value.(copyinOperands)..., value.(copyinReadonlyOperands)..., value.(copyoutOperands)..., value.(copyoutZeroOperands)..., value.(createOperands)..., value.(createZeroOperands)..., value.(noCreateOperands)..., value.(presentOperands)..., value.(deviceptrOperands)..., value.(attachOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(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), ])) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + + IR.create_operation( + "acc.data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -100,58 +50,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function enter_data(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, copyinOperands, createOperands, createZeroOperands, attachOperands, async=nothing, wait=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(copyinOperands)..., value.(createOperands)..., value.(createZeroOperands)..., value.(attachOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(copyinOperands), length(createOperands), length(createZeroOperands), length(attachOperands), ])) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + + IR.create_operation( + "acc.enter_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -166,54 +82,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function exit_data(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, copyoutOperands, deleteOperands, detachOperands, async=nothing, wait=nothing, finalize=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(copyoutOperands)..., value.(deleteOperands)..., value.(detachOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + 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)) + + IR.create_operation( + "acc.exit_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -230,37 +117,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(), -) - _results = IR.Type[] - _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), - isnothing(deviceNumOperand) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - - return IR.create_operation( - "acc.init", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function init(deviceTypeOperands, deviceNumOperand=nothing; ifCond=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(deviceTypeOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(deviceNumOperand) && push!(operands, value(deviceNumOperand)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + 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 ) end @@ -284,64 +155,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,] - _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([ - isnothing(gangNum) ? 0 : 1, - isnothing(gangStatic) ? 0 : 1, - isnothing(workerNum) ? 0 : 1, - isnothing(vectorLength) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop(gangNum=nothing; gangStatic=nothing, workerNum=nothing, vectorLength=nothing, tileOperands, privateOperands, reductionOperands, 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[value.(tileOperands)..., value.(privateOperands)..., value.(reductionOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(gangNum) && push!(operands, value(gangNum)) + !isnothing(gangStatic) && push!(operands, value(gangStatic)) + !isnothing(workerNum) && push!(operands, value(workerNum)) + !isnothing(vectorLength) && push!(operands, value(vectorLength)) + push!(attributes, operandsegmentsizes([(gangNum==nothing) ? 0 : 1(gangStatic==nothing) ? 0 : 1(workerNum==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1length(tileOperands), length(privateOperands), length(reductionOperands), ])) + !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)) + + IR.create_operation( + "acc.loop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -360,106 +196,30 @@ 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(), -) - _results = IR.Type[] - _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) - !isnothing(numGangs) && push!(_operands, numGangs) - !isnothing(numWorkers) && push!(_operands, numWorkers) - !isnothing(vectorLength) && push!(_operands, vectorLength) - !isnothing(ifCond) && push!(_operands, ifCond) - !isnothing(selfCond) && push!(_operands, selfCond) - push!( - _attributes, - operandsegmentsizes([ - isnothing(async) ? 0 : 1, - length(waitOperands), - isnothing(numGangs) ? 0 : 1, - isnothing(numWorkers) ? 0 : 1, - isnothing(vectorLength) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - isnothing(selfCond) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(async=nothing; waitOperands, numGangs=nothing, numWorkers=nothing, vectorLength=nothing, ifCond=nothing, selfCond=nothing, reductionOperands, copyOperands, copyinOperands, copyinReadonlyOperands, copyoutOperands, copyoutZeroOperands, createOperands, createZeroOperands, noCreateOperands, presentOperands, devicePtrOperands, attachOperands, gangPrivateOperands, gangFirstPrivateOperands, asyncAttr=nothing, waitAttr=nothing, selfAttr=nothing, reductionOp=nothing, defaultAttr=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(reductionOperands)..., value.(copyOperands)..., value.(copyinOperands)..., value.(copyinReadonlyOperands)..., value.(copyoutOperands)..., value.(copyoutZeroOperands)..., value.(createOperands)..., value.(createZeroOperands)..., value.(noCreateOperands)..., value.(presentOperands)..., value.(devicePtrOperands)..., value.(attachOperands)..., value.(gangPrivateOperands)..., value.(gangFirstPrivateOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(async) && push!(operands, value(async)) + !isnothing(numGangs) && push!(operands, value(numGangs)) + !isnothing(numWorkers) && push!(operands, value(numWorkers)) + !isnothing(vectorLength) && push!(operands, value(vectorLength)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(selfCond) && push!(operands, value(selfCond)) + push!(attributes, operandsegmentsizes([(async==nothing) ? 0 : 1length(waitOperands), (numGangs==nothing) ? 0 : 1(numWorkers==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1(selfCond==nothing) ? 0 : 1length(reductionOperands), length(copyOperands), length(copyinOperands), length(copyinReadonlyOperands), length(copyoutOperands), length(copyoutZeroOperands), length(createOperands), length(createZeroOperands), length(noCreateOperands), length(presentOperands), length(devicePtrOperands), length(attachOperands), length(gangPrivateOperands), length(gangFirstPrivateOperands), ])) + !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)) + + IR.create_operation( + "acc.parallel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -476,37 +236,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(), -) - _results = IR.Type[] - _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), - isnothing(deviceNumOperand) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - - return IR.create_operation( - "acc.shutdown", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shutdown(deviceTypeOperands, deviceNumOperand=nothing; ifCond=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(deviceTypeOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(deviceNumOperand) && push!(operands, value(deviceNumOperand)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + 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 ) end @@ -551,54 +295,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function update(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, deviceTypeOperands, hostOperands, deviceOperands, async=nothing, wait=nothing, ifPresent=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(deviceTypeOperands)..., value.(hostOperands)..., value.(deviceOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + 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)) + + IR.create_operation( + "acc.update", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -615,42 +330,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(), -) - _results = IR.Type[] - _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), - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - !isnothing(async) && push!(_attributes, namedattribute("async", async)) - - return IR.create_operation( - "acc.wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wait(waitOperands, asyncOperand=nothing; waitDevnum=nothing, ifCond=nothing, async=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + push!(attributes, operandsegmentsizes([length(waitOperands), (asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + + IR.create_operation( + "acc.wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -661,22 +357,18 @@ end acc ops (parallel and loop). It returns values to the immediately enclosing acc op. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "acc.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "acc.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/OpenMP.jl b/src/Dialects/15/OpenMP.jl index eeb4e83a..4e614d55 100644 --- a/src/Dialects/15/OpenMP.jl +++ b/src/Dialects/15/OpenMP.jl @@ -1,7 +1,6 @@ module omp -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -76,27 +75,20 @@ optimization. `memory_order` indicates the memory ordering behavior of the construct. It can be one of `seq_cst`, `acquire` or `relaxed`. """ -function atomic_read( - x::Value, v::Value; hint_val=nothing, memory_order_val=nothing, location=Location() -) - _results = IR.Type[] - _operands = Value[x, v] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(hint_val) && push!(_attributes, namedattribute("hint_val", hint_val)) - !isnothing(memory_order_val) && - push!(_attributes, namedattribute("memory_order_val", memory_order_val)) - - return IR.create_operation( - "omp.atomic.read", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_read(x, v; hint_val=nothing, memory_order_val=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(v), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + + IR.create_operation( + "omp.atomic.read", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -130,31 +122,20 @@ the core update operation is directly translated like regular operations by the host dialect. The front-end must handle semantic checks for allowed operations. """ -function atomic_update( - x::Value; - hint_val=nothing, - memory_order_val=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(hint_val) && push!(_attributes, namedattribute("hint_val", hint_val)) - !isnothing(memory_order_val) && - push!(_attributes, namedattribute("memory_order_val", memory_order_val)) - - return IR.create_operation( - "omp.atomic.update", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_update(x; hint_val=nothing, memory_order_val=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + + IR.create_operation( + "omp.atomic.update", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -175,31 +156,20 @@ optimization. `memory_order` indicates the memory ordering behavior of the construct. It can be one of `seq_cst`, `release` or `relaxed`. """ -function atomic_write( - address::Value, - value::Value; - hint_val=nothing, - memory_order_val=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[address, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(hint_val) && push!(_attributes, namedattribute("hint_val", hint_val)) - !isnothing(memory_order_val) && - push!(_attributes, namedattribute("memory_order_val", memory_order_val)) - - return IR.create_operation( - "omp.atomic.write", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_write(address, value; hint_val=nothing, memory_order_val=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(address), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + + IR.create_operation( + "omp.atomic.write", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -234,29 +204,19 @@ end The cancel construct activates cancellation of the innermost enclosing region of the type specified. """ -function cancel( - if_expr=nothing::Union{Nothing,Value}; - cancellation_construct_type_val, - location=Location(), -) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute( - "cancellation_construct_type_val", cancellation_construct_type_val - ),] - !isnothing(if_expr) && push!(_operands, if_expr) - - return IR.create_operation( - "omp.cancel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cancel(if_expr=nothing; cancellation_construct_type_val, location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("cancellation_construct_type_val", cancellation_construct_type_val), ] + !isnothing(if_expr) && push!(operands, value(if_expr)) + + IR.create_operation( + "omp.cancel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -349,22 +309,18 @@ makes a thread’s temporary view of memory consistent with memory and enforces an order on the memory operations of the variables explicitly specified or implied. """ -function flush(varList::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[varList...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.flush", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function flush(varList; location=Location()) + results = IR.Type[] + operands = Value[value.(varList)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.flush", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -411,31 +367,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ordered(depend_vec_vars; depend_type_val=nothing, num_loops_val=nothing, location=Location()) + results = IR.Type[] + operands = Value[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)) + + IR.create_operation( + "omp.ordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -502,47 +447,23 @@ threads complete. 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}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}, - reduction_vars::Vector{Value}, - reductions=nothing, - proc_bind_val=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[allocate_vars..., allocators_vars..., reduction_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([ - isnothing(if_expr_var) ? 0 : 1, - isnothing(num_threads_var) ? 0 : 1, - length(allocate_vars), - length(allocators_vars), - length(reduction_vars), - ]), - ) - !isnothing(reductions) && push!(_attributes, namedattribute("reductions", reductions)) - !isnothing(proc_bind_val) && - push!(_attributes, namedattribute("proc_bind_val", proc_bind_val)) - - return IR.create_operation( - "omp.parallel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(if_expr_var=nothing; num_threads_var=nothing, allocate_vars, allocators_vars, reduction_vars, reductions=nothing, proc_bind_val=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(allocate_vars)..., value.(allocators_vars)..., value.(reduction_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr_var) && push!(operands, value(if_expr_var)) + !isnothing(num_threads_var) && push!(operands, value(num_threads_var)) + push!(attributes, operandsegmentsizes([(if_expr_var==nothing) ? 0 : 1(num_threads_var==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), length(reduction_vars), ])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !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 ) end @@ -607,22 +528,18 @@ entity for a reduction requested in some ancestor. The reduction is identified by the accumulator, but the value of the accumulator may not be updated immediately. """ -function reduction(operand::Value, accumulator::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand, accumulator] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduction(operand, accumulator; location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(accumulator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -679,38 +596,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( - 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[reduction_vars..., allocate_vars..., allocators_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - 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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sections(reduction_vars, allocate_vars, allocators_vars; reductions=nothing, nowait=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(reduction_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(reduction_vars), length(allocate_vars), length(allocators_vars), ])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.sections", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -738,38 +638,21 @@ for (%i1, %i2) : index = (%c0, %c0) to (%c10, %c10) step (%c1, %c1) { } ``` """ -function simdloop( - lowerBound::Vector{Value}, - upperBound::Vector{Value}, - step::Vector{Value}, - if_expr=nothing::Union{Nothing,Value}; - inclusive=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lowerBound..., upperBound..., step...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(if_expr) && push!(_operands, if_expr) - push!( - _attributes, - operandsegmentsizes([ - length(lowerBound), length(upperBound), length(step), isnothing(if_expr) ? 0 : 1 - ]), - ) - !isnothing(inclusive) && push!(_attributes, namedattribute("inclusive", inclusive)) - - return IR.create_operation( - "omp.simdloop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function simdloop(lowerBound, upperBound, step, if_expr=nothing; inclusive=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), (if_expr==nothing) ? 0 : 1])) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + + IR.create_operation( + "omp.simdloop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -782,32 +665,20 @@ master thread), in the context of its implicit task. The other threads in the team, which do not execute the block, wait at an implicit barrier at the end of the single construct unless a nowait clause is specified. """ -function single( - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}; - nowait=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[allocate_vars..., allocators_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, operandsegmentsizes([length(allocate_vars), length(allocators_vars)]) - ) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.single", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function single(allocate_vars, allocators_vars; nowait=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(allocate_vars), length(allocators_vars), ])) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.single", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -831,41 +702,23 @@ even if the target task is not yet completed. TODO: map, is_device_ptr, 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(), -) - _results = IR.Type[] - _operands = Value[] - _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([ - isnothing(if_expr) ? 0 : 1, - isnothing(device) ? 0 : 1, - isnothing(thread_limit) ? 0 : 1, - ]), - ) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.target", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function target(if_expr=nothing; device=nothing, thread_limit=nothing, nowait=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(device) && push!(operands, value(device)) + !isnothing(thread_limit) && push!(operands, value(thread_limit)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1(thread_limit==nothing) ? 0 : 1])) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.target", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -893,37 +746,20 @@ The `allocators_vars` and `allocate_vars` arguments are a variadic list of values that specify the memory allocator to be used to obtain storage for private values. """ -function taskgroup( - task_reduction_vars::Vector{Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}; - task_reductions=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[task_reduction_vars..., allocate_vars..., allocators_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - length(task_reduction_vars), length(allocate_vars), length(allocators_vars) - ]), - ) - !isnothing(task_reductions) && - push!(_attributes, namedattribute("task_reductions", task_reductions)) - - return IR.create_operation( - "omp.taskgroup", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function taskgroup(task_reduction_vars, allocate_vars, allocators_vars; task_reductions=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(task_reduction_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(task_reduction_vars), length(allocate_vars), length(allocators_vars), ])) + !isnothing(task_reductions) && push!(attributes, namedattribute("task_reductions", task_reductions)) + + IR.create_operation( + "omp.taskgroup", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1025,80 +861,30 @@ construct. Thus, the taskloop construct creates an implicit taskgroup region. If the `nogroup` clause is present, no implicit taskgroup region is created. """ -function taskloop( - lowerBound::Vector{Value}, - upperBound::Vector{Value}, - step::Vector{Value}, - if_expr=nothing::Union{Nothing,Value}; - final_expr=nothing::Union{Nothing,Value}, - in_reduction_vars::Vector{Value}, - reduction_vars::Vector{Value}, - priority=nothing::Union{Nothing,Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}, - grain_size=nothing::Union{Nothing,Value}, - num_tasks=nothing::Union{Nothing,Value}, - inclusive=nothing, - untied=nothing, - mergeable=nothing, - in_reductions=nothing, - reductions=nothing, - nogroup=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - lowerBound..., - upperBound..., - step..., - in_reduction_vars..., - reduction_vars..., - allocate_vars..., - allocators_vars..., - ] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(final_expr) && push!(_operands, final_expr) - !isnothing(priority) && push!(_operands, priority) - !isnothing(grain_size) && push!(_operands, grain_size) - !isnothing(num_tasks) && push!(_operands, num_tasks) - push!( - _attributes, - operandsegmentsizes([ - length(lowerBound), - length(upperBound), - length(step), - isnothing(if_expr) ? 0 : 1, - isnothing(final_expr) ? 0 : 1, - length(in_reduction_vars), - length(reduction_vars), - isnothing(priority) ? 0 : 1, - length(allocate_vars), - length(allocators_vars), - isnothing(grain_size) ? 0 : 1, - isnothing(num_tasks) ? 0 : 1, - ]), - ) - !isnothing(inclusive) && push!(_attributes, namedattribute("inclusive", inclusive)) - !isnothing(untied) && push!(_attributes, namedattribute("untied", untied)) - !isnothing(mergeable) && push!(_attributes, namedattribute("mergeable", mergeable)) - !isnothing(in_reductions) && - push!(_attributes, namedattribute("in_reductions", in_reductions)) - !isnothing(reductions) && push!(_attributes, namedattribute("reductions", reductions)) - !isnothing(nogroup) && push!(_attributes, namedattribute("nogroup", nogroup)) - - return IR.create_operation( - "omp.taskloop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function taskloop(lowerBound, upperBound, step, if_expr=nothing; final_expr=nothing, in_reduction_vars, reduction_vars, priority=nothing, allocate_vars, allocators_vars, grain_size=nothing, num_tasks=nothing, inclusive=nothing, untied=nothing, mergeable=nothing, in_reductions=nothing, reductions=nothing, nogroup=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(in_reduction_vars)..., value.(reduction_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(final_expr) && push!(operands, value(final_expr)) + !isnothing(priority) && push!(operands, value(priority)) + !isnothing(grain_size) && push!(operands, value(grain_size)) + !isnothing(num_tasks) && push!(operands, value(num_tasks)) + push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), (if_expr==nothing) ? 0 : 1(final_expr==nothing) ? 0 : 1length(in_reduction_vars), length(reduction_vars), (priority==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), (grain_size==nothing) ? 0 : 1(num_tasks==nothing) ? 0 : 1])) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + !isnothing(untied) && push!(attributes, namedattribute("untied", untied)) + !isnothing(mergeable) && push!(attributes, namedattribute("mergeable", mergeable)) + !isnothing(in_reductions) && push!(attributes, namedattribute("in_reductions", in_reductions)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nogroup) && push!(attributes, namedattribute("nogroup", nogroup)) + + IR.create_operation( + "omp.taskloop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1144,52 +930,25 @@ The `allocators_vars` and `allocate_vars` arguments are a variadic list of values that specify the memory allocator to be used to obtain storage for private values. """ -function task( - if_expr=nothing::Union{Nothing,Value}; - final_expr=nothing::Union{Nothing,Value}, - in_reduction_vars::Vector{Value}, - priority=nothing::Union{Nothing,Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}, - untied=nothing, - mergeable=nothing, - in_reductions=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in_reduction_vars..., allocate_vars..., allocators_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(final_expr) && push!(_operands, final_expr) - !isnothing(priority) && push!(_operands, priority) - push!( - _attributes, - operandsegmentsizes([ - isnothing(if_expr) ? 0 : 1, - isnothing(final_expr) ? 0 : 1, - length(in_reduction_vars), - isnothing(priority) ? 0 : 1, - length(allocate_vars), - length(allocators_vars), - ]), - ) - !isnothing(untied) && push!(_attributes, namedattribute("untied", untied)) - !isnothing(mergeable) && push!(_attributes, namedattribute("mergeable", mergeable)) - !isnothing(in_reductions) && - push!(_attributes, namedattribute("in_reductions", in_reductions)) - - return IR.create_operation( - "omp.task", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function task(if_expr=nothing; final_expr=nothing, in_reduction_vars, priority=nothing, allocate_vars, allocators_vars, untied=nothing, mergeable=nothing, in_reductions=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(in_reduction_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(final_expr) && push!(operands, value(final_expr)) + !isnothing(priority) && push!(operands, value(priority)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(final_expr==nothing) ? 0 : 1length(in_reduction_vars), (priority==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), ])) + !isnothing(untied) && push!(attributes, namedattribute("untied", untied)) + !isnothing(mergeable) && push!(attributes, namedattribute("mergeable", mergeable)) + !isnothing(in_reductions) && push!(attributes, namedattribute("in_reductions", in_reductions)) + + IR.create_operation( + "omp.task", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1288,22 +1047,18 @@ this operation. The `sym_addr` refers to the address of the symbol, which is a pointer to the original variable. """ -function threadprivate(sym_addr::Value; tls_addr::IR.Type, location=Location()) - _results = IR.Type[tls_addr,] - _operands = Value[sym_addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.threadprivate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function threadprivate(sym_addr; tls_addr::IR.Type, location=Location()) + results = IR.Type[tls_addr, ] + operands = Value[value(sym_addr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.threadprivate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1368,72 +1123,28 @@ 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}, - 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, - nowait=nothing, - ordered_val=nothing, - order_val=nothing, - inclusive=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - lowerBound..., - upperBound..., - step..., - 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(linear_vars), - length(linear_step_vars), - length(reduction_vars), - isnothing(schedule_chunk_var) ? 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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wsloop(lowerBound, upperBound, step, linear_vars, linear_step_vars, reduction_vars, schedule_chunk_var=nothing; reductions=nothing, schedule_val=nothing, schedule_modifier=nothing, simd_modifier=nothing, nowait=nothing, ordered_val=nothing, order_val=nothing, inclusive=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(linear_vars)..., value.(linear_step_vars)..., value.(reduction_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(schedule_chunk_var) && push!(operands, value(schedule_chunk_var)) + push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(linear_vars), length(linear_step_vars), length(reduction_vars), (schedule_chunk_var==nothing) ? 0 : 1])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(schedule_val) && push!(attributes, namedattribute("schedule_val", schedule_val)) + !isnothing(schedule_modifier) && push!(attributes, namedattribute("schedule_modifier", schedule_modifier)) + !isnothing(simd_modifier) && push!(attributes, namedattribute("simd_modifier", simd_modifier)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(ordered_val) && push!(attributes, namedattribute("ordered_val", ordered_val)) + !isnothing(order_val) && push!(attributes, namedattribute("order_val", order_val)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + + IR.create_operation( + "omp.wsloop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1444,22 +1155,18 @@ end terminates the region. The semantics of how the values are yielded is defined by the parent operation. """ -function yield(results::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/PDL.jl b/src/Dialects/15/PDL.jl index c9c7f325..f48e0c22 100644 --- a/src/Dialects/15/PDL.jl +++ b/src/Dialects/15/PDL.jl @@ -1,7 +1,6 @@ module pdl -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,22 +17,18 @@ entities. pdl.apply_native_constraint \"myConstraint\"(%input, %attr, %op : !pdl.value, !pdl.attribute, !pdl.operation) ``` """ -function apply_native_constraint(args::Vector{Value}; name, location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl.apply_native_constraint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_native_constraint(args; name, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl.apply_native_constraint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -65,24 +60,18 @@ void registerNativeRewrite(PDLPatternModule &pdlModule) { } ``` """ -function apply_native_rewrite( - args::Vector{Value}; results::Vector{IR.Type}, name, location=Location() -) - _results = IR.Type[results...,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl.apply_native_rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_native_rewrite(args; results_::Vector{IR.Type}, name, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl.apply_native_rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -111,26 +100,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function attribute(type=nothing; attr::IR.Type, value=nothing, location=Location()) + results = IR.Type[attr, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(type) && push!(operands, value(type)) + !isnothing(value) && push!(attributes, namedattribute("value", value)) + + IR.create_operation( + "pdl.attribute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -147,22 +130,18 @@ operation correspond with the `eraseOp` method on a `PatternRewriter`. pdl.erase %root ``` """ -function erase(operation::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operation,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl.erase", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function erase(operation; location=Location()) + results = IR.Type[] + operands = Value[value(operation), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl.erase", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -187,23 +166,19 @@ 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,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(type) && push!(_operands, type) - - return IR.create_operation( - "pdl.operand", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operand(type=nothing; val::IR.Type, location=Location()) + results = IR.Type[val, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(type) && push!(operands, value(type)) + + IR.create_operation( + "pdl.operand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -228,23 +203,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,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(type) && push!(_operands, type) - - return IR.create_operation( - "pdl.operands", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operands_(type=nothing; val::IR.Type, location=Location()) + results = IR.Type[val, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(type) && push!(operands, value(type)) + + IR.create_operation( + "pdl.operands", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -345,35 +316,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...] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operation(operands_, attributes_, types; op::IR.Type, name=nothing, attributeNames, location=Location()) + results = IR.Type[op, ] + operands = Value[value.(operands_)..., value.(attributes_)..., value.(types)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("attributeNames", attributeNames), ] + push!(attributes, operandsegmentsizes([length(operands), length(attributes), length(types), ])) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "pdl.operation", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -446,32 +402,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(), -) - _results = IR.Type[] - _operands = Value[operation, replValues...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(replOperation) && push!(_operands, replOperation) - push!( - _attributes, - operandsegmentsizes([1, isnothing(replOperation) ? 0 : 1, length(replValues)]), - ) - - return IR.create_operation( - "pdl.replace", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function replace(operation, replOperation=nothing; replValues, location=Location()) + results = IR.Type[] + operands = Value[value(operation), value.(replValues)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(replOperation) && push!(operands, value(replOperation)) + 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 ) end @@ -497,22 +441,18 @@ as defined by the ODS definition of the operation. // the IR snippet, `%pdl_result` would correspond to `%result_1`. ``` """ -function result(parent::Value; val::IR.Type, index, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function result(parent; val::IR.Type, index, location=Location()) + results = IR.Type[val, ] + operands = Value[value(parent), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl.result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -545,23 +485,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(index) && push!(_attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl.results", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function results_(parent; val::IR.Type, index=nothing, location=Location()) + results = IR.Type[val, ] + operands = Value[value(parent), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl.results", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -604,31 +540,21 @@ pdl.rewrite { } ``` """ -function rewrite( - root=nothing::Union{Nothing,Value}; - externalArgs::Vector{Value}, - name=nothing, - body::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[externalArgs...,] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(root) && push!(_operands, root) - push!(_attributes, operandsegmentsizes([isnothing(root) ? 0 : 1, length(externalArgs)])) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "pdl.rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rewrite(root=nothing; externalArgs, name=nothing, body::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(externalArgs)..., ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(root) && push!(operands, value(root)) + push!(attributes, operandsegmentsizes([(root==nothing) ? 0 : 1length(externalArgs), ])) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "pdl.rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/PDLInterp.jl b/src/Dialects/15/PDLInterp.jl index 73ae9a04..c5774e8f 100644 --- a/src/Dialects/15/PDLInterp.jl +++ b/src/Dialects/15/PDLInterp.jl @@ -1,7 +1,6 @@ module pdl_interp -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -20,24 +19,18 @@ otherwise the false destination is taken. pdl_interp.apply_constraint \"myConstraint\"(%input, %attr, %op : !pdl.value, !pdl.attribute, !pdl.operation) -> ^matchDest, ^failureDest ``` """ -function apply_constraint( - args::Vector{Value}; name, trueDest::Block, falseDest::Block, location=Location() -) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.apply_constraint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_constraint(args; name, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.apply_constraint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -63,24 +56,18 @@ pdl_interp.apply_rewrite \"rewriter\"(%root : !pdl.operation) pdl_interp.apply_rewrite \"rewriter\"(%root : !pdl.operation, %value : !pdl.value) ``` """ -function apply_rewrite( - args::Vector{Value}; results::Vector{IR.Type}, name, location=Location() -) - _results = IR.Type[results...,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.apply_rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_rewrite(args; results_::Vector{IR.Type}, name, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.apply_rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -97,24 +84,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.are_equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function are_equal(lhs, rhs; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.are_equal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -163,24 +144,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_attribute(attribute; constantValue, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(attribute), ] + owned_regions = Region[] + 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 ) end @@ -203,31 +178,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( - inputOp::Value; - count, - compareAtLeast=nothing, - trueDest::Block, - falseDest::Block, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_operand_count(inputOp; count, compareAtLeast=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -244,24 +207,18 @@ destination, otherwise the false destination is taken. pdl_interp.check_operation_name of %op is \"foo.op\" -> ^matchDest, ^failureDest ``` """ -function check_operation_name( - inputOp::Value; name, trueDest::Block, falseDest::Block, location=Location() -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.check_operation_name", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_operation_name(inputOp; name, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -284,31 +241,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( - inputOp::Value; - count, - compareAtLeast=nothing, - trueDest::Block, - falseDest::Block, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_result_count(inputOp; count, compareAtLeast=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -325,24 +270,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_type(value; type, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -359,24 +298,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_types(value; types, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -462,42 +395,20 @@ to this operation. %op = pdl_interp.create_operation \"foo.op\"(%arg0 : !pdl.value) {\"attrA\" = %attr0} -> ``` """ -function create_operation( - inputOperands::Vector{Value}, - inputAttributes::Vector{Value}, - inputResultTypes::Vector{Value}; - resultOp::IR.Type, - name, - inputAttributeNames, - inferredResultTypes=nothing, - location=Location(), -) - _results = IR.Type[resultOp,] - _operands = Value[inputOperands..., inputAttributes..., inputResultTypes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("name", name), - namedattribute("inputAttributeNames", inputAttributeNames), - ] - push!( - _attributes, - operandsegmentsizes([ - length(inputOperands), length(inputAttributes), length(inputResultTypes) - ]), - ) - !isnothing(inferredResultTypes) && - push!(_attributes, namedattribute("inferredResultTypes", inferredResultTypes)) - - return IR.create_operation( - "pdl_interp.create_operation", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_operation(inputOperands, inputAttributes, inputResultTypes; resultOp::IR.Type, name, inputAttributeNames, inferredResultTypes=nothing, location=Location()) + results = IR.Type[resultOp, ] + operands = Value[value.(inputOperands)..., value.(inputAttributes)..., value.(inputResultTypes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), namedattribute("inputAttributeNames", inputAttributeNames), ] + push!(attributes, operandsegmentsizes([length(inputOperands), length(inputAttributes), length(inputResultTypes), ])) + !isnothing(inferredResultTypes) && push!(attributes, namedattribute("inferredResultTypes", inferredResultTypes)) + + IR.create_operation( + "pdl_interp.create_operation", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -576,22 +487,18 @@ marked as erased. The semantics of this operation correspond with the pdl_interp.erase %root ``` """ -function erase(inputOp::Value; location=Location()) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.erase", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function erase(inputOp; location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.erase", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -608,22 +515,18 @@ at the specified index. If the index is out of range, returns null. %ops = pdl_interp.extract 1 of %values : !pdl.value ``` """ -function extract(range::Value; result::IR.Type, index, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract(range; result::IR.Type, index, location=Location()) + results = IR.Type[result, ] + operands = Value[value(range), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.extract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -677,22 +580,18 @@ pdl_interp.foreach %op : !pdl.operation in %ops { } -> ^next ``` """ -function foreach(values::Value; region::Region, successor::Block, location=Location()) - _results = IR.Type[] - _operands = Value[values,] - _owned_regions = Region[region,] - _successors = Block[successor,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.foreach", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach(values; region::Region, successor::Block, location=Location()) + results = IR.Type[] + operands = Value[value(values), ] + owned_regions = Region[region, ] + successors = Block[successor, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.foreach", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -748,22 +647,18 @@ returned. %attr = pdl_interp.get_attribute \"attr\" of %op ``` """ -function get_attribute(inputOp::Value; attribute::IR.Type, name, location=Location()) - _results = IR.Type[attribute,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.get_attribute", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_attribute(inputOp; attribute::IR.Type, name, location=Location()) + results = IR.Type[attribute, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.get_attribute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -779,22 +674,18 @@ specific attribute. %type = pdl_interp.get_attribute_type of %attr ``` """ -function get_attribute_type(value::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_attribute_type(value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_attribute_type", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -812,22 +703,18 @@ or range of operand results, null is returned. %op = pdl_interp.get_defining_op of %value : !pdl.value ``` """ -function get_defining_op(value::Value; inputOp::IR.Type, location=Location()) - _results = IR.Type[inputOp,] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.get_defining_op", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_defining_op(value; inputOp::IR.Type, location=Location()) + results = IR.Type[inputOp, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_defining_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -844,22 +731,18 @@ null value is returned. %operand = pdl_interp.get_operand 1 of %op ``` """ -function get_operand(inputOp::Value; value::IR.Type, index, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("index", index),] - - return IR.create_operation( - "pdl_interp.get_operand", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_operand(inputOp; value::IR.Type, index, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.get_operand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -886,23 +769,19 @@ the returned operand group corresponds to all operands of the operation. %operands = pdl_interp.get_operands of %op : !pdl.range ``` """ -function get_operands(inputOp::Value; value::IR.Type, index=nothing, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(index) && push!(_attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl_interp.get_operands", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_operands(inputOp; value::IR.Type, index=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl_interp.get_operands", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -919,22 +798,18 @@ null value is returned. %result = pdl_interp.get_result 1 of %op ``` """ -function get_result(inputOp::Value; value::IR.Type, index, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("index", index),] - - return IR.create_operation( - "pdl_interp.get_result", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_result(inputOp; value::IR.Type, index, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.get_result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -961,23 +836,19 @@ the returned operand group corresponds to all results of the operation. %results = pdl_interp.get_results of %op : !pdl.range ``` """ -function get_results(inputOp::Value; value::IR.Type, index=nothing, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(index) && push!(_attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl_interp.get_results", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_results(inputOp; value::IR.Type, index=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl_interp.get_results", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -998,22 +869,18 @@ similarly to ResultRange::getUsers. %ops = pdl_interp.get_users of %values : !pdl.range ``` """ -function get_users(value::Value; operations::IR.Type, location=Location()) - _results = IR.Type[operations,] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.get_users", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_users(value; operations::IR.Type, location=Location()) + results = IR.Type[operations, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_users", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1033,22 +900,18 @@ value or range thereof. %type = pdl_interp.get_value_type of %values : !pdl.range ``` """ -function get_value_type(value::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_value_type(value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_value_type", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1066,22 +929,18 @@ false destination is taken. 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,] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.is_not_null", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function is_not_null(value; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.is_not_null", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1100,37 +959,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(), -) - _results = IR.Type[] - _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)])) - !isnothing(rootKind) && push!(_attributes, namedattribute("rootKind", rootKind)) - !isnothing(generatedOps) && - push!(_attributes, namedattribute("generatedOps", generatedOps)) - - return IR.create_operation( - "pdl_interp.record_match", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function record_match(inputs, matchedOps; rewriter, rootKind=nothing, generatedOps=nothing, benefit, dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(inputs)..., value.(matchedOps)..., ] + owned_regions = Region[] + 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)) + + IR.create_operation( + "pdl_interp.record_match", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1149,22 +992,18 @@ values must match the number of results specified by the operation. pdl_interp.replace %root with (%val0, %val1 : !pdl.type, !pdl.type) ``` """ -function replace(inputOp::Value, replValues::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[inputOp, replValues...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.replace", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function replace(inputOp, replValues; location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), value.(replValues)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.replace", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1182,28 +1021,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_attribute(attribute; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(attribute), ] + owned_regions = Region[] + 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 ) end @@ -1221,28 +1050,18 @@ otherwise the default destination is taken. pdl_interp.switch_operand_count of %op to [10, 2] -> ^10Dest, ^2Dest, ^defaultDest ``` """ -function switch_operand_count( - inputOp::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[defaultDest, cases...] - _attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_operand_count", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_operand_count(inputOp; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -1260,28 +1079,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( - inputOp::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[defaultDest, cases...] - _attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_operation_name", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_operation_name(inputOp; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -1299,28 +1108,18 @@ otherwise the default destination is taken. pdl_interp.switch_result_count of %op to [0, 2](^0Dest, ^2Dest) -> ^defaultDest ``` """ -function switch_result_count( - inputOp::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[defaultDest, cases...] - _attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_result_count", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_result_count(inputOp; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -1338,24 +1137,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_type(value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -1373,24 +1166,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_types(value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end diff --git a/src/Dialects/15/Quant.jl b/src/Dialects/15/Quant.jl index 42ad32e2..716f005d 100644 --- a/src/Dialects/15/Quant.jl +++ b/src/Dialects/15/Quant.jl @@ -1,7 +1,6 @@ module quant -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -12,39 +11,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(), -) - _results = IR.Type[] - _operands = Value[inputs,] - _owned_regions = Region[] - _successors = Block[] - _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(is_signed) && push!(_attributes, namedattribute("is_signed", is_signed)) - - return IR.create_operation( - "quant.const_fake_quant", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function const_fake_quant(inputs; outputs=nothing::Union{Nothing, IR.Type}, min, max, num_bits, narrow_range=nothing, is_signed=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(inputs), ] + owned_regions = Region[] + successors = Block[] + 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(is_signed) && push!(attributes, namedattribute("is_signed", is_signed)) + + 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) ) end @@ -57,41 +38,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(), -) - _results = IR.Type[] - _operands = Value[inputs,] - _owned_regions = Region[] - _successors = Block[] - _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(is_signed) && push!(_attributes, namedattribute("is_signed", is_signed)) - - return IR.create_operation( - "quant.const_fake_quant_per_axis", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function const_fake_quant_per_axis(inputs; outputs=nothing::Union{Nothing, IR.Type}, min, max, axis, num_bits, narrow_range=nothing, is_signed=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(inputs), ] + owned_regions = Region[] + successors = Block[] + 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(is_signed) && push!(attributes, namedattribute("is_signed", is_signed)) + + 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) ) end @@ -105,25 +66,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() -) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("coupledKey", coupledKey),] - !isnothing(result_0) && push!(_results, result_0) - - return IR.create_operation( - "quant.coupled_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function coupled_ref(arg; result_0=nothing::Union{Nothing, IR.Type}, coupledKey, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("coupledKey", coupledKey), ] + !isnothing(result_0) && push!(results, result_0) + + 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) ) end @@ -131,22 +86,18 @@ end `dcast` """ -function dcast(arg::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.dcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dcast(arg; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.dcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -154,22 +105,18 @@ end `qcast` """ -function qcast(arg::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.qcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function qcast(arg; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.qcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -177,34 +124,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function region(inputs; outputs::Vector{IR.Type}, input_specs, output_specs, logical_kernel, body::Region, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[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), ] + + IR.create_operation( + "quant.region", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -212,22 +143,18 @@ end `return_` """ -function return_(results::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -251,32 +178,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(), -) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function stats(arg; result_0=nothing::Union{Nothing, IR.Type}, layerStats, axisStats=nothing, axis=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + 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)) + + IR.create_operation( + "quant.stats", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -289,25 +205,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() -) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("statsKey", statsKey),] - !isnothing(result_0) && push!(_results, result_0) - - return IR.create_operation( - "quant.stats_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function stats_ref(arg; result_0=nothing::Union{Nothing, IR.Type}, statsKey, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("statsKey", statsKey), ] + !isnothing(result_0) && push!(results, result_0) + + 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) ) end @@ -315,22 +225,18 @@ end `scast` """ -function scast(arg::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.scast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scast(arg; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.scast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/SCF.jl b/src/Dialects/15/SCF.jl index f6a4f2fa..930cf273 100644 --- a/src/Dialects/15/SCF.jl +++ b/src/Dialects/15/SCF.jl @@ -1,7 +1,6 @@ module scf -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -12,22 +11,18 @@ of the `scf.while` construct. If its first argument is true, the \"after\" region of `scf.while` is executed, with the remaining arguments forwarded 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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.condition", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function condition(condition, args; location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.condition", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -180,30 +175,18 @@ func.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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function for_(lowerBound, upperBound, step, initArgs; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(lowerBound), value(upperBound), value(step), value.(initArgs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -307,30 +290,19 @@ Example with thread_dim_mapping attribute: // Sequential context. // """ -function foreach_thread( - num_threads::Vector{Value}; - results::Vector{IR.Type}, - thread_dim_mapping=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[num_threads...,] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(thread_dim_mapping) && - push!(_attributes, namedattribute("thread_dim_mapping", thread_dim_mapping)) - - return IR.create_operation( - "scf.foreach_thread", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach_thread(num_threads; results_::Vector{IR.Type}, thread_dim_mapping=nothing, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(num_threads)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(thread_dim_mapping) && push!(attributes, namedattribute("thread_dim_mapping", thread_dim_mapping)) + + IR.create_operation( + "scf.foreach_thread", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -380,28 +352,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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.if", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function if_(condition; results_::Vector{IR.Type}, thenRegion::Region, elseRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(condition), ] + owned_regions = Region[thenRegion, elseRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -451,36 +413,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - length(lowerBound), length(upperBound), length(step), length(initVals) - ]), - ) - - return IR.create_operation( - "scf.parallel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(lowerBound, upperBound, step, initVals; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(initVals)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -550,22 +495,18 @@ scf.reduce(%operand) : f32 { } ``` """ -function reduce(operand::Value; reductionOperator::Region, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[reductionOperator,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce(operand; reductionOperator::Region, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[reductionOperator, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.reduce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -580,22 +521,18 @@ the operand of \"scf.reduce\". Example for the custom format: scf.reduce.return %res : f32 ``` """ -function reduce_return(result::Value; location=Location()) - _results = IR.Type[] - _operands = Value[result,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.reduce.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_return(result; location=Location()) + results = IR.Type[] + operands = Value[value(result), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.reduce.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -713,28 +650,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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.while", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function while_(inits; results_::Vector{IR.Type}, before::Region, after::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(inits)..., ] + owned_regions = Region[before, after, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.while", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -751,22 +678,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()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/SPIRV.jl b/src/Dialects/15/SPIRV.jl index fe8a6bca..43f9e624 100644 --- a/src/Dialects/15/SPIRV.jl +++ b/src/Dialects/15/SPIRV.jl @@ -1,7 +1,6 @@ module spv -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -46,24 +45,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.AccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AccessChain(base_ptr, indices; component_ptr::IR.Type, location=Location()) + results = IR.Type[component_ptr, ] + operands = Value[value(base_ptr), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.AccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -127,22 +120,18 @@ assumetruekhr-op ::= `spv.AssumeTrueKHR` ssa-use spv.AssumeTrueKHR %arg ``` """ -function AssumeTrueKHR(condition::Value; location=Location()) - _results = IR.Type[] - _operands = Value[condition,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.AssumeTrueKHR", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AssumeTrueKHR(condition; location=Location()) + results = IR.Type[] + operands = Value[value(condition), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.AssumeTrueKHR", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -183,31 +172,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicAnd(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -257,35 +233,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicCompareExchange(pointer, value, comparator; result::IR.Type, memory_scope, equal_semantics, unequal_semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), value(comparator), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -313,35 +272,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicCompareExchangeWeak(pointer, value, comparator; result::IR.Type, memory_scope, equal_semantics, unequal_semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), value(comparator), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -378,31 +320,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicExchange", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicExchange(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -444,31 +373,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicFAddEXT", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicFAddEXT(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -505,31 +421,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicIAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIAdd(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -565,26 +468,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicIDecrement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIDecrement(pointer; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -619,26 +514,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicIIncrement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIIncrement(pointer; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -676,31 +563,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicISub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicISub(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -737,31 +611,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicOr(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -799,31 +660,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicSMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicSMax(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -861,31 +709,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicSMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicSMin(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -923,31 +758,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicUMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicUMax(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -985,31 +807,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicUMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicUMin(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1047,31 +856,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics) - ] - - return IR.create_operation( - "spv.AtomicXor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicXor(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1107,25 +903,19 @@ Results are computed per component. %3 = spv.BitCount %1: vector<4xi32> ``` """ -function BitCount( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.BitCount", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitCount(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitCount", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1171,30 +961,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldInsert(base, insert, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(insert), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitFieldInsert", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1240,29 +1019,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldSExtract(base, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitFieldSExtract", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1290,29 +1059,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldUExtract(base, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitFieldUExtract", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1344,25 +1103,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() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.BitReverse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitReverse(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitReverse", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1405,22 +1158,18 @@ bitcast-op ::= ssa-id `=` `spv.Bitcast` ssa-use %1 = spv.Bitcast %0 : !spv.ptr to !spv.ptr ``` """ -function Bitcast(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Bitcast(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1450,28 +1199,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.BitwiseAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseAnd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitwiseAnd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1501,28 +1241,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.BitwiseOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseOr(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitwiseOr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1552,28 +1283,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.BitwiseXor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseXor(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.BitwiseXor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1611,36 +1333,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(), -) - _results = IR.Type[] - _operands = Value[condition, trueTargetOperands..., falseTargetOperands...] - _owned_regions = Region[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function BranchConditional(condition, trueTargetOperands, falseTargetOperands; branch_weights=nothing, trueTarget::Block, falseTarget::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueTargetOperands)..., value.(falseTargetOperands)..., ] + owned_regions = Region[] + successors = Block[trueTarget, falseTarget, ] + attributes = NamedAttribute[] + 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 ) end @@ -1664,22 +1370,18 @@ spv.Branch ^target spv.Branch ^target(%0, %1: i32, f32) ``` """ -function Branch(targetOperands::Vector{Value}; target::Block, location=Location()) - _results = IR.Type[] - _operands = Value[targetOperands...,] - _owned_regions = Region[] - _successors = Block[target,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Branch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Branch(targetOperands; target::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(targetOperands)..., ] + owned_regions = Region[] + successors = Block[target, ] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Branch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1708,25 +1410,19 @@ ceil-op ::= ssa-id `=` `spv.CL.ceil` ssa-use `:` %3 = spv.CL.ceil %1 : vector<3xf16> ``` """ -function CL_ceil( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_ceil(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.ceil", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1755,23 +1451,19 @@ cos-op ::= ssa-id `=` `spv.CL.cos` ssa-use `:` %3 = spv.CL.cos %1 : vector<3xf16> ``` """ -function CL_cos(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_cos(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1800,23 +1492,19 @@ erf-op ::= ssa-id `=` `spv.CL.erf` ssa-use `:` %3 = spv.CL.erf %1 : vector<3xf16> ``` """ -function CL_erf(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.erf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_erf(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.erf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1845,23 +1533,19 @@ exp-op ::= ssa-id `=` `spv.CL.exp` ssa-use `:` %3 = spv.CL.exp %1 : vector<3xf16> ``` """ -function CL_exp(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_exp(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1890,25 +1574,19 @@ abs-op ::= ssa-id `=` `spv.CL.fabs` ssa-use `:` %3 = spv.CL.fabs %1 : vector<3xf16> ``` """ -function CL_fabs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.fabs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_fabs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.fabs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1937,27 +1615,21 @@ floor-op ::= ssa-id `=` `spv.CL.floor` ssa-use `:` %3 = spv.CL.ceifloorl %1 : vector<3xf16> ``` """ -function CL_floor( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end +function CL_floor(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.floor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) + ) +end """ `CL_fma` @@ -1980,29 +1652,19 @@ fma-op ::= ssa-id `=` `spv.CL.fma` ssa-use, ssa-use, ssa-use `:` %1 = spv.CL.fma %a, %b, %c : vector<3xf16> ``` """ -function CL_fma( - x::Value, - y::Value, - z::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_fma(x, y, z; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.fma", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2031,23 +1693,19 @@ log-op ::= ssa-id `=` `spv.CL.log` ssa-use `:` %3 = spv.CL.log %1 : vector<3xf16> ``` """ -function CL_log(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_log(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2077,25 +1735,19 @@ pow-op ::= ssa-id `=` `spv.CL.pow` ssa-use `:` %3 = spv.CL.pow %0, %1 : vector<3xf16> ``` """ -function CL_pow( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_pow(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.pow", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2123,25 +1775,19 @@ round-op ::= ssa-id `=` `spv.CL.round` ssa-use `:` %3 = spv.CL.round %0 : vector<3xf16> ``` """ -function CL_round( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_round(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.round", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2170,25 +1816,19 @@ rsqrt-op ::= ssa-id `=` `spv.CL.rsqrt` ssa-use `:` %3 = spv.CL.rsqrt %1 : vector<3xf16> ``` """ -function CL_rsqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_rsqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.rsqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2217,25 +1857,19 @@ abs-op ::= ssa-id `=` `spv.CL.s_abs` ssa-use `:` %3 = spv.CL.s_abs %1 : vector<3xi16> ``` """ -function CL_s_abs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.s_abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_s_abs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.s_abs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2264,23 +1898,19 @@ sin-op ::= ssa-id `=` `spv.CL.sin` ssa-use `:` %3 = spv.CL.sin %1 : vector<3xf16> ``` """ -function CL_sin(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_sin(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2309,25 +1939,19 @@ sqrt-op ::= ssa-id `=` `spv.CL.sqrt` ssa-use `:` %3 = spv.CL.sqrt %1 : vector<3xf16> ``` """ -function CL_sqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_sqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2356,25 +1980,19 @@ tanh-op ::= ssa-id `=` `spv.CL.tanh` ssa-use `:` %3 = spv.CL.tanh %1 : vector<3xf16> ``` """ -function CL_tanh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.CL.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_tanh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CL.tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2412,24 +2030,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.CompositeConstruct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CompositeConstruct(constituents; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(constituents)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.CompositeConstruct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2462,24 +2074,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("indices", indices),] - - return IR.create_operation( - "spv.CompositeExtract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CompositeExtract(composite; component::IR.Type, indices, location=Location()) + results = IR.Type[component, ] + operands = Value[value(composite), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indices", indices), ] + + IR.create_operation( + "spv.CompositeExtract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2512,24 +2118,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("indices", indices),] - - return IR.create_operation( - "spv.CompositeInsert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CompositeInsert(object, composite; result::IR.Type, indices, location=Location()) + results = IR.Type[result, ] + operands = Value[value(object), value(composite), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indices", indices), ] + + IR.create_operation( + "spv.CompositeInsert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2682,22 +2282,18 @@ convert-f-to-s-op ::= ssa-id `=` `spv.ConvertFToSOp` ssa-use %3 = spv.ConvertFToS %2 : vector<3xf32> to vector<3xi32> ``` """ -function ConvertFToS(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertFToS", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertFToS(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ConvertFToS", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2726,22 +2322,18 @@ convert-f-to-u-op ::= ssa-id `=` `spv.ConvertFToUOp` ssa-use %3 = spv.ConvertFToU %2 : vector<3xf32> to vector<3xi32> ``` """ -function ConvertFToU(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertFToU", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertFToU(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ConvertFToU", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2769,22 +2361,18 @@ convert-s-to-f-op ::= ssa-id `=` `spv.ConvertSToFOp` ssa-use %3 = spv.ConvertSToF %2 : vector<3xi32> to vector<3xf32> ``` """ -function ConvertSToF(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertSToF", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertSToF(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ConvertSToF", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2812,22 +2400,18 @@ convert-u-to-f-op ::= ssa-id `=` `spv.ConvertUToFOp` ssa-use %3 = spv.ConvertUToF %2 : vector<3xi32> to vector<3xf32> ``` """ -function ConvertUToF(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ConvertUToF", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertUToF(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ConvertUToF", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2927,31 +2511,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CooperativeMatrixLoadNV(pointer, stride, columnmajor; result::IR.Type, memory_access=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(stride), value(columnmajor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -3002,29 +2574,19 @@ For example: !spv.coopmatrix ``` """ -function CooperativeMatrixMulAddNV( - a::Value, - b::Value, - c::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CooperativeMatrixMulAddNV(a, b, c; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.CooperativeMatrixMulAddNV", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3067,31 +2629,19 @@ For example: !spv.ptr, !spv.coopmatrix ``` """ -function CooperativeMatrixStoreNV( - pointer::Value, - object::Value, - stride::Value, - columnmajor::Value; - memory_access=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CooperativeMatrixStoreNV(pointer, object, stride, columnmajor; memory_access=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(pointer), value(object), value(stride), value(columnmajor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -3124,37 +2674,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(), -) - _results = IR.Type[] - _operands = Value[target, source] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CopyMemory(target, source; memory_access=nothing, alignment=nothing, source_memory_access=nothing, source_alignment=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(target), value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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)) + + IR.create_operation( + "spv.CopyMemory", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3298,28 +2833,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FAdd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3348,22 +2874,18 @@ f-convert-op ::= ssa-id `=` `spv.FConvertOp` ssa-use %3 = spv.FConvertOp %2 : vector<3xf32> to vector<3xf64> ``` """ -function FConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3393,28 +2915,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3445,28 +2958,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3496,28 +3000,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FMul(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3545,25 +3040,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() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FNegate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FNegate(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FNegate", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3593,22 +3082,18 @@ fordequal-op ::= ssa-id `=` `spv.FOrdEqual` ssa-use, ssa-use %5 = spv.FOrdEqual %2, %3 : vector<4xf32> ``` """ -function FOrdEqual(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.FOrdEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3638,24 +3123,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3685,24 +3164,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3732,24 +3205,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3779,24 +3246,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3826,24 +3287,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FOrdNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FOrdNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FOrdNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3875,28 +3330,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FRem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FRem(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FRem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3925,28 +3371,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FSub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FSub(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FSub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3976,24 +3413,20 @@ funordequal-op ::= ssa-id `=` `spv.FUnordEqual` ssa-use, ssa-use %5 = spv.FUnordEqual %2, %3 : vector<4xf32> ``` """ -function FUnordEqual(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.FUnordEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end +function FUnordEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `FUnordGreaterThanEqual` @@ -4021,24 +3454,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FUnordGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4068,24 +3495,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FUnordGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4115,24 +3536,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FUnordLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4162,24 +3577,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FUnordLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4209,24 +3618,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.FUnordNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FUnordNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.FUnordNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4314,28 +3717,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(), -) - _results = IR.Type[] - _operands = Value[arguments...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("callee", callee),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.FunctionCall", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FunctionCall(arguments; result=nothing::Union{Nothing, IR.Type}, callee, location=Location()) + results = IR.Type[] + operands = Value[value.(arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.FunctionCall", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4368,25 +3762,19 @@ acos-op ::= ssa-id `=` `spv.GL.Acos` ssa-use `:` %3 = spv.GL.Acos %1 : vector<3xf16> ``` """ -function GL_Acos( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Acos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Acos(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Acos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4419,25 +3807,19 @@ asin-op ::= ssa-id `=` `spv.GL.Asin` ssa-use `:` %3 = spv.GL.Asin %1 : vector<3xf16> ``` """ -function GL_Asin( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Asin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Asin(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Asin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4470,25 +3852,19 @@ atan-op ::= ssa-id `=` `spv.GL.Atan` ssa-use `:` %3 = spv.GL.Atan %1 : vector<3xf16> ``` """ -function GL_Atan( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Atan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Atan(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Atan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4518,25 +3894,19 @@ ceil-op ::= ssa-id `=` `spv.GL.Ceil` ssa-use `:` %3 = spv.GL.Ceil %1 : vector<3xf16> ``` """ -function GL_Ceil( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Ceil(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Ceil", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4567,23 +3937,19 @@ cos-op ::= ssa-id `=` `spv.GL.Cos` ssa-use `:` %3 = spv.GL.Cos %1 : vector<3xf16> ``` """ -function GL_Cos(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Cos(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4614,25 +3980,19 @@ cosh-op ::= ssa-id `=` `spv.GL.Cosh` ssa-use `:` %3 = spv.GL.Cosh %1 : vector<3xf16> ``` """ -function GL_Cosh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Cosh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Cosh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Cosh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4663,23 +4023,19 @@ exp-op ::= ssa-id `=` `spv.GL.Exp` ssa-use `:` %3 = spv.GL.Exp %1 : vector<3xf16> ``` """ -function GL_Exp(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Exp(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4708,25 +4064,19 @@ abs-op ::= ssa-id `=` `spv.GL.FAbs` ssa-use `:` %3 = spv.GL.FAbs %1 : vector<3xf16> ``` """ -function GL_FAbs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.FAbs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FAbs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.FAbs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4755,22 +4105,18 @@ fclamp-op ::= ssa-id `=` `spv.GL.FClamp` ssa-use, ssa-use, ssa-use `:` %3 = spv.GL.FClamp %x, %min, %max : vector<3xf16> ``` """ -function GL_FClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GL.FClamp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_FClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GL.FClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4800,25 +4146,19 @@ fmax-op ::= ssa-id `=` `spv.GL.FMax` ssa-use `:` %3 = spv.GL.FMax %0, %1 : vector<3xf16> ``` """ -function GL_FMax( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.FMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FMax(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.FMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4848,25 +4188,19 @@ fmin-op ::= ssa-id `=` `spv.GL.FMin` ssa-use `:` %3 = spv.GL.FMin %0, %1 : vector<3xf16> ``` """ -function GL_FMin( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.FMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FMin(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.FMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4888,29 +4222,19 @@ Result Type and the type of all operands must be the same type. Results are comp %0 = spv.GL.FMix %x : vector<4xf32>, %y : vector<4xf32>, %a : vector<4xf32> -> vector<4xf32> ``` """ -function GL_FMix( - x::Value, - y::Value, - a::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x, y, a] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.FMix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FMix(x, y, a; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(y), value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.FMix", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4939,25 +4263,19 @@ sign-op ::= ssa-id `=` `spv.GL.FSign` ssa-use `:` %3 = spv.GL.FSign %1 : vector<3xf16> ``` """ -function GL_FSign( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.FSign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FSign(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.FSign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4974,25 +4292,19 @@ computed per component. This instruction is currently limited to 32-bit width components. """ -function GL_FindUMsb( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.FindUMsb", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FindUMsb(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.FindUMsb", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5022,25 +4334,19 @@ floor-op ::= ssa-id `=` `spv.GL.Floor` ssa-use `:` %3 = spv.GL.Floor %1 : vector<3xf16> ``` """ -function GL_Floor( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Floor(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Floor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5079,22 +4385,18 @@ fma-op ::= ssa-id `=` `spv.GL.Fma` ssa-use, ssa-use, ssa-use `:` %1 = spv.GL.Fma %a, %b, %c : vector<3xf16> ``` """ -function GL_Fma(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GL.Fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_Fma(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GL.Fma", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5136,22 +4438,18 @@ frexpstruct-op ::= ssa-id `=` `spv.GL.FrexpStruct` ssa-use `:` %3 = spv.GL.FrexpStruct %0 : vector<3xf32> -> !spv.struct, vector<3xi32>> ``` """ -function GL_FrexpStruct(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GL.FrexpStruct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_FrexpStruct(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GL.FrexpStruct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5180,25 +4478,19 @@ rsqrt-op ::= ssa-id `=` `spv.GL.InverseSqrt` ssa-use `:` %3 = spv.GL.InverseSqrt %1 : vector<3xf16> ``` """ -function GL_InverseSqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.InverseSqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_InverseSqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.InverseSqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5236,25 +4528,19 @@ component. %y = spv.GL.Ldexp %x : vector<3xf32>, %exp : vector<3xi32> -> vector<3xf32> ``` """ -function GL_Ldexp( - x::Value, exp::Value; y=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[x, exp] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(y) && push!(_results, y) - - return IR.create_operation( - "spv.GL.Ldexp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Ldexp(x, exp; y=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(exp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(y) && push!(results, y) + + IR.create_operation( + "spv.GL.Ldexp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5286,23 +4572,19 @@ log-op ::= ssa-id `=` `spv.GL.Log` ssa-use `:` %3 = spv.GL.Log %1 : vector<3xf16> ``` """ -function GL_Log(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Log(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5334,26 +4616,20 @@ pow-op ::= ssa-id `=` `spv.GL.Pow` ssa-use `:` %2 = spv.GL.Pow %0, %1 : f32 %3 = spv.GL.Pow %0, %1 : vector<3xf16> ``` -""" -function GL_Pow( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +""" +function GL_Pow(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Pow", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5382,25 +4658,19 @@ floor-op ::= ssa-id `=` `spv.GL.Round` ssa-use `:` %3 = spv.GL.Round %1 : vector<3xf16> ``` """ -function GL_Round( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Round(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Round", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5428,25 +4698,19 @@ abs-op ::= ssa-id `=` `spv.GL.SAbs` ssa-use `:` %3 = spv.GL.SAbs %1 : vector<3xi16> ``` """ -function GL_SAbs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.SAbs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_SAbs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.SAbs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5474,22 +4738,18 @@ uclamp-op ::= ssa-id `=` `spv.GL.UClamp` ssa-use, ssa-use, ssa-use `:` %3 = spv.GL.SClamp %x, %min, %max : vector<3xsi16> ``` """ -function GL_SClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GL.SClamp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_SClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GL.SClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5518,25 +4778,19 @@ smax-op ::= ssa-id `=` `spv.GL.SMax` ssa-use `:` %3 = spv.GL.SMax %0, %1 : vector<3xi16> ``` """ -function GL_SMax( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.SMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_SMax(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.SMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5565,25 +4819,19 @@ smin-op ::= ssa-id `=` `spv.GL.SMin` ssa-use `:` %3 = spv.GL.SMin %0, %1 : vector<3xi16> ``` """ -function GL_SMin( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.SMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_SMin(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.SMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5611,25 +4859,19 @@ sign-op ::= ssa-id `=` `spv.GL.SSign` ssa-use `:` %3 = spv.GL.SSign %1 : vector<3xi16> ``` """ -function GL_SSign( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.SSign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_SSign(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.SSign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5660,23 +4902,19 @@ sin-op ::= ssa-id `=` `spv.GL.Sin` ssa-use `:` %3 = spv.GL.Sin %1 : vector<3xf16> ``` """ -function GL_Sin(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Sin(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5707,25 +4945,19 @@ sinh-op ::= ssa-id `=` `spv.GL.Sinh` ssa-use `:` %3 = spv.GL.Sinh %1 : vector<3xf16> ``` """ -function GL_Sinh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Sinh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Sinh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Sinh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5754,25 +4986,19 @@ sqrt-op ::= ssa-id `=` `spv.GL.Sqrt` ssa-use `:` %3 = spv.GL.Sqrt %1 : vector<3xf16> ``` """ -function GL_Sqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Sqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5803,23 +5029,19 @@ tan-op ::= ssa-id `=` `spv.GL.Tan` ssa-use `:` %3 = spv.GL.Tan %1 : vector<3xf16> ``` """ -function GL_Tan(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Tan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Tan(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Tan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5850,25 +5072,19 @@ tanh-op ::= ssa-id `=` `spv.GL.Tanh` ssa-use `:` %3 = spv.GL.Tanh %1 : vector<3xf16> ``` """ -function GL_Tanh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.Tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Tanh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.Tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5896,22 +5112,18 @@ uclamp-op ::= ssa-id `=` `spv.GL.UClamp` ssa-use, ssa-use, ssa-use `:` %3 = spv.GL.UClamp %x, %min, %max : vector<3xui16> ``` """ -function GL_UClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.GL.UClamp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_UClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.GL.UClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5940,25 +5152,19 @@ smax-op ::= ssa-id `=` `spv.GL.UMax` ssa-use `:` %3 = spv.GL.UMax %0, %1 : vector<3xi16> ``` """ -function GL_UMax( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.UMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_UMax(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.UMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5987,25 +5193,19 @@ smin-op ::= ssa-id `=` `spv.GL.UMin` ssa-use `:` %3 = spv.GL.UMin %0, %1 : vector<3xi16> ``` """ -function GL_UMin( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GL.UMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_UMin(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GL.UMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6131,29 +5331,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(), -) - _results = IR.Type[] - _operands = Value[value, localid] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GroupBroadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupBroadcast(value, localid; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(localid), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GroupBroadcast", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6186,24 +5376,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - - return IR.create_operation( - "spv.GroupNonUniformBallot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformBallot(predicate; result::IR.Type, execution_scope, location=Location()) + results = IR.Type[result, ] + operands = Value[value(predicate), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + + IR.create_operation( + "spv.GroupNonUniformBallot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6243,34 +5427,24 @@ group-non-uniform-broadcast-op ::= ssa-id `=` %scalar_value = ... : f32 %vector_value = ... : vector<4xf32> %id = ... : i32 -%0 = spv.GroupNonUniformBroadcast \"Subgroup\" %scalar_value, %id : f32, i32 -%1 = spv.GroupNonUniformBroadcast \"Workgroup\" %vector_value, %id : - vector<4xf32>, i32 -``` -""" -function GroupNonUniformBroadcast( - value::Value, - id::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, id] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.GroupNonUniformBroadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +%0 = spv.GroupNonUniformBroadcast \"Subgroup\" %scalar_value, %id : f32, i32 +%1 = spv.GroupNonUniformBroadcast \"Workgroup\" %vector_value, %id : + vector<4xf32>, i32 +``` +""" +function GroupNonUniformBroadcast(value, id; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(id), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.GroupNonUniformBroadcast", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6359,33 +5533,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFAdd(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformFAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6434,33 +5594,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformFMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6509,33 +5655,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformFMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6581,33 +5713,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMul(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformFMul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6651,33 +5769,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformIAdd(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformIAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6721,33 +5825,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformIMul(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformIMul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6791,33 +5881,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformSMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformSMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6861,33 +5937,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformSMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformSMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6932,33 +5994,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformUMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformUMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7003,33 +6051,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,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformUMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spv.GroupNonUniformUMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7064,28 +6098,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.IAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IAdd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.IAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7115,22 +6140,18 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.IEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function IEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.IEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7165,28 +6186,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.IMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IMul(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.IMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7216,22 +6228,18 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.INotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function INotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.INotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7256,32 +6264,28 @@ component width. Member 1 of the result gets 0 if Operand 1 ≥ Operand 2, and gets 1 otherwise. - - - -#### Example: - -```mlir -%2 = spv.ISubBorrow %0, %1 : !spv.struct<(i32, i32)> -%2 = spv.ISubBorrow %0, %1 : !spv.struct<(vector<2xi32>, vector<2xi32>)> -``` -""" -function ISubBorrow(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.ISubBorrow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, + + + +#### Example: + +```mlir +%2 = spv.ISubBorrow %0, %1 : !spv.struct<(i32, i32)> +%2 = spv.ISubBorrow %0, %1 : !spv.struct<(vector<2xi32>, vector<2xi32>)> +``` +""" +function ISubBorrow(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ISubBorrow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7316,28 +6320,19 @@ isub-op ::= `spv.ISub` ssa-use, ssa-use ``` """ -function ISub( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.ISub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ISub(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.ISub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7377,32 +6372,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(imageoperands) && - push!(_attributes, namedattribute("imageoperands", imageoperands)) - - return IR.create_operation( - "spv.ImageDrefGather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ImageDrefGather(sampledimage, coordinate, dref, operand_arguments; result::IR.Type, imageoperands=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(sampledimage), value(coordinate), value(dref), value.(operand_arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(imageoperands) && push!(attributes, namedattribute("imageoperands", imageoperands)) + + IR.create_operation( + "spv.ImageDrefGather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7422,22 +6404,18 @@ same as Result Type. %0 = spv.Image %1 : !spv.sampled_image> ``` """ -function Image(sampledimage::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[sampledimage,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Image", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Image(sampledimage; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(sampledimage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Image", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7475,22 +6453,18 @@ See the client API specification for additional image type restrictions. %5 = spv.ImageQuerySize %2 : !spv.image -> vector<3xi32> ``` """ -function ImageQuerySize(image::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[image,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ImageQuerySize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ImageQuerySize(image; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(image), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ImageQuerySize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7516,28 +6490,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.InBoundsPtrAccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function InBoundsPtrAccessChain(base_ptr, element, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base_ptr), value(element), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.InBoundsPtrAccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7567,22 +6531,18 @@ isinf-op ::= ssa-id `=` `spv.IsInf` ssa-use %3 = spv.IsInf %1: vector<4xi32> ``` """ -function IsInf(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.IsInf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function IsInf(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.IsInf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7612,22 +6572,18 @@ isnan-op ::= ssa-id `=` `spv.IsNan` ssa-use %3 = spv.IsNan %1: vector<4xi32> ``` """ -function IsNan(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.IsNan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function IsNan(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.IsNan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7664,31 +6620,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Load(ptr; value::IR.Type, memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(ptr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spv.Load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7717,22 +6662,18 @@ logical-and ::= `spv.LogicalAnd` ssa-use `,` ssa-use %2 = spv.LogicalAnd %0, %1 : vector<4xi1> ``` """ -function LogicalAnd(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.LogicalAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function LogicalAnd(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.LogicalAnd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7761,24 +6702,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.LogicalEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function LogicalEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.LogicalEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7807,24 +6742,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.LogicalNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function LogicalNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.LogicalNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7850,22 +6779,18 @@ logical-not ::= `spv.LogicalNot` ssa-use `:` operand-type %2 = spv.LogicalNot %0 : vector<4xi1> ``` """ -function LogicalNot(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.LogicalNot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function LogicalNot(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.LogicalNot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7894,22 +6819,18 @@ logical-or ::= `spv.LogicalOr` ssa-use `,` ssa-use %2 = spv.LogicalOr %0, %1 : vector<4xi1> ``` """ -function LogicalOr(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.LogicalOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function LogicalOr(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.LogicalOr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7988,24 +6909,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.MatrixTimesMatrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function MatrixTimesMatrix(leftmatrix, rightmatrix; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(leftmatrix), value(rightmatrix), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.MatrixTimesMatrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8037,24 +6952,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.MatrixTimesScalar", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function MatrixTimesScalar(matrix, scalar; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(matrix), value(scalar), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.MatrixTimesScalar", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8242,23 +7151,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()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.Not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Not(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.Not", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8277,34 +7182,30 @@ y must have the same type as x. ``` -float-scalar-vector-type ::= float-type | - `vector<` integer-literal `x` float-type `>` -ordered-op ::= ssa-id `=` `spv.Ordered` ssa-use, ssa-use -```mlir - -#### Example: - -``` -%4 = spv.Ordered %0, %1 : f32 -%5 = spv.Ordered %2, %3 : vector<4xf32> -``` -""" -function Ordered(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.Ordered", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` +ordered-op ::= ssa-id `=` `spv.Ordered` ssa-use, ssa-use +```mlir + +#### Example: + +``` +%4 = spv.Ordered %0, %1 : f32 +%5 = spv.Ordered %2, %3 : vector<4xf32> +``` +""" +function Ordered(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Ordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8353,28 +7254,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.PtrAccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function PtrAccessChain(base_ptr, element, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base_ptr), value(element), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.PtrAccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8473,22 +7364,18 @@ return-value-op ::= `spv.ReturnValue` ssa-use `:` spirv-type spv.ReturnValue %0 : f32 ``` """ -function ReturnValue(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ReturnValue", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ReturnValue(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ReturnValue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8517,22 +7404,18 @@ s-convert-op ::= ssa-id `=` `spv.SConvertOp` ssa-use %3 = spv.SConvertOp %2 : vector<3xi32> to vector<3xi64> ``` """ -function SConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8564,28 +7447,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.SDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.SDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8615,24 +7489,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8662,24 +7530,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8709,24 +7571,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8756,22 +7612,18 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8804,28 +7656,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.SMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.SMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8849,25 +7692,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() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.SNegate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SNegate(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.SNegate", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8900,28 +7737,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.SRem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SRem(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.SRem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8964,29 +7792,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Select(condition, true_value, false_value; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(true_value), value(false_value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.Select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9066,28 +7884,19 @@ shift-left-logical-op ::= ssa-id `=` `spv.ShiftLeftLogical` %5 = spv.ShiftLeftLogical %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftLeftLogical( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.ShiftLeftLogical", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ShiftLeftLogical(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.ShiftLeftLogical", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9124,28 +7933,19 @@ shift-right-arithmetic-op ::= ssa-id `=` `spv.ShiftRightArithmetic` %5 = spv.ShiftRightArithmetic %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftRightArithmetic( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.ShiftRightArithmetic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ShiftRightArithmetic(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.ShiftRightArithmetic", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9183,28 +7983,19 @@ shift-right-logical-op ::= ssa-id `=` `spv.ShiftRightLogical` %5 = spv.ShiftRightLogical %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftRightLogical( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.ShiftRightLogical", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ShiftRightLogical(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.ShiftRightLogical", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9429,34 +8220,27 @@ store-op ::= `spv.Store ` storage-class ssa-use `, ` ssa-use `, ` #### Example: ```mlir -%0 = spv.Variable : !spv.ptr -%1 = spv.FMul ... : f32 -spv.Store \"Function\" %0, %1 : f32 -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() -) - _results = IR.Type[] - _operands = Value[ptr, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +%0 = spv.Variable : !spv.ptr +%1 = spv.FMul ... : f32 +spv.Store \"Function\" %0, %1 : f32 +spv.Store \"Function\" %0, %1 [\"Volatile\"] : f32 +spv.Store \"Function\" %0, %1 [\"Aligned\", 4] : f32 +``` +""" +function Store(ptr, value; memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(ptr), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spv.Store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9490,22 +8274,18 @@ subgroup-ballot-op ::= ssa-id `=` `spv.SubgroupBallotKHR` %0 = spv.SubgroupBallotKHR %predicate : vector<4xi32> ``` """ -function SubgroupBallotKHR(predicate::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[predicate,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SubgroupBallotKHR", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SubgroupBallotKHR(predicate; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(predicate), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SubgroupBallotKHR", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9540,22 +8320,18 @@ subgroup-block-read-INTEL-op ::= ssa-id `=` `spv.SubgroupBlockReadINTEL` %0 = spv.SubgroupBlockReadINTEL \"StorageBuffer\" %ptr : i32 ``` """ -function SubgroupBlockReadINTEL(ptr::Value; value::IR.Type, location=Location()) - _results = IR.Type[value,] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SubgroupBlockReadINTEL", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SubgroupBlockReadINTEL(ptr; value::IR.Type, location=Location()) + results = IR.Type[value, ] + operands = Value[value(ptr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SubgroupBlockReadINTEL", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9589,22 +8365,18 @@ subgroup-block-write-INTEL-op ::= ssa-id `=` `spv.SubgroupBlockWriteINTEL` spv.SubgroupBlockWriteINTEL \"StorageBuffer\" %ptr, %value : i32 ``` """ -function SubgroupBlockWriteINTEL(ptr::Value, value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[ptr, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.SubgroupBlockWriteINTEL", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SubgroupBlockWriteINTEL(ptr, value; location=Location()) + results = IR.Type[] + operands = Value[value(ptr), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.SubgroupBlockWriteINTEL", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9636,22 +8408,18 @@ matrix-type ``` """ -function Transpose(matrix::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[matrix,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.Transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Transpose(matrix; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(matrix), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9681,22 +8449,18 @@ u-convert-op ::= ssa-id `=` `spv.UConvertOp` ssa-use %3 = spv.UConvertOp %2 : vector<3xi32> to vector<3xi64> ``` """ -function UConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.UConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.UConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9727,28 +8491,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.UDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.UDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9778,24 +8533,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.UGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.UGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9825,24 +8574,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.UGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.UGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9872,24 +8615,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ULessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ULessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ULessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9919,22 +8656,18 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.ULessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ULessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.ULessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9965,28 +8698,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(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spv.UMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.UMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -10058,22 +8782,18 @@ unordered-op ::= ssa-id `=` `spv.Unordered` ssa-use, ssa-use %5 = spv.Unordered %2, %3 : vector<4xf32> ``` """ -function Unordered(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.Unordered", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Unordered(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.Unordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10141,28 +8861,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,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("storage_class", storage_class),] - !isnothing(initializer) && push!(_operands, initializer) - - return IR.create_operation( - "spv.Variable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Variable(initializer=nothing; 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), ] + !isnothing(initializer) && push!(operands, value(initializer)) + + IR.create_operation( + "spv.Variable", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10188,24 +8899,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.VectorExtractDynamic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function VectorExtractDynamic(vector, index; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.VectorExtractDynamic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10243,29 +8948,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function VectorInsertDynamic(vector, component, index; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(vector), value(component), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spv.VectorInsertDynamic", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -10306,24 +9001,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("components", components),] - - return IR.create_operation( - "spv.VectorShuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function VectorShuffle(vector1, vector2; result::IR.Type, components, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("components", components), ] + + IR.create_operation( + "spv.VectorShuffle", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10345,24 +9034,18 @@ Scalar must have the same type as the Component Type in Result Type. %0 = spv.VectorTimesScalar %vector, %scalar : vector<4xf32> ``` """ -function VectorTimesScalar( - vector::Value, scalar::Value; result::IR.Type, location=Location() -) - _results = IR.Type[result,] - _operands = Value[vector, scalar] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.VectorTimesScalar", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function VectorTimesScalar(vector, scalar; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value(scalar), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.VectorTimesScalar", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10385,22 +9068,18 @@ spv.mlir.yield ::= `spv.mlir.yield` ssa-id : spirv-type spv.mlir.yield %0 ``` """ -function mlir_yield(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spv.mlir.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mlir_yield(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spv.mlir.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Shape.jl b/src/Dialects/15/Shape.jl index 7eefaf1c..e8da193a 100644 --- a/src/Dialects/15/Shape.jl +++ b/src/Dialects/15/Shape.jl @@ -1,7 +1,6 @@ module shape -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -14,25 +13,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -52,22 +45,18 @@ inputs have differing ranks or differ in extents of shared dimensions. %s1 = shape.any [?,?], [1,2] // [1,2] ``` """ -function any(inputs::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.any", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function any(inputs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.any", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -91,25 +80,19 @@ ready to execute. %wt = shape.assuming_all %w0, %w2 // Passing ``` """ -function assuming_all( - inputs::Vector{Value}; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.assuming_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function assuming_all(inputs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.assuming_all", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -123,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assuming(witness; results_::Vector{IR.Type}, doRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(witness), ] + owned_regions = Region[doRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.assuming", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -152,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming_yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assuming_yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.assuming_yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -194,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(error) && push!(_attributes, namedattribute("error", error)) - - return IR.create_operation( - "shape.broadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function broadcast(shapes; result::IR.Type, error=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(error) && push!(attributes, namedattribute("error", error)) + + IR.create_operation( + "shape.broadcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -227,22 +194,18 @@ concat([2,3], [4,5]) -> [2,3,4,5] concat([], []) -> [] concat([], [4,5,6]) -> [4,5,6] """ -function concat(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.concat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function concat(lhs, rhs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.concat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -360,25 +323,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_broadcastable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_broadcastable(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -395,25 +352,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_eq(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -436,25 +387,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() -) - _results = IR.Type[] - _operands = Value[pred,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("msg", msg),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_require", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_require(pred; result=nothing::Union{Nothing, IR.Type}, msg, location=Location()) + results = IR.Type[] + operands = Value[value(pred), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("msg", msg), ] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -465,22 +410,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.debug_print", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function debug_print(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.debug_print", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -501,25 +442,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function div(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.div", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -530,25 +465,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function from_extent_tensor(input; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -565,25 +494,19 @@ the shape. %s1 = shape.from_extents ``` """ -function from_extents( - extents::Vector{Value}; shape=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[extents...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(shape) && push!(_results, shape) - - return IR.create_operation( - "shape.from_extents", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function from_extents(extents; shape=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(extents)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(shape) && push!(results, shape) + + IR.create_operation( + "shape.from_extents", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -663,25 +586,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function get_extent(shape, dim; extent=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), value(dim), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(extent) && push!(results, extent) + + 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) ) end @@ -694,25 +611,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function index_to_size(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -734,25 +645,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.is_broadcastable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function is_broadcastable(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -764,25 +669,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function max(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.max", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -813,30 +712,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function meet(arg0, arg1; result=nothing::Union{Nothing, IR.Type}, error=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(arg0), value(arg1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(error) && push!(attributes, namedattribute("error", error)) + + IR.create_operation( + "shape.meet", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -848,25 +737,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function min(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.min", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -880,25 +763,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -911,25 +788,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() -) - _results = IR.Type[] - _operands = Value[shape,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.num_elements", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function num_elements(shape; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -938,23 +809,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()) - _results = IR.Type[] - _operands = Value[shape,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(rank) && push!(_results, rank) - - return IR.create_operation( - "shape.rank", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rank(shape; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + IR.create_operation( + "shape.rank", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -991,28 +858,18 @@ func.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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce(shape, initVals; result::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result..., ] + operands = Value[value(shape), value.(initVals)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.reduce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1022,22 +879,18 @@ end The `shape.return` operation represents a return operation within a function. The operation takes variable number of operands and produces no results. """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1050,25 +903,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.shape_eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shape_eq(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1078,23 +925,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()) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.shape_of", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shape_of(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1106,25 +949,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function size_to_index(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1152,24 +989,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.split_at", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function split_at(operand, index; head::IR.Type, tail::IR.Type, location=Location()) + results = IR.Type[head, tail, ] + operands = Value[value(operand), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.split_at", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1182,22 +1013,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.to_extent_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function to_extent_tensor(input; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.to_extent_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1218,22 +1045,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.value_as_shape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function value_as_shape(arg; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.value_as_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1272,28 +1095,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function with_shape(operand, shape; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1301,22 +1115,18 @@ end `yield` """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/SparseTensor.jl b/src/Dialects/15/SparseTensor.jl index 18983dd7..c16c31f1 100644 --- a/src/Dialects/15/SparseTensor.jl +++ b/src/Dialects/15/SparseTensor.jl @@ -1,7 +1,6 @@ module sparse_tensor -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -104,36 +103,20 @@ because we never use its values, only its sparse structure: } -> tensor ``` """ -function binary( - x::Value, - y::Value; - output::IR.Type, - left_identity=nothing, - right_identity=nothing, - overlapRegion::Region, - leftRegion::Region, - rightRegion::Region, - location=Location(), -) - _results = IR.Type[output,] - _operands = Value[x, y] - _owned_regions = Region[overlapRegion, leftRegion, rightRegion] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(left_identity) && - push!(_attributes, namedattribute("left_identity", left_identity)) - !isnothing(right_identity) && - push!(_attributes, namedattribute("right_identity", right_identity)) - - return IR.create_operation( - "sparse_tensor.binary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function binary(x, y; output::IR.Type, left_identity=nothing, right_identity=nothing, overlapRegion::Region, leftRegion::Region, rightRegion::Region, location=Location()) + results = IR.Type[output, ] + operands = Value[value(x), value(y), ] + owned_regions = Region[overlapRegion, leftRegion, rightRegion, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(left_identity) && push!(attributes, namedattribute("left_identity", left_identity)) + !isnothing(right_identity) && push!(attributes, namedattribute("right_identity", right_identity)) + + IR.create_operation( + "sparse_tensor.binary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -159,30 +142,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(), -) - _results = IR.Type[] - _operands = Value[tensor, indices, values, filled, added, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.compress", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function compress(tensor, indices, values, filled, added, count; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(indices), value(values), value(filled), value(added), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.compress", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -219,22 +190,18 @@ Examples: %4 = sparse_tensor.convert %d : tensor to tensor<100xf64, #SV> ``` """ -function convert(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.convert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function convert(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.convert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -270,29 +237,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.expand", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand(tensor; values::IR.Type, filled::IR.Type, added::IR.Type, count::IR.Type, location=Location()) + results = IR.Type[values, filled, added, count, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.expand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -317,22 +273,18 @@ sparse_tensor.lex_insert %tensor, %indices, %val : tensor<1024x1024xf64, #CSR>, memref, memref ``` """ -function lex_insert(tensor::Value, indices::Value, value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[tensor, indices, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.lex_insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function lex_insert(tensor, indices, value; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(indices), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.lex_insert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -362,29 +314,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function load(tensor; result=nothing::Union{Nothing, IR.Type}, hasInserts=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(hasInserts) && push!(attributes, namedattribute("hasInserts", hasInserts)) + + 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) ) end @@ -406,22 +349,18 @@ typed sparse tensor with inital contents into a computation. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.new", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function new(source; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.new", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -441,22 +380,18 @@ a buffer defined by a pointer. sparse_tensor.out %t, %dest : tensor<1024x1024xf64, #CSR>, !Dest ``` """ -function out(tensor::Value, dest::Value; location=Location()) - _results = IR.Type[] - _operands = Value[tensor, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.out", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function out(tensor, dest; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.out", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -499,30 +434,19 @@ Example of Matrix->Vector reduction using max(product(x_i), 100): } -> tensor ``` """ -function reduce( - x::Value, - y::Value, - identity::Value; - output=nothing::Union{Nothing,IR.Type}, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x, y, identity] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "sparse_tensor.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function reduce(x, y, identity; output=nothing::Union{Nothing, IR.Type}, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(y), value(identity), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "sparse_tensor.reduce", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -544,22 +468,18 @@ indices array. : tensor<64x64xf64, #CSR> to memref ``` """ -function indices(tensor::Value, dim::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor, dim] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.indices", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function indices(tensor, dim; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), value(dim), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.indices", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -581,22 +501,18 @@ pointers array. : tensor<64x64xf64, #CSR> to memref ``` """ -function pointers(tensor::Value, dim::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor, dim] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.pointers", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pointers(tensor, dim; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), value(dim), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.pointers", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -617,22 +533,18 @@ values array. %1 = sparse_tensor.values %0 : tensor<64x64xf64, #CSR> to memref ``` """ -function values(tensor::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.values", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function values(tensor; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.values", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -700,28 +612,18 @@ the output, while missing values are filled with 1): } ``` """ -function unary( - x::Value; - output::IR.Type, - presentRegion::Region, - absentRegion::Region, - location=Location(), -) - _results = IR.Type[output,] - _operands = Value[x,] - _owned_regions = Region[presentRegion, absentRegion] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.unary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function unary(x; output::IR.Type, presentRegion::Region, absentRegion::Region, location=Location()) + results = IR.Type[output, ] + operands = Value[value(x), ] + owned_regions = Region[presentRegion, absentRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.unary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -741,22 +643,18 @@ Yields a value from within a `binary` or `unary` block. } ``` """ -function yield(result::Value; location=Location()) - _results = IR.Type[] - _operands = Value[result,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(result; location=Location()) + results = IR.Type[] + operands = Value[value(result), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Tensor.jl b/src/Dialects/15/Tensor.jl index 5a987c97..cd0c8a8d 100644 --- a/src/Dialects/15/Tensor.jl +++ b/src/Dialects/15/Tensor.jl @@ -1,7 +1,6 @@ module tensor -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -27,22 +26,18 @@ converting to a mismatching constant dimension. %5 = tensor.cast %4 : tensor to tensor<*xf32> ``` """ -function cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -71,22 +66,18 @@ Examples: : tensor into tensor ``` """ -function collapse_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function collapse_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "tensor.collapse_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -115,25 +106,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() -) - _results = IR.Type[] - _operands = Value[source, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "tensor.dim", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function dim(source, index; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "tensor.dim", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -162,22 +147,18 @@ Examples: : tensor into tensor ``` """ -function expand_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "tensor.expand_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -199,24 +180,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract(tensor, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.extract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -281,40 +256,19 @@ dims, to map the rank-reduced type to the source type by dropping ones: 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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract_slice(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "tensor.extract_slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -336,22 +290,18 @@ will result in a tensor [[%a, %b, %c] [%d, %e, %f]] """ -function from_elements(elements::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[elements...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.from_elements", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function from_elements(elements; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(elements)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.from_elements", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -377,24 +327,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.generate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generate(dynamicExtents; result::IR.Type, body::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(dynamicExtents)..., ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.generate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -419,24 +363,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function insert(scalar, dest, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(scalar), value(dest), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.insert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -495,41 +433,19 @@ Unlike ExtractSliceOp however, there is no need for a specific inference. 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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function insert_slice(source, dest, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(dest), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "tensor.insert_slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -605,36 +521,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,] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pad(source, low, high; result::IR.Type, static_low, static_high, nofold=nothing, region::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(low)..., value.(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), ])) + !isnothing(nofold) && push!(attributes, namedattribute("nofold", nofold)) + + IR.create_operation( + "tensor.pad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -699,40 +599,19 @@ Verification in the rank-reduced case: The same verification discussion and mechanisms apply as for ExtractSliceOp. Unlike ExtractSliceOp however, there is no need for a specific inference. """ -function parallel_insert_slice( - source::Value, - dest::Value, - offsets::Vector{Value}, - sizes::Vector{Value}, - strides::Vector{Value}; - static_offsets, - static_sizes, - static_strides, - location=Location(), -) - _results = IR.Type[] - _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.parallel_insert_slice", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel_insert_slice(source, dest, offsets, sizes, strides; static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "tensor.parallel_insert_slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -748,23 +627,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()) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rank(tensor; result_0=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result_0) && push!(results, result_0) + + IR.create_operation( + "tensor.rank", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -802,22 +677,18 @@ Result type is unranked. : (tensor<*xf32>, tensor) -> tensor<*xf32> ``` """ -function reshape(source::Value, shape::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source, shape] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(source, shape; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -846,22 +717,18 @@ TODO: This operation is easy to extend to broadcast to dynamically shaped %t = tensor.splat %s [%m, %n] : tensor ``` """ -function splat(input::Value; aggregate::IR.Type, location=Location()) - _results = IR.Type[aggregate,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.splat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function splat(input; aggregate::IR.Type, location=Location()) + results = IR.Type[aggregate, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.splat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -872,22 +739,18 @@ This operation is used to yield a single value from a within a region. It is used to create dynamically sized tensors (see `tensor.generate` and `tensor.pad` ops). """ -function yield(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Tosa.jl b/src/Dialects/15/Tosa.jl index 9da216f6..c5299075 100644 --- a/src/Dialects/15/Tosa.jl +++ b/src/Dialects/15/Tosa.jl @@ -1,7 +1,6 @@ module tosa -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -9,22 +8,18 @@ import ..Dialects: namedattribute, operandsegmentsizes Elementwise absolute value operation """ -function abs(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function abs(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.abs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -34,22 +29,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function add(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.add", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -63,29 +54,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("double_round", double_round),] - - return IR.create_operation( - "tosa.apply_scale", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_scale(value, multiplier, shift; output::IR.Type, double_round, location=Location()) + results = IR.Type[output, ] + operands = Value[value(value), value(multiplier), value(shift), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("double_round", double_round), ] + + IR.create_operation( + "tosa.apply_scale", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -95,22 +75,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.argmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function argmax(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.argmax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -120,24 +96,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("round", round),] - - return IR.create_operation( - "tosa.arithmetic_right_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function arithmetic_right_shift(input1, input2; output::IR.Type, round, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("round", round), ] + + IR.create_operation( + "tosa.arithmetic_right_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -148,36 +118,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avg_pool2d(input; output::IR.Type, kernel, stride, pad, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[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)) + + IR.create_operation( + "tosa.avg_pool2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -187,22 +140,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_and(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_and", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -211,22 +160,18 @@ end Elementwise bitwise NOT of input tensor. """ -function bitwise_not(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_not(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_not", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -236,22 +181,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_or(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_or", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -261,22 +202,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_xor(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_xor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -303,22 +240,18 @@ Performs a set of permissible cast operations signed 8 to float int8 float signed 16 to float int16 float """ -function cast(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -327,22 +260,18 @@ end Elementwise ceiling operation """ -function ceil(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ceil(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.ceil", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -355,29 +284,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clamp(input; output::IR.Type, min_int, max_int, min_fp, max_fp, location=Location()) + results = IR.Type[output, ] + operands = Value[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), ] + + IR.create_operation( + "tosa.clamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -386,22 +304,18 @@ end Elementwise count leading zeros operation """ -function clz(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.clz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clz(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.clz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -411,22 +325,18 @@ end 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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.concat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function concat(input1; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value.(input1)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.concat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -462,38 +372,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv2d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.conv2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -502,38 +393,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv3d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.conv3d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -545,24 +417,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("identifier", identifier),] - - return IR.create_operation( - "tosa.custom", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function custom(inputs; outputs::Vector{IR.Type}, identifier, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("identifier", identifier), ] + + IR.create_operation( + "tosa.custom", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -572,38 +438,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv2d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.depthwise_conv2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -613,22 +460,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function div(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.div", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -637,22 +480,18 @@ end Elementwise comparison operation """ -function equal(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.equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function equal(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.equal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -661,22 +500,18 @@ end Elementwise e to the x operation """ -function exp(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function exp(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.exp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -685,22 +520,18 @@ end Elementwise floor operation """ -function floor(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function floor(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.floor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -709,31 +540,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fully_connected(input, weight, bias; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(bias), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -743,22 +562,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gather(values, indices; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(values), value(indices), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.gather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -767,22 +582,18 @@ end Elementwise comparison operation """ -function greater_equal(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.greater_equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function greater_equal(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.greater_equal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -791,22 +602,18 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.greater", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function greater(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.greater", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -816,22 +623,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.identity", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function identity(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.identity", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -841,53 +644,38 @@ 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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.cond_if", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end +function cond_if(cond, inputs; output::Vector{IR.Type}, then_branch::Region, else_branch::Region, location=Location()) + results = IR.Type[output..., ] + operands = Value[value(cond), value.(inputs)..., ] + owned_regions = Region[then_branch, else_branch, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.cond_if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `log` Elementwise natural logarithm operation """ -function log(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function log(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.log", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -897,22 +685,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_and(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_and", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -922,24 +706,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_left_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_left_shift(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_left_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -948,22 +726,18 @@ end Elementwise logical NOT of input. """ -function logical_not(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_not(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_not", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -973,22 +747,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_or(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_or", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -998,24 +768,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_right_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_right_shift(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_right_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1025,22 +789,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_xor(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_xor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1051,26 +811,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul(a, b; c::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[c, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -1082,26 +835,18 @@ size given by is passed over the input tensor, with the 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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function max_pool2d(input; output::IR.Type, kernel, stride, pad, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1111,22 +856,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.maximum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maximum(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.maximum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1136,22 +877,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.minimum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function minimum(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.minimum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1161,22 +898,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("shift", shift),] - - return IR.create_operation( - "tosa.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mul(input1, input2; output::IR.Type, shift, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("shift", shift), ] + + IR.create_operation( + "tosa.mul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1185,26 +918,19 @@ end Elementwise negation operation """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function negate(input1; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -1213,32 +939,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pad(input1, padding, pad_const=nothing; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(padding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(pad_const) && push!(operands, value(pad_const)) + !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 ) end @@ -1248,22 +962,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pow(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.pow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1273,22 +983,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.reciprocal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reciprocal(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.reciprocal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1297,22 +1003,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_all(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_all", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1321,22 +1023,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_any", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_any(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_any", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1345,22 +1043,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_max(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1369,22 +1063,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_min(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1393,22 +1083,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_prod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_prod(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_prod", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1417,22 +1103,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_sum(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1441,24 +1123,18 @@ 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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reluN(input; output::IR.Type, max_int, max_fp, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1482,41 +1158,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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rescale(input; output::IR.Type, input_zp, output_zp, multiplier, shift, scale32, double_round, per_channel, location=Location()) + results = IR.Type[output, ] + operands = Value[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 @@ -1527,22 +1180,18 @@ Returns a tensor with the same type/values as the input, with a new shape 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("new_shape", new_shape),] - - return IR.create_operation( - "tosa.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(input1; output::IR.Type, new_shape, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("new_shape", new_shape), ] + + IR.create_operation( + "tosa.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1554,41 +1203,18 @@ expected use, stride_y is approximately (IH< ``` """ -function structured_split_reduction( - target::Value; - init_or_alloc_op::IR.Type, - fill_op::IR.Type, - split_linalg_op::IR.Type, - combining_linalg_op::IR.Type, - split_factor=nothing, - insert_split_dimension=nothing, - use_scaling_algorithm=nothing, - use_alloc=nothing, - location=Location(), -) - _results = IR.Type[init_or_alloc_op, fill_op, split_linalg_op, combining_linalg_op] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(split_factor) && - push!(_attributes, namedattribute("split_factor", split_factor)) - !isnothing(insert_split_dimension) && - push!(_attributes, namedattribute("insert_split_dimension", insert_split_dimension)) - !isnothing(use_scaling_algorithm) && - push!(_attributes, namedattribute("use_scaling_algorithm", use_scaling_algorithm)) - !isnothing(use_alloc) && push!(_attributes, namedattribute("use_alloc", use_alloc)) - - return IR.create_operation( - "transform.structured.split_reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_split_reduction(target; init_or_alloc_op::IR.Type, fill_op::IR.Type, split_linalg_op::IR.Type, combining_linalg_op::IR.Type, split_factor=nothing, insert_split_dimension=nothing, use_scaling_algorithm=nothing, use_alloc=nothing, location=Location()) + results = IR.Type[init_or_alloc_op, fill_op, split_linalg_op, combining_linalg_op, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(split_factor) && push!(attributes, namedattribute("split_factor", split_factor)) + !isnothing(insert_split_dimension) && push!(attributes, namedattribute("insert_split_dimension", insert_split_dimension)) + !isnothing(use_scaling_algorithm) && push!(attributes, namedattribute("use_scaling_algorithm", use_scaling_algorithm)) + !isnothing(use_alloc) && push!(attributes, namedattribute("use_alloc", use_alloc)) + + IR.create_operation( + "transform.structured.split_reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -791,34 +634,20 @@ that of the list associated with the `target` handle. If the internal implementation of tiling for any of the operations fails, produces a definite failure. """ -function structured_tile( - target::Value, - dynamic_sizes::Vector{Value}; - tiled_linalg_op::IR.Type, - loops::Vector{IR.Type}, - static_sizes=nothing, - interchange=nothing, - location=Location(), -) - _results = IR.Type[tiled_linalg_op, loops...] - _operands = Value[target, dynamic_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(static_sizes) && - push!(_attributes, namedattribute("static_sizes", static_sizes)) - !isnothing(interchange) && - push!(_attributes, namedattribute("interchange", interchange)) - - return IR.create_operation( - "transform.structured.tile", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile(target, dynamic_sizes; tiled_linalg_op::IR.Type, loops::Vector{IR.Type}, static_sizes=nothing, interchange=nothing, location=Location()) + results = IR.Type[tiled_linalg_op, loops..., ] + operands = Value[value(target), value.(dynamic_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_sizes) && push!(attributes, namedattribute("static_sizes", static_sizes)) + !isnothing(interchange) && push!(attributes, namedattribute("interchange", interchange)) + + IR.create_operation( + "transform.structured.tile", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -867,35 +696,21 @@ These two returned handles point to: %3:2 = transform.structured.tile_to_foreach_thread_op %0 tile_sizes [10, 20, 0] ``` """ -function structured_tile_to_foreach_thread_op( - target::Value; - foreach_thread_op::IR.Type, - tiled_op::IR.Type, - num_threads=nothing, - tile_sizes=nothing, - thread_dim_mapping=nothing, - location=Location(), -) - _results = IR.Type[foreach_thread_op, tiled_op] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(num_threads) && - push!(_attributes, namedattribute("num_threads", num_threads)) - !isnothing(tile_sizes) && push!(_attributes, namedattribute("tile_sizes", tile_sizes)) - !isnothing(thread_dim_mapping) && - push!(_attributes, namedattribute("thread_dim_mapping", thread_dim_mapping)) - - return IR.create_operation( - "transform.structured.tile_to_foreach_thread_op", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile_to_foreach_thread_op(target; foreach_thread_op::IR.Type, tiled_op::IR.Type, num_threads=nothing, tile_sizes=nothing, thread_dim_mapping=nothing, location=Location()) + results = IR.Type[foreach_thread_op, tiled_op, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(num_threads) && push!(attributes, namedattribute("num_threads", num_threads)) + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + !isnothing(thread_dim_mapping) && push!(attributes, namedattribute("thread_dim_mapping", thread_dim_mapping)) + + IR.create_operation( + "transform.structured.tile_to_foreach_thread_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -924,31 +739,23 @@ reason. The operation always returns the handle to the target op that is expected to be isolated from above. """ -function structured_vectorize( - target::Value; transformed::IR.Type, vectorize_padding=nothing, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(vectorize_padding) && - push!(_attributes, namedattribute("vectorize_padding", vectorize_padding)) - - return IR.create_operation( - "transform.structured.vectorize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_vectorize(target; transformed::IR.Type, vectorize_padding=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(vectorize_padding) && push!(attributes, namedattribute("vectorize_padding", vectorize_padding)) + + IR.create_operation( + "transform.structured.vectorize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -961,25 +768,19 @@ parent operations in the same order as the list associated with the operand, except for operations that are parents to more than one input which are only present once. """ -function loop_get_parent_for( - target::Value; parent::IR.Type, num_loops=nothing, location=Location() -) - _results = IR.Type[parent,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(num_loops) && push!(_attributes, namedattribute("num_loops", num_loops)) - - return IR.create_operation( - "transform.loop.get_parent_for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_get_parent_for(target; parent::IR.Type, num_loops=nothing, location=Location()) + results = IR.Type[parent, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(num_loops) && push!(attributes, namedattribute("num_loops", num_loops)) + + IR.create_operation( + "transform.loop.get_parent_for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -997,22 +798,18 @@ have a SymbolTable ancestor (typically true because of the top-level module). Returns the handle to the list of outlined functions in the same order as the operand handle. """ -function loop_outline(target::Value; transformed::IR.Type, func_name, location=Location()) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("func_name", func_name),] - - return IR.create_operation( - "transform.loop.outline", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_outline(target; transformed::IR.Type, func_name, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("func_name", func_name), ] + + IR.create_operation( + "transform.loop.outline", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1040,31 +837,19 @@ one. TODO: Return both the peeled loop and the remainder loop. """ -function loop_peel( - target::Value; - transformed::IR.Type, - fail_if_already_divisible=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(fail_if_already_divisible) && push!( - _attributes, - namedattribute("fail_if_already_divisible", fail_if_already_divisible), - ) - - return IR.create_operation( - "transform.loop.peel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_peel(target; transformed::IR.Type, fail_if_already_divisible=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(fail_if_already_divisible) && push!(attributes, namedattribute("fail_if_already_divisible", fail_if_already_divisible)) + + IR.create_operation( + "transform.loop.peel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1091,32 +876,20 @@ properly, the transform succeeds. Otherwise the transform silently fails. The return handle points to only the subset of successfully produced pipelined loops, which can be empty. """ -function loop_pipeline( - target::Value; - transformed::IR.Type, - iteration_interval=nothing, - read_latency=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(iteration_interval) && - push!(_attributes, namedattribute("iteration_interval", iteration_interval)) - !isnothing(read_latency) && - push!(_attributes, namedattribute("read_latency", read_latency)) - - return IR.create_operation( - "transform.loop.pipeline", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_pipeline(target; transformed::IR.Type, iteration_interval=nothing, read_latency=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(iteration_interval) && push!(attributes, namedattribute("iteration_interval", iteration_interval)) + !isnothing(read_latency) && push!(attributes, namedattribute("read_latency", read_latency)) + + IR.create_operation( + "transform.loop.pipeline", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1136,27 +909,22 @@ properly, the transform succeeds. Otherwise the transform silently fails. Does not return handles as the operation may result in the loop being removed after a full unrolling. """ -function loop_unroll(target::Value; factor, location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("factor", factor),] - - return IR.create_operation( - "transform.loop.unroll", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_unroll(target; factor, location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("factor", factor), ] + + IR.create_operation( + "transform.loop.unroll", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -1220,28 +988,19 @@ Remark: this op allows one to implement a simple \"try\" construct as follows: } ``` """ -function alternatives( - scope=nothing::Union{Nothing,Value}; - results::Vector{IR.Type}, - alternatives::Vector{Region}, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[] - _owned_regions = Region[alternatives...,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(scope) && push!(_operands, scope) - - return IR.create_operation( - "transform.alternatives", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alternatives(scope=nothing; results_::Vector{IR.Type}, alternatives::Vector{Region}, location=Location()) + results = IR.Type[results_..., ] + operands = Value[] + owned_regions = Region[alternatives..., ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(scope) && push!(operands, value(scope)) + + IR.create_operation( + "transform.alternatives", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1263,22 +1022,18 @@ the entire sequence fails immediately leaving the payload IR in potentially invalid state, i.e., this operation offers no transformation rollback capabilities. """ -function foreach(target::Value; body::Region, location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.foreach", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach(target; body::Region, location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.foreach", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1300,22 +1055,18 @@ resulting list will be just \"(A, B)\". Note that no other semantic ordering is applied, e.g., \"B\" may itself be a parent of \"A\". This may have an impact on the further transformation applied to the handle produced here. """ -function get_closest_isolated_parent(target::Value; parent::IR.Type, location=Location()) - _results = IR.Type[parent,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.get_closest_isolated_parent", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_closest_isolated_parent(target; parent::IR.Type, location=Location()) + results = IR.Type[parent, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.get_closest_isolated_parent", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1331,26 +1082,19 @@ and so on. If `deduplicate` is set, do not add the given Payload IR operation more than once to the final list regardless of it coming from the same or different handles. Consumes the operands and produces a new handle. """ -function merge_handles( - handles::Vector{Value}; result::IR.Type, deduplicate=nothing, location=Location() -) - _results = IR.Type[result,] - _operands = Value[handles...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(deduplicate) && - push!(_attributes, namedattribute("deduplicate", deduplicate)) - - return IR.create_operation( - "transform.merge_handles", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function merge_handles(handles; result::IR.Type, deduplicate=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(handles)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(deduplicate) && push!(attributes, namedattribute("deduplicate", deduplicate)) + + IR.create_operation( + "transform.merge_handles", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1372,22 +1116,18 @@ The transformation is considered successful regardless of whether some Payload IR ops actually matched the pattern and only fails if the pattern could not be looked up or compiled. """ -function pdl_match(root::Value; matched::IR.Type, pattern_name, location=Location()) - _results = IR.Type[matched,] - _operands = Value[root,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pattern_name", pattern_name),] - - return IR.create_operation( - "transform.pdl_match", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pdl_match(root; matched::IR.Type, pattern_name, location=Location()) + results = IR.Type[matched, ] + operands = Value[value(root), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("pattern_name", pattern_name), ] + + IR.create_operation( + "transform.pdl_match", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1416,24 +1156,18 @@ MergeHandlesOp may be used to deduplicate the associated list of payload IR ops when necessary. Furthermore, a combination of ReplicateOp and MergeHandlesOp can be used to construct arbitrary lists with repetitions. """ -function replicate( - pattern::Value, handles::Vector{Value}; replicated::Vector{IR.Type}, location=Location() -) - _results = IR.Type[replicated...,] - _operands = Value[pattern, handles...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.replicate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function replicate(pattern, handles; replicated::Vector{IR.Type}, location=Location()) + results = IR.Type[replicated..., ] + operands = Value[value(pattern), value.(handles)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.replicate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1453,28 +1187,19 @@ IR, typically the root operation of the pass interpreting the transform dialect. Operand omission is only allowed for sequences not contained in another sequence. """ -function sequence( - root=nothing::Union{Nothing,Value}; - results::Vector{IR.Type}, - body::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(root) && push!(_operands, root) - - return IR.create_operation( - "transform.sequence", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sequence(root=nothing; results_::Vector{IR.Type}, body::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(root) && push!(operands, value(root)) + + IR.create_operation( + "transform.sequence", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1514,25 +1239,19 @@ available. This op is a possible top-level Transform IR op, the argument of its entry block corresponds to either the root op of the payload IR or the ops associated with its operand when provided. """ -function with_pdl_patterns( - root=nothing::Union{Nothing,Value}; body::Region, location=Location() -) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(root) && push!(_operands, root) - - return IR.create_operation( - "transform.with_pdl_patterns", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function with_pdl_patterns(root=nothing; body::Region, location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(root) && push!(operands, value(root)) + + IR.create_operation( + "transform.with_pdl_patterns", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1543,22 +1262,18 @@ This terminator operation yields operation handles from regions of the transform IR ops back to the containing op. It is not itself associated with any transformation on the payload IR and is used for flow purposes only. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/Vector.jl b/src/Dialects/15/Vector.jl index 5c4ff923..7a7b9531 100644 --- a/src/Dialects/15/Vector.jl +++ b/src/Dialects/15/Vector.jl @@ -1,7 +1,6 @@ module vector -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -62,22 +61,18 @@ equal. %7 = vector.bitcast %6 : vector to vector ``` """ -function bitcast(source::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(source; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -112,22 +107,18 @@ shaped vector with the same element type is always legal. %2 = vector.broadcast %1 : vector<16xf32> to vector<4x16xf32> ``` """ -function broadcast(source::Value; vector::IR.Type, location=Location()) - _results = IR.Type[vector,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.broadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function broadcast(source; vector::IR.Type, location=Location()) + results = IR.Type[vector, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.broadcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -162,28 +153,18 @@ vector.compressstore %base[%i, %j], %mask, %value : memref, vector<16xi1>, vector<16xf32> ``` """ -function compressstore( - base::Value, - indices::Vector{Value}, - mask::Value, - valueToStore::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[base, indices..., mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.compressstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function compressstore(base, indices, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.compressstore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -354,36 +335,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...] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function contract(lhs, rhs, acc, masks; result_0::IR.Type, indexing_maps, iterator_types, kind=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(lhs), value(rhs), value(acc), value.(masks)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) + + IR.create_operation( + "vector.contract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -417,22 +381,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.create_mask", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_mask(operands_; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.create_mask", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -467,29 +427,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.expandload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expandload(base, indices, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.expandload", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -515,28 +464,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(position) && push!(_operands, position) - - return IR.create_operation( - "vector.extractelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extractelement(vector, position=nothing; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(position) && push!(operands, value(position)) + + IR.create_operation( + "vector.extractelement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -584,24 +524,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.extract_map", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract_map(vector, ids; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(vector), value.(ids)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.extract_map", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -618,25 +552,19 @@ the proper position. Degenerates to an element type in the 0-D case. %2 = vector.extract %0[3, 3, 3]: vector<4x8x16xf32> ``` """ -function extract( - vector::Value; result_0=nothing::Union{Nothing,IR.Type}, position, location=Location() -) - _results = IR.Type[] - _operands = Value[vector,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("position", position),] - !isnothing(result_0) && push!(_results, result_0) - - return IR.create_operation( - "vector.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extract(vector; result_0=nothing::Union{Nothing, IR.Type}, position, location=Location()) + results = IR.Type[] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + !isnothing(result_0) && push!(results, result_0) + + IR.create_operation( + "vector.extract", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -666,28 +594,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract_strided_slice(vector; result_0::IR.Type, offsets, sizes, strides, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -708,29 +626,19 @@ to the `llvm.fma.*` intrinsic. %3 = vector.fma %0, %1, %2: vector<8x16xf32> ``` """ -function fma( - lhs::Value, - rhs::Value, - acc::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs, acc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "vector.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fma(lhs, rhs, acc; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "vector.fma", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -759,24 +667,18 @@ http://llvm.org/docs/LangRef.html#llvm-matrix-transpose-intrinsic : (vector<16xf32>) -> vector<16xf32> ``` """ -function flat_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( - "vector.flat_transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function flat_transpose(matrix; res::IR.Type, rows, columns, location=Location()) + results = IR.Type[res, ] + operands = Value[value(matrix), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -811,30 +713,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gather(base, indices, index_vec, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(index_vec), value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.gather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -859,30 +749,20 @@ 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=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(position) && push!(_operands, position) - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "vector.insertelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insertelement(source, dest, position=nothing; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(position) && push!(operands, value(position)) + !isnothing(result) && push!(results, result) + + IR.create_operation( + "vector.insertelement", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -932,29 +812,19 @@ For instance: into vector<64x4x32xf32> ``` """ -function insert_map( - vector::Value, - dest::Value, - ids::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[vector, dest, ids...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "vector.insert_map", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert_map(vector, dest, ids; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(vector), value(dest), value.(ids)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "vector.insert_map", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -972,29 +842,19 @@ position. Degenerates to a scalar source type when n = 0. %5 = vector.insert %3, %4[3, 3, 3] : f32 into vector<4x8x16xf32> ``` """ -function insert( - source::Value, - dest::Value; - res=nothing::Union{Nothing,IR.Type}, - position, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("position", position),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "vector.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert(source, dest; res=nothing::Union{Nothing, IR.Type}, position, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "vector.insert", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1020,32 +880,19 @@ the proper location as specified by the offsets. vector<2x4xf32> into vector<16x4x8xf32> ``` """ -function insert_strided_slice( - source::Value, - dest::Value; - res=nothing::Union{Nothing,IR.Type}, - offsets, - strides, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("offsets", offsets), namedattribute("strides", strides) - ] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "vector.insert_strided_slice", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert_strided_slice(source, dest; res=nothing::Union{Nothing, IR.Type}, offsets, strides, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("offsets", offsets), namedattribute("strides", strides), ] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "vector.insert_strided_slice", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1105,22 +952,18 @@ Example 6: Explicit out-of-bound vector load. %result = vector.load %memref[%c0] : memref<7xf32>, vector<8xf32> ``` """ -function load(base::Value, indices::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(base, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1152,29 +995,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.maskedload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maskedload(base, indices, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.maskedload", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1206,28 +1038,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(), -) - _results = IR.Type[] - _operands = Value[base, indices..., mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.maskedstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maskedstore(base, indices, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.maskedstore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1258,34 +1080,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matrix_multiply(lhs, rhs; res::IR.Type, lhs_rows, lhs_columns, rhs_columns, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(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( + "vector.matrix_multiply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1306,32 +1112,19 @@ Takes an initial accumulator operand. vector<4x16xf32> into f32 ``` """ -function multi_reduction( - source::Value, - acc::Value; - dest=nothing::Union{Nothing,IR.Type}, - kind, - reduction_dims, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, acc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("kind", kind), namedattribute("reduction_dims", reduction_dims) - ] - !isnothing(dest) && push!(_results, dest) - - return IR.create_operation( - "vector.multi_reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function multi_reduction(source, acc; dest=nothing::Union{Nothing, IR.Type}, kind, reduction_dims, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dims", reduction_dims), ] + !isnothing(dest) && push!(results, dest) + + IR.create_operation( + "vector.multi_reduction", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1385,30 +1178,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(kind) && push!(_attributes, namedattribute("kind", kind)) - - return IR.create_operation( - "vector.outerproduct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function outerproduct(lhs, rhs, acc; result_0::IR.Type, kind=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(lhs), value(rhs), value.(acc)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) + + IR.create_operation( + "vector.outerproduct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1436,22 +1218,18 @@ value for all data types, opening/closing bracket, comma, newline). ``` """ -function print(source::Value; location=Location()) - _results = IR.Type[] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.print", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function print(source; location=Location()) + results = IR.Type[] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.print", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1477,29 +1255,19 @@ http://llvm.org/docs/LangRef.html#vector-reduction-intrinsics %4 = vector.reduction , %0, %1 : vector<16xf32> into f32 ``` """ -function reduction( - vector::Value, - acc=nothing::Union{Nothing,Value}; - dest::IR.Type, - kind, - location=Location(), -) - _results = IR.Type[dest,] - _operands = Value[vector,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - !isnothing(acc) && push!(_operands, acc) - - return IR.create_operation( - "vector.reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduction(vector, acc=nothing; dest::IR.Type, kind, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), ] + !isnothing(acc) && push!(operands, value(acc)) + + IR.create_operation( + "vector.reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1587,30 +1355,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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(vector, input_shape, output_shape; result::IR.Type, fixed_vector_sizes, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value.(input_shape)..., value.(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), ])) + + IR.create_operation( + "vector.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1631,37 +1388,20 @@ reduction in the scan. vector<4x8x16x32xf32>, vector<4x16x32xf32> ``` """ -function scan( - source::Value, - initial_value::Value; - dest=nothing::Union{Nothing,IR.Type}, - accumulated_value=nothing::Union{Nothing,IR.Type}, - kind, - reduction_dim, - inclusive, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, initial_value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("kind", kind), - namedattribute("reduction_dim", reduction_dim), - namedattribute("inclusive", inclusive), - ] - !isnothing(dest) && push!(_results, dest) - !isnothing(accumulated_value) && push!(_results, accumulated_value) - - return IR.create_operation( - "vector.scan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function scan(source, initial_value; dest=nothing::Union{Nothing, IR.Type}, accumulated_value=nothing::Union{Nothing, IR.Type}, kind, reduction_dim, inclusive, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(initial_value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dim", reduction_dim), namedattribute("inclusive", inclusive), ] + !isnothing(dest) && push!(results, dest) + !isnothing(accumulated_value) && push!(results, accumulated_value) + + IR.create_operation( + "vector.scan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1698,29 +1438,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(), -) - _results = IR.Type[] - _operands = Value[base, indices..., index_vec, mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.scatter", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scatter(base, indices, index_vec, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(index_vec), value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.scatter", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1759,22 +1488,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.shape_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shape_cast(source; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.shape_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1809,25 +1534,19 @@ according to the given mask. The legality rules are: : vector<2xf32>, vector<2xf32> ; yields vector<4xf32> ``` """ -function shuffle( - v1::Value, v2::Value; vector=nothing::Union{Nothing,IR.Type}, mask, location=Location() -) - _results = IR.Type[] - _operands = Value[v1, v2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mask", mask),] - !isnothing(vector) && push!(_results, vector) - - return IR.create_operation( - "vector.shuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shuffle(v1, v2; vector=nothing::Union{Nothing, IR.Type}, mask, location=Location()) + results = IR.Type[] + operands = Value[value(v1), value(v2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mask", mask), ] + !isnothing(vector) && push!(results, vector) + + IR.create_operation( + "vector.shuffle", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1844,22 +1563,18 @@ required to be of integer/index/float type. %t = vector.splat %s : vector<8x16xi32> ``` """ -function splat(input::Value; aggregate::IR.Type, location=Location()) - _results = IR.Type[aggregate,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.splat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function splat(input; aggregate::IR.Type, location=Location()) + results = IR.Type[aggregate, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.splat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1917,24 +1632,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() -) - _results = IR.Type[] - _operands = Value[valueToStore, base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(valueToStore, base, indices; location=Location()) + results = IR.Type[] + operands = Value[value(valueToStore), value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2096,36 +1805,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("permutation_map", permutation_map),] - !isnothing(mask) && push!(_operands, mask) - push!( - _attributes, operandsegmentsizes([1, length(indices), 1, isnothing(mask) ? 0 : 1]) - ) - !isnothing(in_bounds) && push!(_attributes, namedattribute("in_bounds", in_bounds)) - - return IR.create_operation( - "vector.transfer_read", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transfer_read(source, indices, padding, mask=nothing; vector::IR.Type, permutation_map, in_bounds=nothing, location=Location()) + results = IR.Type[vector, ] + operands = Value[value(source), value.(indices)..., value(padding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] + !isnothing(mask) && push!(operands, value(mask)) + push!(attributes, operandsegmentsizes([1, length(indices), 1, (mask==nothing) ? 0 : 1])) + !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) + + IR.create_operation( + "vector.transfer_read", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2209,37 +1903,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(), -) - _results = IR.Type[] - _operands = Value[vector, source, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("permutation_map", permutation_map),] - !isnothing(mask) && push!(_operands, mask) - push!( - _attributes, operandsegmentsizes([1, 1, length(indices), isnothing(mask) ? 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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transfer_write(vector, source, indices, mask=nothing; result=nothing::Union{Nothing, IR.Type}, permutation_map, in_bounds=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(vector), value(source), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] + !isnothing(mask) && push!(operands, value(mask)) + 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)) + + IR.create_operation( + "vector.transfer_write", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2268,22 +1947,18 @@ the transp array [i_1, .., i_n] must be a permutation of [0, .., n-1]. [c, f] ] ``` """ -function transpose(vector::Value; result::IR.Type, transp, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(vector; result::IR.Type, transp, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("transp", transp), ] + + IR.create_operation( + "vector.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2309,22 +1984,18 @@ operation ::= `vector.type_cast` ssa-use : memref-type to memref-type %VA = vector.type_cast %A : memref<5x4x3xf32> to memref> ``` """ -function type_cast(memref::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.type_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function type_cast(memref; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.type_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2430,29 +2101,18 @@ some_synchronization_primitive // Execute in parallel on all threads/lanes. ``` """ -function warp_execute_on_lane_0( - laneid::Value, - args::Vector{Value}; - results::Vector{IR.Type}, - warp_size, - warpRegion::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[laneid, args...] - _owned_regions = Region[warpRegion,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("warp_size", warp_size),] - - return IR.create_operation( - "vector.warp_execute_on_lane_0", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function warp_execute_on_lane_0(laneid, args; results_::Vector{IR.Type}, warp_size, warpRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(laneid), value.(args)..., ] + owned_regions = Region[warpRegion, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("warp_size", warp_size), ] + + IR.create_operation( + "vector.warp_execute_on_lane_0", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2467,22 +2127,18 @@ parent operation\'s results. If the parent operation defines no value the vector.yield may be omitted when printing the region. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/15/X86Vector.jl b/src/Dialects/15/X86Vector.jl index 61bc575b..2c2d5665 100644 --- a/src/Dialects/15/X86Vector.jl +++ b/src/Dialects/15/X86Vector.jl @@ -1,32 +1,25 @@ module x86vector -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_dp_ps_256(a, b, c; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -48,25 +41,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_dot(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -74,25 +61,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_compress(a, src, k; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(src), value(k), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -111,33 +92,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_compress(k, a, src=nothing; dst=nothing::Union{Nothing, IR.Type}, constant_src=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(k), value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(src) && push!(operands, value(src)) + !isnothing(dst) && push!(results, dst) + !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) ) end @@ -155,31 +124,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_rndscale(src, k, a, imm, rounding; dst=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dst) && push!(results, dst) + + 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) ) end @@ -187,31 +144,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_rndscale_pd_512(src, k, a, imm, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -219,31 +164,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_rndscale_ps_512(src, k, a, imm, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -261,31 +194,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_scalef(src, a, b, k, rounding; dst=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dst) && push!(results, dst) + + 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) ) end @@ -293,31 +214,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_scalef_pd_512(src, a, b, k, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -325,31 +234,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_scalef_ps_512(src, a, b, k, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -357,25 +254,19 @@ end `avx_intr_rsqrt_ps_256` """ -function avx_intr_rsqrt_ps_256( - a::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_rsqrt_ps_256(a; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -383,23 +274,19 @@ end `avx_rsqrt` """ -function avx_rsqrt(a::Value; b=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[a,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(b) && push!(_results, b) - - return IR.create_operation( - "x86vector.avx.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_rsqrt(a; b=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(b) && push!(results, b) + + 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) ) end @@ -407,24 +294,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.intr.vp2intersect.d.512", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avx512_intr_vp2intersect_d_512(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.intr.vp2intersect.d.512", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -444,24 +325,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.vp2intersect", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avx512_vp2intersect(a, b; k1::IR.Type, k2::IR.Type, location=Location()) + results = IR.Type[k1, k2, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.vp2intersect", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -469,24 +344,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.intr.vp2intersect.q.512", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avx512_intr_vp2intersect_q_512(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.intr.vp2intersect.q.512", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/AMDGPU.jl b/src/Dialects/16/AMDGPU.jl index fce02f51..4bc71f42 100644 --- a/src/Dialects/16/AMDGPU.jl +++ b/src/Dialects/16/AMDGPU.jl @@ -1,7 +1,6 @@ module amdgpu -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -67,52 +66,25 @@ order (that is, v[0] will go to arg[7:0], v[1] to arg[15:8] and so on). The negateA, negateB, and negateC flags are only supported for double-precision operations on gfx940+. """ -function mfma( - sourceA::Value, - sourceB::Value, - destC::Value; - destD::IR.Type, - m, - n, - k, - blocks, - cbsz=nothing, - abid=nothing, - blgp=nothing, - reducePrecision=nothing, - negateA=nothing, - negateB=nothing, - negateC=nothing, - location=Location(), -) - _results = IR.Type[destD,] - _operands = Value[sourceA, sourceB, destC] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("m", m), - namedattribute("n", n), - namedattribute("k", k), - namedattribute("blocks", blocks), - ] - !isnothing(cbsz) && push!(_attributes, namedattribute("cbsz", cbsz)) - !isnothing(abid) && push!(_attributes, namedattribute("abid", abid)) - !isnothing(blgp) && push!(_attributes, namedattribute("blgp", blgp)) - !isnothing(reducePrecision) && - push!(_attributes, namedattribute("reducePrecision", reducePrecision)) - !isnothing(negateA) && push!(_attributes, namedattribute("negateA", negateA)) - !isnothing(negateB) && push!(_attributes, namedattribute("negateB", negateB)) - !isnothing(negateC) && push!(_attributes, namedattribute("negateC", negateC)) - - return IR.create_operation( - "amdgpu.mfma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mfma(sourceA, sourceB, destC; destD::IR.Type, m, n, k, blocks, cbsz=nothing, abid=nothing, blgp=nothing, reducePrecision=nothing, negateA=nothing, negateB=nothing, negateC=nothing, location=Location()) + results = IR.Type[destD, ] + operands = Value[value(sourceA), value(sourceB), value(destC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("m", m), namedattribute("n", n), namedattribute("k", k), namedattribute("blocks", blocks), ] + !isnothing(cbsz) && push!(attributes, namedattribute("cbsz", cbsz)) + !isnothing(abid) && push!(attributes, namedattribute("abid", abid)) + !isnothing(blgp) && push!(attributes, namedattribute("blgp", blgp)) + !isnothing(reducePrecision) && push!(attributes, namedattribute("reducePrecision", reducePrecision)) + !isnothing(negateA) && push!(attributes, namedattribute("negateA", negateA)) + !isnothing(negateB) && push!(attributes, namedattribute("negateB", negateB)) + !isnothing(negateC) && push!(attributes, namedattribute("negateC", negateC)) + + IR.create_operation( + "amdgpu.mfma", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -136,39 +108,22 @@ Out of bounds atomic operations are ignored in hardware. See `amdgpu.raw_buffer_load` for a description of how the underlying instruction is constructed. """ -function raw_buffer_atomic_fadd( - value::Value, - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, 1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_atomic_fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_atomic_fadd(value, memref, indices, sgprOffset=nothing; boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_atomic_fadd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -204,39 +159,22 @@ are translated to intrinsic arguments as follows: to 2 to disable bounds checks, otherwise it is 3 - The cache coherency bits are off """ -function raw_buffer_load( - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - value::IR.Type, - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[value,] - _operands = Value[memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_load(memref, indices, sgprOffset=nothing; value::IR.Type, boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -260,39 +198,22 @@ components is partically completed is chipset-dependent. See `amdgpu.raw_buffer_load` for a description of how the underlying instruction is constructed. """ -function raw_buffer_store( - value::Value, - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, 1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_store(value, memref, indices, sgprOffset=nothing; boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/AMX.jl b/src/Dialects/16/AMX.jl index 4df6ab3e..67b68f6a 100644 --- a/src/Dialects/16/AMX.jl +++ b/src/Dialects/16/AMX.jl @@ -1,38 +1,24 @@ module amx -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbf16ps", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbf16ps(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbf16ps", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -40,31 +26,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbssd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbssd(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbssd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -72,31 +45,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbsud", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbsud(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbsud", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -104,31 +64,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbusd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbusd(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbusd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -136,31 +83,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbuud", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbuud(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbuud", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -168,29 +102,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tileloadd64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tileloadd64(operand_0, operand_1, operand_2, operand_3; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tileloadd64", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -198,29 +121,18 @@ end `tilestored64` """ -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tilestored64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tilestored64(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tilestored64", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -228,22 +140,18 @@ end `tilezero` """ -function tilezero(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( - "amx.tilezero", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tilezero(operand_0, operand_1; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tilezero", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -261,22 +169,18 @@ corresponding tile configuration. %0 = amx.tile_load %arg0[%c0, %c0] : memref into vector<16x64xi8> ``` """ -function tile_load(base::Value, indices::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_load(base, indices; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -295,22 +199,18 @@ pairs of \"bf16\"). The operation is eventually lowered into the : vector<16x32xbf16>, vector<16x32xbf16>, vector<16x16xf32> ``` """ -function tile_mulf(lhs::Value, rhs::Value, acc::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_mulf(lhs, rhs, acc; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_mulf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -332,32 +232,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_muli(lhs, rhs, acc; res::IR.Type, isZextLhs=nothing, isZextRhs=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(isZextLhs) && push!(attributes, namedattribute("isZextLhs", isZextLhs)) + !isnothing(isZextRhs) && push!(attributes, namedattribute("isZextRhs", isZextRhs)) + + IR.create_operation( + "amx.tile_muli", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -375,22 +263,18 @@ corresponding tile configuration. amx.tile_store %arg1[%c0, %c0], %0 : memref, vector<16x64xi8> ``` """ -function tile_store(base::Value, indices::Vector{Value}, val::Value; location=Location()) - _results = IR.Type[] - _operands = Value[base, indices..., val] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_store(base, indices, val; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(val), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Affine.jl b/src/Dialects/16/Affine.jl index bc9c2707..fb820a89 100644 --- a/src/Dialects/16/Affine.jl +++ b/src/Dialects/16/Affine.jl @@ -1,7 +1,6 @@ module affine -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -26,22 +25,18 @@ have ‘index’ type. %2 = affine.apply affine_map<(i)[s0] -> (i+s0)> (%42)[%n] ``` """ -function apply(mapOperands::Vector{Value}; result_0::IR.Type, map, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply(mapOperands; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(mapOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.apply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -68,27 +63,18 @@ In the above example, `%indices:3` conceptually holds the following: %indices_2 = affine.apply #map2()[%linear_index] ``` """ -function delinearize_index( - linear_index::Value, - basis::Vector{Value}; - multi_index::Vector{IR.Type}, - location=Location(), -) - _results = IR.Type[multi_index...,] - _operands = Value[linear_index, basis...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.delinearize_index", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function delinearize_index(linear_index, basis; multi_index::Vector{IR.Type}, location=Location()) + results = IR.Type[multi_index..., ] + operands = Value[value(linear_index), value.(basis)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.delinearize_index", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -199,24 +185,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function for_(operand_0; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -290,28 +270,18 @@ func.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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.if", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function if_(operand_0; results_::Vector{IR.Type}, thenRegion::Region, elseRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[thenRegion, elseRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -337,22 +307,18 @@ Example 2: Uses \'symbol\' keyword for symbols \'%n\' and \'%m\'. %1 = affine.load %0[%i0 + symbol(%n), %i1 + symbol(%m)] : memref<100x100xf32> ``` """ -function 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.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(memref, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -368,22 +334,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map", map),] - - return IR.create_operation( - "affine.max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function max(operands_; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -409,22 +371,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map", map),] - - return IR.create_operation( - "affine.min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function min(operands_; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -493,40 +451,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(mapOperands; results_::Vector{IR.Type}, reductions, lowerBoundsMap, lowerBoundsGroups, upperBoundsMap, upperBoundsGroups, steps, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[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), ] + + IR.create_operation( + "affine.parallel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -548,33 +484,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function prefetch(memref, indices; isWrite, localityHint, isDataCache, location=Location()) + results = IR.Type[] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -600,22 +521,18 @@ Example 2: Uses \'symbol\' keyword for symbols \'%n\' and \'%m\'. 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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, memref, indices; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -658,24 +575,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.vector_load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vector_load(memref, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.vector_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -720,24 +631,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() -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.vector_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vector_store(value, memref, indices; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.vector_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -755,22 +660,18 @@ Otherwise, it has to be present in the syntax to indicate which values are yielded. ``` """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Arith.jl b/src/Dialects/16/Arith.jl index 6e683d07..de698463 100644 --- a/src/Dialects/16/Arith.jl +++ b/src/Dialects/16/Arith.jl @@ -1,7 +1,6 @@ module arith -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -28,30 +27,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.addf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function addf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.addf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -76,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.addi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function addi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.addi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -119,24 +102,18 @@ indicates no overflow. %x:2 = arith.addui_extended %y, %z : tensor<4x?xi8>, tensor<4x?xi1> ``` """ -function addui_extended( - lhs::Value, rhs::Value; sum::IR.Type, overflow::IR.Type, location=Location() -) - _results = IR.Type[sum, overflow] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.addui_extended", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function addui_extended(lhs, rhs; sum::IR.Type, overflow::IR.Type, location=Location()) + results = IR.Type[sum, overflow, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.addui_extended", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -161,25 +138,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.andi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function andi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.andi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -201,22 +172,18 @@ endianness for the source and target types (e.g. float is big-endian and 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -235,25 +202,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ceildivsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ceildivsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -274,25 +235,19 @@ behavior. %a = arith.ceildivui %b, %c : i64 ``` """ -function ceildivui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ceildivui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ceildivui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -323,29 +278,18 @@ attribute by the parser. %r3 = \"arith.cmpf\"(%0, %1) {predicate: 0} : (f8, f8) -> i1 ``` """ -function cmpf( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - predicate, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("predicate", predicate),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.cmpf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cmpf(lhs, rhs; result::IR.Type, predicate, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "arith.cmpf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -414,29 +358,18 @@ complement or large positives : (vector<4xi64>, vector<4xi64>) -> vector<4xi1> ``` """ -function cmpi( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - predicate, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("predicate", predicate),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.cmpi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cmpi(lhs, rhs; result::IR.Type, predicate, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "arith.cmpi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -481,30 +414,20 @@ end `divf` """ -function divf( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.divf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.divf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -530,25 +453,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.divsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.divsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -575,25 +492,19 @@ behavior. %x = arith.divui %y, %z : tensor<4x?xi8> ``` """ -function divui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.divui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.divui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -604,22 +515,18 @@ Cast a floating-point value to a larger floating-point-typed value. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extf(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -643,22 +550,18 @@ of the most-significant bit of the input. %5 = arith.extsi %0 : vector<2 x i32> to vector<2 x i64> ``` """ -function extsi(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extsi(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extsi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -681,22 +584,18 @@ The top-most (N - M) bits of the output are filled with zeros. %5 = arith.extui %0 : vector<2 x i32> to vector<2 x i64> ``` """ -function extui(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extui(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -707,22 +606,18 @@ Cast from a value interpreted as floating-point to the nearest (rounding 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.fptosi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptosi(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.fptosi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -733,22 +628,18 @@ Cast from a value interpreted as floating-point to the nearest (rounding 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.fptoui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptoui(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.fptoui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -768,25 +659,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.floordivsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function floordivsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.floordivsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -798,22 +683,18 @@ vectors. Index is an integer of platform-specific bit width. If casting to 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.index_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function index_cast(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.index_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -825,22 +706,18 @@ vectors. Index is an integer of platform-specific bit width. If casting to a wider integer, the value is zero-extended. If casting to a narrower integer, the value is truncated. """ -function index_castui(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.index_castui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function index_castui(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.index_castui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -863,30 +740,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.maxf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.maxf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -894,25 +761,19 @@ end `maxsi` """ -function maxsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.maxsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.maxsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -920,27 +781,21 @@ end `maxui` """ -function maxui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.maxui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end +function maxui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.maxui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) + ) +end """ `minf` @@ -961,30 +816,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.minf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.minf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -992,25 +837,19 @@ end `minsi` """ -function minsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.minsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.minsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1018,25 +857,19 @@ end `minui` """ -function minui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.minui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.minui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1064,30 +897,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.mulf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mulf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.mulf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1095,25 +918,19 @@ end `muli` """ -function muli( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.muli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function muli(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.muli", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1138,30 +955,20 @@ the same operands. %x:2 = arith.mulsi_extended %y, %z : tensor<4x?xi8> ``` """ -function mulsi_extended( - lhs::Value, - rhs::Value; - low=nothing::Union{Nothing,IR.Type}, - high=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(low) && push!(_results, low) - !isnothing(high) && push!(_results, high) - - return IR.create_operation( - "arith.mulsi_extended", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mulsi_extended(lhs, rhs; low=nothing::Union{Nothing, IR.Type}, high=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(low) && push!(results, low) + !isnothing(high) && push!(results, high) + + IR.create_operation( + "arith.mulsi_extended", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1186,30 +993,20 @@ the same operands. %x:2 = arith.mului_extended %y, %z : tensor<4x?xi8> ``` """ -function mului_extended( - lhs::Value, - rhs::Value; - low=nothing::Union{Nothing,IR.Type}, - high=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(low) && push!(_results, low) - !isnothing(high) && push!(_results, high) - - return IR.create_operation( - "arith.mului_extended", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mului_extended(lhs, rhs; low=nothing::Union{Nothing, IR.Type}, high=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(low) && push!(results, low) + !isnothing(high) && push!(results, high) + + IR.create_operation( + "arith.mului_extended", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1234,29 +1031,20 @@ It has no standard attributes. %x = arith.negf %y : tensor<4x?xf8> ``` """ -function negf( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.negf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function negf(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.negf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1281,25 +1069,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ori", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ori(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ori", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1307,30 +1089,20 @@ end `remf` """ -function remf( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.remf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.remf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1356,25 +1128,19 @@ behavior. %x = arith.remsi %y, %z : tensor<4x?xi8> ``` """ -function remsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.remsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.remsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1400,25 +1166,19 @@ behavior. %x = arith.remui %y, %z : tensor<4x?xi8> ``` """ -function remui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.remui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.remui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1430,22 +1190,18 @@ floating-point value. If the value cannot be exactly represented, it is 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.sitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sitofp(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.sitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1463,25 +1219,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shli(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shli", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1503,25 +1253,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shrsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shrsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shrsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1540,25 +1284,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shrui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shrui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shrui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1586,30 +1324,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.subf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.subf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1617,25 +1345,19 @@ end `subi` """ -function subi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.subi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.subi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1647,22 +1369,18 @@ The destination type must be strictly narrower than the source type. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.truncf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function truncf(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.truncf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1684,22 +1402,18 @@ The top-most (N - M) bits of the input are discarded. %5 = arith.trunci %0 : vector<2 x i32> to vector<2 x i16> ``` """ -function trunci(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.trunci", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function trunci(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.trunci", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1711,22 +1425,18 @@ floating-point value. If the value cannot be exactly represented, it is 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.uitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function uitofp(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.uitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1751,25 +1461,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.xori", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function xori(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.xori", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1803,29 +1507,19 @@ or tensor is chosen. %vx = arith.select %cond, %vtrue, %vfalse : vector<42xf32> ``` """ -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function select(condition, true_value, false_value; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(true_value), value(false_value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/16/ArmNeon.jl b/src/Dialects/16/ArmNeon.jl index d7f5eb0b..53a93149 100644 --- a/src/Dialects/16/ArmNeon.jl +++ b/src/Dialects/16/ArmNeon.jl @@ -1,7 +1,6 @@ module arm_neon -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -15,22 +14,18 @@ vector to the destination SIMD&FP register. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.intr.smull", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_smull(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.intr.smull", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -46,22 +41,18 @@ corresponding entry of `a`: 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.2d.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function _2d_sdot(a, b, c; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.2d.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -75,22 +66,18 @@ where vector operands are partitioned into groups of four elements. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.intr.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdot(a, b, c; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.intr.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/ArmSVE.jl b/src/Dialects/16/ArmSVE.jl index 3dee6dd7..9b6f7da5 100644 --- a/src/Dialects/16/ArmSVE.jl +++ b/src/Dialects/16/ArmSVE.jl @@ -1,31 +1,24 @@ module arm_sve -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fadd(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fadd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -36,24 +29,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.addf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_addf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.addf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -61,24 +48,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_add(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.add", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -89,24 +70,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.addi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_addi(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.addi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -114,24 +89,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fdiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fdiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -142,24 +111,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -167,24 +130,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fmul(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -195,24 +152,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.mulf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_mulf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.mulf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -220,24 +171,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_mul(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.mul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -248,24 +193,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.muli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_muli(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.muli", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -273,24 +212,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sdiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -301,24 +234,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divi_signed", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divi_signed(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divi_signed", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -326,24 +253,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fsub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fsub(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fsub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -354,24 +275,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.subf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_subf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.subf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -379,24 +294,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sub(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -407,24 +316,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.subi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_subi(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.subi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -432,24 +335,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.udiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_udiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.udiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -460,24 +357,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divi_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divi_unsigned(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divi_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -485,24 +376,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdot(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -520,22 +405,18 @@ to the overlapping element of the first vector input. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sdot(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -543,24 +424,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.smmla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_smmla(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.smmla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -581,22 +456,18 @@ the result to the first input using modular arithmetic. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.smmla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function smmla(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.smmla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -604,24 +475,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.udot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_udot(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.udot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -639,22 +504,18 @@ to the overlapping element of the first vector input. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.udot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function udot(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.udot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -662,24 +523,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.ummla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ummla(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.ummla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -700,22 +555,18 @@ the result to the first input using modular arithmetic. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.ummla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ummla(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.ummla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Async.jl b/src/Dialects/16/Async.jl index 84750ab3..f0f83ac2 100644 --- a/src/Dialects/16/Async.jl +++ b/src/Dialects/16/Async.jl @@ -1,7 +1,6 @@ module async -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -19,25 +18,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add_to_group(operand, group; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(group), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + 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) ) end @@ -61,22 +54,18 @@ group become ready. async.await_all %0 ``` """ -function await_all(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.await_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function await_all(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.await_all", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -96,23 +85,19 @@ async.await %0 : !async.token %2 = async.await %1 : !async.value ``` """ -function await(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "async.await", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function await(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "async.await", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -130,24 +115,18 @@ is encoded as a symbol reference attribute named \"callee\". %2 = async.call @my_add(%0, %1) : (f32, f32) -> !async.value ``` """ -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( - "async.call", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operands_; result_0::Vector{IR.Type}, callee, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + + IR.create_operation( + "async.call", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -157,23 +136,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()) - _results = IR.Type[] - _operands = Value[id,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(handle) && push!(_results, handle) - - return IR.create_operation( - "async.coro.begin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function coro_begin(id; handle=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(id), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(handle) && push!(results, handle) + + 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) ) end @@ -184,22 +159,18 @@ The `async.coro.end` marks the point where a coroutine needs to return control back to the caller if it is not an initial invocation of the 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.end", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_end(handle; location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.end", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -209,22 +180,18 @@ end The `async.coro.free` deallocates the coroutine frame created by the async.coro.begin operation. """ -function coro_free(id::Value, handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[id, handle] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.free", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_free(id, handle; location=Location()) + results = IR.Type[] + operands = Value[value(id), value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.free", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -258,25 +225,19 @@ end The `async.coro.saves` saves the coroutine state. """ -function coro_save( - handle::Value; state=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(state) && push!(_results, state) - - return IR.create_operation( - "async.coro.save", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function coro_save(handle; state=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(state) && push!(results, state) + + 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) ) end @@ -292,28 +253,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(), -) - _results = IR.Type[] - _operands = Value[state,] - _owned_regions = Region[] - _successors = Block[suspendDest, resumeDest, cleanupDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.suspend", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_suspend(state; suspendDest::Block, resumeDest::Block, cleanupDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(state), ] + owned_regions = Region[] + successors = Block[suspendDest, resumeDest, cleanupDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.suspend", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -334,25 +285,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() -) - _results = IR.Type[] - _operands = Value[size,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "async.create_group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function create_group(size; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(size), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -397,30 +342,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}, - bodyOperands::Vector{Value}; - token::IR.Type, - bodyResults::Vector{IR.Type}, - bodyRegion::Region, - location=Location(), -) - _results = IR.Type[token, bodyResults...] - _operands = Value[dependencies..., bodyOperands...] - _owned_regions = Region[bodyRegion,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dependencies), length(bodyOperands)])) - - return IR.create_operation( - "async.execute", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function execute(dependencies, bodyOperands; token::IR.Type, bodyResults::Vector{IR.Type}, bodyRegion::Region, location=Location()) + results = IR.Type[token, bodyResults..., ] + operands = Value[value.(dependencies)..., value.(bodyOperands)..., ] + owned_regions = Region[bodyRegion, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dependencies), length(bodyOperands), ])) + + IR.create_operation( + "async.execute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -501,22 +435,18 @@ async.func @foo() : !async.token { } ``` """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -526,22 +456,18 @@ end The `async.runtime.add_ref` operation adds a reference(s) to async value (token, value or group). """ -function runtime_add_ref(operand::Value; count, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("count", count),] - - return IR.create_operation( - "async.runtime.add_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_add_ref(operand; count, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("count", count), ] + + IR.create_operation( + "async.runtime.add_ref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -551,25 +477,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_add_to_group(operand, group; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(group), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + 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) ) end @@ -580,22 +500,18 @@ The `async.runtime.await_and_resume` operation awaits for the operand to become available or error and resumes the coroutine on a thread managed by the runtime. """ -function runtime_await_and_resume(operand::Value, handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand, handle] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.await_and_resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_await_and_resume(operand, handle; location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.await_and_resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -605,22 +521,18 @@ end The `async.runtime.await` operation blocks the caller thread until the operand becomes available or error. """ -function runtime_await(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.await", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_await(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.await", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -630,25 +542,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_create_group(size; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(size), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -683,22 +589,18 @@ end The `async.runtime.drop_ref` operation drops a reference(s) to async value (token, value or group). """ -function runtime_drop_ref(operand::Value; count, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("count", count),] - - return IR.create_operation( - "async.runtime.drop_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_drop_ref(operand; count, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("count", count), ] + + IR.create_operation( + "async.runtime.drop_ref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -710,25 +612,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_is_error(operand; is_error=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(is_error) && push!(results, is_error) + + 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) ) end @@ -738,25 +634,18 @@ end The `async.runtime.load` operation loads the value from the runtime async.value storage. """ -function runtime_load( - storage::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[storage,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "async.runtime.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_load(storage; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(storage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -794,22 +683,18 @@ end The `async.runtime.resume` operation resumes the coroutine on a thread managed by the runtime. """ -function runtime_resume(handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_resume(handle; location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -819,22 +704,18 @@ end The `async.runtime.set_available` operation switches async token or value state to available. """ -function runtime_set_available(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.set_available", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_set_available(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.set_available", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -844,22 +725,18 @@ end The `async.runtime.set_error` operation switches async token or value state to error. """ -function runtime_set_error(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.set_error", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_set_error(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.set_error", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -869,22 +746,18 @@ end The `async.runtime.store` operation stores the value into the runtime async.value storage. """ -function runtime_store(value::Value, storage::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value, storage] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_store(value, storage; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(storage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -894,22 +767,18 @@ end The `async.yield` is a special terminator operation for the block inside `async.execute` operation. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Bufferization.jl b/src/Dialects/16/Bufferization.jl index 0e7e4a0d..6ed2a8e4 100644 --- a/src/Dialects/16/Bufferization.jl +++ b/src/Dialects/16/Bufferization.jl @@ -1,7 +1,6 @@ module bufferization -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -55,39 +54,22 @@ return %0 : tensor : tensor ``` """ -function alloc_tensor( - dynamic_sizes::Vector{Value}, - copy=nothing::Union{Nothing,Value}; - size_hint=nothing::Union{Nothing,Value}, - result::IR.Type, - memory_space=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[dynamic_sizes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(copy) && push!(_operands, copy) - !isnothing(size_hint) && push!(_operands, size_hint) - push!( - _attributes, - operandsegmentsizes([ - length(dynamic_sizes), isnothing(copy) ? 0 : 1, isnothing(size_hint) ? 0 : 1 - ]), - ) - !isnothing(memory_space) && - push!(_attributes, namedattribute("memory_space", memory_space)) - - return IR.create_operation( - "bufferization.alloc_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloc_tensor(dynamic_sizes, copy=nothing; size_hint=nothing, result::IR.Type, memory_space=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(dynamic_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(copy) && push!(operands, value(copy)) + !isnothing(size_hint) && push!(operands, value(size_hint)) + push!(attributes, operandsegmentsizes([length(dynamic_sizes), (copy==nothing) ? 0 : 1(size_hint==nothing) ? 0 : 1])) + !isnothing(memory_space) && push!(attributes, namedattribute("memory_space", memory_space)) + + IR.create_operation( + "bufferization.alloc_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -107,22 +89,18 @@ views or create an actual copy. Mutating the source or result 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.clone", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clone(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.clone", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -152,22 +130,18 @@ tensor returns undefined results. bufferization.dealloc_tensor %tensor : tensor<1024x1024xf64, #CSR> ``` """ -function dealloc_tensor(tensor::Value; location=Location()) - _results = IR.Type[] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.dealloc_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dealloc_tensor(tensor; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.dealloc_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -188,22 +162,18 @@ This operation is a specialized variant of the built-in `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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.to_memref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function to_memref(tensor; memref::IR.Type, location=Location()) + results = IR.Type[memref, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.to_memref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -228,25 +198,18 @@ involving tensors and memrefs. 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=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "bufferization.to_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function to_tensor(memref; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.to_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Builtin.jl b/src/Dialects/16/Builtin.jl index 2ac242d8..5991a853 100644 --- a/src/Dialects/16/Builtin.jl +++ b/src/Dialects/16/Builtin.jl @@ -1,7 +1,6 @@ module builtin -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -81,24 +80,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "builtin.unrealized_conversion_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function unrealized_conversion_cast(inputs; outputs::Vector{IR.Type}, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "builtin.unrealized_conversion_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Complex.jl b/src/Dialects/16/Complex.jl index 4640547d..3ac0c312 100644 --- a/src/Dialects/16/Complex.jl +++ b/src/Dialects/16/Complex.jl @@ -1,7 +1,6 @@ module complex -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -15,23 +14,18 @@ The `abs` op takes a single complex number and computes its absolute value. %a = complex.abs %b : complex ``` """ -function abs(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function abs(complex; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.abs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -46,25 +40,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -79,23 +67,18 @@ The `angle` op takes a single complex number and computes its argument value wit %a = complex.angle %b : complex ``` """ -function angle(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.angle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function angle(complex; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.angle", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -111,25 +94,19 @@ atan2(y, x) = -i * log((x + i * y) / sqrt(x**2 + y**2)) %a = complex.atan2 %b, %c : complex ``` """ -function atan2( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.atan2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atan2(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.atan2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -145,23 +122,19 @@ complex conjugate. %a = complex.conj %b: complex ``` """ -function conj(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.conj", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function conj(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.conj", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -208,23 +181,19 @@ it, i.e. `cos(x)`, where `x` is the input value. %a = complex.cos %b : complex ``` """ -function cos(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cos(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -240,22 +209,18 @@ floating-point operands, the real and the imaginary part. %a = complex.create %b, %c : complex ``` """ -function create(real::Value, imaginary::Value; complex::IR.Type, location=Location()) - _results = IR.Type[complex,] - _operands = Value[real, imaginary] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.create", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create(real, imaginary; complex::IR.Type, location=Location()) + results = IR.Type[complex, ] + operands = Value[value(real), value(imaginary), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.create", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -269,25 +234,19 @@ division: %a = complex.div %b, %c : complex ``` """ -function div( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function div(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.div", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -302,25 +261,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function eq(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.eq", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -337,23 +290,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -374,23 +323,19 @@ complex.expm1(x) := complex.exp(x) - 1 %a = complex.expm1 %b : complex ``` """ -function expm1(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.expm1", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function expm1(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.expm1", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -405,23 +350,18 @@ The `im` op takes a single complex number and extracts the imaginary part. %a = complex.im %b : complex ``` """ -function im(complex::Value; imaginary=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(imaginary) && push!(_results, imaginary) - - return IR.create_operation( - "complex.im", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function im(complex; imaginary::IR.Type, location=Location()) + results = IR.Type[imaginary, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.im", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -439,23 +379,19 @@ approximately equal to 2.718281. %a = complex.log1p %b : complex ``` """ -function log1p(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.log1p", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log1p(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.log1p", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -472,23 +408,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -501,25 +433,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -534,23 +460,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.neg", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function neg(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.neg", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -566,25 +488,19 @@ equal. %a = complex.neq %b, %c : complex ``` """ -function neq( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.neq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function neq(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.neq", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -600,25 +516,19 @@ exponent. %a = complex.pow %b, %c : complex ``` """ -function pow( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function pow(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.pow", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -633,23 +543,18 @@ The `re` op takes a single complex number and extracts the real part. %a = complex.re %b : complex ``` """ -function re(complex::Value; real=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(real) && push!(_results, real) - - return IR.create_operation( - "complex.re", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function re(complex; real::IR.Type, location=Location()) + results = IR.Type[real, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.re", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -664,23 +569,19 @@ The `rsqrt` operation computes reciprocal of square root. %a = complex.rsqrt %b : complex ``` """ -function rsqrt(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rsqrt(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.rsqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -696,23 +597,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sign(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -728,23 +625,19 @@ it, i.e. `sin(x)`, where `x` is the input value. %a = complex.sin %b : complex ``` """ -function sin(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sin(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -759,23 +652,19 @@ The `sqrt` operation takes a complex number and returns its square root. %a = complex.sqrt %b : complex ``` """ -function sqrt(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sqrt(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -790,25 +679,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sub(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -824,23 +707,19 @@ it, i.e. `tan(x)`, where `x` is the input value. %a = complex.tan %b : complex ``` """ -function tan(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.tan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tan(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.tan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -856,23 +735,19 @@ tangent. %a = complex.tanh %b : complex ``` """ -function tanh(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tanh(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/16/ControlFlow.jl b/src/Dialects/16/ControlFlow.jl index 23faa5a7..c4177c61 100644 --- a/src/Dialects/16/ControlFlow.jl +++ b/src/Dialects/16/ControlFlow.jl @@ -1,7 +1,6 @@ module cf -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,22 +17,18 @@ runtime to propagate the error to the user. assert %b, \"Expected ... to be true\" ``` """ -function assert(arg::Value; msg, location=Location()) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("msg", msg),] - - return IR.create_operation( - "cf.assert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assert(arg; msg, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("msg", msg), ] + + IR.create_operation( + "cf.assert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -54,22 +49,18 @@ target block. ^bb3(%3: tensor<*xf32>): ``` """ -function br(destOperands::Vector{Value}; dest::Block, location=Location()) - _results = IR.Type[] - _operands = Value[destOperands...,] - _owned_regions = Region[] - _successors = Block[dest,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "cf.br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function br(destOperands; dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(destOperands)..., ] + owned_regions = Region[] + successors = Block[dest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "cf.br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -101,33 +92,19 @@ func.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(), -) - _results = IR.Type[] - _operands = Value[condition, trueDestOperands..., falseDestOperands...] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands)]), - ) - - return IR.create_operation( - "cf.cond_br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cond_br(condition, trueDestOperands, falseDestOperands; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueDestOperands)..., value.(falseDestOperands)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands), ])) + + IR.create_operation( + "cf.cond_br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -150,38 +127,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(), -) - _results = IR.Type[] - _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)]) - ) - !isnothing(case_values) && - push!(_attributes, namedattribute("case_values", case_values)) - - return IR.create_operation( - "cf.switch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch(flag, defaultOperands, caseOperands; case_values=nothing, case_operand_segments, defaultDestination::Block, caseDestinations::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(flag), value.(defaultOperands)..., value.(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), ])) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) + + IR.create_operation( + "cf.switch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/EmitC.jl b/src/Dialects/16/EmitC.jl index 58124247..401d3cb7 100644 --- a/src/Dialects/16/EmitC.jl +++ b/src/Dialects/16/EmitC.jl @@ -1,7 +1,6 @@ module emitc -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -22,22 +21,18 @@ can be applied to a single operand. ``` """ -function apply(operand::Value; result::IR.Type, applicableOperator, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply(operand; result::IR.Type, applicableOperator, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("applicableOperator", applicableOperator), ] + + IR.create_operation( + "emitc.apply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -60,32 +55,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...,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operands_; result_0::Vector{IR.Type}, callee, args=nothing, template_args=nothing, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + !isnothing(args) && push!(attributes, namedattribute("args", args)) + !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 ) end @@ -107,22 +90,18 @@ and EmitC types. !emitc.ptr> to !emitc.ptr ``` """ -function cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "emitc.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "emitc.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Func.jl b/src/Dialects/16/Func.jl index a95ab39a..7cf884b6 100644 --- a/src/Dialects/16/Func.jl +++ b/src/Dialects/16/Func.jl @@ -1,7 +1,6 @@ module func -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -21,27 +20,18 @@ Function values can be created with the %result = func.call_indirect %func(%0, %1) : (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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "func.call_indirect", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call_indirect(callee, callee_operands; results_::Vector{IR.Type}, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(callee), value.(callee_operands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "func.call_indirect", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -59,24 +49,18 @@ symbol reference attribute named \"callee\". %2 = func.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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("callee", callee),] - - return IR.create_operation( - "func.call", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operands_; result_0::Vector{IR.Type}, callee, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + + IR.create_operation( + "func.call", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -209,22 +193,18 @@ func.func @foo() : (i32, f8) { } ``` """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "func.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "func.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/GPU.jl b/src/Dialects/16/GPU.jl index 029430fe..3a927815 100644 --- a/src/Dialects/16/GPU.jl +++ b/src/Dialects/16/GPU.jl @@ -1,7 +1,6 @@ module gpu -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -29,32 +28,21 @@ accumulation as code region. The accumulation operation must be one of: If `uniform` flag is set 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, - uniform=nothing, - body::Region, - location=Location(), -) - _results = IR.Type[] - _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)) - !isnothing(uniform) && push!(_attributes, namedattribute("uniform", uniform)) - - return IR.create_operation( - "gpu.all_reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function all_reduce(value; result_0=nothing::Union{Nothing, IR.Type}, op=nothing, uniform=nothing, body::Region, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result_0) && push!(results, result_0) + !isnothing(op) && push!(attributes, namedattribute("op", op)) + !isnothing(uniform) && push!(attributes, namedattribute("uniform", uniform)) + + 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) ) end @@ -80,38 +68,21 @@ memory accessible both on host and on device. %memref, %token = gpu.alloc async [%dep] host_shared (%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}, - hostShared=nothing, - 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) - ]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - !isnothing(hostShared) && push!(_attributes, namedattribute("hostShared", hostShared)) - - return IR.create_operation( - "gpu.alloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloc(asyncDependencies, dynamicSizes, symbolOperands; memref::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, hostShared=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(asyncDependencies)..., value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(asyncDependencies), length(dynamicSizes), length(symbolOperands), ])) + !isnothing(asyncToken) && push!(results, asyncToken) + !isnothing(hostShared) && push!(attributes, namedattribute("hostShared", hostShared)) + + IR.create_operation( + "gpu.alloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -241,28 +212,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(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies..., memref] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.dealloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dealloc(asyncDependencies, memref; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.dealloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -482,22 +444,18 @@ Writes from the host are guaranteed to be visible to device kernels that are launched afterwards. Writes from the device are guaranteed to be visible on the host after synchronizing with the device kernel completion. """ -function host_register(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.host_register", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function host_register(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.host_register", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -612,60 +570,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}; - kernelOperands::Vector{Value}, - asyncToken=nothing::Union{Nothing,IR.Type}, - kernel, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - asyncDependencies..., - gridSizeX, - gridSizeY, - gridSizeZ, - blockSizeX, - blockSizeY, - blockSizeZ, - kernelOperands..., - ] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kernel", kernel),] - !isnothing(dynamicSharedMemorySize) && push!(_operands, dynamicSharedMemorySize) - push!( - _attributes, - operandsegmentsizes([ - length(asyncDependencies), - 1, - 1, - 1, - 1, - 1, - 1, - isnothing(dynamicSharedMemorySize) ? 0 : 1, - length(kernelOperands), - ]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.launch_func", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function launch_func(asyncDependencies, gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ, dynamicSharedMemorySize=nothing; kernelOperands, asyncToken=nothing::Union{Nothing, IR.Type}, kernel, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(gridSizeX), value(gridSizeY), value(gridSizeZ), value(blockSizeX), value(blockSizeY), value(blockSizeZ), value.(kernelOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kernel", kernel), ] + !isnothing(dynamicSharedMemorySize) && push!(operands, value(dynamicSharedMemorySize)) + push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1length(kernelOperands), ])) + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.launch_func", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -743,57 +662,21 @@ 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( - asyncDependencies::Vector{Value}, - gridSizeX::Value, - gridSizeY::Value, - gridSizeZ::Value, - blockSizeX::Value, - blockSizeY::Value, - blockSizeZ::Value, - dynamicSharedMemorySize=nothing::Union{Nothing,Value}; - asyncToken=nothing::Union{Nothing,IR.Type}, - body::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - asyncDependencies..., - gridSizeX, - gridSizeY, - gridSizeZ, - blockSizeX, - blockSizeY, - blockSizeZ, - ] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(dynamicSharedMemorySize) && push!(_operands, dynamicSharedMemorySize) - push!( - _attributes, - operandsegmentsizes([ - length(asyncDependencies), - 1, - 1, - 1, - 1, - 1, - 1, - isnothing(dynamicSharedMemorySize) ? 0 : 1, - ]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.launch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function launch(asyncDependencies, gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ, dynamicSharedMemorySize=nothing; asyncToken=nothing::Union{Nothing, IR.Type}, body::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(gridSizeX), value(gridSizeY), value(gridSizeZ), value(blockSizeX), value(blockSizeY), value(blockSizeZ), ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dynamicSharedMemorySize) && push!(operands, value(dynamicSharedMemorySize)) + push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1])) + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.launch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -815,29 +698,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function memcpy(asyncDependencies, dst, src; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(dst), value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.memcpy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -859,29 +732,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function memset(asyncDependencies, dst, value; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(dst), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.memset", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -949,22 +812,18 @@ scalar arguments that should be printed. The format string is a C-style printf string, subject to any restrictions imposed by one\'s target platform. """ -function printf(args::Vector{Value}; format, location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("format", format),] - - return IR.create_operation( - "gpu.printf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function printf(args; format, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("format", format), ] + + IR.create_operation( + "gpu.printf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -975,22 +834,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1001,22 +856,18 @@ Operation that sets the current default GPU, using a zero-based index into the set of GPUs on the system. The default GPU setting may be thread-local. """ -function set_default_device(devIndex::Value; location=Location()) - _results = IR.Type[] - _operands = Value[devIndex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.set_default_device", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function set_default_device(devIndex; location=Location()) + results = IR.Type[] + operands = Value[value(devIndex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.set_default_device", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1041,32 +892,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; - shuffleResult=nothing::Union{Nothing,IR.Type}, - valid=nothing::Union{Nothing,IR.Type}, - mode, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, offset, width] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mode", mode),] - !isnothing(shuffleResult) && push!(_results, shuffleResult) - !isnothing(valid) && push!(_results, valid) - - return IR.create_operation( - "gpu.shuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shuffle(value, offset, width; shuffleResult=nothing::Union{Nothing, IR.Type}, valid=nothing::Union{Nothing, IR.Type}, mode, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(offset), value(width), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mode", mode), ] + !isnothing(shuffleResult) && push!(results, shuffleResult) + !isnothing(valid) && push!(results, valid) + + IR.create_operation( + "gpu.shuffle", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1129,35 +968,21 @@ 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}, - a_transpose=nothing, - b_transpose=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[opA, opB, opC] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(a_transpose) && - push!(_attributes, namedattribute("a_transpose", a_transpose)) - !isnothing(b_transpose) && - push!(_attributes, namedattribute("b_transpose", b_transpose)) - - return IR.create_operation( - "gpu.subgroup_mma_compute", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subgroup_mma_compute(opA, opB, opC; res=nothing::Union{Nothing, IR.Type}, a_transpose=nothing, b_transpose=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(opA), value(opB), value(opC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !isnothing(a_transpose) && push!(attributes, namedattribute("a_transpose", a_transpose)) + !isnothing(b_transpose) && push!(attributes, namedattribute("b_transpose", b_transpose)) + + 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) ) end @@ -1184,22 +1009,18 @@ This op is meant to be used along with `gpu.subgroup_mma_compute`. !gpu.mma_matrix<16x16xf32, \"COp\"> ``` """ -function subgroup_mma_constant_matrix(value::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_constant_matrix(value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.subgroup_mma_constant_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1223,24 +1044,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, opType, location=Location() -) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("opType", opType),] - - return IR.create_operation( - "gpu.subgroup_mma_elementwise", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_elementwise(args; res::IR.Type, opType, location=Location()) + results = IR.Type[res, ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("opType", opType), ] + + IR.create_operation( + "gpu.subgroup_mma_elementwise", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1268,30 +1083,19 @@ 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, - transpose=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[srcMemref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("leadDimension", leadDimension),] - !isnothing(transpose) && push!(_attributes, namedattribute("transpose", transpose)) - - return IR.create_operation( - "gpu.subgroup_mma_load_matrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_load_matrix(srcMemref, indices; res::IR.Type, leadDimension, transpose=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(srcMemref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] + !isnothing(transpose) && push!(attributes, namedattribute("transpose", transpose)) + + IR.create_operation( + "gpu.subgroup_mma_load_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1318,30 +1122,19 @@ 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, - transpose=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[src, dstMemref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("leadDimension", leadDimension),] - !isnothing(transpose) && push!(_attributes, namedattribute("transpose", transpose)) - - return IR.create_operation( - "gpu.subgroup_mma_store_matrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_store_matrix(src, dstMemref, indices; leadDimension, transpose=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(dstMemref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] + !isnothing(transpose) && push!(attributes, namedattribute("transpose", transpose)) + + IR.create_operation( + "gpu.subgroup_mma_store_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1360,30 +1153,20 @@ subgroup. The result is equal for all work items of a subgroup. If `uniform` flag is set either none or all work items of a subgroup need to execute this op in convergence. """ -function subgroup_reduce( - value::Value; - result_0=nothing::Union{Nothing,IR.Type}, - op, - uniform=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("op", op),] - !isnothing(result_0) && push!(_results, result_0) - !isnothing(uniform) && push!(_attributes, namedattribute("uniform", uniform)) - - return IR.create_operation( - "gpu.subgroup_reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subgroup_reduce(value; result_0=nothing::Union{Nothing, IR.Type}, op, uniform=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("op", op), ] + !isnothing(result_0) && push!(results, result_0) + !isnothing(uniform) && push!(attributes, namedattribute("uniform", uniform)) + + IR.create_operation( + "gpu.subgroup_reduce", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1511,27 +1294,19 @@ once this op completes. Example usage: gpu.wait [%t0, %t1] ``` """ -function wait( - asyncDependencies::Vector{Value}; - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wait(asyncDependencies; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1547,22 +1322,18 @@ in gpu ops. It returns values to the immediately enclosing gpu op. gpu.yield %f0, %f1 : f32, f32 ``` """ -function yield(values::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[values...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(values; location=Location()) + results = IR.Type[] + operands = Value[value.(values)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Index.jl b/src/Dialects/16/Index.jl index ab08f30f..ad6d11c2 100644 --- a/src/Dialects/16/Index.jl +++ b/src/Dialects/16/Index.jl @@ -1,7 +1,6 @@ module index -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -16,25 +15,19 @@ The `index.add` operation takes two index values and computes their sum. %c = index.add %a, %b ``` """ -function add( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -51,25 +44,19 @@ and. %c = index.and %a, %b ``` """ -function and( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function and(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.and", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -126,22 +113,18 @@ truncated. %1 = index.casts %b : i64 to index ``` """ -function casts(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "index.casts", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function casts(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "index.casts", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -163,22 +146,18 @@ truncated. %1 = index.castu %b : i64 to index ``` """ -function castu(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "index.castu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function castu(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "index.castu", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -198,25 +177,19 @@ Note: division by zero and signed division overflow are undefined behaviour. %c = index.ceildivs %a, %b ``` """ -function ceildivs( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.ceildivs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivs(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.ceildivs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -236,25 +209,19 @@ Note: division by zero is undefined behaviour. %c = index.ceildivu %a, %b ``` """ -function ceildivu( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.ceildivu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivu(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.ceildivu", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -291,29 +258,19 @@ The result is `1` if the comparison is true and `0` otherwise. %2 = index.cmp ne(%a, %b) ``` """ -function cmp( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - pred, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pred", pred),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.cmp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cmp(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, pred, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("pred", pred), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.cmp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -365,25 +322,19 @@ Note: division by zero and signed division overflow are undefined behaviour. %c = index.divs %a, %b ``` """ -function divs( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.divs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divs(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.divs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -403,25 +354,19 @@ Note: division by zero is undefined behaviour. %c = index.divu %a, %b ``` """ -function divu( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.divu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divu(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.divu", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -441,25 +386,19 @@ Note: division by zero and signed division overflow are undefined behaviour. %c = index.floordivs %a, %b ``` """ -function floordivs( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.floordivs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function floordivs(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.floordivs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -476,25 +415,19 @@ maximum value. Treats the leading bit as the sign, i.e. `max(-2, 6) = 6`. %c = index.maxs %a, %b ``` """ -function maxs( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.maxs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxs(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.maxs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -512,25 +445,19 @@ unsigned maximum value. Treats the leading bit as the most significant, i.e. %c = index.maxu %a, %b ``` """ -function maxu( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.maxu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxu(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.maxu", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -547,25 +474,19 @@ minimum value. Treats the leading bit as the sign, i.e. `min(-2, 6) = -2`. %c = index.mins %a, %b ``` """ -function mins( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.mins", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mins(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.mins", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -583,25 +504,19 @@ unsigned minimum value. Treats the leading bit as the most significant, i.e. %c = index.minu %a, %b ``` """ -function minu( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.minu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minu(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.minu", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -617,25 +532,19 @@ The `index.mul` operation takes two index values and computes their product. %c = index.mul %a, %b ``` """ -function mul( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -652,25 +561,19 @@ or. %c = index.or %a, %b ``` """ -function or( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function or(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.or", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -687,25 +590,19 @@ remainder. Treats the leading bit as the sign, i.e. `6 % -2 = 0`. %c = index.rems %a, %b ``` """ -function rems( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.rems", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rems(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.rems", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -723,25 +620,19 @@ unsigned remainder. Treats the leading bit as the most significant, i.e. %c = index.remu %a, %b ``` """ -function remu( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.remu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remu(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.remu", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -760,25 +651,19 @@ index bitwidth, the operation is undefined. %c = index.shl %a, %b ``` """ -function shl( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.shl", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shl(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.shl", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -797,25 +682,19 @@ greater than the index bitwidth, the operation is undefined. %c = index.shrs %a, %b ``` """ -function shrs( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.shrs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shrs(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.shrs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -834,25 +713,19 @@ bitwidth, the operation is undefined. %c = index.shru %a, %b ``` """ -function shru( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.shru", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shru(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.shru", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -902,25 +775,19 @@ of the first from the second operand. %c = index.sub %a, %b ``` """ -function sub( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sub(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.sub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -937,25 +804,19 @@ xor. %c = index.xor %a, %b ``` """ -function xor( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function xor(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.xor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/16/LLVMIR.jl b/src/Dialects/16/LLVMIR.jl index fa1ff047..a60c4cea 100644 --- a/src/Dialects/16/LLVMIR.jl +++ b/src/Dialects/16/LLVMIR.jl @@ -1,32 +1,25 @@ module llvm -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `ashr` """ -function ashr( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.ashr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ashr(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.ashr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -65,25 +58,19 @@ end `add` """ -function add( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -91,22 +78,18 @@ end `addrspacecast` """ -function addrspacecast(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.addrspacecast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function addrspacecast(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.addrspacecast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -246,30 +229,20 @@ end `alloca` """ -function alloca( - arraySize::Value; - res::IR.Type, - alignment=nothing, - elem_type=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[arraySize,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - !isnothing(elem_type) && push!(_attributes, namedattribute("elem_type", elem_type)) - - return IR.create_operation( - "llvm.alloca", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca(arraySize; res::IR.Type, alignment=nothing, elem_type=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arraySize), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(elem_type) && push!(attributes, namedattribute("elem_type", elem_type)) + + IR.create_operation( + "llvm.alloca", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -277,25 +250,19 @@ end `and` """ -function and( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function and(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.and", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -303,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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cmpxchg(ptr, cmp, val; res::IR.Type, success_ordering, failure_ordering, location=Location()) + results = IR.Type[res, ] + operands = Value[value(ptr), value(cmp), value(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 ) end @@ -337,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("bin_op", bin_op), namedattribute("ordering", ordering) - ] - - return IR.create_operation( - "llvm.atomicrmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomicrmw(ptr, val; res::IR.Type, bin_op, ordering, location=Location()) + results = IR.Type[res, ] + operands = Value[value(ptr), value(val), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -364,22 +308,18 @@ end `bitcast` """ -function bitcast(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -387,22 +327,18 @@ end `br` """ -function br(destOperands::Vector{Value}; dest::Block, location=Location()) - _results = IR.Type[] - _operands = Value[destOperands...,] - _owned_regions = Region[] - _successors = Block[dest,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function br(destOperands; dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(destOperands)..., ] + owned_regions = Region[] + successors = Block[dest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -434,35 +370,22 @@ llvm.call @bar(%0) : (f32) -> () llvm.call %1(%0) : (f32) -> () ``` """ -function call( - operand_0::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - callee=nothing, - fastmathFlags=nothing, - branch_weights=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(callee) && push!(_attributes, namedattribute("callee", callee)) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - !isnothing(branch_weights) && - push!(_attributes, namedattribute("branch_weights", branch_weights)) - - return IR.create_operation( - "llvm.call", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operand_0; result=nothing::Union{Nothing, IR.Type}, callee=nothing, fastmathFlags=nothing, branch_weights=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) + + IR.create_operation( + "llvm.call", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -470,36 +393,20 @@ end `cond_br` """ -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...] - _owned_regions = Region[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cond_br(condition, trueDestOperands, falseDestOperands; branch_weights=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueDestOperands)..., value.(falseDestOperands)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + 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 ) end @@ -556,25 +463,18 @@ end `extractelement` """ -function extractelement( - vector::Value, position::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[vector, position] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.extractelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extractelement(vector, position; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(vector), value(position), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.extractelement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -582,22 +482,18 @@ end `extractvalue` """ -function extractvalue(container::Value; res::IR.Type, position, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extractvalue(container; res::IR.Type, position, location=Location()) + results = IR.Type[res, ] + operands = Value[value(container), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "llvm.extractvalue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -605,31 +501,20 @@ end `fadd` """ -function fadd( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fadd(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -637,32 +522,19 @@ end `fcmp` """ -function fcmp( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - predicate, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("predicate", predicate),] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.fcmp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fcmp(lhs, rhs; res::IR.Type, predicate, fastmathFlags=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(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 ) end @@ -670,31 +542,20 @@ end `fdiv` """ -function fdiv( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fdiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -702,31 +563,20 @@ end `fmul` """ -function fmul( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fmul(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -734,30 +584,20 @@ end `fneg` """ -function fneg( - operand::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fneg(operand; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -765,22 +605,18 @@ end `fpext` """ -function fpext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fpext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fpext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fpext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -788,22 +624,18 @@ end `fptosi` """ -function fptosi(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptosi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptosi(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptosi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -811,22 +643,18 @@ end `fptoui` """ -function fptoui(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptoui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptoui(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptoui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -834,22 +662,18 @@ end `fptrunc` """ -function fptrunc(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptrunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptrunc(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptrunc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -857,31 +681,20 @@ end `frem` """ -function frem( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function frem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -889,31 +702,20 @@ end `fsub` """ -function fsub( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fsub(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -946,23 +748,19 @@ end `freeze` """ -function freeze(val::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[val,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.freeze", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function freeze(val; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(val), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.freeze", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -993,32 +791,20 @@ Examples: : (!llvm.ptr) -> !llvm.ptr ``` """ -function getelementptr( - base::Value, - dynamicIndices::Vector{Value}; - res::IR.Type, - rawConstantIndices, - elem_type=nothing, - inbounds=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[base, dynamicIndices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("rawConstantIndices", rawConstantIndices),] - !isnothing(elem_type) && push!(_attributes, namedattribute("elem_type", elem_type)) - !isnothing(inbounds) && push!(_attributes, namedattribute("inbounds", inbounds)) - - return IR.create_operation( - "llvm.getelementptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function getelementptr(base, dynamicIndices; res::IR.Type, rawConstantIndices, elem_type=nothing, inbounds=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(base), value.(dynamicIndices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("rawConstantIndices", rawConstantIndices), ] + !isnothing(elem_type) && push!(attributes, namedattribute("elem_type", elem_type)) + !isnothing(inbounds) && push!(attributes, namedattribute("inbounds", inbounds)) + + IR.create_operation( + "llvm.getelementptr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1253,29 +1039,18 @@ end `icmp` """ -function icmp( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - predicate, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("predicate", predicate),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.icmp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function icmp(lhs, rhs; res::IR.Type, predicate, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "llvm.icmp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1289,43 +1064,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(), -) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function inline_asm(operands_; 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[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + 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(asm_dialect) && push!(attributes, namedattribute("asm_dialect", asm_dialect)) + !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 ) end @@ -1333,29 +1088,19 @@ end `insertelement` """ -function insertelement( - vector::Value, - value::Value, - position::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[vector, value, position] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.insertelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insertelement(vector, value, position; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(vector), value(value), value(position), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.insertelement", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1363,29 +1108,19 @@ end `insertvalue` """ -function insertvalue( - container::Value, - value::Value; - res=nothing::Union{Nothing,IR.Type}, - position, - location=Location(), -) - _results = IR.Type[] - _operands = Value[container, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("position", position),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.insertvalue", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insertvalue(container, value; res=nothing::Union{Nothing, IR.Type}, position, location=Location()) + results = IR.Type[] + operands = Value[value(container), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.insertvalue", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1393,22 +1128,18 @@ end `inttoptr` """ -function inttoptr(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.inttoptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function inttoptr(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.inttoptr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1416,41 +1147,21 @@ end `invoke` """ -function invoke( - callee_operands::Vector{Value}, - normalDestOperands::Vector{Value}, - unwindDestOperands::Vector{Value}; - result_0::Vector{IR.Type}, - callee=nothing, - branch_weights=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) - ]), - ) - !isnothing(callee) && push!(_attributes, namedattribute("callee", callee)) - !isnothing(branch_weights) && - push!(_attributes, namedattribute("branch_weights", branch_weights)) - - return IR.create_operation( - "llvm.invoke", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function invoke(callee_operands, normalDestOperands, unwindDestOperands; result_0::Vector{IR.Type}, callee=nothing, branch_weights=nothing, normalDest::Block, unwindDest::Block, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(callee_operands)..., value.(normalDestOperands)..., value.(unwindDestOperands)..., ] + owned_regions = Region[] + successors = Block[normalDest, unwindDest, ] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(callee_operands), length(normalDestOperands), length(unwindDestOperands), ])) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) + + IR.create_operation( + "llvm.invoke", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1537,25 +1248,19 @@ end `lshr` """ -function lshr( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.lshr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function lshr(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.lshr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1563,25 +1268,19 @@ end `landingpad` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function landingpad(operand_0; res::IR.Type, cleanup=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(cleanup) && push!(attributes, namedattribute("cleanup", cleanup)) + + IR.create_operation( + "llvm.landingpad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1589,42 +1288,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,] - _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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(addr; 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[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(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) + + IR.create_operation( + "llvm.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1662,25 +1343,19 @@ end `mul` """ -function mul( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1725,25 +1400,19 @@ end `or` """ -function or( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function or(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.or", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1751,22 +1420,18 @@ end `ptrtoint` """ -function ptrtoint(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.ptrtoint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ptrtoint(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.ptrtoint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1774,46 +1439,38 @@ end `resume` """ -function resume(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end +function resume(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `return_` """ -function return_(arg=nothing::Union{Nothing,Value}; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(arg) && push!(_operands, arg) - - return IR.create_operation( - "llvm.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(arg=nothing; location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(arg) && push!(operands, value(arg)) + + IR.create_operation( + "llvm.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1821,25 +1478,19 @@ end `sdiv` """ -function sdiv( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.sdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sdiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.sdiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1847,22 +1498,18 @@ end `sext` """ -function sext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.sext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.sext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1870,22 +1517,18 @@ end `sitofp` """ -function sitofp(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.sitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sitofp(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.sitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1893,25 +1536,19 @@ end `srem` """ -function srem( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.srem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function srem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.srem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1919,29 +1556,19 @@ end `select` """ -function select( - condition::Value, - trueValue::Value, - falseValue::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function select(condition, trueValue, falseValue; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(trueValue), value(falseValue), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1949,25 +1576,19 @@ end `shl` """ -function shl( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.shl", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shl(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.shl", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1975,22 +1596,18 @@ end `shufflevector` """ -function shufflevector(v1::Value, v2::Value; res::IR.Type, mask, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shufflevector(v1, v2; res::IR.Type, mask, location=Location()) + results = IR.Type[res, ] + operands = Value[value(v1), value(v2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mask", mask), ] + + IR.create_operation( + "llvm.shufflevector", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1998,42 +1615,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(), -) - _results = IR.Type[] - _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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, addr; access_groups=nothing, alias_scopes=nothing, noalias_scopes=nothing, alignment=nothing, volatile_=nothing, nontemporal=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(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(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) + + IR.create_operation( + "llvm.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2041,25 +1640,19 @@ end `sub` """ -function sub( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sub(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.sub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2067,41 +1660,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(), -) - _results = IR.Type[] - _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)]) - ) - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch(value, defaultOperands, caseOperands; case_values=nothing, case_operand_segments, branch_weights=nothing, defaultDestination::Block, caseDestinations::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), value.(defaultOperands)..., value.(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), ])) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) + !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 ) end @@ -2280,22 +1853,18 @@ end `trunc` """ -function trunc(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.trunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function trunc(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.trunc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2303,25 +1872,19 @@ end `udiv` """ -function udiv( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.udiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function udiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.udiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2329,22 +1892,18 @@ end `uitofp` """ -function uitofp(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.uitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function uitofp(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.uitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2352,25 +1911,19 @@ end `urem` """ -function urem( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.urem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function urem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.urem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2435,25 +1988,19 @@ end `xor` """ -function xor( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function xor(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.xor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2461,5804 +2008,18 @@ end `zext` """ -function zext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.zext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType -import ..Dialects: namedattribute, operandsegmentsizes - -""" -`intr_abs` - -""" -function intr_abs(in::Value, is_int_min_poison::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[in, is_int_min_poison] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_assume` - -""" -function intr_assume(cond::Value; location=Location()) - _results = IR.Type[] - _operands = Value[cond,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.assume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_bitreverse` - -""" -function intr_bitreverse( - in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.bitreverse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`call_intrinsic` - -Call the specified llvm intrinsic. If the intrinsic is overloaded, use -the MLIR function type of this op to determine which intrinsic to call. -""" -function call_intrinsic( - args::Vector{Value}; results::Vector{IR.Type}, intrin, location=Location() -) - _results = IR.Type[results...,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("intrin", intrin),] - - return IR.create_operation( - "llvm.call_intrinsic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_copysign` - -""" -function intr_copysign( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.copysign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_coro_align` - -""" -function intr_coro_align(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.align", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_begin` - -""" -function intr_coro_begin(token::Value, mem::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_end` - -""" -function intr_coro_end(handle::Value, unwind::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_free` - -""" -function intr_coro_free(id::Value, handle::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.id", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_resume` - -""" -function intr_coro_resume(handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_save` - -""" -function intr_coro_save(handle::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.save", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_size` - -""" -function intr_coro_size(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.size", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_suspend` - -""" -function intr_coro_suspend(save::Value, final::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_cos` - -""" -function intr_cos( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_ctlz` - -""" -function intr_ctlz(in::Value, zero_undefined::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_cttz` - -""" -function intr_cttz(in::Value, zero_undefined::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_ctpop` - -""" -function intr_ctpop(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.ctpop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_dbg_addr` - -""" -function intr_dbg_addr(addr::Value; varInfo, location=Location()) - _results = IR.Type[] - _operands = Value[addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("varInfo", varInfo),] - - return IR.create_operation( - "llvm.intr.dbg.addr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_dbg_declare` - -""" -function intr_dbg_declare(addr::Value; varInfo, location=Location()) - _results = IR.Type[] - _operands = Value[addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("varInfo", varInfo),] - - return IR.create_operation( - "llvm.intr.dbg.declare", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_dbg_value` - -""" -function intr_dbg_value(value::Value; varInfo, location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("varInfo", varInfo),] - - return IR.create_operation( - "llvm.intr.dbg.value", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_eh_typeid_for` - -""" -function intr_eh_typeid_for(type_info::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_exp2` - -""" -function intr_exp2( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.exp2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_exp` - -""" -function intr_exp( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_fabs` - -""" -function intr_fabs( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.fabs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_ceil` - -""" -function intr_ceil( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_floor` - -""" -function intr_floor( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_fma` - -""" -function intr_fma( - a::Value, - b::Value, - c::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_fmuladd` - -""" -function intr_fmuladd( - a::Value, - b::Value, - c::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.fmuladd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_trunc` - -""" -function intr_trunc( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.trunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_get_active_lane_mask` - -""" -function intr_get_active_lane_mask(base::Value, n::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_is_fpclass` - -""" -function intr_is_fpclass(in::Value, bit::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[in, bit] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.is.fpclass", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_lifetime_end` - -""" -function intr_lifetime_end(ptr::Value; size, location=Location()) - _results = IR.Type[] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("size", size),] - - return IR.create_operation( - "llvm.intr.lifetime.end", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_lifetime_start` - -""" -function intr_lifetime_start(ptr::Value; size, location=Location()) - _results = IR.Type[] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("size", size),] - - return IR.create_operation( - "llvm.intr.lifetime.start", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_log10` - -""" -function intr_log10( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.log10", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_log2` - -""" -function intr_log2( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.log2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_log` - -""" -function intr_log( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_masked_store` - -""" -function intr_masked_store( - value::Value, data::Value, mask::Value; alignment, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_matrix_column_major_store` - -""" -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_matrix_transpose` - -""" -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_maxnum` - -""" -function intr_maxnum( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.maxnum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_maximum` - -""" -function intr_maximum( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.maximum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_memcpy_inline` - -""" -function intr_memcpy_inline( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, src, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memcpy.inline", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_memcpy` - -""" -function intr_memcpy( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, src, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memcpy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_memmove` - -""" -function intr_memmove( - dst::Value, src::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, src, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memmove", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_memset` - -""" -function intr_memset( - dst::Value, val::Value, len::Value, isVolatile::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[dst, val, len, isVolatile] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.memset", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_minnum` - -""" -function intr_minnum( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.minnum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_minimum` - -""" -function intr_minimum( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.minimum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_powi` - -""" -function intr_powi( - val::Value, power::Value; res::IR.Type, fastmathFlags=nothing, location=Location() -) - _results = IR.Type[res,] - _operands = Value[val, power] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.powi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_pow` - -""" -function intr_pow( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_prefetch` - -""" -function intr_prefetch( - addr::Value, rw::Value, hint::Value, cache::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[addr, rw, hint, cache] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.prefetch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_roundeven` - -""" -function intr_roundeven( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.roundeven", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_round` - -""" -function intr_round( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.sadd.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_smax` - -""" -function intr_smax( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_smin` - -""" -function intr_smin( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.smul.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.ssub.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_sin` - -""" -function intr_sin( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_sqrt` - -""" -function intr_sqrt( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_stackrestore` - -""" -function intr_stackrestore(ptr::Value; location=Location()) - _results = IR.Type[] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.stackrestore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_stacksave` - -""" -function intr_stacksave(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.stacksave", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_experimental_stepvector` - -""" -function intr_experimental_stepvector(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.experimental.stepvector", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.uadd.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_umax` - -""" -function intr_umax( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_umin` - -""" -function intr_umin( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.umul.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.usub.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_ashr` - -""" -function intr_vp_ashr( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.ashr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_add` - -""" -function intr_vp_add( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_and` - -""" -function intr_vp_and( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fadd` - -""" -function intr_vp_fadd( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fdiv` - -""" -function intr_vp_fdiv( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fmul` - -""" -function intr_vp_fmul( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fneg` - -""" -function intr_vp_fneg(op::Value, mask::Value, evl::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[op, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fneg", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fpext` - -""" -function intr_vp_fpext( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fpext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fptosi` - -""" -function intr_vp_fptosi( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fptosi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fptoui` - -""" -function intr_vp_fptoui( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fptoui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fptrunc` - -""" -function intr_vp_fptrunc( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fptrunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_frem` - -""" -function intr_vp_frem( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.frem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fsub` - -""" -function intr_vp_fsub( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fsub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fma` - -""" -function intr_vp_fma( - op1::Value, - op2::Value, - op3::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[op1, op2, op3, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_inttoptr` - -""" -function intr_vp_inttoptr( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.inttoptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_lshr` - -""" -function intr_vp_lshr( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.lshr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_load` - -""" -function intr_vp_load( - ptr::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[ptr, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_merge` - -""" -function intr_vp_merge( - cond::Value, - true_val::Value, - false_val::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[cond, true_val, false_val, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.merge", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_mul` - -""" -function intr_vp_mul( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_or` - -""" -function intr_vp_or( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_ptrtoint` - -""" -function intr_vp_ptrtoint( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.ptrtoint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_add` - -""" -function intr_vp_reduce_add( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_and` - -""" -function intr_vp_reduce_and( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fadd` - -""" -function intr_vp_reduce_fadd( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fmax` - -""" -function intr_vp_reduce_fmax( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fmin` - -""" -function intr_vp_reduce_fmin( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fmin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fmul` - -""" -function intr_vp_reduce_fmul( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_mul` - -""" -function intr_vp_reduce_mul( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_or` - -""" -function intr_vp_reduce_or( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_smax` - -""" -function intr_vp_reduce_smax( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.smax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_smin` - -""" -function intr_vp_reduce_smin( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.smin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_umax` - -""" -function intr_vp_reduce_umax( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.umax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_umin` - -""" -function intr_vp_reduce_umin( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.umin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_xor` - -""" -function intr_vp_reduce_xor( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sdiv` - -""" -function intr_vp_sdiv( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sext` - -""" -function intr_vp_sext( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sitofp` - -""" -function intr_vp_sitofp( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_srem` - -""" -function intr_vp_srem( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.srem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_select` - -""" -function intr_vp_select( - cond::Value, - true_val::Value, - false_val::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[cond, true_val, false_val, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_shl` - -""" -function intr_vp_shl( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.shl", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_store` - -""" -function intr_vp_store(val::Value, ptr::Value, mask::Value, evl::Value; location=Location()) - _results = IR.Type[] - _operands = Value[val, ptr, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_experimental_vp_strided_load` - -""" -function intr_experimental_vp_strided_load( - ptr::Value, stride::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[ptr, stride, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.experimental.vp.strided.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_experimental_vp_strided_store` - -""" -function intr_experimental_vp_strided_store( - val::Value, ptr::Value, stride::Value, mask::Value, evl::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[val, ptr, stride, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.experimental.vp.strided.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sub` - -""" -function intr_vp_sub( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_trunc` - -""" -function intr_vp_trunc( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.trunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_udiv` - -""" -function intr_vp_udiv( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.udiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_uitofp` - -""" -function intr_vp_uitofp( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.uitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_urem` - -""" -function intr_vp_urem( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.urem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_xor` - -""" -function intr_vp_xor( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_zext` - -""" -function intr_vp_zext( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.zext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vacopy` - -""" -function intr_vacopy(dest_list::Value, src_list::Value; location=Location()) - _results = IR.Type[] - _operands = Value[dest_list, src_list] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vacopy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vaend` - -""" -function intr_vaend(arg_list::Value; location=Location()) - _results = IR.Type[] - _operands = Value[arg_list,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vaend", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vastart` - -""" -function intr_vastart(arg_list::Value; location=Location()) - _results = IR.Type[] - _operands = Value[arg_list,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vastart", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_masked_compressstore` - -""" -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.masked.compressstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.masked.expandload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_masked_scatter` - -""" -function intr_masked_scatter( - value::Value, ptrs::Value, mask::Value; alignment, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_extract` - -""" -function intr_vector_extract(srcvec::Value; res::IR.Type, pos, location=Location()) - _results = IR.Type[res,] - _operands = Value[srcvec,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pos", pos),] - - return IR.create_operation( - "llvm.intr.vector.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_insert` - -""" -function intr_vector_insert( - srcvec::Value, - dstvec::Value; - res=nothing::Union{Nothing,IR.Type}, - pos, - location=Location(), -) - _results = IR.Type[] - _operands = Value[srcvec, dstvec] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pos", pos),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.vector.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_vector_reduce_add` - -""" -function intr_vector_reduce_add(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_and` - -""" -function intr_vector_reduce_and(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fadd` - -""" -function intr_vector_reduce_fadd( - start_value::Value, input::Value; res::IR.Type, reassoc=nothing, location=Location() -) - _results = IR.Type[res,] - _operands = Value[start_value, input] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fmax` - -""" -function intr_vector_reduce_fmax(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fmin` - -""" -function intr_vector_reduce_fmin(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fmul` - -""" -function intr_vector_reduce_fmul( - start_value::Value, input::Value; res::IR.Type, reassoc=nothing, location=Location() -) - _results = IR.Type[res,] - _operands = Value[start_value, input] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_mul` - -""" -function intr_vector_reduce_mul(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_or` - -""" -function intr_vector_reduce_or(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_smax` - -""" -function intr_vector_reduce_smax(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_smin` - -""" -function intr_vector_reduce_smin(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_umax` - -""" -function intr_vector_reduce_umax(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_umin` - -""" -function intr_vector_reduce_umin(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_xor` - -""" -function intr_vector_reduce_xor(operand_0::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vscale` - -""" -function intr_vscale(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vscale", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType -import ..Dialects: namedattribute, operandsegmentsizes - -""" -`barrier0` - -""" -function barrier0(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.barrier0", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ntid_x` - -""" -function read_ptx_sreg_ntid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ntid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ntid_y` - -""" -function read_ptx_sreg_ntid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ntid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ntid_z` - -""" -function read_ptx_sreg_ntid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ntid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ctaid_x` - -""" -function read_ptx_sreg_ctaid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ctaid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ctaid_y` - -""" -function read_ptx_sreg_ctaid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ctaid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ctaid_z` - -""" -function read_ptx_sreg_ctaid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ctaid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`cp_async_commit_group` - -""" -function cp_async_commit_group(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.cp.async.commit.group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`cp_async_shared_global` - -""" -function cp_async_shared_global( - dst::Value, src::Value; size, bypass_l1=nothing, location=Location() -) - _results = IR.Type[] - _operands = Value[dst, src] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("size", size),] - !isnothing(bypass_l1) && push!(_attributes, namedattribute("bypass_l1", bypass_l1)) - - return IR.create_operation( - "nvvm.cp.async.shared.global", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`cp_async_wait_group` - -""" -function cp_async_wait_group(; n, location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("n", n),] - - return IR.create_operation( - "nvvm.cp.async.wait.group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_nctaid_x` - -""" -function read_ptx_sreg_nctaid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.nctaid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_nctaid_y` - -""" -function read_ptx_sreg_nctaid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.nctaid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_nctaid_z` - -""" -function read_ptx_sreg_nctaid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.nctaid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_laneid` - -""" -function read_ptx_sreg_laneid(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.laneid", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`ldmatrix` - -""" -function ldmatrix(ptr::Value; res::IR.Type, num, layout, location=Location()) - _results = IR.Type[res,] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("num", num), namedattribute("layout", layout) - ] - - return IR.create_operation( - "nvvm.ldmatrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mma_sync` - -The `nvvm.mma.sync` operation collectively performs the operation -`D = matmul(A, B) + C` using all threads in a warp. - -All the threads in the warp must execute the same `mma.sync` operation. - -For each possible multiplicand PTX data type, there are one or more possible -instruction shapes given as \"mMnNkK\". The below table describes the posssibilities -as well as the types required for the operands. Note that the data type for -C (the accumulator) and D (the result) can vary independently when there are -multiple possibilities in the \"C/D Type\" column. - -When an optional attribute cannot be immediately inferred from the types of -the operands and the result during parsing or validation, an error will be -raised. - -`b1Op` is only relevant when the binary (b1) type is given to -`multiplicandDataType`. It specifies how the multiply-and-acumulate is -performed and is either `xor_popc` or `and_poc`. The default is `xor_popc`. - -`intOverflowBehavior` is only relevant when the `multiplicandType` attribute -is one of `u8, s8, u4, s4`, this attribute describes how overflow is handled -in the accumulator. When the attribute is `satfinite`, the accumulator values -are clamped in the int32 range on overflow. This is the default behavior. -Alternatively, accumulator behavior `wrapped` can also be specified, in -which case overflow wraps from one end of the range to the other. - -`layoutA` and `layoutB` are required and should generally be set to -`#nvvm.mma_layout` and `#nvvm.mma_layout` respectively, but other -combinations are possible for certain layouts according to the table below. - -``` -| A/B Type | Shape | ALayout | BLayout | A Type | B Type | C/D Type | -|----------|-----------|---------|---------|----------|----------|-------------------| -| f64 | .m8n8k4 | row | col | 1x f64 | 1x f64 | 2x f64 | -| f16 | .m8n8k4 | row/col | row/col | 2x f16x2 | 2x f16x2 | 4x f16x2 or 8xf32 | -| | .m16n8k8 | row | col | 2x f16x2 | 1x f16x2 | 2x f16x2 or 4 f32 | -| | .m16n8k16 | row | col | 4x f16x2 | 2x f16x2 | 2x f16x2 or 4 f32 | -| bf16 | .m16n8k8 | row | col | 2x f16x2 | 1x f16x2 | 2x f16x2 or 4 f32 | -| | .m16n8k16 | row | col | 4x f16x2 | 2x f16x2 | 2x f16x2 or 4 f32 | -| tf32 | .m16n8k4 | row | col | 2x i32 | 1x i32 | 4x f32 | -| | .m16n8k8 | row | col | 4x i32 | 2x i32 | 2x f16x2 or 4 f32 | -| u8/s8 | .m8n8k16 | row | col | 1x i32 | 1x i32 | 2x i32 | -| | .m16n8k16 | row | col | 2x i32 | 1x i32 | 4x i32 | -| | .m16n8k32 | row | col | 4x i32 | 2x i32 | 4x i32 | -| u4/s4 | .m8n8k32 | row | col | 1x i32 | 1x i32 | 2x i32 | -| | m16n8k32 | row | col | 2x i32 | 1x i32 | 4x i32 | -| | m16n8k64 | row | col | 4x i32 | 2x i32 | 4x i32 | -| b1 | m8n8k128 | row | col | 1x i32 | 1x i32 | 2x i32 | -| | m16n8k128 | row | col | 2x i32 | 1x i32 | 4x i32 | -``` - - -# Example -```mlir - -%128 = nvvm.mma.sync A[%120, %121, %122, %123] - B[%124, %125] - C[%126, %127] - {layoutA = #nvvm.mma_layout, - layoutB = #nvvm.mma_layout, - shape = {k = 16 : i32, m = 16 : i32, n = 8 : i32}} - : (vector<2xf16>, vector<2xf16>, vector<2xf16>) - -> !llvm.struct<(vector<2xf16>, vector<2xf16>)> -``` -""" -function mma_sync( - operandA::Vector{Value}, - operandB::Vector{Value}, - operandC::Vector{Value}; - res::IR.Type, - shape, - b1Op=nothing, - intOverflowBehavior=nothing, - layoutA, - layoutB, - multiplicandAPtxType=nothing, - multiplicandBPtxType=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[operandA..., operandB..., operandC...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("shape", shape), - namedattribute("layoutA", layoutA), - namedattribute("layoutB", layoutB), - ] - push!( - _attributes, - operandsegmentsizes([length(operandA), length(operandB), length(operandC)]), - ) - !isnothing(b1Op) && push!(_attributes, namedattribute("b1Op", b1Op)) - !isnothing(intOverflowBehavior) && - push!(_attributes, namedattribute("intOverflowBehavior", intOverflowBehavior)) - !isnothing(multiplicandAPtxType) && - push!(_attributes, namedattribute("multiplicandAPtxType", multiplicandAPtxType)) - !isnothing(multiplicandBPtxType) && - push!(_attributes, namedattribute("multiplicandBPtxType", multiplicandBPtxType)) - - return IR.create_operation( - "nvvm.mma.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`rcp_approx_ftz_f` - -""" -function rcp_approx_ftz_f(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.rcp.approx.ftz.f", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`redux_sync` - -""" -function redux_sync( - val::Value, mask_and_clamp::Value; res::IR.Type, kind, location=Location() -) - _results = IR.Type[res,] - _operands = Value[val, mask_and_clamp] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - - return IR.create_operation( - "nvvm.redux.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`shfl_sync` - -""" -function shfl_sync( - dst::Value, - val::Value, - offset::Value, - mask_and_clamp::Value; - res::IR.Type, - kind, - return_value_and_is_valid=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[dst, val, offset, mask_and_clamp] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - !isnothing(return_value_and_is_valid) && push!( - _attributes, - namedattribute("return_value_and_is_valid", return_value_and_is_valid), - ) - - return IR.create_operation( - "nvvm.shfl.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`bar_warp_sync` - -""" -function bar_warp_sync(mask::Value; location=Location()) - _results = IR.Type[] - _operands = Value[mask,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.bar.warp.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_tid_x` - -""" -function read_ptx_sreg_tid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.tid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_tid_y` - -""" -function read_ptx_sreg_tid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.tid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_tid_z` - -""" -function read_ptx_sreg_tid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.tid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`vote_ballot_sync` - -""" -function vote_ballot_sync(mask::Value, pred::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[mask, pred] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.vote.ballot.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_load` - -""" -function wmma_load( - ptr::Value, - stride::Value; - res::IR.Type, - m, - n, - k, - layout, - eltype, - frag, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[ptr, stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("m", m), - namedattribute("n", n), - namedattribute("k", k), - namedattribute("layout", layout), - namedattribute("eltype", eltype), - namedattribute("frag", frag), - ] - - return IR.create_operation( - "nvvm.wmma.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_mma` - -""" -function wmma_mma( - args::Vector{Value}; - res::IR.Type, - m, - n, - k, - layoutA, - layoutB, - eltypeA, - eltypeB, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("m", m), - namedattribute("n", n), - namedattribute("k", k), - namedattribute("layoutA", layoutA), - namedattribute("layoutB", layoutB), - namedattribute("eltypeA", eltypeA), - namedattribute("eltypeB", eltypeB), - ] - - return IR.create_operation( - "nvvm.wmma.mma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_store` - -""" -function wmma_store( - ptr::Value, - args::Vector{Value}, - stride::Value; - m, - n, - k, - layout, - eltype, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ptr, args..., stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("m", m), - namedattribute("n", n), - namedattribute("k", k), - namedattribute("layout", layout), - namedattribute("eltype", eltype), - ] - - return IR.create_operation( - "nvvm.wmma.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_warpsize` - -""" -function read_ptx_sreg_warpsize(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.warpsize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType -import ..Dialects: namedattribute, operandsegmentsizes - -""" -`barrier` - -""" -function barrier(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.barrier", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_dim_x` - -""" -function workgroup_dim_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.dim.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_dim_y` - -""" -function workgroup_dim_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.dim.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_dim_z` - -""" -function workgroup_dim_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.dim.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_id_x` - -""" -function workgroup_id_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.id.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_id_y` - -""" -function workgroup_id_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.id.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_id_z` - -""" -function workgroup_id_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.id.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`grid_dim_x` - -""" -function grid_dim_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.grid.dim.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`grid_dim_y` - -""" -function grid_dim_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.grid.dim.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`grid_dim_z` - -""" -function grid_dim_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.grid.dim.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`buffer_load` - -""" -function buffer_load( - rsrc::Value, - vindex::Value, - offset::Value, - glc::Value, - slc::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[rsrc, vindex, offset, glc, slc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.buffer.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`buffer_store` - -""" -function buffer_store( - vdata::Value, - rsrc::Value, - vindex::Value, - offset::Value, - glc::Value, - slc::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, vindex, offset, glc, slc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.buffer.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_atomic_fadd` - -""" -function raw_buffer_atomic_fadd( - vdata::Value, - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.atomic.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_load` - -""" -function raw_buffer_load( - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_store` - -""" -function raw_buffer_store( - vdata::Value, - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workitem_id_x` - -""" -function workitem_id_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workitem.id.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workitem_id_y` - -""" -function workitem_id_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workitem.id.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workitem_id_z` - -""" -function workitem_id_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workitem.id.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x16bf16_1k` - -""" -function mfma_f32_16x16x16bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x16bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x16f16` - -""" -function mfma_f32_16x16x16f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x16f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x1f32` - -""" -function mfma_f32_16x16x1f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x1f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x2bf16` - -""" -function mfma_f32_16x16x2bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x2bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x4bf16_1k` - -""" -function mfma_f32_16x16x4bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x4bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x4f16` - -""" -function mfma_f32_16x16x4f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x4f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x4f32` - -""" -function mfma_f32_16x16x4f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x4f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x8_xf32` - -""" -function mfma_f32_16x16x8_xf32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x8.xf32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x8bf16` - -""" -function mfma_f32_16x16x8bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x8bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x1f32` - -""" -function mfma_f32_32x32x1f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x1f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x2bf16` - -""" -function mfma_f32_32x32x2bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x2bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x2f32` - -""" -function mfma_f32_32x32x2f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x2f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4_xf32` - -""" -function mfma_f32_32x32x4_xf32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4.xf32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4bf16` - -""" -function mfma_f32_32x32x4bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4bf16_1k` - -""" -function mfma_f32_32x32x4bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4f16` - -""" -function mfma_f32_32x32x4f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x8bf16_1k` - -""" -function mfma_f32_32x32x8bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x8bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x8f16` - -""" -function mfma_f32_32x32x8f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x8f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x1f32` - -""" -function mfma_f32_4x4x1f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x1f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x2bf16` - -""" -function mfma_f32_4x4x2bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x2bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x4bf16_1k` - -""" -function mfma_f32_4x4x4bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x4bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x4f16` - -""" -function mfma_f32_4x4x4f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x4f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f64_16x16x4f64` - -""" -function mfma_f64_16x16x4f64(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f64.16x16x4f64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f64_4x4x4f64` - -""" -function mfma_f64_4x4x4f64(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f64.4x4x4f64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_16x16x16i8` - -""" -function mfma_i32_16x16x16i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.16x16x16i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_16x16x32_i8` - -""" -function mfma_i32_16x16x32_i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.16x16x32.i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_16x16x4i8` - -""" -function mfma_i32_16x16x4i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.16x16x4i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_32x32x16_i8` - -""" -function mfma_i32_32x32x16_i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.32x32x16.i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_32x32x4i8` - -""" -function mfma_i32_32x32x4i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.32x32x4i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_32x32x8i8` - -""" -function mfma_i32_32x32x8i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.32x32x8i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_4x4x4i8` - -""" -function mfma_i32_4x4x4i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.4x4x4i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function zext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.zext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Linalg.jl b/src/Dialects/16/Linalg.jl index 41ff99a9..a94e1018 100644 --- a/src/Dialects/16/Linalg.jl +++ b/src/Dialects/16/Linalg.jl @@ -1,7 +1,6 @@ module linalg -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -74,27 +73,22 @@ in `linalg` generic ops. It returns values to the immediately enclosing linalg.yield %f0, %f1 : f32, f32 ``` """ -function yield(values::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[values...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "linalg.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(values; location=Location()) + results = IR.Type[] + operands = Value[value.(values)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "linalg.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -103,29 +97,19 @@ import ..Dialects: namedattribute, operandsegmentsizes 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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.batch_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -137,29 +121,19 @@ dimensions transposed. Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. """ -function batch_matmul_transpose_b( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{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_transpose_b", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_matmul_transpose_b(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matmul_transpose_b", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -169,29 +143,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.batch_matvec", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_matvec(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -203,29 +167,19 @@ The partial multiplication results are reduced into a 2D output. Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. """ -function batch_reduce_matmul( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{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_reduce_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_reduce_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_reduce_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -242,29 +196,18 @@ Broadcast the input into the given shape by adding `dimensions`. dimensions = [1] ``` """ -function broadcast( - input::Value, - init::Value; - result::Vector{IR.Type}, - dimensions, - region::Region, - location=Location(), -) - _results = IR.Type[result...,] - _operands = Value[input, init] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dimensions", dimensions),] - - return IR.create_operation( - "linalg.broadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function broadcast(input, init; result::Vector{IR.Type}, dimensions, region::Region, location=Location()) + results = IR.Type[result..., ] + operands = Value[value(input), value(init), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimensions", dimensions), ] + + IR.create_operation( + "linalg.broadcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -278,33 +221,21 @@ 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_1d_ncw_fcw( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_1d_ncw_fcw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_1d_ncw_fcw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_1d_ncw_fcw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -314,33 +245,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_1d_nwc_wcf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_1d_nwc_wcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_1d_nwc_wcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -350,29 +269,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_1d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_1d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_1d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -386,33 +295,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nchw_fchw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nchw_fchw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nchw_fchw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -426,33 +323,21 @@ 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_ngchw_fgchw( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_ngchw_fgchw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_ngchw_fgchw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_ngchw_fgchw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -466,33 +351,21 @@ 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_fhwc( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nhwc_fhwc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nhwc_fhwc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nhwc_fhwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -506,33 +379,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nhwc_hwcf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nhwc_hwcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nhwc_hwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -547,33 +408,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nhwc_hwcf_q", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nhwc_hwcf_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nhwc_hwcf_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -583,29 +432,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -615,33 +454,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_3d_ndhwc_dhwcf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_3d_ndhwc_dhwcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_3d_ndhwc_dhwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -652,33 +479,21 @@ Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. This includes the zero point offsets common to quantized operations. """ -function conv_3d_ndhwc_dhwcf_q( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_3d_ndhwc_dhwcf_q", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_3d_ndhwc_dhwcf_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_3d_ndhwc_dhwcf_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -688,29 +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 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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_3d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_3d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -720,31 +525,20 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function copy( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - cast=nothing, - 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)])) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function copy(inputs, outputs; result_tensors::Vector{IR.Type}, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.copy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -755,33 +549,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_1d_nwc_wc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_1d_nwc_wc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_1d_nwc_wc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -791,33 +573,21 @@ 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_1d_nwc_wcm( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_1d_nwc_wcm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_1d_nwc_wcm(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_1d_nwc_wcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -828,33 +598,21 @@ Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions. """ -function depthwise_conv_2d_nchw_chw( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nchw_chw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nchw_chw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nchw_chw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -865,33 +623,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -901,33 +647,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwc_q", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwc_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -937,33 +671,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwcm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwcm(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -973,33 +695,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwcm_q", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwcm_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1010,33 +720,21 @@ Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions. """ -function depthwise_conv_3d_ndhwc_dhwc( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_3d_ndhwc_dhwc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_3d_ndhwc_dhwc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_3d_ndhwc_dhwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1046,33 +744,21 @@ 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_3d_ndhwc_dhwcm( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_3d_ndhwc_dhwcm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_3d_ndhwc_dhwcm(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_3d_ndhwc_dhwcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1082,29 +768,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.dot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dot(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.dot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1114,33 +790,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function elemwise_binary( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - fun=nothing, - cast=nothing, - 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)])) - !isnothing(fun) && push!(_attributes, namedattribute("fun", fun)) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.elemwise_binary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function elemwise_binary(inputs, outputs; result_tensors::Vector{IR.Type}, fun=nothing, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(fun) && push!(attributes, namedattribute("fun", fun)) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.elemwise_binary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1150,33 +814,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function elemwise_unary( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - fun=nothing, - cast=nothing, - 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)])) - !isnothing(fun) && push!(_attributes, namedattribute("fun", fun)) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.elemwise_unary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function elemwise_unary(inputs, outputs; result_tensors::Vector{IR.Type}, fun=nothing, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(fun) && push!(attributes, namedattribute("fun", fun)) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.elemwise_unary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1187,29 +839,19 @@ Works for arbitrary ranked output tensors since the operation performs scalar accesses only and is thus rank polymorphic. Numeric casting is performed on the value operand, promoting it to the same data type as the output. """ -function fill( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{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", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fill(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.fill", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1224,29 +866,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.fill_rng_2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fill_rng_2d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -1349,39 +981,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,] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("indexing_maps", indexing_maps), - namedattribute("iterator_types", iterator_types), - ] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - !isnothing(doc) && push!(_attributes, namedattribute("doc", doc)) - !isnothing(library_call) && - push!(_attributes, namedattribute("library_call", library_call)) - - return IR.create_operation( - "linalg.generic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generic(inputs, outputs; 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[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(doc) && push!(attributes, namedattribute("doc", doc)) + !isnothing(library_call) && push!(attributes, namedattribute("library_call", library_call)) + + IR.create_operation( + "linalg.generic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1412,28 +1026,18 @@ The example above will be printed as: outs(%init: tensor<64xf32>) ``` """ -function map( - inputs::Vector{Value}, - init::Value; - result::Vector{IR.Type}, - mapper::Region, - location=Location(), -) - _results = IR.Type[result...,] - _operands = Value[inputs..., init] - _owned_regions = Region[mapper,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "linalg.map", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function map(inputs, init; result::Vector{IR.Type}, mapper::Region, location=Location()) + results = IR.Type[result..., ] + operands = Value[value.(inputs)..., value(init), ] + owned_regions = Region[mapper, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "linalg.map", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1443,31 +1047,20 @@ 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}, - cast=nothing, - 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)])) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul(inputs, outputs; result_tensors::Vector{IR.Type}, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1477,31 +1070,20 @@ 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_transpose_b( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - cast=nothing, - 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)])) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.matmul_transpose_b", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul_transpose_b(inputs, outputs; result_tensors::Vector{IR.Type}, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.matmul_transpose_b", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1511,29 +1093,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matmul_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matmul_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1543,29 +1115,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matvec", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matvec(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1580,29 +1142,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.mmt4d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mmt4d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.mmt4d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1612,33 +1164,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nchw_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nchw_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nchw_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1652,33 +1192,21 @@ Layout: Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nchw_sum( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nchw_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nchw_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nchw_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1688,33 +1216,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_ncw_max( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ncw_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ncw_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ncw_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1728,33 +1244,21 @@ Layout: Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_ncw_sum( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ncw_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ncw_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ncw_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1764,33 +1268,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ndhwc_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ndhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1800,33 +1292,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ndhwc_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_min(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ndhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1836,33 +1316,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ndhwc_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ndhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1872,33 +1340,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1908,33 +1364,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_max_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_max_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_max_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1944,33 +1388,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_min(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1980,33 +1412,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_min_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_min_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_min_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2020,33 +1440,21 @@ Layout: 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2056,33 +1464,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nwc_max( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nwc_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nwc_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2092,33 +1488,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nwc_max_unsigned( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nwc_max_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nwc_max_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nwc_max_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2128,33 +1512,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nwc_min( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nwc_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nwc_min(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2164,33 +1536,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nwc_min_unsigned( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nwc_min_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nwc_min_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nwc_min_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2204,33 +1564,21 @@ Layout: Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nwc_sum( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nwc_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nwc_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2242,29 +1590,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.quantized_batch_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function quantized_batch_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -2276,29 +1614,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.quantized_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function quantized_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.quantized_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2333,29 +1661,18 @@ The example above will be printed as: dimensions = [1] ``` """ -function reduce( - inputs::Vector{Value}, - inits::Vector{Value}; - result_0::Vector{IR.Type}, - dimensions, - combiner::Region, - location=Location(), -) - _results = IR.Type[result_0...,] - _operands = Value[inputs..., inits...] - _owned_regions = Region[combiner,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dimensions", dimensions),] - - return IR.create_operation( - "linalg.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce(inputs, inits; result_0::Vector{IR.Type}, dimensions, combiner::Region, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(inputs)..., value.(inits)..., ] + owned_regions = Region[combiner, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimensions", dimensions), ] + + IR.create_operation( + "linalg.reduce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2376,29 +1693,18 @@ operation only that produces a transposed \"view\". permutation = [1, 0] ``` """ -function transpose( - input::Value, - init::Value; - result::Vector{IR.Type}, - permutation, - region::Region, - location=Location(), -) - _results = IR.Type[result...,] - _operands = Value[input, init] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("permutation", permutation),] - - return IR.create_operation( - "linalg.transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(input, init; result::Vector{IR.Type}, permutation, region::Region, location=Location()) + results = IR.Type[result..., ] + operands = Value[value(input), value(init), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation", permutation), ] + + IR.create_operation( + "linalg.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2408,29 +1714,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.vecmat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vecmat(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.vecmat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/MLProgram.jl b/src/Dialects/16/MLProgram.jl index 877a3cde..a261f33d 100644 --- a/src/Dialects/16/MLProgram.jl +++ b/src/Dialects/16/MLProgram.jl @@ -1,7 +1,6 @@ module ml_program -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -110,28 +109,18 @@ without additional consideration to evaluation order constraints. ordering (%token -> !ml_program.token) : tensor ``` """ -function global_load_graph( - consumeTokens::Vector{Value}; - result::IR.Type, - produceToken::IR.Type, - global_, - location=Location(), -) - _results = IR.Type[result, produceToken] - _operands = Value[consumeTokens...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("global", global_),] - - return IR.create_operation( - "ml_program.global_load_graph", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function global_load_graph(consumeTokens; result::IR.Type, produceToken::IR.Type, global_, location=Location()) + results = IR.Type[result, produceToken, ] + operands = Value[value.(consumeTokens)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] + + IR.create_operation( + "ml_program.global_load_graph", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -256,28 +245,18 @@ without additional consideration to evaluation order constraints. ordering (%in_token -> !ml_program.token) : tensor ``` """ -function global_store_graph( - value::Value, - consumeTokens::Vector{Value}; - produceToken::IR.Type, - global_, - location=Location(), -) - _results = IR.Type[produceToken,] - _operands = Value[value, consumeTokens...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("global", global_),] - - return IR.create_operation( - "ml_program.global_store_graph", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function global_store_graph(value, consumeTokens; produceToken::IR.Type, global_, location=Location()) + results = IR.Type[produceToken, ] + operands = Value[value(value), value.(consumeTokens)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] + + IR.create_operation( + "ml_program.global_store_graph", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -301,22 +280,18 @@ without additional consideration to evaluation order constraints. See ml_program.global_store @foobar = %0 : tensor ``` """ -function global_store(value::Value; global_, location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("global", global_),] - - return IR.create_operation( - "ml_program.global_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function global_store(value; global_, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] + + IR.create_operation( + "ml_program.global_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -329,22 +304,18 @@ The operation takes variable number of operands and produces no results. The operand number and types must match the signature of the function that contains the operation. """ -function output(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "ml_program.output", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function output(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "ml_program.output", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -357,22 +328,18 @@ The operation takes variable number of operands and produces no results. The operand number and types must match the signature of the function that contains the operation. """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "ml_program.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "ml_program.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Math.jl b/src/Dialects/16/Math.jl index a16123dc..a4b71cfb 100644 --- a/src/Dialects/16/Math.jl +++ b/src/Dialects/16/Math.jl @@ -1,7 +1,6 @@ module math -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,29 +17,20 @@ of the same type. %a = math.absf %b : f64 ``` """ -function absf( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.absf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function absf(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.absf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -58,23 +48,19 @@ same type. %a = math.absi %b : i64 ``` """ -function absi(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.absi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function absi(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.absi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -105,30 +91,20 @@ See also https://en.wikipedia.org/wiki/Atan2 %a = math.atan2 %b, %c : f32 ``` """ -function atan2( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.atan2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atan2(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.atan2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -152,29 +128,20 @@ one result of the same type. It has no standard attributes. %a = math.atan %b : f64 ``` """ -function atan( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.atan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atan(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.atan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -194,29 +161,20 @@ of the same type. It has no standard attributes. Note: This op is not equivalent to powf(..., 1/3.0). """ -function cbrt( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.cbrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cbrt(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.cbrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -240,29 +198,20 @@ result of the same type. It has no standard attributes. %a = math.ceil %b : f64 ``` """ -function ceil( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceil(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.ceil", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -287,30 +236,20 @@ tensor or vector). It has no standard attributes. %a = math.copysign %b, %c : f64 ``` """ -function copysign( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.copysign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function copysign(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.copysign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -334,29 +273,20 @@ result of the same type. It has no standard attributes. %a = math.cos %b : f64 ``` """ -function cos( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cos(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -373,23 +303,19 @@ It operates on scalar, tensor or vector. %a = math.ctlz %b : i32 ``` """ -function ctlz(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ctlz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ctlz(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ctlz", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -406,23 +332,19 @@ It operates on scalar, tensor or vector. %a = math.cttz %b : i32 ``` """ -function cttz(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.cttz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cttz(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.cttz", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -439,23 +361,19 @@ It operates on scalar, tensor or vector. %a = math.ctpop %b : i32 ``` """ -function ctpop(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ctpop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ctpop(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ctpop", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -479,29 +397,20 @@ the same type. It has no standard attributes. %a = math.erf %b : f64 ``` """ -function erf( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.erf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function erf(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.erf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -525,29 +434,20 @@ attributes. %a = math.exp2 %b : f64 ``` """ -function exp2( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.exp2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp2(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.exp2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -573,29 +473,20 @@ standard attributes. %a = math.expm1 %b : f64 ``` """ -function expm1( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.expm1", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function expm1(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.expm1", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -619,29 +510,20 @@ attributes. %a = math.exp %b : f64 ``` """ -function exp( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -677,30 +559,20 @@ The result is a vector of: %a = math.fpowi %base, %power : f64, i32 ``` """ -function fpowi( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.fpowi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fpowi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.fpowi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -724,29 +596,20 @@ result of the same type. It has no standard attributes. %a = math.floor %b : f64 ``` """ -function floor( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function floor(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.floor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -775,31 +638,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fma(a, b, c; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.fma", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -823,25 +675,19 @@ must have the same type. %a = math.ipowi %b, %c : i32 ``` """ -function ipowi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ipowi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ipowi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ipowi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -859,29 +705,20 @@ the same type. %y = math.log10 %x : f64 ``` """ -function log10( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.log10", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log10(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.log10", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -901,29 +738,20 @@ log1p(x) := log(1 + x) %y = math.log1p %x : f64 ``` """ -function log1p( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.log1p", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log1p(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.log1p", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -941,29 +769,20 @@ the same type. %y = math.log2 %x : f64 ``` """ -function log2( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.log2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log2(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.log2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -981,29 +800,20 @@ the same type. %y = math.log %x : f64 ``` """ -function log( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1027,30 +837,20 @@ must have the same type. %a = math.powf %b, %c : f64 ``` """ -function powf( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.powf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function powf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.powf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1077,29 +877,20 @@ rounding direction. %a = math.roundeven %b : f64 ``` """ -function roundeven( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.roundeven", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function roundeven(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.roundeven", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1126,29 +917,20 @@ rounding direction. %a = math.round %b : f64 ``` """ -function round( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function round(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.round", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1166,29 +948,20 @@ one result of the same type. It has no standard attributes. %a = math.rsqrt %b : f64 ``` """ -function rsqrt( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rsqrt(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.rsqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1212,29 +985,20 @@ result of the same type. It has no standard attributes. %a = math.sin %b : f64 ``` """ -function sin( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sin(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1252,29 +1016,20 @@ the same type. It has no standard attributes. %a = math.sqrt %b : f64 ``` """ -function sqrt( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sqrt(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1292,29 +1047,20 @@ result of the same type. It has no standard attributes. %a = math.tan %b : f64 ``` """ -function tan( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.tan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tan(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.tan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1332,29 +1078,20 @@ result of the same type. It has no standard attributes. %a = math.tanh %b : f64 ``` """ -function tanh( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tanh(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1380,29 +1117,20 @@ than the operand, regardless of the current rounding direction. %a = math.trunc %b : f64 ``` """ -function trunc( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.trunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function trunc(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.trunc", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/16/MemRef.jl b/src/Dialects/16/MemRef.jl index 60dca316..03c80f3c 100644 --- a/src/Dialects/16/MemRef.jl +++ b/src/Dialects/16/MemRef.jl @@ -1,7 +1,6 @@ module memref -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -14,22 +13,18 @@ the buffer isn\'t aligned to the given alignment, the behavior is undefined. This operation doesn\'t affect the semantics of a correct program. It\'s for optimization only, and the optimization is best-effort. """ -function assume_alignment(memref::Value; alignment, location=Location()) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "memref.assume_alignment", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assume_alignment(memref; alignment, location=Location()) + results = IR.Type[] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "memref.assume_alignment", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -50,30 +45,19 @@ 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=nothing::Union{Nothing,IR.Type}, - kind, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "memref.atomic_rmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atomic_rmw(value, memref, indices; result=nothing::Union{Nothing, IR.Type}, kind, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "memref.atomic_rmw", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -83,22 +67,18 @@ end \"memref.atomic_yield\" yields an SSA value from a GenericAtomicRMWOp region. """ -function atomic_yield(result::Value; location=Location()) - _results = IR.Type[] - _operands = Value[result,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.atomic_yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_yield(result; location=Location()) + results = IR.Type[] + operands = Value[value(result), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.atomic_yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -116,22 +96,18 @@ memref.copy %arg0, %arg1 : memref to memref Source and destination are expected to have the same element type and shape. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function copy(source, target; location=Location()) + results = IR.Type[] + operands = Value[value(source), value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.copy", location; + operands, owned_regions, successors, attributes, + results=results, + 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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.generic_atomic_rmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generic_atomic_rmw(memref, indices; result::IR.Type, atomic_body::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[atomic_body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.generic_atomic_rmw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -222,28 +188,18 @@ techniques. This is possible because of the [restrictions on dimensions and symbols](Affine.md/#restrictions-on-dimensions-and-symbols) in these contexts. """ -function load( - memref::Value, - indices::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "memref.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function load(memref, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -288,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands)])) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.alloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloc(dynamicSizes, symbolOperands; memref::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "memref.alloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -352,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands)])) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.alloca", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca(dynamicSizes, symbolOperands; memref::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "memref.alloca", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -444,22 +380,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()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.alloca_scope.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca_scope_return(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.alloca_scope.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -519,22 +451,18 @@ Erase rank information. %5 = memref.cast %1 : memref<4x?xf32> to memref<*xf32> ``` """ -function cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -581,22 +509,18 @@ only if the corresponding start dimension in the source type is dynamic. Note: This op currently assumes that the inner strides are of the source/result layout map are the faster-varying ones. """ -function collapse_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function collapse_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "memref.collapse_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -615,22 +539,18 @@ alloc\'d memref (e.g. memrefs returned by `view` operations). memref.dealloc %0 : memref<8x64xf32, affine_map<(d0, d1) -> (d0, d1), 1>> ``` """ -function dealloc(memref::Value; location=Location()) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dealloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dealloc(memref; location=Location()) + results = IR.Type[] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dealloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -659,25 +579,19 @@ The specified memref type is that of the first operand. %y = \"memref.dim\"(%A, %c1) : (memref<4 x ? x f32>, index) -> index ``` """ -function dim( - source::Value, index::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[source, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "memref.dim", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function dim(source, index; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "memref.dim", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -728,22 +642,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dma_start", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dma_start(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dma_start", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -767,24 +677,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() -) - _results = IR.Type[] - _operands = Value[tagMemRef, tagIndices..., numElements] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dma_wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dma_wait(tagMemRef, tagIndices, numElements; location=Location()) + results = IR.Type[] + operands = Value[value(tagMemRef), value.(tagIndices)..., value(numElements), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dma_wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -830,22 +734,18 @@ group. Same for strides. Note: This op currently assumes that the inner strides are of the source/result layout map are the faster-varying ones. """ -function expand_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "memref.expand_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -871,25 +771,19 @@ as a pointer is explicitly discouraged. call @foo(%2) : (!llvm.ptr) ->() ``` """ -function extract_aligned_pointer_as_index( - source::Value; aligned_pointer=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(aligned_pointer) && push!(_results, aligned_pointer) - - return IR.create_operation( - "memref.extract_aligned_pointer_as_index", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extract_aligned_pointer_as_index(source; aligned_pointer=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(aligned_pointer) && push!(results, aligned_pointer) + + IR.create_operation( + "memref.extract_aligned_pointer_as_index", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -937,33 +831,22 @@ This makes lowering more progressive and brings the following benefits: : memref to memref ``` """ -function extract_strided_metadata( - source::Value; - base_buffer=nothing::Union{Nothing,IR.Type}, - offset=nothing::Union{Nothing,IR.Type}, - sizes=nothing::Union{Nothing,Vector{IR.Type}}, - strides=nothing::Union{Nothing,Vector{IR.Type}}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(base_buffer) && push!(_results, base_buffer) - !isnothing(offset) && push!(_results, offset) - !isnothing(sizes) && push!(_results, sizes...) - !isnothing(strides) && push!(_results, strides...) - - return IR.create_operation( - "memref.extract_strided_metadata", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extract_strided_metadata(source; base_buffer=nothing::Union{Nothing, IR.Type}, offset=nothing::Union{Nothing, IR.Type}, sizes=nothing::Union{Nothing, Vector{IR.Type}}, strides=nothing::Union{Nothing, Vector{IR.Type}}, location=Location()) + results = IR.Type[] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(base_buffer) && push!(results, base_buffer) + !isnothing(offset) && push!(results, offset) + !isnothing(sizes) && push!(results, sizes...) + !isnothing(strides) && push!(results, strides...) + + IR.create_operation( + "memref.extract_strided_metadata", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1091,33 +974,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function prefetch(memref, indices; isWrite, localityHint, isDataCache, location=Location()) + results = IR.Type[] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1133,23 +1001,19 @@ The `memref.rank` operation takes a memref operand and returns its rank. %1 = memref.rank %arg1 : memref ``` """ -function rank(memref::Value; result_0=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result_0) && push!(_results, result_0) - - return IR.create_operation( - "memref.rank", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rank(memref; result_0=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result_0) && push!(results, result_0) + + IR.create_operation( + "memref.rank", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1211,30 +1075,20 @@ behavior. %5 = memref.load %old[%index] // undefined behavior ``` """ -function realloc( - source::Value, - dynamicResultSize=nothing::Union{Nothing,Value}; - result_0::IR.Type, - alignment=nothing, - location=Location(), -) - _results = IR.Type[result_0,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(dynamicResultSize) && push!(_operands, dynamicResultSize) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.realloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function realloc(source, dynamicResultSize=nothing; result_0::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dynamicResultSize) && push!(operands, value(dynamicResultSize)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "memref.realloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1276,40 +1130,19 @@ means that `%dst`\'s descriptor will be: %dst.strides = %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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reinterpret_cast(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "memref.reinterpret_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1348,22 +1181,18 @@ Result type is unranked. : (memref<*xf32>, memref) to memref<*xf32> ``` """ -function reshape(source::Value, shape::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source, shape] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(source, shape; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1397,22 +1226,18 @@ techniques. This is possible because of the [restrictions on dimensions and symbols](Affine.md/#restrictions-on-dimensions-and-symbols) in these contexts. """ -function store(value::Value, memref::Value, indices::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, memref, indices; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1429,22 +1254,18 @@ transformation. %1 = memref.transpose %0 (i, j) -> (j, i) : memref to memref (d1 * s0 + d0)>> ``` """ -function transpose(in::Value; result_0::IR.Type, permutation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(in; result_0::IR.Type, permutation, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation", permutation), ] + + IR.create_operation( + "memref.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1486,28 +1307,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.view", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function view(source, byte_shift, sizes; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(source), value(byte_shift), value.(sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.view", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1645,40 +1456,19 @@ Example 5: memref<8x16x4xf32> to memref<6x3xf32, strided<[4, 1], offset: 210>> ``` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subview(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "memref.subview", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1697,22 +1487,18 @@ element types of these must match, and are specified by the memref type. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.tensor_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tensor_store(tensor, memref; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.tensor_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/NVGPU.jl b/src/Dialects/16/NVGPU.jl index 887d8fe9..0323622f 100644 --- a/src/Dialects/16/NVGPU.jl +++ b/src/Dialects/16/NVGPU.jl @@ -1,7 +1,6 @@ module nvgpu -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -54,40 +53,21 @@ nvgpu.device_async_wait %token2 memref<4x5xf32> to memref<2x7x5xf32, 3> ``` """ -function device_async_copy( - dst::Value, - dstIndices::Vector{Value}, - src::Value, - srcIndices::Vector{Value}, - srcElements=nothing::Union{Nothing,Value}; - asyncToken::IR.Type, - dstElements, - bypassL1=nothing, - location=Location(), -) - _results = IR.Type[asyncToken,] - _operands = Value[dst, dstIndices..., src, srcIndices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dstElements", dstElements),] - !isnothing(srcElements) && push!(_operands, srcElements) - push!( - _attributes, - operandsegmentsizes([ - 1, length(dstIndices), 1, length(srcIndices), isnothing(srcElements) ? 0 : 1 - ]), - ) - !isnothing(bypassL1) && push!(_attributes, namedattribute("bypassL1", bypassL1)) - - return IR.create_operation( - "nvgpu.device_async_copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function device_async_copy(dst, dstIndices, src, srcIndices, srcElements=nothing; asyncToken::IR.Type, dstElements, bypassL1=nothing, location=Location()) + results = IR.Type[asyncToken, ] + operands = Value[value(dst), value.(dstIndices)..., value(src), value.(srcIndices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dstElements", dstElements), ] + !isnothing(srcElements) && push!(operands, value(srcElements)) + push!(attributes, operandsegmentsizes([1, length(dstIndices), 1, length(srcIndices), (srcElements==nothing) ? 0 : 1])) + !isnothing(bypassL1) && push!(attributes, namedattribute("bypassL1", bypassL1)) + + IR.create_operation( + "nvgpu.device_async_copy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -111,24 +91,18 @@ Groups are executed in the order they are created. %0 = nvgpu.device_async_create_group ``` """ -function device_async_create_group( - inputTokens::Vector{Value}; asyncToken::IR.Type, location=Location() -) - _results = IR.Type[asyncToken,] - _operands = Value[inputTokens...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvgpu.device_async_create_group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function device_async_create_group(inputTokens; asyncToken::IR.Type, location=Location()) + results = IR.Type[asyncToken, ] + operands = Value[value.(inputTokens)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "nvgpu.device_async_create_group", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -147,23 +121,19 @@ groups uncompleted when the wait can unblock the thread. nvgpu.device_async_wait %0 ``` """ -function device_async_wait(asyncDependencies::Value; numGroups=nothing, location=Location()) - _results = IR.Type[] - _operands = Value[asyncDependencies,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(numGroups) && push!(_attributes, namedattribute("numGroups", numGroups)) - - return IR.create_operation( - "nvgpu.device_async_wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function device_async_wait(asyncDependencies; numGroups=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(asyncDependencies), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(numGroups) && push!(attributes, namedattribute("numGroups", numGroups)) + + IR.create_operation( + "nvgpu.device_async_wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -185,31 +155,18 @@ https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-mat memref -> vector<4x2xf16> ``` """ -function ldmatrix( - srcMemref::Value, - indices::Vector{Value}; - res::IR.Type, - transpose, - numTiles, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[srcMemref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("transpose", transpose), namedattribute("numTiles", numTiles) - ] - - return IR.create_operation( - "nvgpu.ldmatrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ldmatrix(srcMemref, indices; res::IR.Type, transpose, numTiles, location=Location()) + results = IR.Type[res, ] + operands = Value[value(srcMemref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("transpose", transpose), namedattribute("numTiles", numTiles), ] + + IR.create_operation( + "nvgpu.ldmatrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -237,36 +194,20 @@ nvgpu.mma.sp.sync (%a, %b, %c) metadata (%meta) {mmaShape = [16, 8, 32]} : (vector<4x2xf16>, vector<2x2xf16>, vector<2x2xf16>) -> vector<2x2xf16> ``` """ -function mma_sp_sync( - matrixA::Value, - matrixB::Value, - matrixC::Value, - sparseMetadata::Value; - res::IR.Type, - mmaShape, - sparsitySelector=nothing, - tf32Enabled=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[matrixA, matrixB, matrixC, sparseMetadata] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mmaShape", mmaShape),] - !isnothing(sparsitySelector) && - push!(_attributes, namedattribute("sparsitySelector", sparsitySelector)) - !isnothing(tf32Enabled) && - push!(_attributes, namedattribute("tf32Enabled", tf32Enabled)) - - return IR.create_operation( - "nvgpu.mma.sp.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mma_sp_sync(matrixA, matrixB, matrixC, sparseMetadata; res::IR.Type, mmaShape, sparsitySelector=nothing, tf32Enabled=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(matrixA), value(matrixB), value(matrixC), value(sparseMetadata), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mmaShape", mmaShape), ] + !isnothing(sparsitySelector) && push!(attributes, namedattribute("sparsitySelector", sparsitySelector)) + !isnothing(tf32Enabled) && push!(attributes, namedattribute("tf32Enabled", tf32Enabled)) + + IR.create_operation( + "nvgpu.mma.sp.sync", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -292,32 +233,19 @@ This operation is meant to follow the semantic of described here: (vector<4x2xf16>, vector<2x2xf16>, vector<2x2xf32>) -> vector<2x2xf32> ``` """ -function mma_sync( - matrixA::Value, - matrixB::Value, - matrixC::Value; - res::IR.Type, - mmaShape, - tf32Enabled=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[matrixA, matrixB, matrixC] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mmaShape", mmaShape),] - !isnothing(tf32Enabled) && - push!(_attributes, namedattribute("tf32Enabled", tf32Enabled)) - - return IR.create_operation( - "nvgpu.mma.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mma_sync(matrixA, matrixB, matrixC; res::IR.Type, mmaShape, tf32Enabled=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(matrixA), value(matrixB), value(matrixC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mmaShape", mmaShape), ] + !isnothing(tf32Enabled) && push!(attributes, namedattribute("tf32Enabled", tf32Enabled)) + + IR.create_operation( + "nvgpu.mma.sync", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/OpenACC.jl b/src/Dialects/16/OpenACC.jl index 0779ee39..36131c44 100644 --- a/src/Dialects/16/OpenACC.jl +++ b/src/Dialects/16/OpenACC.jl @@ -1,7 +1,6 @@ module acc -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -22,70 +21,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function data(ifCond=nothing; copyOperands, copyinOperands, copyinReadonlyOperands, copyoutOperands, copyoutZeroOperands, createOperands, createZeroOperands, noCreateOperands, presentOperands, deviceptrOperands, attachOperands, defaultAttr=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(copyOperands)..., value.(copyinOperands)..., value.(copyinReadonlyOperands)..., value.(copyoutOperands)..., value.(copyoutZeroOperands)..., value.(createOperands)..., value.(createZeroOperands)..., value.(noCreateOperands)..., value.(presentOperands)..., value.(deviceptrOperands)..., value.(attachOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(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), ])) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + + IR.create_operation( + "acc.data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -100,58 +50,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function enter_data(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, copyinOperands, createOperands, createZeroOperands, attachOperands, async=nothing, wait=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(copyinOperands)..., value.(createOperands)..., value.(createZeroOperands)..., value.(attachOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(copyinOperands), length(createOperands), length(createZeroOperands), length(attachOperands), ])) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + + IR.create_operation( + "acc.enter_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -166,54 +82,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function exit_data(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, copyoutOperands, deleteOperands, detachOperands, async=nothing, wait=nothing, finalize=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(copyoutOperands)..., value.(deleteOperands)..., value.(detachOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + 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)) + + IR.create_operation( + "acc.exit_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -230,37 +117,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(), -) - _results = IR.Type[] - _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), - isnothing(deviceNumOperand) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - - return IR.create_operation( - "acc.init", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function init(deviceTypeOperands, deviceNumOperand=nothing; ifCond=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(deviceTypeOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(deviceNumOperand) && push!(operands, value(deviceNumOperand)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + 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 ) end @@ -284,64 +155,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,] - _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([ - isnothing(gangNum) ? 0 : 1, - isnothing(gangStatic) ? 0 : 1, - isnothing(workerNum) ? 0 : 1, - isnothing(vectorLength) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop(gangNum=nothing; gangStatic=nothing, workerNum=nothing, vectorLength=nothing, tileOperands, privateOperands, reductionOperands, 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[value.(tileOperands)..., value.(privateOperands)..., value.(reductionOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(gangNum) && push!(operands, value(gangNum)) + !isnothing(gangStatic) && push!(operands, value(gangStatic)) + !isnothing(workerNum) && push!(operands, value(workerNum)) + !isnothing(vectorLength) && push!(operands, value(vectorLength)) + push!(attributes, operandsegmentsizes([(gangNum==nothing) ? 0 : 1(gangStatic==nothing) ? 0 : 1(workerNum==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1length(tileOperands), length(privateOperands), length(reductionOperands), ])) + !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)) + + IR.create_operation( + "acc.loop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -360,106 +196,30 @@ 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(), -) - _results = IR.Type[] - _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) - !isnothing(numGangs) && push!(_operands, numGangs) - !isnothing(numWorkers) && push!(_operands, numWorkers) - !isnothing(vectorLength) && push!(_operands, vectorLength) - !isnothing(ifCond) && push!(_operands, ifCond) - !isnothing(selfCond) && push!(_operands, selfCond) - push!( - _attributes, - operandsegmentsizes([ - isnothing(async) ? 0 : 1, - length(waitOperands), - isnothing(numGangs) ? 0 : 1, - isnothing(numWorkers) ? 0 : 1, - isnothing(vectorLength) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - isnothing(selfCond) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(async=nothing; waitOperands, numGangs=nothing, numWorkers=nothing, vectorLength=nothing, ifCond=nothing, selfCond=nothing, reductionOperands, copyOperands, copyinOperands, copyinReadonlyOperands, copyoutOperands, copyoutZeroOperands, createOperands, createZeroOperands, noCreateOperands, presentOperands, devicePtrOperands, attachOperands, gangPrivateOperands, gangFirstPrivateOperands, asyncAttr=nothing, waitAttr=nothing, selfAttr=nothing, reductionOp=nothing, defaultAttr=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(reductionOperands)..., value.(copyOperands)..., value.(copyinOperands)..., value.(copyinReadonlyOperands)..., value.(copyoutOperands)..., value.(copyoutZeroOperands)..., value.(createOperands)..., value.(createZeroOperands)..., value.(noCreateOperands)..., value.(presentOperands)..., value.(devicePtrOperands)..., value.(attachOperands)..., value.(gangPrivateOperands)..., value.(gangFirstPrivateOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(async) && push!(operands, value(async)) + !isnothing(numGangs) && push!(operands, value(numGangs)) + !isnothing(numWorkers) && push!(operands, value(numWorkers)) + !isnothing(vectorLength) && push!(operands, value(vectorLength)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(selfCond) && push!(operands, value(selfCond)) + push!(attributes, operandsegmentsizes([(async==nothing) ? 0 : 1length(waitOperands), (numGangs==nothing) ? 0 : 1(numWorkers==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1(selfCond==nothing) ? 0 : 1length(reductionOperands), length(copyOperands), length(copyinOperands), length(copyinReadonlyOperands), length(copyoutOperands), length(copyoutZeroOperands), length(createOperands), length(createZeroOperands), length(noCreateOperands), length(presentOperands), length(devicePtrOperands), length(attachOperands), length(gangPrivateOperands), length(gangFirstPrivateOperands), ])) + !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)) + + IR.create_operation( + "acc.parallel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -476,37 +236,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(), -) - _results = IR.Type[] - _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), - isnothing(deviceNumOperand) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - - return IR.create_operation( - "acc.shutdown", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shutdown(deviceTypeOperands, deviceNumOperand=nothing; ifCond=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(deviceTypeOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(deviceNumOperand) && push!(operands, value(deviceNumOperand)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + 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 ) end @@ -551,54 +295,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(), -) - _results = IR.Type[] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function update(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, deviceTypeOperands, hostOperands, deviceOperands, async=nothing, wait=nothing, ifPresent=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(deviceTypeOperands)..., value.(hostOperands)..., value.(deviceOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + 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)) + + IR.create_operation( + "acc.update", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -615,42 +330,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(), -) - _results = IR.Type[] - _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), - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - !isnothing(async) && push!(_attributes, namedattribute("async", async)) - - return IR.create_operation( - "acc.wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wait(waitOperands, asyncOperand=nothing; waitDevnum=nothing, ifCond=nothing, async=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + push!(attributes, operandsegmentsizes([length(waitOperands), (asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + + IR.create_operation( + "acc.wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -661,22 +357,18 @@ end acc ops (parallel and loop). It returns values to the immediately enclosing acc op. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "acc.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "acc.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/OpenMP.jl b/src/Dialects/16/OpenMP.jl index f2b6ce9a..34f8ff34 100644 --- a/src/Dialects/16/OpenMP.jl +++ b/src/Dialects/16/OpenMP.jl @@ -1,7 +1,6 @@ module omp -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -76,27 +75,20 @@ optimization. `memory_order` indicates the memory ordering behavior of the construct. It can be one of `seq_cst`, `acquire` or `relaxed`. """ -function atomic_read( - x::Value, v::Value; hint_val=nothing, memory_order_val=nothing, location=Location() -) - _results = IR.Type[] - _operands = Value[x, v] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(hint_val) && push!(_attributes, namedattribute("hint_val", hint_val)) - !isnothing(memory_order_val) && - push!(_attributes, namedattribute("memory_order_val", memory_order_val)) - - return IR.create_operation( - "omp.atomic.read", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_read(x, v; hint_val=nothing, memory_order_val=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(v), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + + IR.create_operation( + "omp.atomic.read", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -130,31 +122,20 @@ the core update operation is directly translated like regular operations by the host dialect. The front-end must handle semantic checks for allowed operations. """ -function atomic_update( - x::Value; - hint_val=nothing, - memory_order_val=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(hint_val) && push!(_attributes, namedattribute("hint_val", hint_val)) - !isnothing(memory_order_val) && - push!(_attributes, namedattribute("memory_order_val", memory_order_val)) - - return IR.create_operation( - "omp.atomic.update", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_update(x; hint_val=nothing, memory_order_val=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + + IR.create_operation( + "omp.atomic.update", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -175,31 +156,20 @@ optimization. `memory_order` indicates the memory ordering behavior of the construct. It can be one of `seq_cst`, `release` or `relaxed`. """ -function atomic_write( - address::Value, - value::Value; - hint_val=nothing, - memory_order_val=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[address, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(hint_val) && push!(_attributes, namedattribute("hint_val", hint_val)) - !isnothing(memory_order_val) && - push!(_attributes, namedattribute("memory_order_val", memory_order_val)) - - return IR.create_operation( - "omp.atomic.write", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_write(address, value; hint_val=nothing, memory_order_val=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(address), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + + IR.create_operation( + "omp.atomic.write", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -234,29 +204,19 @@ end The cancel construct activates cancellation of the innermost enclosing region of the type specified. """ -function cancel( - if_expr=nothing::Union{Nothing,Value}; - cancellation_construct_type_val, - location=Location(), -) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute( - "cancellation_construct_type_val", cancellation_construct_type_val - ),] - !isnothing(if_expr) && push!(_operands, if_expr) - - return IR.create_operation( - "omp.cancel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cancel(if_expr=nothing; cancellation_construct_type_val, location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("cancellation_construct_type_val", cancellation_construct_type_val), ] + !isnothing(if_expr) && push!(operands, value(if_expr)) + + IR.create_operation( + "omp.cancel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -349,22 +309,18 @@ makes a thread’s temporary view of memory consistent with memory and enforces an order on the memory operations of the variables explicitly specified or implied. """ -function flush(varList::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[varList...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.flush", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function flush(varList; location=Location()) + results = IR.Type[] + operands = Value[value.(varList)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.flush", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -411,31 +367,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ordered(depend_vec_vars; depend_type_val=nothing, num_loops_val=nothing, location=Location()) + results = IR.Type[] + operands = Value[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)) + + IR.create_operation( + "omp.ordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -502,47 +447,23 @@ threads complete. 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}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}, - reduction_vars::Vector{Value}, - reductions=nothing, - proc_bind_val=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[allocate_vars..., allocators_vars..., reduction_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([ - isnothing(if_expr_var) ? 0 : 1, - isnothing(num_threads_var) ? 0 : 1, - length(allocate_vars), - length(allocators_vars), - length(reduction_vars), - ]), - ) - !isnothing(reductions) && push!(_attributes, namedattribute("reductions", reductions)) - !isnothing(proc_bind_val) && - push!(_attributes, namedattribute("proc_bind_val", proc_bind_val)) - - return IR.create_operation( - "omp.parallel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(if_expr_var=nothing; num_threads_var=nothing, allocate_vars, allocators_vars, reduction_vars, reductions=nothing, proc_bind_val=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(allocate_vars)..., value.(allocators_vars)..., value.(reduction_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr_var) && push!(operands, value(if_expr_var)) + !isnothing(num_threads_var) && push!(operands, value(num_threads_var)) + push!(attributes, operandsegmentsizes([(if_expr_var==nothing) ? 0 : 1(num_threads_var==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), length(reduction_vars), ])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !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 ) end @@ -607,22 +528,18 @@ entity for a reduction requested in some ancestor. The reduction is identified by the accumulator, but the value of the accumulator may not be updated immediately. """ -function reduction(operand::Value, accumulator::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand, accumulator] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduction(operand, accumulator; location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(accumulator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -679,38 +596,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( - 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[reduction_vars..., allocate_vars..., allocators_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - 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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sections(reduction_vars, allocate_vars, allocators_vars; reductions=nothing, nowait=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(reduction_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(reduction_vars), length(allocate_vars), length(allocators_vars), ])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.sections", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -759,56 +659,25 @@ for (%i1, %i2) : index = (%c0, %c0) to (%c10, %c10) step (%c1, %c1) { } ``` """ -function simdloop( - lowerBound::Vector{Value}, - upperBound::Vector{Value}, - step::Vector{Value}, - aligned_vars::Vector{Value}, - if_expr=nothing::Union{Nothing,Value}; - nontemporal_vars::Vector{Value}, - alignment_values=nothing, - order_val=nothing, - simdlen=nothing, - safelen=nothing, - inclusive=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - lowerBound..., upperBound..., step..., aligned_vars..., nontemporal_vars... - ] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(if_expr) && push!(_operands, if_expr) - push!( - _attributes, - operandsegmentsizes([ - length(lowerBound), - length(upperBound), - length(step), - length(aligned_vars), - isnothing(if_expr) ? 0 : 1, - length(nontemporal_vars), - ]), - ) - !isnothing(alignment_values) && - push!(_attributes, namedattribute("alignment_values", alignment_values)) - !isnothing(order_val) && push!(_attributes, namedattribute("order_val", order_val)) - !isnothing(simdlen) && push!(_attributes, namedattribute("simdlen", simdlen)) - !isnothing(safelen) && push!(_attributes, namedattribute("safelen", safelen)) - !isnothing(inclusive) && push!(_attributes, namedattribute("inclusive", inclusive)) - - return IR.create_operation( - "omp.simdloop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function simdloop(lowerBound, upperBound, step, aligned_vars, if_expr=nothing; nontemporal_vars, alignment_values=nothing, order_val=nothing, simdlen=nothing, safelen=nothing, inclusive=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(aligned_vars)..., value.(nontemporal_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(aligned_vars), (if_expr==nothing) ? 0 : 1length(nontemporal_vars), ])) + !isnothing(alignment_values) && push!(attributes, namedattribute("alignment_values", alignment_values)) + !isnothing(order_val) && push!(attributes, namedattribute("order_val", order_val)) + !isnothing(simdlen) && push!(attributes, namedattribute("simdlen", simdlen)) + !isnothing(safelen) && push!(attributes, namedattribute("safelen", safelen)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + + IR.create_operation( + "omp.simdloop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -821,32 +690,20 @@ master thread), in the context of its implicit task. The other threads in the team, which do not execute the block, wait at an implicit barrier at the end of the single construct unless a nowait clause is specified. """ -function single( - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}; - nowait=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[allocate_vars..., allocators_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, operandsegmentsizes([length(allocate_vars), length(allocators_vars)]) - ) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.single", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function single(allocate_vars, allocators_vars; nowait=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(allocate_vars), length(allocators_vars), ])) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.single", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -870,41 +727,23 @@ even if the target task is not yet completed. TODO: map, is_device_ptr, 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(), -) - _results = IR.Type[] - _operands = Value[] - _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([ - isnothing(if_expr) ? 0 : 1, - isnothing(device) ? 0 : 1, - isnothing(thread_limit) ? 0 : 1, - ]), - ) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.target", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function target(if_expr=nothing; device=nothing, thread_limit=nothing, nowait=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(device) && push!(operands, value(device)) + !isnothing(thread_limit) && push!(operands, value(thread_limit)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1(thread_limit==nothing) ? 0 : 1])) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.target", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -939,43 +778,21 @@ The \$map_types specifies the types and modifiers for the map clause. TODO: depend clause and map_type_modifier values iterator and mapper. """ -function target_data( - if_expr=nothing::Union{Nothing,Value}; - device=nothing::Union{Nothing,Value}, - use_device_ptr::Vector{Value}, - use_device_addr::Vector{Value}, - map_operands::Vector{Value}, - map_types, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[use_device_ptr..., use_device_addr..., map_operands...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map_types", map_types),] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(device) && push!(_operands, device) - push!( - _attributes, - operandsegmentsizes([ - isnothing(if_expr) ? 0 : 1, - isnothing(device) ? 0 : 1, - length(use_device_ptr), - length(use_device_addr), - length(map_operands), - ]), - ) - - return IR.create_operation( - "omp.target_data", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function target_data(if_expr=nothing; device=nothing, use_device_ptr, use_device_addr, map_operands, map_types, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(use_device_ptr)..., value.(use_device_addr)..., value.(map_operands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("map_types", map_types), ] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(device) && push!(operands, value(device)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1length(use_device_ptr), length(use_device_addr), length(map_operands), ])) + + IR.create_operation( + "omp.target_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1003,38 +820,22 @@ The \$map_types specifies the types and modifiers for the map clause. TODO: depend clause and map_type_modifier values iterator and mapper. """ -function target_enter_data( - if_expr=nothing::Union{Nothing,Value}; - device=nothing::Union{Nothing,Value}, - map_operands::Vector{Value}, - nowait=nothing, - map_types, - location=Location(), -) - _results = IR.Type[] - _operands = Value[map_operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map_types", map_types),] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(device) && push!(_operands, device) - push!( - _attributes, - operandsegmentsizes([ - isnothing(if_expr) ? 0 : 1, isnothing(device) ? 0 : 1, length(map_operands) - ]), - ) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.target_enter_data", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function target_enter_data(if_expr=nothing; device=nothing, map_operands, nowait=nothing, map_types, location=Location()) + results = IR.Type[] + operands = Value[value.(map_operands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map_types", map_types), ] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(device) && push!(operands, value(device)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1length(map_operands), ])) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.target_enter_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1062,38 +863,22 @@ The \$map_types specifies the types and modifiers for the map clause. TODO: depend clause and map_type_modifier values iterator and mapper. """ -function target_exit_data( - if_expr=nothing::Union{Nothing,Value}; - device=nothing::Union{Nothing,Value}, - map_operands::Vector{Value}, - nowait=nothing, - map_types, - location=Location(), -) - _results = IR.Type[] - _operands = Value[map_operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map_types", map_types),] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(device) && push!(_operands, device) - push!( - _attributes, - operandsegmentsizes([ - isnothing(if_expr) ? 0 : 1, isnothing(device) ? 0 : 1, length(map_operands) - ]), - ) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.target_exit_data", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function target_exit_data(if_expr=nothing; device=nothing, map_operands, nowait=nothing, map_types, location=Location()) + results = IR.Type[] + operands = Value[value.(map_operands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map_types", map_types), ] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(device) && push!(operands, value(device)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1length(map_operands), ])) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.target_exit_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1121,37 +906,20 @@ The `allocators_vars` and `allocate_vars` arguments are a variadic list of values that specify the memory allocator to be used to obtain storage for private values. """ -function taskgroup( - task_reduction_vars::Vector{Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}; - task_reductions=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[task_reduction_vars..., allocate_vars..., allocators_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - length(task_reduction_vars), length(allocate_vars), length(allocators_vars) - ]), - ) - !isnothing(task_reductions) && - push!(_attributes, namedattribute("task_reductions", task_reductions)) - - return IR.create_operation( - "omp.taskgroup", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function taskgroup(task_reduction_vars, allocate_vars, allocators_vars; task_reductions=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(task_reduction_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(task_reduction_vars), length(allocate_vars), length(allocators_vars), ])) + !isnothing(task_reductions) && push!(attributes, namedattribute("task_reductions", task_reductions)) + + IR.create_operation( + "omp.taskgroup", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1253,80 +1021,30 @@ construct. Thus, the taskloop construct creates an implicit taskgroup region. If the `nogroup` clause is present, no implicit taskgroup region is created. """ -function taskloop( - lowerBound::Vector{Value}, - upperBound::Vector{Value}, - step::Vector{Value}, - if_expr=nothing::Union{Nothing,Value}; - final_expr=nothing::Union{Nothing,Value}, - in_reduction_vars::Vector{Value}, - reduction_vars::Vector{Value}, - priority=nothing::Union{Nothing,Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}, - grain_size=nothing::Union{Nothing,Value}, - num_tasks=nothing::Union{Nothing,Value}, - inclusive=nothing, - untied=nothing, - mergeable=nothing, - in_reductions=nothing, - reductions=nothing, - nogroup=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - lowerBound..., - upperBound..., - step..., - in_reduction_vars..., - reduction_vars..., - allocate_vars..., - allocators_vars..., - ] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(final_expr) && push!(_operands, final_expr) - !isnothing(priority) && push!(_operands, priority) - !isnothing(grain_size) && push!(_operands, grain_size) - !isnothing(num_tasks) && push!(_operands, num_tasks) - push!( - _attributes, - operandsegmentsizes([ - length(lowerBound), - length(upperBound), - length(step), - isnothing(if_expr) ? 0 : 1, - isnothing(final_expr) ? 0 : 1, - length(in_reduction_vars), - length(reduction_vars), - isnothing(priority) ? 0 : 1, - length(allocate_vars), - length(allocators_vars), - isnothing(grain_size) ? 0 : 1, - isnothing(num_tasks) ? 0 : 1, - ]), - ) - !isnothing(inclusive) && push!(_attributes, namedattribute("inclusive", inclusive)) - !isnothing(untied) && push!(_attributes, namedattribute("untied", untied)) - !isnothing(mergeable) && push!(_attributes, namedattribute("mergeable", mergeable)) - !isnothing(in_reductions) && - push!(_attributes, namedattribute("in_reductions", in_reductions)) - !isnothing(reductions) && push!(_attributes, namedattribute("reductions", reductions)) - !isnothing(nogroup) && push!(_attributes, namedattribute("nogroup", nogroup)) - - return IR.create_operation( - "omp.taskloop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function taskloop(lowerBound, upperBound, step, if_expr=nothing; final_expr=nothing, in_reduction_vars, reduction_vars, priority=nothing, allocate_vars, allocators_vars, grain_size=nothing, num_tasks=nothing, inclusive=nothing, untied=nothing, mergeable=nothing, in_reductions=nothing, reductions=nothing, nogroup=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(in_reduction_vars)..., value.(reduction_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(final_expr) && push!(operands, value(final_expr)) + !isnothing(priority) && push!(operands, value(priority)) + !isnothing(grain_size) && push!(operands, value(grain_size)) + !isnothing(num_tasks) && push!(operands, value(num_tasks)) + push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), (if_expr==nothing) ? 0 : 1(final_expr==nothing) ? 0 : 1length(in_reduction_vars), length(reduction_vars), (priority==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), (grain_size==nothing) ? 0 : 1(num_tasks==nothing) ? 0 : 1])) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + !isnothing(untied) && push!(attributes, namedattribute("untied", untied)) + !isnothing(mergeable) && push!(attributes, namedattribute("mergeable", mergeable)) + !isnothing(in_reductions) && push!(attributes, namedattribute("in_reductions", in_reductions)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nogroup) && push!(attributes, namedattribute("nogroup", nogroup)) + + IR.create_operation( + "omp.taskloop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1372,52 +1090,25 @@ The `allocators_vars` and `allocate_vars` arguments are a variadic list of values that specify the memory allocator to be used to obtain storage for private values. """ -function task( - if_expr=nothing::Union{Nothing,Value}; - final_expr=nothing::Union{Nothing,Value}, - in_reduction_vars::Vector{Value}, - priority=nothing::Union{Nothing,Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}, - untied=nothing, - mergeable=nothing, - in_reductions=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in_reduction_vars..., allocate_vars..., allocators_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(final_expr) && push!(_operands, final_expr) - !isnothing(priority) && push!(_operands, priority) - push!( - _attributes, - operandsegmentsizes([ - isnothing(if_expr) ? 0 : 1, - isnothing(final_expr) ? 0 : 1, - length(in_reduction_vars), - isnothing(priority) ? 0 : 1, - length(allocate_vars), - length(allocators_vars), - ]), - ) - !isnothing(untied) && push!(_attributes, namedattribute("untied", untied)) - !isnothing(mergeable) && push!(_attributes, namedattribute("mergeable", mergeable)) - !isnothing(in_reductions) && - push!(_attributes, namedattribute("in_reductions", in_reductions)) - - return IR.create_operation( - "omp.task", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function task(if_expr=nothing; final_expr=nothing, in_reduction_vars, priority=nothing, allocate_vars, allocators_vars, untied=nothing, mergeable=nothing, in_reductions=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(in_reduction_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(final_expr) && push!(operands, value(final_expr)) + !isnothing(priority) && push!(operands, value(priority)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(final_expr==nothing) ? 0 : 1length(in_reduction_vars), (priority==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), ])) + !isnothing(untied) && push!(attributes, namedattribute("untied", untied)) + !isnothing(mergeable) && push!(attributes, namedattribute("mergeable", mergeable)) + !isnothing(in_reductions) && push!(attributes, namedattribute("in_reductions", in_reductions)) + + IR.create_operation( + "omp.task", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1516,22 +1207,18 @@ this operation. The `sym_addr` refers to the address of the symbol, which is a pointer to the original variable. """ -function threadprivate(sym_addr::Value; tls_addr::IR.Type, location=Location()) - _results = IR.Type[tls_addr,] - _operands = Value[sym_addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.threadprivate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function threadprivate(sym_addr; tls_addr::IR.Type, location=Location()) + results = IR.Type[tls_addr, ] + operands = Value[value(sym_addr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.threadprivate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1596,72 +1283,28 @@ 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}, - 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, - nowait=nothing, - ordered_val=nothing, - order_val=nothing, - inclusive=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - lowerBound..., - upperBound..., - step..., - 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(linear_vars), - length(linear_step_vars), - length(reduction_vars), - isnothing(schedule_chunk_var) ? 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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wsloop(lowerBound, upperBound, step, linear_vars, linear_step_vars, reduction_vars, schedule_chunk_var=nothing; reductions=nothing, schedule_val=nothing, schedule_modifier=nothing, simd_modifier=nothing, nowait=nothing, ordered_val=nothing, order_val=nothing, inclusive=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(linear_vars)..., value.(linear_step_vars)..., value.(reduction_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(schedule_chunk_var) && push!(operands, value(schedule_chunk_var)) + push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(linear_vars), length(linear_step_vars), length(reduction_vars), (schedule_chunk_var==nothing) ? 0 : 1])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(schedule_val) && push!(attributes, namedattribute("schedule_val", schedule_val)) + !isnothing(schedule_modifier) && push!(attributes, namedattribute("schedule_modifier", schedule_modifier)) + !isnothing(simd_modifier) && push!(attributes, namedattribute("simd_modifier", simd_modifier)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(ordered_val) && push!(attributes, namedattribute("ordered_val", ordered_val)) + !isnothing(order_val) && push!(attributes, namedattribute("order_val", order_val)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + + IR.create_operation( + "omp.wsloop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1672,22 +1315,18 @@ end terminates the region. The semantics of how the values are yielded is defined by the parent operation. """ -function yield(results::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/PDL.jl b/src/Dialects/16/PDL.jl index d819792d..8e458b94 100644 --- a/src/Dialects/16/PDL.jl +++ b/src/Dialects/16/PDL.jl @@ -1,7 +1,6 @@ module pdl -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,22 +17,18 @@ entities. pdl.apply_native_constraint \"myConstraint\"(%input, %attr, %op : !pdl.value, !pdl.attribute, !pdl.operation) ``` """ -function apply_native_constraint(args::Vector{Value}; name, location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl.apply_native_constraint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_native_constraint(args; name, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl.apply_native_constraint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -65,24 +60,18 @@ void registerNativeRewrite(PDLPatternModule &pdlModule) { } ``` """ -function apply_native_rewrite( - args::Vector{Value}; results::Vector{IR.Type}, name, location=Location() -) - _results = IR.Type[results...,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl.apply_native_rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_native_rewrite(args; results_::Vector{IR.Type}, name, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl.apply_native_rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -111,29 +100,20 @@ defined within a `pdl.rewrite` region, the constant value must be specified. %attr = pdl.attribute = \"hello\" ``` """ -function attribute( - valueType=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(valueType) && push!(_operands, valueType) - !isnothing(value) && push!(_attributes, namedattribute("value", value)) - - return IR.create_operation( - "pdl.attribute", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function attribute(valueType=nothing; attr::IR.Type, value=nothing, location=Location()) + results = IR.Type[attr, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(valueType) && push!(operands, value(valueType)) + !isnothing(value) && push!(attributes, namedattribute("value", value)) + + IR.create_operation( + "pdl.attribute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -150,22 +130,18 @@ operation correspond with the `eraseOp` method on a `PatternRewriter`. pdl.erase %root ``` """ -function erase(opValue::Value; location=Location()) - _results = IR.Type[] - _operands = Value[opValue,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl.erase", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function erase(opValue; location=Location()) + results = IR.Type[] + operands = Value[value(opValue), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl.erase", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -190,25 +166,19 @@ may partially constrain an operand by specifying an expected value type %operand = pdl.operand : %type ``` """ -function operand( - valueType=nothing::Union{Nothing,Value}; value::IR.Type, location=Location() -) - _results = IR.Type[value,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(valueType) && push!(_operands, valueType) - - return IR.create_operation( - "pdl.operand", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operand(valueType=nothing; value::IR.Type, location=Location()) + results = IR.Type[value, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(valueType) && push!(operands, value(valueType)) + + IR.create_operation( + "pdl.operand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -233,25 +203,19 @@ operands by specifying expected value types (via `pdl.types` operations). %typed_operands = pdl.operands : %types ``` """ -function operands( - valueType=nothing::Union{Nothing,Value}; value::IR.Type, location=Location() -) - _results = IR.Type[value,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(valueType) && push!(_operands, valueType) - - return IR.create_operation( - "pdl.operands", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operands_(valueType=nothing; value::IR.Type, location=Location()) + results = IR.Type[value, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(valueType) && push!(operands, value(valueType)) + + IR.create_operation( + "pdl.operands", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -352,37 +316,20 @@ def MyOp { %op = pdl.operation \"foo.op\" -> (%result, %otherResults : !pdl.type, !pdl.range) ``` """ -function operation( - operandValues::Vector{Value}, - attributeValues::Vector{Value}, - typeValues::Vector{Value}; - op::IR.Type, - opName=nothing, - attributeValueNames, - location=Location(), -) - _results = IR.Type[op,] - _operands = Value[operandValues..., attributeValues..., typeValues...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("attributeValueNames", attributeValueNames),] - push!( - _attributes, - operandsegmentsizes([ - length(operandValues), length(attributeValues), length(typeValues) - ]), - ) - !isnothing(opName) && push!(_attributes, namedattribute("opName", opName)) - - return IR.create_operation( - "pdl.operation", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operation(operandValues, attributeValues, typeValues; op::IR.Type, opName=nothing, attributeValueNames, location=Location()) + results = IR.Type[op, ] + operands = Value[value.(operandValues)..., value.(attributeValues)..., value.(typeValues)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("attributeValueNames", attributeValueNames), ] + push!(attributes, operandsegmentsizes([length(operandValues), length(attributeValues), length(typeValues), ])) + !isnothing(opName) && push!(attributes, namedattribute("opName", opName)) + + IR.create_operation( + "pdl.operation", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -457,22 +404,18 @@ determine how to extract the underlying elements. If we can\'t, e.g. if there are multiple sub ranges used for construction, we won\'t be able to determine their sizes during constraint time. """ -function range(arguments::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[arguments...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl.range", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function range(arguments; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl.range", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -501,32 +444,20 @@ pdl.replace %root with (%vals : !pdl.range) pdl.replace %root with %otherOp ``` """ -function replace( - opValue::Value, - replOperation=nothing::Union{Nothing,Value}; - replValues::Vector{Value}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[opValue, replValues...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(replOperation) && push!(_operands, replOperation) - push!( - _attributes, - operandsegmentsizes([1, isnothing(replOperation) ? 0 : 1, length(replValues)]), - ) - - return IR.create_operation( - "pdl.replace", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function replace(opValue, replOperation=nothing; replValues, location=Location()) + results = IR.Type[] + operands = Value[value(opValue), value.(replValues)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(replOperation) && push!(operands, value(replOperation)) + 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 ) end @@ -552,22 +483,18 @@ as defined by the ODS definition of the operation. // the IR snippet, `%pdl_result` would correspond to `%result_1`. ``` """ -function result(parent::Value; val::IR.Type, index, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function result(parent; val::IR.Type, index, location=Location()) + results = IR.Type[val, ] + operands = Value[value(parent), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl.result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -600,23 +527,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(index) && push!(_attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl.results", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function results_(parent; val::IR.Type, index=nothing, location=Location()) + results = IR.Type[val, ] + operands = Value[value(parent), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl.results", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -659,31 +582,21 @@ pdl.rewrite { } ``` """ -function rewrite( - root=nothing::Union{Nothing,Value}; - externalArgs::Vector{Value}, - name=nothing, - bodyRegion::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[externalArgs...,] - _owned_regions = Region[bodyRegion,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(root) && push!(_operands, root) - push!(_attributes, operandsegmentsizes([isnothing(root) ? 0 : 1, length(externalArgs)])) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "pdl.rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rewrite(root=nothing; externalArgs, name=nothing, bodyRegion::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(externalArgs)..., ] + owned_regions = Region[bodyRegion, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(root) && push!(operands, value(root)) + push!(attributes, operandsegmentsizes([(root==nothing) ? 0 : 1length(externalArgs), ])) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "pdl.rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/PDLInterp.jl b/src/Dialects/16/PDLInterp.jl index 23673f60..a6c76ec9 100644 --- a/src/Dialects/16/PDLInterp.jl +++ b/src/Dialects/16/PDLInterp.jl @@ -1,7 +1,6 @@ module pdl_interp -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -20,24 +19,18 @@ otherwise the false destination is taken. pdl_interp.apply_constraint \"myConstraint\"(%input, %attr, %op : !pdl.value, !pdl.attribute, !pdl.operation) -> ^matchDest, ^failureDest ``` """ -function apply_constraint( - args::Vector{Value}; name, trueDest::Block, falseDest::Block, location=Location() -) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.apply_constraint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_constraint(args; name, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.apply_constraint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -63,24 +56,18 @@ pdl_interp.apply_rewrite \"rewriter\"(%root : !pdl.operation) pdl_interp.apply_rewrite \"rewriter\"(%root : !pdl.operation, %value : !pdl.value) ``` """ -function apply_rewrite( - args::Vector{Value}; results::Vector{IR.Type}, name, location=Location() -) - _results = IR.Type[results...,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.apply_rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_rewrite(args; results_::Vector{IR.Type}, name, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.apply_rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -97,24 +84,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.are_equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function are_equal(lhs, rhs; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.are_equal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -163,24 +144,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_attribute(attribute; constantValue, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(attribute), ] + owned_regions = Region[] + 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 ) end @@ -203,31 +178,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( - inputOp::Value; - count, - compareAtLeast=nothing, - trueDest::Block, - falseDest::Block, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_operand_count(inputOp; count, compareAtLeast=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -244,24 +207,18 @@ destination, otherwise the false destination is taken. pdl_interp.check_operation_name of %op is \"foo.op\" -> ^matchDest, ^failureDest ``` """ -function check_operation_name( - inputOp::Value; name, trueDest::Block, falseDest::Block, location=Location() -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.check_operation_name", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_operation_name(inputOp; name, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -284,31 +241,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( - inputOp::Value; - count, - compareAtLeast=nothing, - trueDest::Block, - falseDest::Block, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_result_count(inputOp; count, compareAtLeast=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -325,24 +270,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_type(value; type, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -359,24 +298,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_types(value; types, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -462,42 +395,20 @@ to this operation. %op = pdl_interp.create_operation \"foo.op\"(%arg0 : !pdl.value) {\"attrA\" = %attr0} -> ``` """ -function create_operation( - inputOperands::Vector{Value}, - inputAttributes::Vector{Value}, - inputResultTypes::Vector{Value}; - resultOp::IR.Type, - name, - inputAttributeNames, - inferredResultTypes=nothing, - location=Location(), -) - _results = IR.Type[resultOp,] - _operands = Value[inputOperands..., inputAttributes..., inputResultTypes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("name", name), - namedattribute("inputAttributeNames", inputAttributeNames), - ] - push!( - _attributes, - operandsegmentsizes([ - length(inputOperands), length(inputAttributes), length(inputResultTypes) - ]), - ) - !isnothing(inferredResultTypes) && - push!(_attributes, namedattribute("inferredResultTypes", inferredResultTypes)) - - return IR.create_operation( - "pdl_interp.create_operation", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_operation(inputOperands, inputAttributes, inputResultTypes; resultOp::IR.Type, name, inputAttributeNames, inferredResultTypes=nothing, location=Location()) + results = IR.Type[resultOp, ] + operands = Value[value.(inputOperands)..., value.(inputAttributes)..., value.(inputResultTypes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), namedattribute("inputAttributeNames", inputAttributeNames), ] + push!(attributes, operandsegmentsizes([length(inputOperands), length(inputAttributes), length(inputResultTypes), ])) + !isnothing(inferredResultTypes) && push!(attributes, namedattribute("inferredResultTypes", inferredResultTypes)) + + IR.create_operation( + "pdl_interp.create_operation", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -522,22 +433,18 @@ or `!pdl.range` entities. %valueRange = pdl_interp.create_range : !pdl.range ``` """ -function create_range(arguments::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[arguments...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.create_range", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_range(arguments; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.create_range", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -616,22 +523,18 @@ marked as erased. The semantics of this operation correspond with the pdl_interp.erase %root ``` """ -function erase(inputOp::Value; location=Location()) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.erase", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function erase(inputOp; location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.erase", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -648,22 +551,18 @@ at the specified index. If the index is out of range, returns null. %ops = pdl_interp.extract 1 of %values : !pdl.value ``` """ -function extract(range::Value; result::IR.Type, index, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract(range; result::IR.Type, index, location=Location()) + results = IR.Type[result, ] + operands = Value[value(range), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.extract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -717,22 +616,18 @@ pdl_interp.foreach %op : !pdl.operation in %ops { } -> ^next ``` """ -function foreach(values::Value; region::Region, successor::Block, location=Location()) - _results = IR.Type[] - _operands = Value[values,] - _owned_regions = Region[region,] - _successors = Block[successor,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.foreach", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach(values; region::Region, successor::Block, location=Location()) + results = IR.Type[] + operands = Value[value(values), ] + owned_regions = Region[region, ] + successors = Block[successor, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.foreach", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -797,22 +692,18 @@ returned. %attr = pdl_interp.get_attribute \"attr\" of %op ``` """ -function get_attribute(inputOp::Value; attribute::IR.Type, name, location=Location()) - _results = IR.Type[attribute,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.get_attribute", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_attribute(inputOp; attribute::IR.Type, name, location=Location()) + results = IR.Type[attribute, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.get_attribute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -828,22 +719,18 @@ specific attribute. %type = pdl_interp.get_attribute_type of %attr ``` """ -function get_attribute_type(value::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_attribute_type(value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_attribute_type", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -861,22 +748,18 @@ or range of operand results, null is returned. %op = pdl_interp.get_defining_op of %value : !pdl.value ``` """ -function get_defining_op(value::Value; inputOp::IR.Type, location=Location()) - _results = IR.Type[inputOp,] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.get_defining_op", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_defining_op(value; inputOp::IR.Type, location=Location()) + results = IR.Type[inputOp, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_defining_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -893,22 +776,18 @@ null value is returned. %operand = pdl_interp.get_operand 1 of %op ``` """ -function get_operand(inputOp::Value; value::IR.Type, index, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("index", index),] - - return IR.create_operation( - "pdl_interp.get_operand", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_operand(inputOp; value::IR.Type, index, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.get_operand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -935,23 +814,19 @@ the returned operand group corresponds to all operands of the operation. %operands = pdl_interp.get_operands of %op : !pdl.range ``` """ -function get_operands(inputOp::Value; value::IR.Type, index=nothing, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(index) && push!(_attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl_interp.get_operands", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_operands(inputOp; value::IR.Type, index=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl_interp.get_operands", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -968,22 +843,18 @@ null value is returned. %result = pdl_interp.get_result 1 of %op ``` """ -function get_result(inputOp::Value; value::IR.Type, index, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("index", index),] - - return IR.create_operation( - "pdl_interp.get_result", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_result(inputOp; value::IR.Type, index, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.get_result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1010,23 +881,19 @@ the returned operand group corresponds to all results of the operation. %results = pdl_interp.get_results of %op : !pdl.range ``` """ -function get_results(inputOp::Value; value::IR.Type, index=nothing, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(index) && push!(_attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl_interp.get_results", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_results(inputOp; value::IR.Type, index=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl_interp.get_results", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1047,22 +914,18 @@ similarly to ResultRange::getUsers. %ops = pdl_interp.get_users of %values : !pdl.range ``` """ -function get_users(value::Value; operations::IR.Type, location=Location()) - _results = IR.Type[operations,] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.get_users", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_users(value; operations::IR.Type, location=Location()) + results = IR.Type[operations, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_users", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1082,22 +945,18 @@ value or range thereof. %type = pdl_interp.get_value_type of %values : !pdl.range ``` """ -function get_value_type(value::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_value_type(value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_value_type", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1115,22 +974,18 @@ false destination is taken. 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,] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.is_not_null", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function is_not_null(value; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.is_not_null", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1149,37 +1004,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(), -) - _results = IR.Type[] - _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)])) - !isnothing(rootKind) && push!(_attributes, namedattribute("rootKind", rootKind)) - !isnothing(generatedOps) && - push!(_attributes, namedattribute("generatedOps", generatedOps)) - - return IR.create_operation( - "pdl_interp.record_match", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function record_match(inputs, matchedOps; rewriter, rootKind=nothing, generatedOps=nothing, benefit, dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(inputs)..., value.(matchedOps)..., ] + owned_regions = Region[] + 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)) + + IR.create_operation( + "pdl_interp.record_match", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1198,22 +1037,18 @@ values must match the number of results specified by the operation. pdl_interp.replace %root with (%val0, %val1 : !pdl.type, !pdl.type) ``` """ -function replace(inputOp::Value, replValues::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[inputOp, replValues...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.replace", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function replace(inputOp, replValues; location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), value.(replValues)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.replace", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1231,28 +1066,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_attribute(attribute; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(attribute), ] + owned_regions = Region[] + 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 ) end @@ -1270,28 +1095,18 @@ otherwise the default destination is taken. pdl_interp.switch_operand_count of %op to [10, 2] -> ^10Dest, ^2Dest, ^defaultDest ``` """ -function switch_operand_count( - inputOp::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[defaultDest, cases...] - _attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_operand_count", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_operand_count(inputOp; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -1309,28 +1124,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( - inputOp::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[defaultDest, cases...] - _attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_operation_name", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_operation_name(inputOp; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -1348,28 +1153,18 @@ otherwise the default destination is taken. pdl_interp.switch_result_count of %op to [0, 2](^0Dest, ^2Dest) -> ^defaultDest ``` """ -function switch_result_count( - inputOp::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[defaultDest, cases...] - _attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_result_count", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_result_count(inputOp; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -1387,24 +1182,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_type(value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -1422,24 +1211,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_types(value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end diff --git a/src/Dialects/16/Quant.jl b/src/Dialects/16/Quant.jl index 607bc962..8bfcd69e 100644 --- a/src/Dialects/16/Quant.jl +++ b/src/Dialects/16/Quant.jl @@ -1,29 +1,24 @@ module quant -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `dcast` """ -function dcast(arg::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.dcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dcast(arg; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.dcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -31,22 +26,18 @@ end `qcast` """ -function qcast(arg::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.qcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function qcast(arg; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.qcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -54,22 +45,18 @@ end `scast` """ -function scast(arg::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.scast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scast(arg; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.scast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/SCF.jl b/src/Dialects/16/SCF.jl index 544512d4..10d8b486 100644 --- a/src/Dialects/16/SCF.jl +++ b/src/Dialects/16/SCF.jl @@ -1,7 +1,6 @@ module scf -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -12,22 +11,18 @@ of the `scf.while` construct. If its first argument is true, the \"after\" region of `scf.while` is executed, with the remaining arguments forwarded 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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.condition", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function condition(condition, args; location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.condition", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -180,30 +175,18 @@ func.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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function for_(lowerBound, upperBound, step, initArgs; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(lowerBound), value(upperBound), value(step), value.(initArgs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -332,31 +315,20 @@ Example with privatized tensors: } ``` """ -function foreach_thread( - num_threads::Vector{Value}, - outputs::Vector{Value}; - results::Vector{IR.Type}, - mapping=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[num_threads..., outputs...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(num_threads), length(outputs)])) - !isnothing(mapping) && push!(_attributes, namedattribute("mapping", mapping)) - - return IR.create_operation( - "scf.foreach_thread", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach_thread(num_threads, outputs; results_::Vector{IR.Type}, mapping=nothing, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(num_threads)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(num_threads), length(outputs), ])) + !isnothing(mapping) && push!(attributes, namedattribute("mapping", mapping)) + + IR.create_operation( + "scf.foreach_thread", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -406,28 +378,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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.if", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function if_(condition; results_::Vector{IR.Type}, thenRegion::Region, elseRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(condition), ] + owned_regions = Region[thenRegion, elseRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -462,29 +424,18 @@ default { } ``` """ -function index_switch( - arg::Value; - results::Vector{IR.Type}, - cases, - defaultRegion::Region, - caseRegions::Vector{Region}, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[arg,] - _owned_regions = Region[defaultRegion, caseRegions...] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("cases", cases),] - - return IR.create_operation( - "scf.index_switch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function index_switch(arg; results_::Vector{IR.Type}, cases, defaultRegion::Region, caseRegions::Vector{Region}, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(arg), ] + owned_regions = Region[defaultRegion, caseRegions..., ] + successors = Block[] + attributes = NamedAttribute[namedattribute("cases", cases), ] + + IR.create_operation( + "scf.index_switch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -534,36 +485,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - length(lowerBound), length(upperBound), length(step), length(initVals) - ]), - ) - - return IR.create_operation( - "scf.parallel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(lowerBound, upperBound, step, initVals; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(initVals)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -633,22 +567,18 @@ scf.reduce(%operand) : f32 { } ``` """ -function reduce(operand::Value; reductionOperator::Region, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[reductionOperator,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce(operand; reductionOperator::Region, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[reductionOperator, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.reduce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -663,22 +593,18 @@ the operand of \"scf.reduce\". Example for the custom format: scf.reduce.return %res : f32 ``` """ -function reduce_return(result::Value; location=Location()) - _results = IR.Type[] - _operands = Value[result,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.reduce.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_return(result; location=Location()) + results = IR.Type[] + operands = Value[value(result), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.reduce.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -796,28 +722,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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.while", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function while_(inits; results_::Vector{IR.Type}, before::Region, after::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(inits)..., ] + owned_regions = Region[before, after, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.while", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -834,22 +750,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()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/SPIRV.jl b/src/Dialects/16/SPIRV.jl index 4a35a89a..11fb3244 100644 --- a/src/Dialects/16/SPIRV.jl +++ b/src/Dialects/16/SPIRV.jl @@ -1,7 +1,6 @@ module spirv -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -46,24 +45,18 @@ access-chain-op ::= ssa-id `=` `spirv.AccessChain` ssa-use %3 = spirv.Load \"Function\" %2 [\"Volatile\"] : !spirv.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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.AccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AccessChain(base_ptr, indices; component_ptr::IR.Type, location=Location()) + results = IR.Type[component_ptr, ] + operands = Value[value(base_ptr), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.AccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -147,31 +140,18 @@ atomic-and-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicAnd(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicAnd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -221,35 +201,18 @@ atomic-compare-exchange-op ::= : !spirv.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] - _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( - "spirv.AtomicCompareExchange", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicCompareExchange(pointer, value, comparator; result::IR.Type, memory_scope, equal_semantics, unequal_semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), value(comparator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("equal_semantics", equal_semantics), namedattribute("unequal_semantics", unequal_semantics), ] + + IR.create_operation( + "spirv.AtomicCompareExchange", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -277,35 +240,18 @@ atomic-compare-exchange-weak-op ::= : !spirv.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] - _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( - "spirv.AtomicCompareExchangeWeak", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicCompareExchangeWeak(pointer, value, comparator; result::IR.Type, memory_scope, equal_semantics, unequal_semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), value(comparator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("equal_semantics", equal_semantics), namedattribute("unequal_semantics", unequal_semantics), ] + + IR.create_operation( + "spirv.AtomicCompareExchangeWeak", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -342,31 +288,18 @@ atomic-exchange-op ::= : !spirv.ptr ``` """ -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( - "spirv.AtomicExchange", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicExchange(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicExchange", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -403,31 +336,18 @@ atomic-iadd-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicIAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIAdd(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicIAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -463,26 +383,18 @@ atomic-idecrement-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicIDecrement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIDecrement(pointer; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicIDecrement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -517,26 +429,18 @@ atomic-iincrement-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicIIncrement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIIncrement(pointer; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicIIncrement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -574,31 +478,18 @@ atomic-isub-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicISub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicISub(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicISub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -635,31 +526,18 @@ atomic-or-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicOr(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicOr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -697,31 +575,18 @@ atomic-smax-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicSMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicSMax(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicSMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -759,31 +624,18 @@ atomic-smin-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicSMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicSMin(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicSMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -821,31 +673,18 @@ atomic-umax-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicUMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicUMax(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicUMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -883,31 +722,18 @@ atomic-umin-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicUMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicUMin(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicUMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -945,31 +771,18 @@ atomic-xor-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicXor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicXor(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicXor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1005,25 +818,19 @@ Results are computed per component. %3 = spirv.BitCount %1: vector<4xi32> ``` """ -function BitCount( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitCount", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitCount(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitCount", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1069,30 +876,19 @@ The type of Base and Insert must be the same as Result Type. %0 = spirv.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(), -) - _results = IR.Type[] - _operands = Value[base, insert, offset, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitFieldInsert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldInsert(base, insert, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(insert), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitFieldInsert", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1138,29 +934,19 @@ The type of Base must be the same as Result Type. %0 = spirv.BitFieldSExtract %base, %offset, %count : vector<3xi32>, i8, i8 ``` """ -function BitFieldSExtract( - base::Value, - offset::Value, - count::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[base, offset, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitFieldSExtract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldSExtract(base, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitFieldSExtract", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1188,29 +974,19 @@ bitfield-extract-u-op ::= ssa-id `=` `spirv.BitFieldUExtract` ssa-use %0 = spirv.BitFieldUExtract %base, %offset, %count : vector<3xi32>, i8, i8 ``` """ -function BitFieldUExtract( - base::Value, - offset::Value, - count::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[base, offset, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitFieldUExtract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldUExtract(base, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitFieldUExtract", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1242,25 +1018,19 @@ The type of Base must be the same as Result Type. %3 = spirv.BitReverse %1 : vector<4xi32> ``` """ -function BitReverse( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitReverse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitReverse(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitReverse", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1303,22 +1073,18 @@ bitcast-op ::= ssa-id `=` `spirv.Bitcast` ssa-use %1 = spirv.Bitcast %0 : !spirv.ptr to !spirv.ptr ``` """ -function Bitcast(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.Bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Bitcast(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1348,28 +1114,19 @@ Results are computed per component, and within each component, per bit. %2 = spirv.BitwiseAnd %0, %1 : vector<4xi32> ``` """ -function BitwiseAnd( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitwiseAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseAnd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitwiseAnd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1399,28 +1156,19 @@ Results are computed per component, and within each component, per bit. %2 = spirv.BitwiseOr %0, %1 : vector<4xi32> ``` """ -function BitwiseOr( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitwiseOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseOr(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitwiseOr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1450,28 +1198,19 @@ Results are computed per component, and within each component, per bit. %2 = spirv.BitwiseXor %0, %1 : vector<4xi32> ``` """ -function BitwiseXor( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitwiseXor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseXor(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitwiseXor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1509,36 +1248,20 @@ spirv.BranchConditional %condition, ^true_branch, ^false_branch spirv.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(), -) - _results = IR.Type[] - _operands = Value[condition, trueTargetOperands..., falseTargetOperands...] - _owned_regions = Region[] - _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( - "spirv.BranchConditional", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function BranchConditional(condition, trueTargetOperands, falseTargetOperands; branch_weights=nothing, trueTarget::Block, falseTarget::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueTargetOperands)..., value.(falseTargetOperands)..., ] + owned_regions = Region[] + successors = Block[trueTarget, falseTarget, ] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([1, length(trueTargetOperands), length(falseTargetOperands), ])) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) + + IR.create_operation( + "spirv.BranchConditional", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1562,22 +1285,18 @@ spirv.Branch ^target spirv.Branch ^target(%0, %1: i32, f32) ``` """ -function Branch(targetOperands::Vector{Value}; target::Block, location=Location()) - _results = IR.Type[] - _operands = Value[targetOperands...,] - _owned_regions = Region[] - _successors = Block[target,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.Branch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Branch(targetOperands; target::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(targetOperands)..., ] + owned_regions = Region[] + successors = Block[target, ] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Branch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1606,25 +1325,19 @@ ceil-op ::= ssa-id `=` `spirv.CL.ceil` ssa-use `:` %3 = spirv.CL.ceil %1 : vector<3xf16> ``` """ -function CL_ceil( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_ceil(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.ceil", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1653,23 +1366,19 @@ cos-op ::= ssa-id `=` `spirv.CL.cos` ssa-use `:` %3 = spirv.CL.cos %1 : vector<3xf16> ``` """ -function CL_cos(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_cos(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1698,23 +1407,19 @@ erf-op ::= ssa-id `=` `spirv.CL.erf` ssa-use `:` %3 = spirv.CL.erf %1 : vector<3xf16> ``` """ -function CL_erf(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.erf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_erf(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.erf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1743,23 +1448,19 @@ exp-op ::= ssa-id `=` `spirv.CL.exp` ssa-use `:` %3 = spirv.CL.exp %1 : vector<3xf16> ``` """ -function CL_exp(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_exp(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1788,25 +1489,19 @@ abs-op ::= ssa-id `=` `spirv.CL.fabs` ssa-use `:` %3 = spirv.CL.fabs %1 : vector<3xf16> ``` """ -function CL_fabs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.fabs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_fabs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.fabs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1836,25 +1531,19 @@ fmax-op ::= ssa-id `=` `spirv.CL.fmax` ssa-use `:` %3 = spirv.CL.fmax %0, %1 : vector<3xf16> ``` """ -function CL_fmax( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.fmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_fmax(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.fmax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1883,25 +1572,19 @@ fmin-op ::= ssa-id `=` `spirv.CL.fmin` ssa-use `:` %3 = spirv.CL.fmin %0, %1 : vector<3xf16> ``` """ -function CL_fmin( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.fmin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_fmin(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.fmin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1930,25 +1613,19 @@ floor-op ::= ssa-id `=` `spirv.CL.floor` ssa-use `:` %3 = spirv.CL.ceifloorl %1 : vector<3xf16> ``` """ -function CL_floor( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_floor(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.floor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1975,29 +1652,19 @@ fma-op ::= ssa-id `=` `spirv.CL.fma` ssa-use, ssa-use, ssa-use `:` %1 = spirv.CL.fma %a, %b, %c : vector<3xf16> ``` """ -function CL_fma( - x::Value, - y::Value, - z::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_fma(x, y, z; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.fma", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2026,23 +1693,19 @@ log-op ::= ssa-id `=` `spirv.CL.log` ssa-use `:` %3 = spirv.CL.log %1 : vector<3xf16> ``` """ -function CL_log(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_log(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2072,25 +1735,19 @@ pow-op ::= ssa-id `=` `spirv.CL.pow` ssa-use `:` %3 = spirv.CL.pow %0, %1 : vector<3xf16> ``` """ -function CL_pow( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_pow(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.pow", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2119,25 +1776,19 @@ rint-op ::= ssa-id `=` `spirv.CL.rint` ssa-use `:` %1 = spirv.CL.rint %1 : vector<3xf16> ``` """ -function CL_rint( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.rint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_rint(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.rint", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2165,25 +1816,19 @@ round-op ::= ssa-id `=` `spirv.CL.round` ssa-use `:` %3 = spirv.CL.round %0 : vector<3xf16> ``` """ -function CL_round( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_round(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.round", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2212,25 +1857,19 @@ rsqrt-op ::= ssa-id `=` `spirv.CL.rsqrt` ssa-use `:` %3 = spirv.CL.rsqrt %1 : vector<3xf16> ``` """ -function CL_rsqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_rsqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.rsqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2259,25 +1898,19 @@ abs-op ::= ssa-id `=` `spirv.CL.s_abs` ssa-use `:` %3 = spirv.CL.s_abs %1 : vector<3xi16> ``` """ -function CL_s_abs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.s_abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_s_abs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.s_abs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2303,25 +1936,19 @@ smax-op ::= ssa-id `=` `spirv.CL.s_max` ssa-use `:` %3 = spirv.CL.s_max %0, %1 : vector<3xi16> ``` """ -function CL_s_max( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.s_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_s_max(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.s_max", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2347,25 +1974,19 @@ smin-op ::= ssa-id `=` `spirv.CL.s_min` ssa-use `:` %3 = spirv.CL.s_min %0, %1 : vector<3xi16> ``` """ -function CL_s_min( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.s_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_s_min(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.s_min", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2394,23 +2015,19 @@ sin-op ::= ssa-id `=` `spirv.CL.sin` ssa-use `:` %3 = spirv.CL.sin %1 : vector<3xf16> ``` """ -function CL_sin(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_sin(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2439,25 +2056,19 @@ sqrt-op ::= ssa-id `=` `spirv.CL.sqrt` ssa-use `:` %3 = spirv.CL.sqrt %1 : vector<3xf16> ``` """ -function CL_sqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_sqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2486,25 +2097,19 @@ tanh-op ::= ssa-id `=` `spirv.CL.tanh` ssa-use `:` %3 = spirv.CL.tanh %1 : vector<3xf16> ``` """ -function CL_tanh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_tanh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2530,25 +2135,19 @@ umax-op ::= ssa-id `=` `spirv.CL.u_max` ssa-use `:` %3 = spirv.CL.u_max %0, %1 : vector<3xi16> ``` """ -function CL_u_max( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.u_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_u_max(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.u_max", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2574,25 +2173,19 @@ umin-op ::= ssa-id `=` `spirv.CL.u_min` ssa-use `:` %3 = spirv.CL.u_min %0, %1 : vector<3xi16> ``` """ -function CL_u_min( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.u_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_u_min(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.u_min", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2630,24 +2223,18 @@ composite-construct-op ::= ssa-id `=` `spirv.CompositeConstruct` %0 = spirv.CompositeConstruct %1, %2, %3 : vector<3xf32> ``` """ -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( - "spirv.CompositeConstruct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CompositeConstruct(constituents; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(constituents)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.CompositeConstruct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2680,24 +2267,18 @@ composite-extract-op ::= ssa-id `=` `spirv.CompositeExtract` ssa-use %2 = spirv.CompositeExtract %1[1 : i32] : !spirv.array<4x!spirv.array<4xf32>> ``` """ -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( - "spirv.CompositeExtract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CompositeExtract(composite; component::IR.Type, indices, location=Location()) + results = IR.Type[component, ] + operands = Value[value(composite), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indices", indices), ] + + IR.create_operation( + "spirv.CompositeExtract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2730,24 +2311,18 @@ composite-insert-op ::= ssa-id `=` `spirv.CompositeInsert` ssa-use, ssa-use %0 = spirv.CompositeInsert %object, %composite[1 : i32] : f32 into !spirv.array<4xf32> ``` """ -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( - "spirv.CompositeInsert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CompositeInsert(object, composite; result::IR.Type, indices, location=Location()) + results = IR.Type[result, ] + operands = Value[value(object), value(composite), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indices", indices), ] + + IR.create_operation( + "spirv.CompositeInsert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2900,22 +2475,18 @@ convert-f-to-s-op ::= ssa-id `=` `spirv.ConvertFToSOp` ssa-use %3 = spirv.ConvertFToS %2 : vector<3xf32> to vector<3xi32> ``` """ -function ConvertFToS(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ConvertFToS", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertFToS(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ConvertFToS", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2944,22 +2515,18 @@ convert-f-to-u-op ::= ssa-id `=` `spirv.ConvertFToUOp` ssa-use %3 = spirv.ConvertFToU %2 : vector<3xf32> to vector<3xi32> ``` """ -function ConvertFToU(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ConvertFToU", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertFToU(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ConvertFToU", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2987,22 +2554,18 @@ convert-s-to-f-op ::= ssa-id `=` `spirv.ConvertSToFOp` ssa-use %3 = spirv.ConvertSToF %2 : vector<3xi32> to vector<3xf32> ``` """ -function ConvertSToF(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ConvertSToF", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertSToF(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ConvertSToF", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3030,22 +2593,18 @@ convert-u-to-f-op ::= ssa-id `=` `spirv.ConvertUToFOp` ssa-use %3 = spirv.ConvertUToF %2 : vector<3xi32> to vector<3xf32> ``` """ -function ConvertUToF(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ConvertUToF", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertUToF(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ConvertUToF", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3078,37 +2637,22 @@ copy-memory-op ::= `spirv.CopyMemory ` storage-class ssa-use spirv.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(), -) - _results = IR.Type[] - _operands = Value[target, source] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !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( - "spirv.CopyMemory", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CopyMemory(target, source; memory_access=nothing, alignment=nothing, source_memory_access=nothing, source_alignment=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(target), value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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)) + + IR.create_operation( + "spirv.CopyMemory", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3150,31 +2694,18 @@ atomic-fadd-op ::= !spirv.ptr ``` """ -function EXT_AtomicFAdd( - 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( - "spirv.EXT.AtomicFAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function EXT_AtomicFAdd(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.EXT.AtomicFAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3318,28 +2849,19 @@ fadd-op ::= ssa-id `=` `spirv.FAdd` ssa-use, ssa-use %5 = spirv.FAdd %2, %3 : vector<4xf32> ``` """ -function FAdd( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FAdd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3368,22 +2890,18 @@ f-convert-op ::= ssa-id `=` `spirv.FConvertOp` ssa-use %3 = spirv.FConvertOp %2 : vector<3xf32> to vector<3xf64> ``` """ -function FConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.FConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3413,28 +2931,19 @@ fdiv-op ::= ssa-id `=` `spirv.FDiv` ssa-use, ssa-use %5 = spirv.FDiv %2, %3 : vector<4xf32> ``` """ -function FDiv( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3465,28 +2974,19 @@ fmod-op ::= ssa-id `=` `spirv.FMod` ssa-use, ssa-use %5 = spirv.FMod %2, %3 : vector<4xf32> ``` """ -function FMod( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3516,28 +3016,19 @@ fmul-op ::= `spirv.FMul` ssa-use, ssa-use %5 = spirv.FMul %2, %3 : vector<4xf32> ``` """ -function FMul( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FMul(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3565,25 +3056,19 @@ fmul-op ::= `spirv.FNegate` ssa-use `:` float-scalar-vector-type %3 = spirv.FNegate %2 : vector<4xf32> ``` """ -function FNegate( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FNegate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FNegate(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FNegate", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3613,28 +3098,18 @@ fordequal-op ::= ssa-id `=` `spirv.FOrdEqual` ssa-use, ssa-use %5 = spirv.FOrdEqual %2, %3 : vector<4xf32> ``` """ -function FOrdEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3664,28 +3139,18 @@ fordgte-op ::= ssa-id `=` `spirv.FOrdGreaterThanEqual` ssa-use, ssa-use %5 = spirv.FOrdGreaterThanEqual %2, %3 : vector<4xf32> ``` """ -function FOrdGreaterThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3715,28 +3180,18 @@ fordgt-op ::= ssa-id `=` `spirv.FOrdGreaterThan` ssa-use, ssa-use %5 = spirv.FOrdGreaterThan %2, %3 : vector<4xf32> ``` """ -function FOrdGreaterThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3766,28 +3221,18 @@ fordlte-op ::= ssa-id `=` `spirv.FOrdLessThanEqual` ssa-use, ssa-use %5 = spirv.FOrdLessThanEqual %2, %3 : vector<4xf32> ``` """ -function FOrdLessThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3817,28 +3262,18 @@ fordlt-op ::= ssa-id `=` `spirv.FOrdLessThan` ssa-use, ssa-use %5 = spirv.FOrdLessThan %2, %3 : vector<4xf32> ``` """ -function FOrdLessThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3868,28 +3303,18 @@ fordneq-op ::= ssa-id `=` `spirv.FOrdNotEqual` ssa-use, ssa-use %5 = spirv.FOrdNotEqual %2, %3 : vector<4xf32> ``` """ -function FOrdNotEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3921,28 +3346,19 @@ frem-op ::= ssa-id `=` `spirv.FRemOp` ssa-use, ssa-use %5 = spirv.FRemOp %2, %3 : vector<4xf32> ``` """ -function FRem( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FRem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FRem(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FRem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3971,28 +3387,19 @@ fsub-op ::= ssa-id `=` `spirv.FRemOp` ssa-use, ssa-use %5 = spirv.FRemOp %2, %3 : vector<4xf32> ``` """ -function FSub( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FSub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FSub(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FSub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4022,28 +3429,18 @@ funordequal-op ::= ssa-id `=` `spirv.FUnordEqual` ssa-use, ssa-use %5 = spirv.FUnordEqual %2, %3 : vector<4xf32> ``` """ -function FUnordEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4073,28 +3470,18 @@ funordgte-op ::= ssa-id `=` `spirv.FUnordGreaterThanEqual` ssa-use, ssa-use %5 = spirv.FUnordGreaterThanEqual %2, %3 : vector<4xf32> ``` """ -function FUnordGreaterThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4124,28 +3511,18 @@ funordgt-op ::= ssa-id `=` `spirv.FUnordGreaterThan` ssa-use, ssa-use %5 = spirv.FUnordGreaterThan %2, %3 : vector<4xf32> ``` """ -function FUnordGreaterThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4175,28 +3552,18 @@ funordlte-op ::= ssa-id `=` `spirv.FUnordLessThanEqual` ssa-use, ssa-use %5 = spirv.FUnordLessThanEqual %2, %3 : vector<4xf32> ``` """ -function FUnordLessThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4226,28 +3593,18 @@ funordlt-op ::= ssa-id `=` `spirv.FUnordLessThan` ssa-use, ssa-use %5 = spirv.FUnordLessThan %2, %3 : vector<4xf32> ``` """ -function FUnordLessThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4277,28 +3634,18 @@ funordneq-op ::= ssa-id `=` `spirv.FUnordNotEqual` ssa-use, ssa-use %5 = spirv.FUnordNotEqual %2, %3 : vector<4xf32> ``` """ -function FUnordNotEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4394,28 +3741,19 @@ spirv.FunctionCall @f_void(%arg0) : (i32) -> () %0 = spirv.FunctionCall @f_iadd(%arg0, %arg1) : (i32, i32) -> i32 ``` """ -function FunctionCall( - arguments::Vector{Value}; - return_value=nothing::Union{Nothing,IR.Type}, - callee, - location=Location(), -) - _results = IR.Type[] - _operands = Value[arguments...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("callee", callee),] - !isnothing(return_value) && push!(_results, return_value) - - return IR.create_operation( - "spirv.FunctionCall", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FunctionCall(arguments; return_value=nothing::Union{Nothing, IR.Type}, callee, location=Location()) + results = IR.Type[] + operands = Value[value.(arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + !isnothing(return_value) && push!(results, return_value) + + IR.create_operation( + "spirv.FunctionCall", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4448,25 +3786,19 @@ acos-op ::= ssa-id `=` `spirv.GL.Acos` ssa-use `:` %3 = spirv.GL.Acos %1 : vector<3xf16> ``` """ -function GL_Acos( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Acos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Acos(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Acos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4499,25 +3831,19 @@ asin-op ::= ssa-id `=` `spirv.GL.Asin` ssa-use `:` %3 = spirv.GL.Asin %1 : vector<3xf16> ``` """ -function GL_Asin( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Asin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Asin(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Asin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4550,25 +3876,19 @@ atan-op ::= ssa-id `=` `spirv.GL.Atan` ssa-use `:` %3 = spirv.GL.Atan %1 : vector<3xf16> ``` """ -function GL_Atan( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Atan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Atan(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Atan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4598,25 +3918,19 @@ ceil-op ::= ssa-id `=` `spirv.GL.Ceil` ssa-use `:` %3 = spirv.GL.Ceil %1 : vector<3xf16> ``` """ -function GL_Ceil( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Ceil(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Ceil", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4647,23 +3961,19 @@ cos-op ::= ssa-id `=` `spirv.GL.Cos` ssa-use `:` %3 = spirv.GL.Cos %1 : vector<3xf16> ``` """ -function GL_Cos(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Cos(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4694,25 +4004,19 @@ cosh-op ::= ssa-id `=` `spirv.GL.Cosh` ssa-use `:` %3 = spirv.GL.Cosh %1 : vector<3xf16> ``` """ -function GL_Cosh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Cosh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Cosh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Cosh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4743,25 +4047,21 @@ exp-op ::= ssa-id `=` `spirv.GL.Exp` ssa-use `:` %3 = spirv.GL.Exp %1 : vector<3xf16> ``` """ -function GL_Exp(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end +function GL_Exp(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) + ) +end """ `GL_FAbs` @@ -4788,25 +4088,19 @@ abs-op ::= ssa-id `=` `spirv.GL.FAbs` ssa-use `:` %3 = spirv.GL.FAbs %1 : vector<3xf16> ``` """ -function GL_FAbs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FAbs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FAbs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FAbs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4835,22 +4129,18 @@ fclamp-op ::= ssa-id `=` `spirv.GL.FClamp` ssa-use, ssa-use, ssa-use `:` %3 = spirv.GL.FClamp %x, %min, %max : vector<3xf16> ``` """ -function GL_FClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GL.FClamp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_FClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GL.FClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4880,25 +4170,19 @@ fmax-op ::= ssa-id `=` `spirv.GL.FMax` ssa-use `:` %3 = spirv.GL.FMax %0, %1 : vector<3xf16> ``` """ -function GL_FMax( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FMax(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4928,25 +4212,19 @@ fmin-op ::= ssa-id `=` `spirv.GL.FMin` ssa-use `:` %3 = spirv.GL.FMin %0, %1 : vector<3xf16> ``` """ -function GL_FMin( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FMin(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4968,29 +4246,19 @@ Result Type and the type of all operands must be the same type. Results are comp %0 = spirv.GL.FMix %x : vector<4xf32>, %y : vector<4xf32>, %a : vector<4xf32> -> vector<4xf32> ``` """ -function GL_FMix( - x::Value, - y::Value, - a::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x, y, a] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FMix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FMix(x, y, a; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(y), value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FMix", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5019,25 +4287,19 @@ sign-op ::= ssa-id `=` `spirv.GL.FSign` ssa-use `:` %3 = spirv.GL.FSign %1 : vector<3xf16> ``` """ -function GL_FSign( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FSign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FSign(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FSign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5054,25 +4316,19 @@ computed per component. This instruction is currently limited to 32-bit width components. """ -function GL_FindUMsb( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FindUMsb", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FindUMsb(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FindUMsb", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5102,25 +4358,19 @@ floor-op ::= ssa-id `=` `spirv.GL.Floor` ssa-use `:` %3 = spirv.GL.Floor %1 : vector<3xf16> ``` """ -function GL_Floor( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Floor(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Floor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5159,22 +4409,18 @@ fma-op ::= ssa-id `=` `spirv.GL.Fma` ssa-use, ssa-use, ssa-use `:` %1 = spirv.GL.Fma %a, %b, %c : vector<3xf16> ``` """ -function GL_Fma(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GL.Fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_Fma(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GL.Fma", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5216,22 +4462,18 @@ frexpstruct-op ::= ssa-id `=` `spirv.GL.FrexpStruct` ssa-use `:` %3 = spirv.GL.FrexpStruct %0 : vector<3xf32> -> !spirv.struct, vector<3xi32>> ``` """ -function GL_FrexpStruct(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GL.FrexpStruct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_FrexpStruct(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GL.FrexpStruct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5260,25 +4502,19 @@ rsqrt-op ::= ssa-id `=` `spirv.GL.InverseSqrt` ssa-use `:` %3 = spirv.GL.InverseSqrt %1 : vector<3xf16> ``` """ -function GL_InverseSqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.InverseSqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_InverseSqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.InverseSqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5316,25 +4552,19 @@ component. %y = spirv.GL.Ldexp %x : vector<3xf32>, %exp : vector<3xi32> -> vector<3xf32> ``` """ -function GL_Ldexp( - x::Value, exp::Value; y=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[x, exp] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(y) && push!(_results, y) - - return IR.create_operation( - "spirv.GL.Ldexp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Ldexp(x, exp; y=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(exp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(y) && push!(results, y) + + IR.create_operation( + "spirv.GL.Ldexp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5366,23 +4596,19 @@ log-op ::= ssa-id `=` `spirv.GL.Log` ssa-use `:` %3 = spirv.GL.Log %1 : vector<3xf16> ``` """ -function GL_Log(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Log(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5415,25 +4641,19 @@ pow-op ::= ssa-id `=` `spirv.GL.Pow` ssa-use `:` %3 = spirv.GL.Pow %0, %1 : vector<3xf16> ``` """ -function GL_Pow( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Pow(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Pow", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5464,25 +4684,19 @@ round-even-op ::= ssa-id `=` `spirv.GL.RoundEven` ssa-use `:` %3 = spirv.GL.RoundEven %1 : vector<3xf16> ``` """ -function GL_RoundEven( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.RoundEven", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_RoundEven(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.RoundEven", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5514,25 +4728,19 @@ round-op ::= ssa-id `=` `spirv.GL.Round` ssa-use `:` %3 = spirv.GL.Round %1 : vector<3xf16> ``` """ -function GL_Round( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Round(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Round", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5560,25 +4768,19 @@ abs-op ::= ssa-id `=` `spirv.GL.SAbs` ssa-use `:` %3 = spirv.GL.SAbs %1 : vector<3xi16> ``` """ -function GL_SAbs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.SAbs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_SAbs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.SAbs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5606,22 +4808,18 @@ uclamp-op ::= ssa-id `=` `spirv.GL.UClamp` ssa-use, ssa-use, ssa-use `:` %3 = spirv.GL.SClamp %x, %min, %max : vector<3xsi16> ``` """ -function GL_SClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GL.SClamp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_SClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GL.SClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5650,25 +4848,19 @@ smax-op ::= ssa-id `=` `spirv.GL.SMax` ssa-use `:` %3 = spirv.GL.SMax %0, %1 : vector<3xi16> ``` """ -function GL_SMax( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.SMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_SMax(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.SMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5690,32 +4882,26 @@ integer-scalar-vector-type ::= integer-type | smin-op ::= ssa-id `=` `spirv.GL.SMin` ssa-use `:` integer-scalar-vector-type ``` -#### Example: - -```mlir -%2 = spirv.GL.SMin %0, %1 : i32 -%3 = spirv.GL.SMin %0, %1 : vector<3xi16> -``` -""" -function GL_SMin( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) +#### Example: - return IR.create_operation( - "spirv.GL.SMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +```mlir +%2 = spirv.GL.SMin %0, %1 : i32 +%3 = spirv.GL.SMin %0, %1 : vector<3xi16> +``` +""" +function GL_SMin(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.SMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5743,25 +4929,19 @@ sign-op ::= ssa-id `=` `spirv.GL.SSign` ssa-use `:` %3 = spirv.GL.SSign %1 : vector<3xi16> ``` """ -function GL_SSign( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.SSign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_SSign(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.SSign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5792,23 +4972,19 @@ sin-op ::= ssa-id `=` `spirv.GL.Sin` ssa-use `:` %3 = spirv.GL.Sin %1 : vector<3xf16> ``` """ -function GL_Sin(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Sin(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5839,25 +5015,19 @@ sinh-op ::= ssa-id `=` `spirv.GL.Sinh` ssa-use `:` %3 = spirv.GL.Sinh %1 : vector<3xf16> ``` """ -function GL_Sinh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Sinh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Sinh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Sinh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5886,25 +5056,19 @@ sqrt-op ::= ssa-id `=` `spirv.GL.Sqrt` ssa-use `:` %3 = spirv.GL.Sqrt %1 : vector<3xf16> ``` """ -function GL_Sqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Sqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5935,23 +5099,19 @@ tan-op ::= ssa-id `=` `spirv.GL.Tan` ssa-use `:` %3 = spirv.GL.Tan %1 : vector<3xf16> ``` """ -function GL_Tan(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Tan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Tan(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Tan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5982,25 +5142,19 @@ tanh-op ::= ssa-id `=` `spirv.GL.Tanh` ssa-use `:` %3 = spirv.GL.Tanh %1 : vector<3xf16> ``` """ -function GL_Tanh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Tanh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6028,22 +5182,18 @@ uclamp-op ::= ssa-id `=` `spirv.GL.UClamp` ssa-use, ssa-use, ssa-use `:` %3 = spirv.GL.UClamp %x, %min, %max : vector<3xui16> ``` """ -function GL_UClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GL.UClamp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_UClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GL.UClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6072,25 +5222,19 @@ smax-op ::= ssa-id `=` `spirv.GL.UMax` ssa-use `:` %3 = spirv.GL.UMax %0, %1 : vector<3xi16> ``` """ -function GL_UMax( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.UMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_UMax(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.UMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6119,25 +5263,19 @@ smin-op ::= ssa-id `=` `spirv.GL.UMin` ssa-use `:` %3 = spirv.GL.UMin %0, %1 : vector<3xi16> ``` """ -function GL_UMin( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.UMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_UMin(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.UMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6163,22 +5301,18 @@ Workgroup, CrossWorkgroup, or Function. !spirv.ptr ``` """ -function GenericCastToPtrExplicit(pointer::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[pointer,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GenericCastToPtrExplicit", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GenericCastToPtrExplicit(pointer; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GenericCastToPtrExplicit", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6201,22 +5335,18 @@ Result Type and Pointer must point to the same type. !spirv.ptr ``` """ -function GenericCastToPtr(pointer::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[pointer,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GenericCastToPtr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GenericCastToPtr(pointer; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GenericCastToPtr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6342,29 +5472,19 @@ group-broadcast-op ::= ssa-id `=` `spirv.GroupBroadcast` scope ssa_use, vector<4xf32>, vector<3xi32> ``` """ -function GroupBroadcast( - value::Value, - localid::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, localid] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupBroadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupBroadcast(value, localid; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(localid), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupBroadcast", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6400,32 +5520,19 @@ op ::= ssa-id `=` `spirv.GroupFAdd` scope operation ssa-use %0 = spirv.GroupFAdd %value : f32 ``` """ -function GroupFAdd( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupFAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupFAdd(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupFAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6461,32 +5568,19 @@ op ::= ssa-id `=` `spirv.GroupFMax` scope operation ssa-use %0 = spirv.GroupFMax %value : f32 ``` """ -function GroupFMax( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupFMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupFMax(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupFMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6522,32 +5616,19 @@ op ::= ssa-id `=` `spirv.GroupFMin` scope operation ssa-use %0 = spirv.GroupFMin %value : f32 ``` """ -function GroupFMin( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupFMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupFMin(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupFMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6578,38 +5659,25 @@ op ::= ssa-id `=` `spirv.KHR.GroupFMul` scope operation ssa-use `:` float-type ``` -#### Example: - -```mlir -%0 = spirv.KHR.GroupFMul %value : f32 -``` -""" -function KHR_GroupFMul( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) +#### Example: - return IR.create_operation( - "spirv.KHR.GroupFMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +```mlir +%0 = spirv.KHR.GroupFMul %value : f32 +``` +""" +function KHR_GroupFMul(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.KHR.GroupFMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6645,32 +5713,19 @@ op ::= ssa-id `=` `spirv.GroupIAdd` scope operation ssa-use %0 = spirv.GroupIAdd %value : i32 ``` """ -function GroupIAdd( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupIAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupIAdd(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupIAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6707,32 +5762,19 @@ op ::= ssa-id `=` `spirv.KHR.GroupIMul` scope operation ssa-use %0 = spirv.KHR.GroupIMul %value : i32 ``` """ -function KHR_GroupIMul( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.KHR.GroupIMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function KHR_GroupIMul(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.KHR.GroupIMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6765,24 +5807,18 @@ non-uniform-ballot-op ::= ssa-id `=` `spirv.GroupNonUniformBallot` scope %0 = spirv.GroupNonUniformBallot \"SubGroup\" %predicate : vector<4xi32> ``` """ -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( - "spirv.GroupNonUniformBallot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformBallot(predicate; result::IR.Type, execution_scope, location=Location()) + results = IR.Type[result, ] + operands = Value[value(predicate), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + + IR.create_operation( + "spirv.GroupNonUniformBallot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6827,29 +5863,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(), -) - _results = IR.Type[] - _operands = Value[value, id] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupNonUniformBroadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupNonUniformBroadcast(value, id; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(id), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupNonUniformBroadcast", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6938,33 +5964,19 @@ non-uniform-fadd-op ::= ssa-id `=` `spirv.GroupNonUniformFAdd` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformFAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFAdd(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformFAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7013,33 +6025,19 @@ non-uniform-fmax-op ::= ssa-id `=` `spirv.GroupNonUniformFMax` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformFMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformFMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7088,33 +6086,19 @@ non-uniform-fmin-op ::= ssa-id `=` `spirv.GroupNonUniformFMin` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformFMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformFMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7160,33 +6144,19 @@ non-uniform-fmul-op ::= ssa-id `=` `spirv.GroupNonUniformFMul` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformFMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMul(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformFMul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7230,33 +6200,19 @@ non-uniform-iadd-op ::= ssa-id `=` `spirv.GroupNonUniformIAdd` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformIAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformIAdd(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformIAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7300,33 +6256,19 @@ non-uniform-imul-op ::= ssa-id `=` `spirv.GroupNonUniformIMul` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformIMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformIMul(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformIMul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7370,33 +6312,19 @@ non-uniform-smax-op ::= ssa-id `=` `spirv.GroupNonUniformSMax` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformSMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformSMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformSMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7440,33 +6368,19 @@ non-uniform-smin-op ::= ssa-id `=` `spirv.GroupNonUniformSMin` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformSMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformSMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformSMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7495,29 +6409,19 @@ invocation or greater than or equal to the size of the group. %0 = spirv.GroupNonUniformShuffleDown %val, %delta : f32, i32 ``` """ -function GroupNonUniformShuffleDown( - value::Value, - delta::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, delta] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupNonUniformShuffleDown", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupNonUniformShuffleDown(value, delta; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(delta), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupNonUniformShuffleDown", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7535,38 +6439,28 @@ Id must be a scalar of integer type, whose Signedness operand is 0. The resulting value is undefined if Id is an inactive invocation, or is greater than or equal to the size of the group. - - - -#### Example: - -```mlir -%0 = spirv.GroupNonUniformShuffle %val, %id : f32, i32 -``` -""" -function GroupNonUniformShuffle( - value::Value, - id::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, id] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupNonUniformShuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), + + + +#### Example: + +```mlir +%0 = spirv.GroupNonUniformShuffle %val, %id : f32, i32 +``` +""" +function GroupNonUniformShuffle(value, id; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(id), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupNonUniformShuffle", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7594,29 +6488,19 @@ the selected lane is inactive. %0 = spirv.GroupNonUniformShuffleUp %val, %delta : f32, i32 ``` """ -function GroupNonUniformShuffleUp( - value::Value, - delta::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, delta] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupNonUniformShuffleUp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupNonUniformShuffleUp(value, delta; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(delta), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupNonUniformShuffleUp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7644,29 +6528,19 @@ equal to the size of the group. %0 = spirv.GroupNonUniformShuffleXor %val, %mask : f32, i32 ``` """ -function GroupNonUniformShuffleXor( - value::Value, - mask::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, mask] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupNonUniformShuffleXor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupNonUniformShuffleXor(value, mask; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(mask), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupNonUniformShuffleXor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7711,33 +6585,19 @@ non-uniform-umax-op ::= ssa-id `=` `spirv.GroupNonUniformUMax` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformUMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformUMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformUMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7782,33 +6642,19 @@ non-uniform-umin-op ::= ssa-id `=` `spirv.GroupNonUniformUMin` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformUMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformUMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformUMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7845,32 +6691,19 @@ op ::= ssa-id `=` `spirv.GroupSMax` scope operation ssa-use %0 = spirv.GroupSMax %value : i32 ``` """ -function GroupSMax( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupSMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupSMax(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupSMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7907,32 +6740,19 @@ op ::= ssa-id `=` `spirv.GroupSMin` scope operation ssa-use %0 = spirv.GroupSMin %value : i32 ``` """ -function GroupSMin( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupSMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupSMin(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupSMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7968,32 +6788,19 @@ op ::= ssa-id `=` `spirv.GroupUMax` scope operation ssa-use %0 = spirv.GroupUMax %value : i32 ``` """ -function GroupUMax( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupUMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupUMax(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupUMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8030,32 +6837,19 @@ op ::= ssa-id `=` `spirv.GroupUMin` scope operation ssa-use %0 = spirv.GroupUMin %value : i32 ``` """ -function GroupUMin( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupUMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupUMin(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupUMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8088,22 +6882,18 @@ the component width, and 0 otherwise. %2 = spirv.IAddCarry %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)> ``` """ -function IAddCarry(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( - "spirv.IAddCarry", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function IAddCarry(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.IAddCarry", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8138,28 +6928,19 @@ iadd-op ::= ssa-id `=` `spirv.IAdd` ssa-use, ssa-use ``` """ -function IAdd( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.IAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IAdd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.IAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8189,28 +6970,18 @@ iequal-op ::= ssa-id `=` `spirv.IEqual` ssa-use, ssa-use ``` """ -function IEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.IEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.IEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8245,28 +7016,19 @@ imul-op ::= ssa-id `=` `spirv.IMul` ssa-use, ssa-use ``` """ -function IMul( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.IMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IMul(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.IMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8300,36 +7062,20 @@ present, it is the same as specifying the memory operand None. !spirv.jointmatrix<8x16xi32, ColumnMajor, Subgroup> ``` """ -function INTEL_JointMatrixLoad( - pointer::Value, - stride::Value; - result::IR.Type, - layout, - scope, - memory_access=nothing, - alignment=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[pointer, stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("layout", layout), namedattribute("scope", scope) - ] - !isnothing(memory_access) && - push!(_attributes, namedattribute("memory_access", memory_access)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "spirv.INTEL.JointMatrixLoad", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function INTEL_JointMatrixLoad(pointer, stride; result::IR.Type, layout, scope, memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(stride), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("layout", layout), namedattribute("scope", scope), ] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spirv.INTEL.JointMatrixLoad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8367,30 +7113,19 @@ integer type. -> !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> ``` """ -function INTEL_JointMatrixMad( - a::Value, - b::Value, - c::Value; - result=nothing::Union{Nothing,IR.Type}, - scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("scope", scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.INTEL.JointMatrixMad", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function INTEL_JointMatrixMad(a, b, c; result=nothing::Union{Nothing, IR.Type}, scope, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("scope", scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.INTEL.JointMatrixMad", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8427,37 +7162,21 @@ spirv.INTEL.JointMatrixStore %ptr, %m, %stride {memory_access = #spirv.memory_access} : (!spirv.ptr, !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) ``` -""" -function INTEL_JointMatrixStore( - pointer::Value, - object::Value, - stride::Value; - layout, - scope, - memory_access=nothing, - alignment=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[pointer, object, stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("layout", layout), namedattribute("scope", scope) - ] - !isnothing(memory_access) && - push!(_attributes, namedattribute("memory_access", memory_access)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "spirv.INTEL.JointMatrixStore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +""" +function INTEL_JointMatrixStore(pointer, object, stride; layout, scope, memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(pointer), value(object), value(stride), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("layout", layout), namedattribute("scope", scope), ] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spirv.INTEL.JointMatrixStore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8535,22 +7254,18 @@ subgroup-block-read-INTEL-op ::= ssa-id `=` `spirv.INTEL.SubgroupBlockRead` %0 = spirv.INTEL.SubgroupBlockRead \"StorageBuffer\" %ptr : i32 ``` """ -function INTEL_SubgroupBlockRead(ptr::Value; value::IR.Type, location=Location()) - _results = IR.Type[value,] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.INTEL.SubgroupBlockRead", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function INTEL_SubgroupBlockRead(ptr; value::IR.Type, location=Location()) + results = IR.Type[value, ] + operands = Value[value(ptr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.INTEL.SubgroupBlockRead", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8584,22 +7299,18 @@ subgroup-block-write-INTEL-op ::= ssa-id `=` `spirv.INTEL.SubgroupBlockWrite` spirv.INTEL.SubgroupBlockWrite \"StorageBuffer\" %ptr, %value : i32 ``` """ -function INTEL_SubgroupBlockWrite(ptr::Value, value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[ptr, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.INTEL.SubgroupBlockWrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function INTEL_SubgroupBlockWrite(ptr, value; location=Location()) + results = IR.Type[] + operands = Value[value(ptr), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.INTEL.SubgroupBlockWrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8629,28 +7340,18 @@ inot-equal-op ::= ssa-id `=` `spirv.INotEqual` ssa-use, ssa-use ``` """ -function INotEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.INotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function INotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.INotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8685,22 +7386,18 @@ otherwise. %2 = spirv.ISubBorrow %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)> ``` """ -function ISubBorrow(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( - "spirv.ISubBorrow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ISubBorrow(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ISubBorrow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8735,28 +7432,19 @@ isub-op ::= `spirv.ISub` ssa-use, ssa-use ``` """ -function ISub( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ISub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ISub(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.ISub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8796,32 +7484,19 @@ image-operands ::= `\"None\"` | `\"Bias\"` | `\"Lod\"` | `\"Grad\"` %0 = spirv.ImageDrefGather %1 : !spirv.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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(imageoperands) && - push!(_attributes, namedattribute("imageoperands", imageoperands)) - - return IR.create_operation( - "spirv.ImageDrefGather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ImageDrefGather(sampledimage, coordinate, dref, operand_arguments; result::IR.Type, imageoperands=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(sampledimage), value(coordinate), value(dref), value.(operand_arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(imageoperands) && push!(attributes, namedattribute("imageoperands", imageoperands)) + + IR.create_operation( + "spirv.ImageDrefGather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8841,25 +7516,18 @@ same as Result Type. %0 = spirv.Image %1 : !spirv.sampled_image> ``` """ -function Image( - sampledimage::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[sampledimage,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.Image", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Image(sampledimage; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(sampledimage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Image", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8897,22 +7565,18 @@ See the client API specification for additional image type restrictions. %5 = spirv.ImageQuerySize %2 : !spirv.image -> vector<3xi32> ``` """ -function ImageQuerySize(image::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[image,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ImageQuerySize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ImageQuerySize(image; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(image), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ImageQuerySize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8938,28 +7602,18 @@ func @inbounds_ptr_access_chain(%arg0: !spirv.ptr, %arg1 : } ``` """ -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( - "spirv.InBoundsPtrAccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function InBoundsPtrAccessChain(base_ptr, element, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base_ptr), value(element), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.InBoundsPtrAccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8989,23 +7643,18 @@ isinf-op ::= ssa-id `=` `spirv.IsInf` ssa-use %3 = spirv.IsInf %1: vector<4xi32> ``` """ -function IsInf(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.IsInf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IsInf(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.IsInf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9035,23 +7684,18 @@ isnan-op ::= ssa-id `=` `spirv.IsNan` ssa-use %3 = spirv.IsNan %1: vector<4xi32> ``` """ -function IsNan(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.IsNan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IsNan(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.IsNan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9072,22 +7716,18 @@ assumetruekhr-op ::= `spirv.KHR.AssumeTrue` ssa-use spirv.KHR.AssumeTrue %arg ``` """ -function KHR_AssumeTrue(condition::Value; location=Location()) - _results = IR.Type[] - _operands = Value[condition,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.KHR.AssumeTrue", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function KHR_AssumeTrue(condition; location=Location()) + results = IR.Type[] + operands = Value[value(condition), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.KHR.AssumeTrue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9121,22 +7761,18 @@ subgroup-ballot-op ::= ssa-id `=` `spirv.KHR.SubgroupBallot` %0 = spirv.KHR.SubgroupBallot %predicate : vector<4xi32> ``` """ -function KHR_SubgroupBallot(predicate::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[predicate,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.KHR.SubgroupBallot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function KHR_SubgroupBallot(predicate; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(predicate), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.KHR.SubgroupBallot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9173,31 +7809,20 @@ load-op ::= ssa-id ` = spirv.Load ` storage-class ssa-use %3 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(memory_access) && - push!(_attributes, namedattribute("memory_access", memory_access)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "spirv.Load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Load(ptr; value::IR.Type, memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(ptr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spirv.Load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9226,28 +7851,18 @@ logical-and ::= `spirv.LogicalAnd` ssa-use `,` ssa-use %2 = spirv.LogicalAnd %0, %1 : vector<4xi1> ``` """ -function LogicalAnd( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.LogicalAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function LogicalAnd(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.LogicalAnd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9276,28 +7891,18 @@ logical-equal ::= `spirv.LogicalEqual` ssa-use `,` ssa-use %2 = spirv.LogicalEqual %0, %1 : vector<4xi1> ``` """ -function LogicalEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.LogicalEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function LogicalEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.LogicalEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9315,39 +7920,29 @@ Result Type must be a scalar or vector of Boolean type. ``` -logical-not-equal ::= `spirv.LogicalNotEqual` ssa-use `,` ssa-use - `:` operand-type -``` - -#### Example: - -```mlir -%2 = spirv.LogicalNotEqual %0, %1 : i1 -%2 = spirv.LogicalNotEqual %0, %1 : vector<4xi1> -``` -""" -function LogicalNotEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.LogicalNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +logical-not-equal ::= `spirv.LogicalNotEqual` ssa-use `,` ssa-use + `:` operand-type +``` + +#### Example: + +```mlir +%2 = spirv.LogicalNotEqual %0, %1 : i1 +%2 = spirv.LogicalNotEqual %0, %1 : vector<4xi1> +``` +""" +function LogicalNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.LogicalNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9373,25 +7968,18 @@ logical-not ::= `spirv.LogicalNot` ssa-use `:` operand-type %2 = spirv.LogicalNot %0 : vector<4xi1> ``` """ -function LogicalNot( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.LogicalNot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function LogicalNot(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.LogicalNot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9420,28 +8008,18 @@ logical-or ::= `spirv.LogicalOr` ssa-use `,` ssa-use %2 = spirv.LogicalOr %0, %1 : vector<4xi1> ``` """ -function LogicalOr( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.LogicalOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function LogicalOr(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.LogicalOr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9520,24 +8098,18 @@ ssa-use `:` matrix-type `,` matrix-type `->` matrix-type !spirv.matrix<4 x vector<4xf32>> ``` """ -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( - "spirv.MatrixTimesMatrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function MatrixTimesMatrix(leftmatrix, rightmatrix; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(leftmatrix), value(rightmatrix), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.MatrixTimesMatrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9568,28 +8140,19 @@ ssa-use `:` matrix-type `,` float-type `->` matrix-type ``` """ -function MatrixTimesScalar( - matrix::Value, - scalar::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[matrix, scalar] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.MatrixTimesScalar", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function MatrixTimesScalar(matrix, scalar; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(matrix), value(scalar), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.MatrixTimesScalar", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9849,31 +8412,19 @@ For example: : !spirv.ptr as !spirv.coopmatrix ``` """ -function NV_CooperativeMatrixLoad( - 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( - "spirv.NV.CooperativeMatrixLoad", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function NV_CooperativeMatrixLoad(pointer, stride, columnmajor; result::IR.Type, memory_access=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(stride), value(columnmajor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + + IR.create_operation( + "spirv.NV.CooperativeMatrixLoad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9924,29 +8475,19 @@ For example: !spirv.coopmatrix ``` """ -function NV_CooperativeMatrixMulAdd( - a::Value, - b::Value, - c::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.NV.CooperativeMatrixMulAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function NV_CooperativeMatrixMulAdd(a, b, c; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.NV.CooperativeMatrixMulAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9989,31 +8530,19 @@ For example: !spirv.ptr, !spirv.coopmatrix ``` """ -function NV_CooperativeMatrixStore( - pointer::Value, - object::Value, - stride::Value, - columnmajor::Value; - memory_access=nothing, - location=Location(), -) - _results = IR.Type[] - _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( - "spirv.NV.CooperativeMatrixStore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function NV_CooperativeMatrixStore(pointer, object, stride, columnmajor; memory_access=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(pointer), value(object), value(stride), value(columnmajor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + + IR.create_operation( + "spirv.NV.CooperativeMatrixStore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10043,23 +8572,19 @@ Results are computed per component, and within each component, per bit. %3 = spirv.Not %1 : vector<4xi32> ``` """ -function Not(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.Not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Not(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.Not", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -10090,28 +8615,18 @@ ordered-op ::= ssa-id `=` `spirv.Ordered` ssa-use, ssa-use %5 = spirv.Ordered %2, %3 : vector<4xf32> ``` """ -function Ordered( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.Ordered", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Ordered(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Ordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10160,28 +8675,18 @@ func @ptr_access_chain(%arg0: !spirv.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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.PtrAccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function PtrAccessChain(base_ptr, element, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base_ptr), value(element), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.PtrAccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10204,22 +8709,18 @@ Result Type and Pointer must point to the same type. !spirv.ptr ``` """ -function PtrCastToGeneric(pointer::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[pointer,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.PtrCastToGeneric", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function PtrCastToGeneric(pointer; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.PtrCastToGeneric", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10318,22 +8819,18 @@ return-value-op ::= `spirv.ReturnValue` ssa-use `:` spirv-type spirv.ReturnValue %0 : f32 ``` """ -function ReturnValue(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ReturnValue", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ReturnValue(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ReturnValue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10362,22 +8859,18 @@ s-convert-op ::= ssa-id `=` `spirv.SConvertOp` ssa-use %3 = spirv.SConvertOp %2 : vector<3xi32> to vector<3xi64> ``` """ -function SConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.SConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10409,28 +8902,19 @@ sdiv-op ::= ssa-id `=` `spirv.SDiv` ssa-use, ssa-use ``` """ -function SDiv( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.SDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -10473,30 +8957,19 @@ is undefined. %r = spirv.SDotAccSat %a, %b, %acc : (vector<4xi8>, vector<4xi8>, i32) -> i32 ``` """ -function SDotAccSat( - vector1::Value, - vector2::Value, - accumulator::Value; - result::IR.Type, - format=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2, accumulator] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.SDotAccSat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SDotAccSat(vector1, vector2, accumulator; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), value(accumulator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.SDotAccSat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10525,34 +8998,28 @@ is the result width and R is computed with enough precision to avoid overflow and underflow. - -#### Example: - -```mlir -%r = spirv.SDot %a, %b {format = #spirv.packed_vector_format}: (i32, i32) -> i32 -%r = spirv.SDot %a, %b {format = #spirv.packed_vector_format}: (i32, i32) -> i64 -%r = spirv.SDot %a, %b : (vector<4xi8>, vector<4xi8>) -> i32 -``` -""" -function SDot( - vector1::Value, vector2::Value; result::IR.Type, format=nothing, location=Location() -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.SDot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, + +#### Example: + +```mlir +%r = spirv.SDot %a, %b {format = #spirv.packed_vector_format}: (i32, i32) -> i32 +%r = spirv.SDot %a, %b {format = #spirv.packed_vector_format}: (i32, i32) -> i64 +%r = spirv.SDot %a, %b : (vector<4xi8>, vector<4xi8>) -> i32 +``` +""" +function SDot(vector1, vector2; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.SDot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10582,28 +9049,18 @@ sgreater-than-equal-op ::= ssa-id `=` `spirv.SGreaterThanEqual` ssa-use, ssa-use ``` """ -function SGreaterThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10633,28 +9090,18 @@ sgreater-than-op ::= ssa-id `=` `spirv.SGreaterThan` ssa-use, ssa-use ``` """ -function SGreaterThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10684,28 +9131,18 @@ sless-than-equal-op ::= ssa-id `=` `spirv.SLessThanEqual` ssa-use, ssa-use ``` """ -function SLessThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10735,28 +9172,18 @@ sless-than-op ::= ssa-id `=` `spirv.SLessThan` ssa-use, ssa-use ``` """ -function SLessThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10789,28 +9216,19 @@ smod-op ::= ssa-id `=` `spirv.SMod` ssa-use, ssa-use ``` """ -function SMod( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.SMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -10839,24 +9257,18 @@ Member 1 of the result gets the high-order bits of the multiplication. %2 = spirv.SMulExtended %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)> ``` """ -function SMulExtended( - 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( - "spirv.SMulExtended", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SMulExtended(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SMulExtended", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10880,25 +9292,19 @@ must equal the component width in Result Type. %3 = spirv.SNegate %2 : vector<4xi32> ``` """ -function SNegate( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SNegate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SNegate(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.SNegate", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -10931,28 +9337,19 @@ srem-op ::= ssa-id `=` `spirv.SRem` ssa-use, ssa-use ``` """ -function SRem( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SRem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SRem(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.SRem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -10997,30 +9394,19 @@ is undefined. %r = spirv.SUDotAccSat %a, %b, %acc : (vector<4xi8>, vector<4xi8>, i32) -> i32 ``` """ -function SUDotAccSat( - vector1::Value, - vector2::Value, - accumulator::Value; - result::IR.Type, - format=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2, accumulator] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.SUDotAccSat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SUDotAccSat(vector1, vector2, accumulator; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), value(accumulator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.SUDotAccSat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11060,25 +9446,19 @@ avoid overflow and underflow. %r = spirv.SUDot %a, %b : (vector<4xi8>, vector<4xi8>) -> i32 ``` """ -function SUDot( - vector1::Value, vector2::Value; result::IR.Type, format=nothing, location=Location() -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.SUDot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SUDot(vector1, vector2; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.SUDot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11121,29 +9501,19 @@ select-op ::= ssa-id `=` `spirv.Select` ssa-use, ssa-use, ssa-use %3 = spirv.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(), -) - _results = IR.Type[] - _operands = Value[condition, true_value, false_value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.Select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Select(condition, true_value, false_value; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(true_value), value(false_value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.Select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -11223,28 +9593,19 @@ shift-left-logical-op ::= ssa-id `=` `spirv.ShiftLeftLogical` %5 = spirv.ShiftLeftLogical %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftLeftLogical( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ShiftLeftLogical", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ShiftLeftLogical(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.ShiftLeftLogical", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -11281,28 +9642,19 @@ shift-right-arithmetic-op ::= ssa-id `=` `spirv.ShiftRightArithmetic` %5 = spirv.ShiftRightArithmetic %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftRightArithmetic( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ShiftRightArithmetic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ShiftRightArithmetic(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.ShiftRightArithmetic", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -11340,28 +9692,19 @@ shift-right-logical-op ::= ssa-id `=` `spirv.ShiftRightLogical` %5 = spirv.ShiftRightLogical %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftRightLogical( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ShiftRightLogical", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ShiftRightLogical(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.ShiftRightLogical", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -11593,27 +9936,20 @@ spirv.Store \"Function\" %0, %1 [\"Volatile\"] : f32 spirv.Store \"Function\" %0, %1 [\"Aligned\", 4] : f32 ``` """ -function Store( - ptr::Value, value::Value; memory_access=nothing, alignment=nothing, location=Location() -) - _results = IR.Type[] - _operands = Value[ptr, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(memory_access) && - push!(_attributes, namedattribute("memory_access", memory_access)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "spirv.Store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Store(ptr, value; memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(ptr), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spirv.Store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11643,24 +9979,20 @@ matrix-type %0 = spirv.Transpose %matrix: !spirv.matrix<2 x vector<3xf32>> -> !spirv.matrix<3 x vector<2xf32>> -``` -""" -function Transpose(matrix::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[matrix,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.Transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +``` +""" +function Transpose(matrix; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(matrix), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11690,22 +10022,18 @@ u-convert-op ::= ssa-id `=` `spirv.UConvertOp` ssa-use %3 = spirv.UConvertOp %2 : vector<3xi32> to vector<3xi64> ``` """ -function UConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.UConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.UConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11736,28 +10064,19 @@ udiv-op ::= ssa-id `=` `spirv.UDiv` ssa-use, ssa-use ``` """ -function UDiv( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.UDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.UDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -11802,30 +10121,19 @@ is undefined. %r = spirv.UDotAccSat %a, %b, %acc : (vector<4xi8>, vector<4xi8>, i32) -> i32 ``` """ -function UDotAccSat( - vector1::Value, - vector2::Value, - accumulator::Value; - result::IR.Type, - format=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2, accumulator] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.UDotAccSat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UDotAccSat(vector1, vector2, accumulator; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), value(accumulator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.UDotAccSat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11865,25 +10173,19 @@ overflow and underflow. %r = spirv.UDot %a, %b : (vector<4xi8>, vector<4xi8>) -> i32 ``` """ -function UDot( - vector1::Value, vector2::Value; result::IR.Type, format=nothing, location=Location() -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.UDot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UDot(vector1, vector2; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.UDot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11913,28 +10215,18 @@ ugreater-than-equal-op ::= ssa-id `=` `spirv.UGreaterThanEqual` ssa-use, ssa-use ``` """ -function UGreaterThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.UGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.UGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11964,28 +10256,18 @@ ugreater-than-op ::= ssa-id `=` `spirv.UGreaterThan` ssa-use, ssa-use ``` """ -function UGreaterThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.UGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.UGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12015,28 +10297,18 @@ uless-than-equal-op ::= ssa-id `=` `spirv.ULessThanEqual` ssa-use, ssa-use ``` """ -function ULessThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ULessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ULessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ULessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12066,28 +10338,18 @@ uless-than-op ::= ssa-id `=` `spirv.ULessThan` ssa-use, ssa-use ``` """ -function ULessThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ULessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ULessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ULessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12118,28 +10380,19 @@ umod-op ::= ssa-id `=` `spirv.UMod` ssa-use, ssa-use ``` """ -function UMod( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.UMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.UMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -12169,24 +10422,18 @@ Member 1 of the result gets the high-order bits of the multiplication. %2 = spirv.UMulExtended %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)> ``` """ -function UMulExtended( - 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( - "spirv.UMulExtended", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UMulExtended(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.UMulExtended", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12258,28 +10505,18 @@ unordered-op ::= ssa-id `=` `spirv.Unordered` ssa-use, ssa-use %5 = spirv.Unordered %2, %3 : vector<4xf32> ``` """ -function Unordered( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.Unordered", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Unordered(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Unordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12347,28 +10584,19 @@ where `init` specifies initializer. %2 = spirv.Variable init(%0): !spirv.ptr ``` """ -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),] - !isnothing(initializer) && push!(_operands, initializer) - - return IR.create_operation( - "spirv.Variable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Variable(initializer=nothing; 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), ] + !isnothing(initializer) && push!(operands, value(initializer)) + + IR.create_operation( + "spirv.Variable", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12394,25 +10622,18 @@ or equal to the number of components in Vector. %2 = spirv.VectorExtractDynamic %0[%1] : vector<8xf32>, i32 ``` """ -function VectorExtractDynamic( - vector::Value, index::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[vector, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.VectorExtractDynamic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function VectorExtractDynamic(vector, index; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.VectorExtractDynamic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12450,29 +10671,19 @@ vector-insert-dynamic-op ::= `spirv.VectorInsertDynamic ` ssa-use `,` %2 = spirv.VectorInsertDynamic %scalar %0[%1] : f32, vector<8xf32>, i32 ``` """ -function VectorInsertDynamic( - vector::Value, - component::Value, - index::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[vector, component, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.VectorInsertDynamic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function VectorInsertDynamic(vector, component, index; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(vector), value(component), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.VectorInsertDynamic", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -12513,24 +10724,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("components", components),] - - return IR.create_operation( - "spirv.VectorShuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function VectorShuffle(vector1, vector2; result::IR.Type, components, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("components", components), ] + + IR.create_operation( + "spirv.VectorShuffle", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12552,24 +10757,18 @@ Scalar must have the same type as the Component Type in Result Type. %0 = spirv.VectorTimesScalar %vector, %scalar : vector<4xf32> ``` """ -function VectorTimesScalar( - vector::Value, scalar::Value; result::IR.Type, location=Location() -) - _results = IR.Type[result,] - _operands = Value[vector, scalar] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.VectorTimesScalar", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function VectorTimesScalar(vector, scalar; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value(scalar), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.VectorTimesScalar", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12592,22 +10791,18 @@ spirv.mlir.yield ::= `spirv.mlir.yield` ssa-id : spirv-type spirv.mlir.yield %0 ``` """ -function mlir_yield(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.mlir.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mlir_yield(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.mlir.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Shape.jl b/src/Dialects/16/Shape.jl index 06993eed..62ba00c3 100644 --- a/src/Dialects/16/Shape.jl +++ b/src/Dialects/16/Shape.jl @@ -1,7 +1,6 @@ module shape -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -14,25 +13,19 @@ at least one of the operands can hold an error, i.e. if it is of type 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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -52,22 +45,18 @@ inputs have differing ranks or differ in extents of shared dimensions. %s1 = shape.any [?,?], [1,2] // [1,2] ``` """ -function any(inputs::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.any", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function any(inputs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.any", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -91,25 +80,19 @@ ready to execute. %wt = shape.assuming_all %w0, %w2 // Passing ``` """ -function assuming_all( - inputs::Vector{Value}; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.assuming_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function assuming_all(inputs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.assuming_all", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -123,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assuming(witness; results_::Vector{IR.Type}, doRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(witness), ] + owned_regions = Region[doRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.assuming", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -152,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming_yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assuming_yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.assuming_yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -194,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(error) && push!(_attributes, namedattribute("error", error)) - - return IR.create_operation( - "shape.broadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function broadcast(shapes; result::IR.Type, error=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(error) && push!(attributes, namedattribute("error", error)) + + IR.create_operation( + "shape.broadcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -227,22 +194,18 @@ concat([2,3], [4,5]) -> [2,3,4,5] concat([], []) -> [] concat([], [4,5,6]) -> [4,5,6] """ -function concat(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.concat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function concat(lhs, rhs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.concat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -360,25 +323,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_broadcastable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_broadcastable(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -395,25 +352,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_eq(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -436,25 +387,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() -) - _results = IR.Type[] - _operands = Value[pred,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("msg", msg),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_require", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_require(pred; result=nothing::Union{Nothing, IR.Type}, msg, location=Location()) + results = IR.Type[] + operands = Value[value(pred), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("msg", msg), ] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -465,22 +410,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.debug_print", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function debug_print(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.debug_print", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -494,25 +435,19 @@ return type carries error information else the behavior is undefined. This is a convenience op that performs the equivalent of getting the extent of a shape (e.g., `dim(x, i) == get_extent(shape_of(x), i)`). """ -function dim( - value::Value, index::Value; extent=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[value, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(extent) && push!(_results, extent) - - return IR.create_operation( - "shape.dim", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function dim(value, index; extent=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(extent) && push!(results, extent) + + IR.create_operation( + "shape.dim", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -533,25 +468,19 @@ toward 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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function div(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.div", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -562,25 +491,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function from_extent_tensor(input; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -597,25 +520,19 @@ the shape. %s1 = shape.from_extents ``` """ -function from_extents( - extents::Vector{Value}; shape=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[extents...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(shape) && push!(_results, shape) - - return IR.create_operation( - "shape.from_extents", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function from_extents(extents; shape=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(extents)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(shape) && push!(results, shape) + + IR.create_operation( + "shape.from_extents", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -709,25 +626,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function get_extent(shape, dim; extent=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), value(dim), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(extent) && push!(results, extent) + + 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) ) end @@ -740,25 +651,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function index_to_size(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -780,25 +685,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.is_broadcastable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function is_broadcastable(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -810,25 +709,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function max(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.max", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -859,30 +752,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function meet(arg0, arg1; result=nothing::Union{Nothing, IR.Type}, error=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(arg0), value(arg1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(error) && push!(attributes, namedattribute("error", error)) + + IR.create_operation( + "shape.meet", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -894,25 +777,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function min(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.min", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -926,25 +803,19 @@ at least one of the operands can hold an error, i.e. if it is of type 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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -957,25 +828,19 @@ type `size` and potential errors will be propagated. Otherwise, if the argument 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() -) - _results = IR.Type[] - _operands = Value[shape,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.num_elements", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function num_elements(shape; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -984,23 +849,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()) - _results = IR.Type[] - _operands = Value[shape,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(rank) && push!(_results, rank) - - return IR.create_operation( - "shape.rank", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rank(shape; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + IR.create_operation( + "shape.rank", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1038,28 +899,18 @@ func.func @reduce(%shape : !shape.shape, %init : !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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce(shape, initVals; result::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result..., ] + operands = Value[value(shape), value.(initVals)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.reduce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1070,22 +921,18 @@ The `shape.return` operation represents a return operation within a function. The operation takes variable number of operands and produces no results. """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1098,25 +945,19 @@ regarded 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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.shape_eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shape_eq(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1126,23 +967,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()) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.shape_of", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shape_of(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1154,25 +991,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function size_to_index(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1200,24 +1031,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.split_at", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function split_at(operand, index; head::IR.Type, tail::IR.Type, location=Location()) + results = IR.Type[head, tail, ] + operands = Value[value(operand), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.split_at", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1230,22 +1055,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.to_extent_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function to_extent_tensor(input; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.to_extent_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1267,22 +1088,18 @@ E.g., This operation is the complement of `shape_of` wrt ValueShape values. """ -function value_as_shape(arg::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.value_as_shape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function value_as_shape(arg; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.value_as_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1293,22 +1110,18 @@ The operation takes !shape.value_shape, a.k.a. (value, shape) tuple as an argument, and returns its value. The behavior is undefined for unknown and invalid arguments. """ -function value_of(arg::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.value_of", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function value_of(arg; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.value_of", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1347,28 +1160,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function with_shape(operand, shape; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1376,22 +1180,18 @@ end `yield` """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/SparseTensor.jl b/src/Dialects/16/SparseTensor.jl index c9f8124d..e46789f1 100644 --- a/src/Dialects/16/SparseTensor.jl +++ b/src/Dialects/16/SparseTensor.jl @@ -1,7 +1,6 @@ module sparse_tensor -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -105,36 +104,20 @@ because we never use its values, only its sparse structure: } -> tensor ``` """ -function binary( - x::Value, - y::Value; - output::IR.Type, - left_identity=nothing, - right_identity=nothing, - overlapRegion::Region, - leftRegion::Region, - rightRegion::Region, - location=Location(), -) - _results = IR.Type[output,] - _operands = Value[x, y] - _owned_regions = Region[overlapRegion, leftRegion, rightRegion] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(left_identity) && - push!(_attributes, namedattribute("left_identity", left_identity)) - !isnothing(right_identity) && - push!(_attributes, namedattribute("right_identity", right_identity)) - - return IR.create_operation( - "sparse_tensor.binary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function binary(x, y; output::IR.Type, left_identity=nothing, right_identity=nothing, overlapRegion::Region, leftRegion::Region, rightRegion::Region, location=Location()) + results = IR.Type[output, ] + operands = Value[value(x), value(y), ] + owned_regions = Region[overlapRegion, leftRegion, rightRegion, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(left_identity) && push!(attributes, namedattribute("left_identity", left_identity)) + !isnothing(right_identity) && push!(attributes, namedattribute("right_identity", right_identity)) + + IR.create_operation( + "sparse_tensor.binary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -161,32 +144,19 @@ done \"in place\", and referencing the old SSA value is undefined behavior. : memref, memref, memref, tensor<4x4xf64, #CSR> ``` """ -function compress( - values::Value, - filled::Value, - added::Value, - count::Value, - tensor::Value, - indices::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[values, filled, added, count, tensor, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "sparse_tensor.compress", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function compress(values, filled, added, count, tensor, indices; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(values), value(filled), value(added), value(count), value(tensor), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "sparse_tensor.compress", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -209,22 +179,18 @@ can be dynamically-sized. : tensor<64x64xf64, #CSR>, tensor<64x64xf64, #CSR> to tensor<128x64xf64, #CSR> ``` """ -function concatenate(inputs::Vector{Value}; result::IR.Type, dimension, location=Location()) - _results = IR.Type[result,] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dimension", dimension),] - - return IR.create_operation( - "sparse_tensor.concatenate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function concatenate(inputs; result::IR.Type, dimension, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), ] + + IR.create_operation( + "sparse_tensor.concatenate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -267,22 +233,18 @@ Examples: %4 = sparse_tensor.convert %d : tensor to tensor<100xf64, #SV> ``` """ -function convert(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.convert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function convert(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.convert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -318,29 +280,18 @@ side-effecting context that sets and resets the expanded arrays. : tensor<4x4xf64, #CSR> to memref, memref, memref ``` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand(tensor; values::IR.Type, filled::IR.Type, added::IR.Type, count::IR.Type, location=Location()) + results = IR.Type[values, filled, added, count, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.expand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -406,28 +357,18 @@ sparse_tensor.foreach in %0 : tensor<2x3xf64, #ROW_MAJOR> do { ``` """ -function foreach( - tensor::Value, - initArgs::Vector{Value}; - results::Vector{IR.Type}, - region::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[tensor, initArgs...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.foreach", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach(tensor, initArgs; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(tensor), value.(initArgs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.foreach", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -443,25 +384,19 @@ Example of querying the size of the index array for level 0: : !sparse_tensor.storage_specifier<#COO> to i64 ``` """ -function storage_specifier_get( - specifier::Value; result::IR.Type, specifierKind, dim=nothing, location=Location() -) - _results = IR.Type[result,] - _operands = Value[specifier,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("specifierKind", specifierKind),] - !isnothing(dim) && push!(_attributes, namedattribute("dim", dim)) - - return IR.create_operation( - "sparse_tensor.storage_specifier.get", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function storage_specifier_get(specifier; result::IR.Type, specifierKind, dim=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(specifier), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("specifierKind", specifierKind), ] + !isnothing(dim) && push!(attributes, namedattribute("dim", dim)) + + IR.create_operation( + "sparse_tensor.storage_specifier.get", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -495,29 +430,19 @@ This operation is scheduled to be unified with the dense counterpart %result = sparse_tensor.insert %val into %tensor[%i,%j] : tensor<1024x1024xf64, #CSR> ``` """ -function insert( - value::Value, - tensor::Value, - indices::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, tensor, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "sparse_tensor.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert(value, tensor, indices; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(tensor), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "sparse_tensor.insert", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -549,29 +474,20 @@ Examples: %1 = sparse_tensor.load %0 hasInserts : tensor<16x32xf32, #CSR> ``` """ -function load( - tensor::Value; - result=nothing::Union{Nothing,IR.Type}, - hasInserts=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function load(tensor; result=nothing::Union{Nothing, IR.Type}, hasInserts=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(hasInserts) && push!(attributes, namedattribute("hasInserts", hasInserts)) + + 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) ) end @@ -600,24 +516,19 @@ storage is planned for the future. sparse_tensor.new %source : !Source to tensor<1024x1024xf64, #CSR> ``` """ -function new(source::Value; result::IR.Type, expandSymmetry=nothing, location=Location()) - _results = IR.Type[result,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(expandSymmetry) && - push!(_attributes, namedattribute("expandSymmetry", expandSymmetry)) - - return IR.create_operation( - "sparse_tensor.new", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function new(source; result::IR.Type, expandSymmetry=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(expandSymmetry) && push!(attributes, namedattribute("expandSymmetry", expandSymmetry)) + + IR.create_operation( + "sparse_tensor.new", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -635,25 +546,19 @@ accurate nomenclature is used. %noe = sparse_tensor.number_of_entries %tensor : tensor<64x64xf64, #CSR> ``` """ -function number_of_entries( - tensor::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "sparse_tensor.number_of_entries", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function number_of_entries(tensor; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "sparse_tensor.number_of_entries", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -676,22 +581,18 @@ is solely defined by side-effects and not SSA values. sparse_tensor.out %t, %dest : tensor<1024x1024xf64, #CSR>, !Dest ``` """ -function out(tensor::Value, dest::Value; location=Location()) - _results = IR.Type[] - _operands = Value[tensor, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.out", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function out(tensor, dest; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.out", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -739,35 +640,22 @@ through the old SSA value after this operation is undefined behavior. : xindex, memref, f64 ``` """ -function push_back( - curSize::Value, - inBuffer::Value, - value::Value, - n=nothing::Union{Nothing,Value}; - outBuffer=nothing::Union{Nothing,IR.Type}, - newSize=nothing::Union{Nothing,IR.Type}, - inbounds=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[curSize, inBuffer, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(n) && push!(_operands, n) - !isnothing(outBuffer) && push!(_results, outBuffer) - !isnothing(newSize) && push!(_results, newSize) - !isnothing(inbounds) && push!(_attributes, namedattribute("inbounds", inbounds)) - - return IR.create_operation( - "sparse_tensor.push_back", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function push_back(curSize, inBuffer, value, n=nothing; outBuffer=nothing::Union{Nothing, IR.Type}, newSize=nothing::Union{Nothing, IR.Type}, inbounds=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(curSize), value(inBuffer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(n) && push!(operands, value(n)) + !isnothing(outBuffer) && push!(results, outBuffer) + !isnothing(newSize) && push!(results, newSize) + !isnothing(inbounds) && push!(attributes, namedattribute("inbounds", inbounds)) + + IR.create_operation( + "sparse_tensor.push_back", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -809,30 +697,19 @@ Example of Matrix->Vector reduction using max(product(x_i), 100): } -> tensor ``` """ -function reduce( - x::Value, - y::Value, - identity::Value; - output=nothing::Union{Nothing,IR.Type}, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x, y, identity] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "sparse_tensor.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function reduce(x, y, identity; output=nothing::Union{Nothing, IR.Type}, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(y), value(identity), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "sparse_tensor.reduce", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -886,25 +763,19 @@ Example of selecting lower triangle of a matrix: } -> tensor ``` """ -function select( - x::Value; output=nothing::Union{Nothing,IR.Type}, region::Region, location=Location() -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "sparse_tensor.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function select(x; output=nothing::Union{Nothing, IR.Type}, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "sparse_tensor.select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -922,31 +793,20 @@ Example of updating the sizes of the index array for level 0: ``` """ -function storage_specifier_set( - specifier::Value, - value::Value; - result=nothing::Union{Nothing,IR.Type}, - specifierKind, - dim=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[specifier, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("specifierKind", specifierKind),] - !isnothing(result) && push!(_results, result) - !isnothing(dim) && push!(_attributes, namedattribute("dim", dim)) - - return IR.create_operation( - "sparse_tensor.storage_specifier.set", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function storage_specifier_set(specifier, value; result=nothing::Union{Nothing, IR.Type}, specifierKind, dim=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(specifier), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("specifierKind", specifierKind), ] + !isnothing(result) && push!(results, result) + !isnothing(dim) && push!(attributes, namedattribute("dim", dim)) + + IR.create_operation( + "sparse_tensor.storage_specifier.set", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -977,33 +837,21 @@ sparse_tensor.sort %n, %xy jointly %y1 { nx = 2 : index, ny = 2 : index} : memref jointly memref ``` """ -function sort_coo( - n::Value, - xy::Value, - ys::Vector{Value}; - nx=nothing, - ny=nothing, - stable=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[n, xy, ys...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(nx) && push!(_attributes, namedattribute("nx", nx)) - !isnothing(ny) && push!(_attributes, namedattribute("ny", ny)) - !isnothing(stable) && push!(_attributes, namedattribute("stable", stable)) - - return IR.create_operation( - "sparse_tensor.sort_coo", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sort_coo(n, xy, ys; nx=nothing, ny=nothing, stable=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(n), value(xy), value.(ys)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(nx) && push!(attributes, namedattribute("nx", nx)) + !isnothing(ny) && push!(attributes, namedattribute("ny", ny)) + !isnothing(stable) && push!(attributes, namedattribute("stable", stable)) + + IR.create_operation( + "sparse_tensor.sort_coo", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1046,26 +894,20 @@ sparse_tensor.sort stable %n, %x1, %x2 jointly y1, %y2 : memref, memref jointly memref, memref ``` """ -function sort( - n::Value, xs::Vector{Value}, ys::Vector{Value}; stable=nothing, location=Location() -) - _results = IR.Type[] - _operands = Value[n, xs..., ys...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([1, length(xs), length(ys)])) - !isnothing(stable) && push!(_attributes, namedattribute("stable", stable)) - - return IR.create_operation( - "sparse_tensor.sort", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sort(n, xs, ys; stable=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(n), value.(xs)..., value.(ys)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([1, length(xs), length(ys), ])) + !isnothing(stable) && push!(attributes, namedattribute("stable", stable)) + + IR.create_operation( + "sparse_tensor.sort", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1122,22 +964,18 @@ and (3, 6). : tensor<64x64xf64, #COO> to memref ``` """ -function indices_buffer(tensor::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.indices_buffer", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function indices_buffer(tensor; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.indices_buffer", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1159,22 +997,18 @@ scheme (either by calling a support library or through direct code). : tensor<64x64xf64, #CSR> to memref ``` """ -function indices(tensor::Value; result::IR.Type, dimension, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dimension", dimension),] - - return IR.create_operation( - "sparse_tensor.indices", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function indices(tensor; result::IR.Type, dimension, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), ] + + IR.create_operation( + "sparse_tensor.indices", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1196,22 +1030,18 @@ scheme (either by calling a support library or through direct code). : tensor<64x64xf64, #CSR> to memref ``` """ -function pointers(tensor::Value; result::IR.Type, dimension, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dimension", dimension),] - - return IR.create_operation( - "sparse_tensor.pointers", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pointers(tensor; result::IR.Type, dimension, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), ] + + IR.create_operation( + "sparse_tensor.pointers", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1232,22 +1062,18 @@ scheme (either by calling a support library or through direct code). %1 = sparse_tensor.values %0 : tensor<64x64xf64, #CSR> to memref ``` """ -function values(tensor::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.values", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function values(tensor; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.values", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1317,28 +1143,18 @@ the output, while missing values are filled with 1): } ``` """ -function unary( - x::Value; - output::IR.Type, - presentRegion::Region, - absentRegion::Region, - location=Location(), -) - _results = IR.Type[output,] - _operands = Value[x,] - _owned_regions = Region[presentRegion, absentRegion] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.unary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function unary(x; output::IR.Type, presentRegion::Region, absentRegion::Region, location=Location()) + results = IR.Type[output, ] + operands = Value[value(x), ] + owned_regions = Region[presentRegion, absentRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.unary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1359,23 +1175,19 @@ Yields a value from within a `binary`, `unary`, `reduce`, } ``` """ -function yield(result=nothing::Union{Nothing,Value}; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_operands, result) - - return IR.create_operation( - "sparse_tensor.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(result=nothing; location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(operands, value(result)) + + IR.create_operation( + "sparse_tensor.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Tensor.jl b/src/Dialects/16/Tensor.jl index 9bb711e4..0cb9de34 100644 --- a/src/Dialects/16/Tensor.jl +++ b/src/Dialects/16/Tensor.jl @@ -1,7 +1,6 @@ module tensor -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -27,22 +26,18 @@ converting to a mismatching constant dimension. %5 = tensor.cast %4 : tensor to tensor<*xf32> ``` """ -function cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -71,22 +66,18 @@ Examples: : tensor into tensor ``` """ -function collapse_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function collapse_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "tensor.collapse_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -115,25 +106,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() -) - _results = IR.Type[] - _operands = Value[source, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "tensor.dim", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function dim(source, index; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "tensor.dim", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -153,22 +138,18 @@ with a `tensor.empty` destination. Note: This op can be lowered to a `bufferization.alloc_tensor`, at which point it turns into an explicit buffer allocation. """ -function empty(dynamicSizes::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[dynamicSizes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.empty", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function empty(dynamicSizes; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(dynamicSizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.empty", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -197,22 +178,18 @@ Examples: : tensor into tensor ``` """ -function expand_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "tensor.expand_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -231,28 +208,18 @@ the rank of the accessed value. All indices should all be of `index` type. %5 = tensor.extract %rt[%1, %2] : tensor ``` """ -function extract( - tensor::Value, - indices::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[tensor, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "tensor.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extract(tensor, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.extract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -317,40 +284,19 @@ dims, to map the rank-reduced type to the source type by dropping ones: 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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract_slice(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "tensor.extract_slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -372,22 +318,18 @@ will result in a tensor [[%a, %b, %c] [%d, %e, %f]] """ -function from_elements(elements::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[elements...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.from_elements", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function from_elements(elements; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(elements)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.from_elements", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -488,30 +430,19 @@ op: (memref<4x4xf32>, memref) -> memref> ``` """ -function gather( - source::Value, - indices::Value; - result::IR.Type, - gather_dims, - unique=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[source, indices] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("gather_dims", gather_dims),] - !isnothing(unique) && push!(_attributes, namedattribute("unique", unique)) - - return IR.create_operation( - "tensor.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gather(source, indices; result::IR.Type, gather_dims, unique=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(indices), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("gather_dims", gather_dims), ] + !isnothing(unique) && push!(attributes, namedattribute("unique", unique)) + + IR.create_operation( + "tensor.gather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -537,24 +468,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.generate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generate(dynamicExtents; result::IR.Type, body::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(dynamicExtents)..., ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.generate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -577,29 +502,18 @@ indices should be of `index` type. %5 = tensor.insert %rt into %dest[%1, %2] : tensor ``` """ -function insert( - scalar::Value, - dest::Value, - indices::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[scalar, dest, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "tensor.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert(scalar, dest, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(scalar), value(dest), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.insert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -658,42 +572,19 @@ Unlike ExtractSliceOp however, there is no need for a specific inference. tensor<1x?xf32> into tensor<8x16x4xf32> ``` """ -function insert_slice( - source::Value, - dest::Value, - offsets::Vector{Value}, - sizes::Vector{Value}, - strides::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - static_offsets, - static_sizes, - static_strides, - location=Location(), -) - _results = IR.Type[] - _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)]), - ) - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "tensor.insert_slice", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert_slice(source, dest, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(dest), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "tensor.insert_slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -736,43 +627,21 @@ Example NC_to_NCnc with padding: inner_tiles = [8, 2] into %arg1 : tensor<13x15xf32> -> tensor<2x8x8x2xf32> ``` """ -function pack( - source::Value, - dest::Value, - padding_value=nothing::Union{Nothing,Value}; - inner_tiles::Vector{Value}, - result=nothing::Union{Nothing,IR.Type}, - outer_dims_perm=nothing, - inner_dims_pos, - static_inner_tiles, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest, inner_tiles...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("inner_dims_pos", inner_dims_pos), - namedattribute("static_inner_tiles", static_inner_tiles), - ] - !isnothing(padding_value) && push!(_operands, padding_value) - push!( - _attributes, - operandsegmentsizes([1, 1, isnothing(padding_value) ? 0 : 1, length(inner_tiles)]), - ) - !isnothing(result) && push!(_results, result) - !isnothing(outer_dims_perm) && - push!(_attributes, namedattribute("outer_dims_perm", outer_dims_perm)) - - return IR.create_operation( - "tensor.pack", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function pack(source, dest, padding_value=nothing; inner_tiles, result::IR.Type, outer_dims_perm=nothing, inner_dims_pos, static_inner_tiles, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(dest), value.(inner_tiles)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("inner_dims_pos", inner_dims_pos), namedattribute("static_inner_tiles", static_inner_tiles), ] + !isnothing(padding_value) && push!(operands, value(padding_value)) + push!(attributes, operandsegmentsizes([1, 1, (padding_value==nothing) ? 0 : 1length(inner_tiles), ])) + !isnothing(outer_dims_perm) && push!(attributes, namedattribute("outer_dims_perm", outer_dims_perm)) + + IR.create_operation( + "tensor.pack", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -848,36 +717,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,] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pad(source, low, high; result::IR.Type, static_low, static_high, nofold=nothing, region::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(low)..., value.(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), ])) + !isnothing(nofold) && push!(attributes, namedattribute("nofold", nofold)) + + IR.create_operation( + "tensor.pad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -942,40 +795,19 @@ rank-reducing behavior of tensor.insert_slice and tensor.extract_slice. The same verification discussion and mechanisms apply as for ExtractSliceOp. Unlike ExtractSliceOp however, there is no need for a specific inference. """ -function parallel_insert_slice( - source::Value, - dest::Value, - offsets::Vector{Value}, - sizes::Vector{Value}, - strides::Vector{Value}; - static_offsets, - static_sizes, - static_strides, - location=Location(), -) - _results = IR.Type[] - _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.parallel_insert_slice", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel_insert_slice(source, dest, offsets, sizes, strides; static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "tensor.parallel_insert_slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -991,23 +823,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()) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rank(tensor; result_0=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result_0) && push!(results, result_0) + + IR.create_operation( + "tensor.rank", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1045,22 +873,18 @@ Result type is unranked. : (tensor<*xf32>, tensor) -> tensor<*xf32> ``` """ -function reshape(source::Value, shape::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source, shape] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(source, shape; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1164,31 +988,19 @@ op: some_side_effecting_op_writing_into %v, ...: memref> ``` """ -function scatter( - source::Value, - dest::Value, - indices::Value; - result::IR.Type, - scatter_dims, - unique=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[source, dest, indices] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("scatter_dims", scatter_dims),] - !isnothing(unique) && push!(_attributes, namedattribute("unique", unique)) - - return IR.create_operation( - "tensor.scatter", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scatter(source, dest, indices; result::IR.Type, scatter_dims, unique=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(dest), value(indices), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("scatter_dims", scatter_dims), ] + !isnothing(unique) && push!(attributes, namedattribute("unique", unique)) + + IR.create_operation( + "tensor.scatter", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1217,22 +1029,18 @@ TODO: This operation is easy to extend to broadcast to dynamically shaped %t = tensor.splat %s [%m, %n] : tensor ``` """ -function splat(input::Value; aggregate::IR.Type, location=Location()) - _results = IR.Type[aggregate,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.splat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function splat(input; aggregate::IR.Type, location=Location()) + results = IR.Type[aggregate, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.splat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1260,37 +1068,19 @@ Example CK to KCck: inner_tiles = [8, 32] into %dest : tensor<8x16x8x32xf32> -> tensor<128x256xf32> ``` """ -function unpack( - source::Value, - dest::Value, - inner_tiles::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - outer_dims_perm=nothing, - inner_dims_pos, - static_inner_tiles, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest, inner_tiles...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("inner_dims_pos", inner_dims_pos), - namedattribute("static_inner_tiles", static_inner_tiles), - ] - !isnothing(result) && push!(_results, result) - !isnothing(outer_dims_perm) && - push!(_attributes, namedattribute("outer_dims_perm", outer_dims_perm)) - - return IR.create_operation( - "tensor.unpack", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function unpack(source, dest, inner_tiles; result::IR.Type, outer_dims_perm=nothing, inner_dims_pos, static_inner_tiles, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(dest), value.(inner_tiles)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("inner_dims_pos", inner_dims_pos), namedattribute("static_inner_tiles", static_inner_tiles), ] + !isnothing(outer_dims_perm) && push!(attributes, namedattribute("outer_dims_perm", outer_dims_perm)) + + IR.create_operation( + "tensor.unpack", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1301,22 +1091,18 @@ This operation is used to yield a single value from a within a region. It is used to create dynamically sized tensors (see `tensor.generate` and `tensor.pad` ops). """ -function yield(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Tosa.jl b/src/Dialects/16/Tosa.jl index e5d20427..0d5aaba3 100644 --- a/src/Dialects/16/Tosa.jl +++ b/src/Dialects/16/Tosa.jl @@ -1,7 +1,6 @@ module tosa -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -9,22 +8,18 @@ import ..Dialects: namedattribute, operandsegmentsizes Elementwise absolute value operation """ -function abs(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function abs(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.abs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -34,22 +29,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function add(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.add", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -63,29 +54,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("double_round", double_round),] - - return IR.create_operation( - "tosa.apply_scale", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_scale(value, multiplier, shift; output::IR.Type, double_round, location=Location()) + results = IR.Type[output, ] + operands = Value[value(value), value(multiplier), value(shift), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("double_round", double_round), ] + + IR.create_operation( + "tosa.apply_scale", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -95,22 +75,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.argmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function argmax(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.argmax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -120,24 +96,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("round", round),] - - return IR.create_operation( - "tosa.arithmetic_right_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function arithmetic_right_shift(input1, input2; output::IR.Type, round, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("round", round), ] + + IR.create_operation( + "tosa.arithmetic_right_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -148,36 +118,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avg_pool2d(input; output::IR.Type, kernel, stride, pad, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[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)) + + IR.create_operation( + "tosa.avg_pool2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -187,22 +140,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_and(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_and", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -211,22 +160,18 @@ end Elementwise bitwise NOT of input tensor. """ -function bitwise_not(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_not(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_not", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -236,22 +181,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_or(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_or", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -261,22 +202,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_xor(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_xor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -303,22 +240,18 @@ Performs a set of permissible cast operations signed 8 to float int8 float signed 16 to float int16 float """ -function cast(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -327,22 +260,18 @@ end Elementwise ceiling operation """ -function ceil(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ceil(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.ceil", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -355,29 +284,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clamp(input; output::IR.Type, min_int, max_int, min_fp, max_fp, location=Location()) + results = IR.Type[output, ] + operands = Value[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), ] + + IR.create_operation( + "tosa.clamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -386,22 +304,18 @@ end Elementwise count leading zeros operation """ -function clz(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.clz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clz(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.clz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -411,22 +325,18 @@ end 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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.concat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function concat(input1; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value.(input1)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.concat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -462,38 +372,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv2d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.conv2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -502,38 +393,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv3d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.conv3d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -559,33 +431,18 @@ set of attributes to the custom operator. `outputs is the list of tensors returned by the operator. The number of operators is backend specific. """ -function custom( - inputs::Vector{Value}; - outputs::Vector{IR.Type}, - identifier, - config, - implementation_attrs, - location=Location(), -) - _results = IR.Type[outputs...,] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("identifier", identifier), - namedattribute("config", config), - namedattribute("implementation_attrs", implementation_attrs), - ] - - return IR.create_operation( - "tosa.custom", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function custom(inputs; outputs::Vector{IR.Type}, identifier, config, implementation_attrs, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("identifier", identifier), namedattribute("config", config), namedattribute("implementation_attrs", implementation_attrs), ] + + IR.create_operation( + "tosa.custom", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -595,38 +452,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv2d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.depthwise_conv2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -636,22 +474,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function div(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.div", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -660,28 +494,19 @@ end Elementwise comparison operation """ -function equal( - input1::Value, - input2::Value; - output=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[input1, input2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "tosa.equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function equal(input1, input2; output=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "tosa.equal", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -690,22 +515,18 @@ end Elementwise e to the x operation """ -function exp(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function exp(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.exp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -714,22 +535,18 @@ end Elementwise floor operation """ -function floor(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function floor(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.floor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -738,31 +555,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fully_connected(input, weight, bias; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(bias), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -772,22 +577,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gather(values, indices; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(values), value(indices), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.gather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -796,22 +597,18 @@ end Elementwise comparison operation """ -function greater_equal(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.greater_equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function greater_equal(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.greater_equal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -820,22 +617,18 @@ 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.greater", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function greater(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.greater", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -845,22 +638,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.identity", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function identity(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.identity", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -870,29 +659,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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.cond_if", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cond_if(cond, inputs; output::Vector{IR.Type}, then_branch::Region, else_branch::Region, location=Location()) + results = IR.Type[output..., ] + operands = Value[value(cond), value.(inputs)..., ] + owned_regions = Region[then_branch, else_branch, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.cond_if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -901,22 +679,18 @@ end Elementwise natural logarithm operation """ -function log(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function log(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.log", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -926,22 +700,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_and(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_and", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -951,24 +721,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_left_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_left_shift(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_left_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -977,25 +741,19 @@ end Elementwise logical NOT of input. """ -function logical_not( - input1::Value; output=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "tosa.logical_not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function logical_not(input1; output=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "tosa.logical_not", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1005,22 +763,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_or(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_or", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1030,24 +784,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_right_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_right_shift(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_right_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1057,22 +805,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_xor(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_xor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1083,26 +827,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul(a, b; c::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[c, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -1114,26 +851,18 @@ size given by is passed over the input tensor, with the 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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function max_pool2d(input; output::IR.Type, kernel, stride, pad, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1143,22 +872,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.maximum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maximum(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.maximum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1168,22 +893,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.minimum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function minimum(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.minimum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1193,22 +914,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("shift", shift),] - - return IR.create_operation( - "tosa.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mul(input1, input2; output::IR.Type, shift, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("shift", shift), ] + + IR.create_operation( + "tosa.mul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1217,26 +934,19 @@ end Elementwise negation operation """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function negate(input1; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -1245,32 +955,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pad(input1, padding, pad_const=nothing; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(padding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(pad_const) && push!(operands, value(pad_const)) + !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 ) end @@ -1280,22 +978,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pow(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.pow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1309,24 +1003,18 @@ tensor arguments. RFFT2D takes advantage of Hermitian symmetry to only calculate the first half of the final output axis. Imaginary values with locations (0,0), (0,W/2), (H/2,0) and (H/2,W/2) are zero. """ -function rfft2d( - input::Value; output_real::IR.Type, output_imag::IR.Type, location=Location() -) - _results = IR.Type[output_real, output_imag] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.rfft2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rfft2d(input; output_real::IR.Type, output_imag::IR.Type, location=Location()) + results = IR.Type[output_real, output_imag, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.rfft2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1336,22 +1024,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.reciprocal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reciprocal(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.reciprocal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1360,22 +1044,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_all(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_all", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1384,22 +1064,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_any", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_any(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_any", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1408,22 +1084,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_max(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1432,22 +1104,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_min(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1456,22 +1124,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_prod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_prod(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_prod", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1480,22 +1144,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reduce_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_sum(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reduce_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1519,41 +1179,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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rescale(input; output::IR.Type, input_zp, output_zp, multiplier, shift, scale32, double_round, per_channel, location=Location()) + results = IR.Type[output, ] + operands = Value[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 @@ -1564,22 +1201,18 @@ Returns a tensor with the same type/values as the input, with a new shape 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("new_shape", new_shape),] - - return IR.create_operation( - "tosa.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(input1; output::IR.Type, new_shape, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("new_shape", new_shape), ] + + IR.create_operation( + "tosa.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1593,29 +1226,18 @@ output dimensions can be derived from the input dimensions by inverting the scale. And the [order_y, border_x] values adjust the output size to allow fractional sampling beyond integer input position (IH-1,IW-1). """ -function resize( - input::Value; output::IR.Type, scale, offset, border, mode, location=Location() -) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("scale", scale), - namedattribute("offset", offset), - namedattribute("border", border), - namedattribute("mode", mode), - ] - - return IR.create_operation( - "tosa.resize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function resize(input; output::IR.Type, scale, offset, border, mode, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("scale", scale), namedattribute("offset", offset), namedattribute("border", border), namedattribute("mode", mode), ] + + IR.create_operation( + "tosa.resize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1626,22 +1248,18 @@ Returns a tensor with the same type/values as the input, with the data reversed along the given axis. No data conversion happens during a reverse operation. """ -function reverse(input::Value; output::IR.Type, axis, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reverse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reverse(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reverse", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1651,22 +1269,18 @@ end Elementwise reciprocal square root operation. For integer operation, a TABLE should be used with the appropriate ranges. """ -function rsqrt(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rsqrt(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.rsqrt", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1676,24 +1290,18 @@ end The values_out tensor is set to the values_in tensor with data modified as follows: data from the input tensor is inserted at the positions specified by the indices tensor. """ -function scatter( - values_in::Value, indices::Value, input::Value; values_out::IR.Type, location=Location() -) - _results = IR.Type[values_out,] - _operands = Value[values_in, indices, input] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.scatter", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scatter(values_in, indices, input; values_out::IR.Type, location=Location()) + results = IR.Type[values_out, ] + operands = Value[value(values_in), value(indices), value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.scatter", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1702,24 +1310,18 @@ end Elementwise select of the output based on a condition. """ -function select( - pred::Value, on_true::Value, on_false::Value; output::IR.Type, location=Location() -) - _results = IR.Type[output,] - _operands = Value[pred, on_true, on_false] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function select(pred, on_true, on_false; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(pred), value(on_true), value(on_false), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.select", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1732,22 +1334,18 @@ with the following definition. The sigmoid table has 513 entries each of 16-bit precision and covering the input range -16.0 to +16.0 in steps of 1/16. """ -function sigmoid(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.sigmoid", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sigmoid(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.sigmoid", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1758,24 +1356,18 @@ Extracts a slice of the input1 on the given axis, beginning at the start coordinates, and extending for size elements in each direction. No data conversion happens during a slice operation. """ -function slice(input::Value; output::IR.Type, start, size, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("start", start), namedattribute("size", size) - ] - - return IR.create_operation( - "tosa.slice", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function slice(input; output::IR.Type, start, size, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("start", start), namedattribute("size", size), ] + + IR.create_operation( + "tosa.slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1785,22 +1377,18 @@ end Elementwise subtraction of input1 and input2. Axis of size 1 will be broadcast as necessary. """ -function sub(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.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sub(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.sub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1822,22 +1410,18 @@ The TABLE operator is expected to be used as follows: * If an int8_t result is required then follow the TABLE operator with a RESCALE with a right shift of 15 """ -function table(input::Value, table::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input, table] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.table", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function table(input, table; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(table), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.table", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1849,22 +1433,18 @@ For quantized integer data types, the TABLE operator should be used instead with the following definition. The tanh_table has 513 entries each of 16-bit precision and covering the input range -8.0 to +8.0 in steps of 1/32. """ -function tanh(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tanh(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.tanh", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1873,22 +1453,18 @@ end Replicates input 0 multiplies times along each dimension. """ -function tile(input1::Value; output::IR.Type, multiples, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("multiples", multiples),] - - return IR.create_operation( - "tosa.tile", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile(input1; output::IR.Type, multiples, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("multiples", multiples), ] + + IR.create_operation( + "tosa.tile", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1898,38 +1474,19 @@ end Performs a 2D transposed convolution over the given tensor input, using the weights tensor. """ -function transpose_conv2d( - input::Value, - filter::Value, - bias::Value; - output::IR.Type, - out_pad, - stride, - out_shape, - quantization_info=nothing, - location=Location(), -) - _results = IR.Type[output,] - _operands = Value[input, filter, bias] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("out_pad", out_pad), - namedattribute("stride", stride), - namedattribute("out_shape", out_shape), - ] - !isnothing(quantization_info) && - push!(_attributes, namedattribute("quantization_info", quantization_info)) - - return IR.create_operation( - "tosa.transpose_conv2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose_conv2d(input, filter, bias; output::IR.Type, out_pad, stride, out_shape, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(filter), value(bias), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("out_pad", out_pad), namedattribute("stride", stride), namedattribute("out_shape", out_shape), ] + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) + + IR.create_operation( + "tosa.transpose_conv2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1938,22 +1495,18 @@ end Permutes the dimensions based on perm. """ -function transpose(input1::Value, perms::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1, perms] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(input1, perms; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(perms), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1965,28 +1518,18 @@ exits to another control point. This action is performed repeatedly after updating and re-evaluating the Boolean condition every iteration. This implements the semantic foreach or while iterative loop structure. """ -function while_loop( - inputs::Vector{Value}; - output::Vector{IR.Type}, - cond::Region, - body::Region, - location=Location(), -) - _results = IR.Type[output...,] - _operands = Value[inputs...,] - _owned_regions = Region[cond, body] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.while_loop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function while_loop(inputs; output::Vector{IR.Type}, cond::Region, body::Region, location=Location()) + results = IR.Type[output..., ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[cond, body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.while_loop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1997,22 +1540,18 @@ return operation within the conditional and body of structured control flow. Operation takes variadic operands but produces no results of its own. """ -function yield(inputs::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(inputs; location=Location()) + results = IR.Type[] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Transform.jl b/src/Dialects/16/Transform.jl index 0e46184e..bea8fe02 100644 --- a/src/Dialects/16/Transform.jl +++ b/src/Dialects/16/Transform.jl @@ -1,7 +1,6 @@ module transform -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -33,36 +32,22 @@ handles. TODO: Support affine.apply targets. TODO: Allow mixed PDL_Operation/int64_t for lower_bounds and upper_bounds. """ -function affine_simplify_bounded_affine_ops( - target::Value, - bounded_values::Vector{Value}; - lower_bounds, - upper_bounds, - location=Location(), -) - _results = IR.Type[] - _operands = Value[target, bounded_values...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("lower_bounds", lower_bounds), - namedattribute("upper_bounds", upper_bounds), - ] - - return IR.create_operation( - "transform.affine.simplify_bounded_affine_ops", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function affine_simplify_bounded_affine_ops(target, bounded_values; lower_bounds, upper_bounds, location=Location()) + results = IR.Type[] + operands = Value[value(target), value.(bounded_values)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("lower_bounds", lower_bounds), namedattribute("upper_bounds", upper_bounds), ] + + IR.create_operation( + "transform.affine.simplify_bounded_affine_ops", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -76,24 +61,18 @@ This operation consumes the `target` handle and produces the `transformed` handle. `target` is expected to be a `tensor.empty` operation. The transform always succeeds. """ -function bufferization_empty_tensor_to_alloc_tensor( - target::Value; transformed::IR.Type, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.bufferization.empty_tensor_to_alloc_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bufferization_empty_tensor_to_alloc_tensor(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.bufferization.empty_tensor_to_alloc_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -118,60 +97,30 @@ Many ops implement `BufferizableOpInterface` via an external model. These external models must be registered when applying this transform op; otherwise, said ops would be considered non-bufferizable. """ -function bufferization_one_shot_bufferize( - target::Value; - function_boundary_type_conversion=nothing, - allow_return_allocs=nothing, - allow_unknown_ops=nothing, - bufferize_function_boundaries=nothing, - create_deallocs=nothing, - target_is_module=nothing, - test_analysis_only=nothing, - print_conflicts=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(function_boundary_type_conversion) && push!( - _attributes, - namedattribute( - "function_boundary_type_conversion", function_boundary_type_conversion - ), - ) - !isnothing(allow_return_allocs) && - push!(_attributes, namedattribute("allow_return_allocs", allow_return_allocs)) - !isnothing(allow_unknown_ops) && - push!(_attributes, namedattribute("allow_unknown_ops", allow_unknown_ops)) - !isnothing(bufferize_function_boundaries) && push!( - _attributes, - namedattribute("bufferize_function_boundaries", bufferize_function_boundaries), - ) - !isnothing(create_deallocs) && - push!(_attributes, namedattribute("create_deallocs", create_deallocs)) - !isnothing(target_is_module) && - push!(_attributes, namedattribute("target_is_module", target_is_module)) - !isnothing(test_analysis_only) && - push!(_attributes, namedattribute("test_analysis_only", test_analysis_only)) - !isnothing(print_conflicts) && - push!(_attributes, namedattribute("print_conflicts", print_conflicts)) - - return IR.create_operation( - "transform.bufferization.one_shot_bufferize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bufferization_one_shot_bufferize(target; function_boundary_type_conversion=nothing, allow_return_allocs=nothing, allow_unknown_ops=nothing, bufferize_function_boundaries=nothing, create_deallocs=nothing, target_is_module=nothing, test_analysis_only=nothing, print_conflicts=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(function_boundary_type_conversion) && push!(attributes, namedattribute("function_boundary_type_conversion", function_boundary_type_conversion)) + !isnothing(allow_return_allocs) && push!(attributes, namedattribute("allow_return_allocs", allow_return_allocs)) + !isnothing(allow_unknown_ops) && push!(attributes, namedattribute("allow_unknown_ops", allow_unknown_ops)) + !isnothing(bufferize_function_boundaries) && push!(attributes, namedattribute("bufferize_function_boundaries", bufferize_function_boundaries)) + !isnothing(create_deallocs) && push!(attributes, namedattribute("create_deallocs", create_deallocs)) + !isnothing(target_is_module) && push!(attributes, namedattribute("target_is_module", target_is_module)) + !isnothing(test_analysis_only) && push!(attributes, namedattribute("test_analysis_only", test_analysis_only)) + !isnothing(print_conflicts) && push!(attributes, namedattribute("print_conflicts", print_conflicts)) + + IR.create_operation( + "transform.bufferization.one_shot_bufferize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -212,31 +161,20 @@ The returned handle points to the same LaunchOp operand, consuming it and producing a new SSA value to satisfy chaining and linearity of the IR properties. """ -function gpu_map_foreach_to_blocks( - target::Value; - result::IR.Type, - gridDim=nothing, - generate_gpu_launch=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(gridDim) && push!(_attributes, namedattribute("gridDim", gridDim)) - !isnothing(generate_gpu_launch) && - push!(_attributes, namedattribute("generate_gpu_launch", generate_gpu_launch)) - - return IR.create_operation( - "transform.gpu.map_foreach_to_blocks", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gpu_map_foreach_to_blocks(target; result::IR.Type, gridDim=nothing, generate_gpu_launch=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(gridDim) && push!(attributes, namedattribute("gridDim", gridDim)) + !isnothing(generate_gpu_launch) && push!(attributes, namedattribute("generate_gpu_launch", generate_gpu_launch)) + + IR.create_operation( + "transform.gpu.map_foreach_to_blocks", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -319,36 +257,24 @@ gpu.launch blocks(%bx, %by, %bz) in (%x = %0, %y = %1, %z = %2) } ``` """ -function gpu_map_nested_foreach_to_threads( - target::Value; - result::IR.Type, - blockDim=nothing, - syncAfterDistribute=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(blockDim) && push!(_attributes, namedattribute("blockDim", blockDim)) - !isnothing(syncAfterDistribute) && - push!(_attributes, namedattribute("syncAfterDistribute", syncAfterDistribute)) - - return IR.create_operation( - "transform.gpu.map_nested_foreach_to_threads", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gpu_map_nested_foreach_to_threads(target; result::IR.Type, blockDim=nothing, syncAfterDistribute=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(blockDim) && push!(attributes, namedattribute("blockDim", blockDim)) + !isnothing(syncAfterDistribute) && push!(attributes, namedattribute("syncAfterDistribute", syncAfterDistribute)) + + IR.create_operation( + "transform.gpu.map_nested_foreach_to_threads", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -366,22 +292,18 @@ properly, the transform succeeds. Otherwise the transform silently fails. The return handle points to only the subset of successfully produced computational operations, which can be empty. """ -function structured_decompose(target::Value; transformed::IR.Type, location=Location()) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.decompose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_decompose(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.decompose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -419,24 +341,18 @@ op are rejected by this operation. This operation reads and frees the producer handle. This operation reads the containing op handle. """ -function structured_fuse_into_containing_op( - producer_op::Value, containing_op::Value; fused_op::IR.Type, location=Location() -) - _results = IR.Type[fused_op,] - _operands = Value[producer_op, containing_op] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.fuse_into_containing_op", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_fuse_into_containing_op(producer_op, containing_op; fused_op::IR.Type, location=Location()) + results = IR.Type[fused_op, ] + operands = Value[value(producer_op), value(containing_op), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.fuse_into_containing_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -446,32 +362,20 @@ end Tiles the operations pointed to by the target handle and fuses their producers greedily using the options provided as attributes. """ -function structured_fuse( - target::Value; - transformed::IR.Type, - loops::Vector{IR.Type}, - tile_sizes=nothing, - tile_interchange=nothing, - location=Location(), -) - _results = IR.Type[transformed, loops...] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(tile_sizes) && push!(_attributes, namedattribute("tile_sizes", tile_sizes)) - !isnothing(tile_interchange) && - push!(_attributes, namedattribute("tile_interchange", tile_interchange)) - - return IR.create_operation( - "transform.structured.fuse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_fuse(target; transformed::IR.Type, loops::Vector{IR.Type}, tile_sizes=nothing, tile_interchange=nothing, location=Location()) + results = IR.Type[transformed, loops..., ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + !isnothing(tile_interchange) && push!(attributes, namedattribute("tile_interchange", tile_interchange)) + + IR.create_operation( + "transform.structured.fuse", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -490,22 +394,18 @@ The return handle points to only the subset of successfully produced equivalent generic operations, which can be empty or contain the original ops if they were already in generic form. """ -function structured_generalize(target::Value; transformed::IR.Type, location=Location()) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.generalize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_generalize(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.generalize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -525,26 +425,19 @@ If any interchange fails, the transform definitely fails. The return handle points to only the subset of successfully produced interchanged operations, which can be empty. """ -function structured_interchange( - target::Value; transformed::IR.Type, iterator_interchange=nothing, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(iterator_interchange) && - push!(_attributes, namedattribute("iterator_interchange", iterator_interchange)) - - return IR.create_operation( - "transform.structured.interchange", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_interchange(target; transformed::IR.Type, iterator_interchange=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(iterator_interchange) && push!(attributes, namedattribute("iterator_interchange", iterator_interchange)) + + IR.create_operation( + "transform.structured.interchange", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -565,29 +458,19 @@ values) do not satify the constraints mentioned above. It produces a silenceable failure if at least one target op is not a Linalg op or fails to vectorize. """ -function structured_masked_vectorize( - target::Value, - vector_sizes::Vector{Value}; - static_vector_sizes=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[target, vector_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(static_vector_sizes) && - push!(_attributes, namedattribute("static_vector_sizes", static_vector_sizes)) - - return IR.create_operation( - "transform.structured.masked_vectorize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_masked_vectorize(target, vector_sizes; static_vector_sizes=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(target), value.(vector_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_vector_sizes) && push!(attributes, namedattribute("static_vector_sizes", static_vector_sizes)) + + IR.create_operation( + "transform.structured.masked_vectorize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -621,35 +504,22 @@ Otherwise it succeeds. This operation does not consume the target handle and produces new handles: it is a navigation op. """ -function structured_match( - target::Value; - results::IR.Type, - ops=nothing, - interface=nothing, - op_attrs=nothing, - filter_result_type=nothing, - location=Location(), -) - _results = IR.Type[results,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(ops) && push!(_attributes, namedattribute("ops", ops)) - !isnothing(interface) && push!(_attributes, namedattribute("interface", interface)) - !isnothing(op_attrs) && push!(_attributes, namedattribute("op_attrs", op_attrs)) - !isnothing(filter_result_type) && - push!(_attributes, namedattribute("filter_result_type", filter_result_type)) - - return IR.create_operation( - "transform.structured.match", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_match(target; results_::IR.Type, ops=nothing, interface=nothing, op_attrs=nothing, filter_result_type=nothing, location=Location()) + results = IR.Type[results_, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ops) && push!(attributes, namedattribute("ops", ops)) + !isnothing(interface) && push!(attributes, namedattribute("interface", interface)) + !isnothing(op_attrs) && push!(attributes, namedattribute("op_attrs", op_attrs)) + !isnothing(filter_result_type) && push!(attributes, namedattribute("filter_result_type", filter_result_type)) + + IR.create_operation( + "transform.structured.match", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -709,34 +579,19 @@ structured.split %common after %splitr { dimension = 0 } // ... ``` """ -function structured_multitile_sizes( - target::Value; - low_size::IR.Type, - high_size::IR.Type, - split_point::IR.Type, - dimension, - target_size, - divisor=nothing, - location=Location(), -) - _results = IR.Type[low_size, high_size, split_point] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("dimension", dimension), namedattribute("target_size", target_size) - ] - !isnothing(divisor) && push!(_attributes, namedattribute("divisor", divisor)) - - return IR.create_operation( - "transform.structured.multitile_sizes", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_multitile_sizes(target; low_size::IR.Type, high_size::IR.Type, split_point::IR.Type, dimension, target_size, divisor=nothing, location=Location()) + results = IR.Type[low_size, high_size, split_point, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), namedattribute("target_size", target_size), ] + !isnothing(divisor) && push!(attributes, namedattribute("divisor", divisor)) + + IR.create_operation( + "transform.structured.multitile_sizes", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -801,30 +656,19 @@ reason. The returned handle point to the packed LinalgOp. """ -function structured_pack( - target::Value, - packed_sizes::Vector{Value}; - packed_op::IR.Type, - static_packed_sizes=nothing, - location=Location(), -) - _results = IR.Type[packed_op,] - _operands = Value[target, packed_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(static_packed_sizes) && - push!(_attributes, namedattribute("static_packed_sizes", static_packed_sizes)) - - return IR.create_operation( - "transform.structured.pack", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_pack(target, packed_sizes; packed_op::IR.Type, static_packed_sizes=nothing, location=Location()) + results = IR.Type[packed_op, ] + operands = Value[value(target), value.(packed_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_packed_sizes) && push!(attributes, namedattribute("static_packed_sizes", static_packed_sizes)) + + IR.create_operation( + "transform.structured.pack", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -866,33 +710,20 @@ the transformed `tensor.pack` and one to the transformed `tensor.unpack`. The last handle for `tensor.unpack` is empty if `target_pack_or_unpack_op` was not itself a `tensor.unpack`. """ -function structured_pack_transpose( - target_pack_or_un_pack_op::Value, - target_linalg_op::Value; - packed_op::IR.Type, - pack_op::IR.Type, - un_pack_op::IR.Type, - outer_perm=nothing, - inner_perm=nothing, - location=Location(), -) - _results = IR.Type[packed_op, pack_op, un_pack_op] - _operands = Value[target_pack_or_un_pack_op, target_linalg_op] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(outer_perm) && push!(_attributes, namedattribute("outer_perm", outer_perm)) - !isnothing(inner_perm) && push!(_attributes, namedattribute("inner_perm", inner_perm)) - - return IR.create_operation( - "transform.structured.pack_transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_pack_transpose(target_pack_or_un_pack_op, target_linalg_op; packed_op::IR.Type, pack_op::IR.Type, un_pack_op::IR.Type, outer_perm=nothing, inner_perm=nothing, location=Location()) + results = IR.Type[packed_op, pack_op, un_pack_op, ] + operands = Value[value(target_pack_or_un_pack_op), value(target_linalg_op), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(outer_perm) && push!(attributes, namedattribute("outer_perm", outer_perm)) + !isnothing(inner_perm) && push!(attributes, namedattribute("inner_perm", inner_perm)) + + IR.create_operation( + "transform.structured.pack_transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -912,41 +743,23 @@ properly, the transform succeeds. Otherwise the transform silently fails. The return handle points to only the subset of successfully produced padded operations, which can be empty. """ -function structured_pad( - target::Value; - transformed::IR.Type, - padding_values=nothing, - padding_dimensions=nothing, - pack_paddings=nothing, - hoist_paddings=nothing, - transpose_paddings=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(padding_values) && - push!(_attributes, namedattribute("padding_values", padding_values)) - !isnothing(padding_dimensions) && - push!(_attributes, namedattribute("padding_dimensions", padding_dimensions)) - !isnothing(pack_paddings) && - push!(_attributes, namedattribute("pack_paddings", pack_paddings)) - !isnothing(hoist_paddings) && - push!(_attributes, namedattribute("hoist_paddings", hoist_paddings)) - !isnothing(transpose_paddings) && - push!(_attributes, namedattribute("transpose_paddings", transpose_paddings)) - - return IR.create_operation( - "transform.structured.pad", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_pad(target; transformed::IR.Type, padding_values=nothing, padding_dimensions=nothing, pack_paddings=nothing, hoist_paddings=nothing, transpose_paddings=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(padding_values) && push!(attributes, namedattribute("padding_values", padding_values)) + !isnothing(padding_dimensions) && push!(attributes, namedattribute("padding_dimensions", padding_dimensions)) + !isnothing(pack_paddings) && push!(attributes, namedattribute("pack_paddings", pack_paddings)) + !isnothing(hoist_paddings) && push!(attributes, namedattribute("hoist_paddings", hoist_paddings)) + !isnothing(transpose_paddings) && push!(attributes, namedattribute("transpose_paddings", transpose_paddings)) + + IR.create_operation( + "transform.structured.pad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -969,41 +782,23 @@ properly, the transform succeeds. When successful, the return handle points to the \$target operation that was modified inplace. """ -function structured_promote( - target::Value; - transformed::IR.Type, - operands_to_promote=nothing, - use_full_tile_buffers=nothing, - use_full_tiles_by_default=nothing, - use_alloca=nothing, - alignment=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(operands_to_promote) && - push!(_attributes, namedattribute("operands_to_promote", operands_to_promote)) - !isnothing(use_full_tile_buffers) && - push!(_attributes, namedattribute("use_full_tile_buffers", use_full_tile_buffers)) - !isnothing(use_full_tiles_by_default) && push!( - _attributes, - namedattribute("use_full_tiles_by_default", use_full_tiles_by_default), - ) - !isnothing(use_alloca) && push!(_attributes, namedattribute("use_alloca", use_alloca)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "transform.structured.promote", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_promote(target; transformed::IR.Type, operands_to_promote=nothing, use_full_tile_buffers=nothing, use_full_tiles_by_default=nothing, use_alloca=nothing, alignment=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(operands_to_promote) && push!(attributes, namedattribute("operands_to_promote", operands_to_promote)) + !isnothing(use_full_tile_buffers) && push!(attributes, namedattribute("use_full_tile_buffers", use_full_tile_buffers)) + !isnothing(use_full_tiles_by_default) && push!(attributes, namedattribute("use_full_tiles_by_default", use_full_tiles_by_default)) + !isnothing(use_alloca) && push!(attributes, namedattribute("use_alloca", use_alloca)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "transform.structured.promote", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1020,24 +815,18 @@ This op is for debugging/experiments only. This operation consumes the `target` handle. """ -function structured_replace( - target::Value; replacement::IR.Type, bodyRegion::Region, location=Location() -) - _results = IR.Type[replacement,] - _operands = Value[target,] - _owned_regions = Region[bodyRegion,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.replace", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_replace(target; replacement::IR.Type, bodyRegion::Region, location=Location()) + results = IR.Type[replacement, ] + operands = Value[value(target), ] + owned_regions = Region[bodyRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.replace", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1065,22 +854,18 @@ dimensions after multiple transformations have been applied). Loops can always be recovered by navigating from the tiled operations if needed. """ -function structured_scalarize(target::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.scalarize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_scalarize(target; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.scalarize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1105,34 +890,19 @@ of the structured op after splitting, in the same order as the target operand, with the first handle corresponding to the part with lower iteration space indices. """ -function structured_split( - target::Value, - dynamic_split_point=nothing::Union{Nothing,Value}; - first::IR.Type, - second::IR.Type, - dimension, - static_split_point, - location=Location(), -) - _results = IR.Type[first, second] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("dimension", dimension), - namedattribute("static_split_point", static_split_point), - ] - !isnothing(dynamic_split_point) && push!(_operands, dynamic_split_point) - - return IR.create_operation( - "transform.structured.split", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_split(target, dynamic_split_point=nothing; first::IR.Type, second::IR.Type, dimension, static_split_point, location=Location()) + results = IR.Type[first, second, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), namedattribute("static_split_point", static_split_point), ] + !isnothing(dynamic_split_point) && push!(operands, value(dynamic_split_point)) + + IR.create_operation( + "transform.structured.split", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1272,43 +1042,23 @@ Is transformed to: return %4 : tensor<16x32xf32> ``` """ -function structured_split_reduction( - target::Value; - init_or_alloc_op::IR.Type, - fill_op::IR.Type, - split_linalg_op::IR.Type, - combining_linalg_op::IR.Type, - split_factor=nothing, - insert_split_dimension=nothing, - inner_parallel=nothing, - use_scaling_algorithm=nothing, - use_alloc=nothing, - location=Location(), -) - _results = IR.Type[init_or_alloc_op, fill_op, split_linalg_op, combining_linalg_op] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(split_factor) && - push!(_attributes, namedattribute("split_factor", split_factor)) - !isnothing(insert_split_dimension) && - push!(_attributes, namedattribute("insert_split_dimension", insert_split_dimension)) - !isnothing(inner_parallel) && - push!(_attributes, namedattribute("inner_parallel", inner_parallel)) - !isnothing(use_scaling_algorithm) && - push!(_attributes, namedattribute("use_scaling_algorithm", use_scaling_algorithm)) - !isnothing(use_alloc) && push!(_attributes, namedattribute("use_alloc", use_alloc)) - - return IR.create_operation( - "transform.structured.split_reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_split_reduction(target; init_or_alloc_op::IR.Type, fill_op::IR.Type, split_linalg_op::IR.Type, combining_linalg_op::IR.Type, split_factor=nothing, insert_split_dimension=nothing, inner_parallel=nothing, use_scaling_algorithm=nothing, use_alloc=nothing, location=Location()) + results = IR.Type[init_or_alloc_op, fill_op, split_linalg_op, combining_linalg_op, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(split_factor) && push!(attributes, namedattribute("split_factor", split_factor)) + !isnothing(insert_split_dimension) && push!(attributes, namedattribute("insert_split_dimension", insert_split_dimension)) + !isnothing(inner_parallel) && push!(attributes, namedattribute("inner_parallel", inner_parallel)) + !isnothing(use_scaling_algorithm) && push!(attributes, namedattribute("use_scaling_algorithm", use_scaling_algorithm)) + !isnothing(use_alloc) && push!(attributes, namedattribute("use_alloc", use_alloc)) + + IR.create_operation( + "transform.structured.split_reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1351,34 +1101,20 @@ that of the list associated with the `target` handle. If the internal implementation of tiling for any of the operations fails, produces a definite failure. """ -function structured_tile( - target::Value, - dynamic_sizes::Vector{Value}; - tiled_linalg_op::IR.Type, - loops::Vector{IR.Type}, - static_sizes=nothing, - interchange=nothing, - location=Location(), -) - _results = IR.Type[tiled_linalg_op, loops...] - _operands = Value[target, dynamic_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(static_sizes) && - push!(_attributes, namedattribute("static_sizes", static_sizes)) - !isnothing(interchange) && - push!(_attributes, namedattribute("interchange", interchange)) - - return IR.create_operation( - "transform.structured.tile", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile(target, dynamic_sizes; tiled_linalg_op::IR.Type, loops::Vector{IR.Type}, static_sizes=nothing, interchange=nothing, location=Location()) + results = IR.Type[tiled_linalg_op, loops..., ] + operands = Value[value(target), value.(dynamic_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_sizes) && push!(attributes, namedattribute("static_sizes", static_sizes)) + !isnothing(interchange) && push!(attributes, namedattribute("interchange", interchange)) + + IR.create_operation( + "transform.structured.tile", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1449,36 +1185,21 @@ is transformed into: } -> tensor ``` """ -function structured_tile_reduction_using_foreach_thread( - target::Value; - foreach_thread_op::IR.Type, - fill_op::IR.Type, - split_linalg_op::IR.Type, - combining_linalg_op::IR.Type, - num_threads=nothing, - tile_sizes=nothing, - mapping=nothing, - location=Location(), -) - _results = IR.Type[foreach_thread_op, fill_op, split_linalg_op, combining_linalg_op] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(num_threads) && - push!(_attributes, namedattribute("num_threads", num_threads)) - !isnothing(tile_sizes) && push!(_attributes, namedattribute("tile_sizes", tile_sizes)) - !isnothing(mapping) && push!(_attributes, namedattribute("mapping", mapping)) - - return IR.create_operation( - "transform.structured.tile_reduction_using_foreach_thread", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile_reduction_using_foreach_thread(target; foreach_thread_op::IR.Type, fill_op::IR.Type, split_linalg_op::IR.Type, combining_linalg_op::IR.Type, num_threads=nothing, tile_sizes=nothing, mapping=nothing, location=Location()) + results = IR.Type[foreach_thread_op, fill_op, split_linalg_op, combining_linalg_op, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(num_threads) && push!(attributes, namedattribute("num_threads", num_threads)) + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + !isnothing(mapping) && push!(attributes, namedattribute("mapping", mapping)) + + IR.create_operation( + "transform.structured.tile_reduction_using_foreach_thread", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1552,31 +1273,19 @@ is transformed into: } -> tensor ``` """ -function structured_tile_reduction_using_scf( - target::Value; - for_op::IR.Type, - fill_op::IR.Type, - split_linalg_op::IR.Type, - combining_linalg_op::IR.Type, - tile_sizes=nothing, - location=Location(), -) - _results = IR.Type[for_op, fill_op, split_linalg_op, combining_linalg_op] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(tile_sizes) && push!(_attributes, namedattribute("tile_sizes", tile_sizes)) - - return IR.create_operation( - "transform.structured.tile_reduction_using_scf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile_reduction_using_scf(target; for_op::IR.Type, fill_op::IR.Type, split_linalg_op::IR.Type, combining_linalg_op::IR.Type, tile_sizes=nothing, location=Location()) + results = IR.Type[for_op, fill_op, split_linalg_op, combining_linalg_op, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + + IR.create_operation( + "transform.structured.tile_reduction_using_scf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1637,51 +1346,24 @@ These two returned handles point to: %3:2 = transform.structured.tile_to_foreach_thread_op %0 tile_sizes [0, %sz, 20] ``` """ -function structured_tile_to_foreach_thread_op( - target::Value, - num_threads::Vector{Value}, - tile_sizes::Vector{Value}, - packed_num_threads=nothing::Union{Nothing,Value}; - packed_tile_sizes=nothing::Union{Nothing,Value}, - foreach_thread_op::IR.Type, - tiled_op::IR.Type, - static_num_threads=nothing, - static_tile_sizes=nothing, - mapping=nothing, - location=Location(), -) - _results = IR.Type[foreach_thread_op, tiled_op] - _operands = Value[target, num_threads..., tile_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(packed_num_threads) && push!(_operands, packed_num_threads) - !isnothing(packed_tile_sizes) && push!(_operands, packed_tile_sizes) - push!( - _attributes, - operandsegmentsizes([ - 1, - length(num_threads), - length(tile_sizes), - isnothing(packed_num_threads) ? 0 : 1, - isnothing(packed_tile_sizes) ? 0 : 1, - ]), - ) - !isnothing(static_num_threads) && - push!(_attributes, namedattribute("static_num_threads", static_num_threads)) - !isnothing(static_tile_sizes) && - push!(_attributes, namedattribute("static_tile_sizes", static_tile_sizes)) - !isnothing(mapping) && push!(_attributes, namedattribute("mapping", mapping)) - - return IR.create_operation( - "transform.structured.tile_to_foreach_thread_op", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile_to_foreach_thread_op(target, num_threads, tile_sizes, packed_num_threads=nothing; packed_tile_sizes=nothing, foreach_thread_op::IR.Type, tiled_op::IR.Type, static_num_threads=nothing, static_tile_sizes=nothing, mapping=nothing, location=Location()) + results = IR.Type[foreach_thread_op, tiled_op, ] + operands = Value[value(target), value.(num_threads)..., value.(tile_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(packed_num_threads) && push!(operands, value(packed_num_threads)) + !isnothing(packed_tile_sizes) && push!(operands, value(packed_tile_sizes)) + push!(attributes, operandsegmentsizes([1, length(num_threads), length(tile_sizes), (packed_num_threads==nothing) ? 0 : 1(packed_tile_sizes==nothing) ? 0 : 1])) + !isnothing(static_num_threads) && push!(attributes, namedattribute("static_num_threads", static_num_threads)) + !isnothing(static_tile_sizes) && push!(attributes, namedattribute("static_tile_sizes", static_tile_sizes)) + !isnothing(mapping) && push!(attributes, namedattribute("mapping", mapping)) + + IR.create_operation( + "transform.structured.tile_to_foreach_thread_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1724,34 +1406,20 @@ that of the list associated with the `target` handle. If the internal implementation of tiling for any of the operations fails, produces a definite failure. """ -function structured_tile_to_scf_for( - target::Value, - dynamic_sizes::Vector{Value}; - tiled_linalg_op::IR.Type, - loops::Vector{IR.Type}, - static_sizes=nothing, - interchange=nothing, - location=Location(), -) - _results = IR.Type[tiled_linalg_op, loops...] - _operands = Value[target, dynamic_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(static_sizes) && - push!(_attributes, namedattribute("static_sizes", static_sizes)) - !isnothing(interchange) && - push!(_attributes, namedattribute("interchange", interchange)) - - return IR.create_operation( - "transform.structured.tile_to_scf_for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile_to_scf_for(target, dynamic_sizes; tiled_linalg_op::IR.Type, loops::Vector{IR.Type}, static_sizes=nothing, interchange=nothing, location=Location()) + results = IR.Type[tiled_linalg_op, loops..., ] + operands = Value[value(target), value.(dynamic_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_sizes) && push!(attributes, namedattribute("static_sizes", static_sizes)) + !isnothing(interchange) && push!(attributes, namedattribute("interchange", interchange)) + + IR.create_operation( + "transform.structured.tile_to_scf_for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1792,53 +1460,26 @@ reason. The operation always returns the handle to the target op that is expected to be isolated from above. """ -function structured_vectorize( - target::Value; - transformed::IR.Type, - vectorize_padding=nothing, - vectorize_nd_extract=nothing, - disable_multi_reduction_to_contract_patterns=nothing, - disable_transfer_permutation_map_lowering_patterns=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(vectorize_padding) && - push!(_attributes, namedattribute("vectorize_padding", vectorize_padding)) - !isnothing(vectorize_nd_extract) && - push!(_attributes, namedattribute("vectorize_nd_extract", vectorize_nd_extract)) - !isnothing(disable_multi_reduction_to_contract_patterns) && push!( - _attributes, - namedattribute( - "disable_multi_reduction_to_contract_patterns", - disable_multi_reduction_to_contract_patterns, - ), - ) - !isnothing(disable_transfer_permutation_map_lowering_patterns) && push!( - _attributes, - namedattribute( - "disable_transfer_permutation_map_lowering_patterns", - disable_transfer_permutation_map_lowering_patterns, - ), - ) - - return IR.create_operation( - "transform.structured.vectorize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_vectorize(target; transformed::IR.Type, vectorize_padding=nothing, vectorize_nd_extract=nothing, disable_multi_reduction_to_contract_patterns=nothing, disable_transfer_permutation_map_lowering_patterns=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(vectorize_padding) && push!(attributes, namedattribute("vectorize_padding", vectorize_padding)) + !isnothing(vectorize_nd_extract) && push!(attributes, namedattribute("vectorize_nd_extract", vectorize_nd_extract)) + !isnothing(disable_multi_reduction_to_contract_patterns) && push!(attributes, namedattribute("disable_multi_reduction_to_contract_patterns", disable_multi_reduction_to_contract_patterns)) + !isnothing(disable_transfer_permutation_map_lowering_patterns) && push!(attributes, namedattribute("disable_transfer_permutation_map_lowering_patterns", disable_transfer_permutation_map_lowering_patterns)) + + IR.create_operation( + "transform.structured.vectorize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -1855,29 +1496,22 @@ multibuffered allocation. This operation returns the new allocation if multi-buffering succeeds, and failure otherwise. """ -function memref_multibuffer( - target::Value; transformed::IR.Type, factor, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("factor", factor),] - - return IR.create_operation( - "transform.memref.multibuffer", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function memref_multibuffer(target; transformed::IR.Type, factor, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("factor", factor), ] + + IR.create_operation( + "transform.memref.multibuffer", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -1890,26 +1524,20 @@ of operations associated with the handle contains parent operations in the same order as the list associated with the operand, except for operations that are parents to more than one input which are only present once. """ -function loop_get_parent_for( - target::Value; parent::IR.Type, num_loops=nothing, affine=nothing, location=Location() -) - _results = IR.Type[parent,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(num_loops) && push!(_attributes, namedattribute("num_loops", num_loops)) - !isnothing(affine) && push!(_attributes, namedattribute("affine", affine)) - - return IR.create_operation( - "transform.loop.get_parent_for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_get_parent_for(target; parent::IR.Type, num_loops=nothing, affine=nothing, location=Location()) + results = IR.Type[parent, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(num_loops) && push!(attributes, namedattribute("num_loops", num_loops)) + !isnothing(affine) && push!(attributes, namedattribute("affine", affine)) + + IR.create_operation( + "transform.loop.get_parent_for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1924,22 +1552,18 @@ perform loop coalescing in a bottom-up one-by-one manner. The return handle points to the coalesced loop if coalescing happens, or the given input loop if coalescing does not happen. """ -function loop_coalesce(target::Value; transformed::IR.Type, location=Location()) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.loop.coalesce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_coalesce(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.loop.coalesce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1957,22 +1581,18 @@ have a SymbolTable ancestor (typically true because of the top-level module). Returns the handle to the list of outlined functions in the same order as the operand handle. """ -function loop_outline(target::Value; transformed::IR.Type, func_name, location=Location()) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("func_name", func_name),] - - return IR.create_operation( - "transform.loop.outline", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_outline(target; transformed::IR.Type, func_name, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("func_name", func_name), ] + + IR.create_operation( + "transform.loop.outline", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2000,31 +1620,19 @@ one. TODO: Return both the peeled loop and the remainder loop. """ -function loop_peel( - target::Value; - transformed::IR.Type, - fail_if_already_divisible=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(fail_if_already_divisible) && push!( - _attributes, - namedattribute("fail_if_already_divisible", fail_if_already_divisible), - ) - - return IR.create_operation( - "transform.loop.peel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_peel(target; transformed::IR.Type, fail_if_already_divisible=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(fail_if_already_divisible) && push!(attributes, namedattribute("fail_if_already_divisible", fail_if_already_divisible)) + + IR.create_operation( + "transform.loop.peel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2051,32 +1659,20 @@ properly, the transform succeeds. Otherwise the transform silently fails. The return handle points to only the subset of successfully produced pipelined loops, which can be empty. """ -function loop_pipeline( - target::Value; - transformed::IR.Type, - iteration_interval=nothing, - read_latency=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(iteration_interval) && - push!(_attributes, namedattribute("iteration_interval", iteration_interval)) - !isnothing(read_latency) && - push!(_attributes, namedattribute("read_latency", read_latency)) - - return IR.create_operation( - "transform.loop.pipeline", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_pipeline(target; transformed::IR.Type, iteration_interval=nothing, read_latency=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(iteration_interval) && push!(attributes, namedattribute("iteration_interval", iteration_interval)) + !isnothing(read_latency) && push!(attributes, namedattribute("read_latency", read_latency)) + + IR.create_operation( + "transform.loop.pipeline", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2097,27 +1693,22 @@ fails. Does not return handles as the operation may result in the loop being removed after a full unrolling. """ -function loop_unroll(target::Value; factor, location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("factor", factor),] - - return IR.create_operation( - "transform.loop.unroll", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_unroll(target; factor, location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("factor", factor), ] + + IR.create_operation( + "transform.loop.unroll", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -2181,28 +1772,19 @@ Remark: this op allows one to implement a simple \"try\" construct as follows: } ``` """ -function alternatives( - scope=nothing::Union{Nothing,Value}; - results::Vector{IR.Type}, - alternatives::Vector{Region}, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[] - _owned_regions = Region[alternatives...,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(scope) && push!(_operands, scope) - - return IR.create_operation( - "transform.alternatives", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alternatives(scope=nothing; results_::Vector{IR.Type}, alternatives::Vector{Region}, location=Location()) + results = IR.Type[results_..., ] + operands = Value[] + owned_regions = Region[alternatives..., ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(scope) && push!(operands, value(scope)) + + IR.create_operation( + "transform.alternatives", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2210,22 +1792,18 @@ end `cast` """ -function cast(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2251,22 +1829,18 @@ This op generates as many handles as the terminating YieldOp has operands. For each result, the payload ops of the corresponding YieldOp operand are merged and mapped to the same resulting handle. """ -function foreach(target::Value; results::Vector{IR.Type}, body::Region, location=Location()) - _results = IR.Type[results...,] - _operands = Value[target,] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.foreach", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach(target; results_::Vector{IR.Type}, body::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(target), ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.foreach", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2288,22 +1862,18 @@ resulting list will be just \"(A, B)\". Note that no other semantic ordering is applied, e.g., \"B\" may itself be a parent of \"A\". This may have an impact on the further transformation applied to the handle produced here. """ -function get_closest_isolated_parent(target::Value; parent::IR.Type, location=Location()) - _results = IR.Type[parent,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.get_closest_isolated_parent", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_closest_isolated_parent(target; parent::IR.Type, location=Location()) + results = IR.Type[parent, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.get_closest_isolated_parent", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2318,24 +1888,18 @@ definitely fails. The return handle points to the consuming operations operations, which can be empty. """ -function get_consumers_of_result( - target::Value; consumers::IR.Type, result_number, location=Location() -) - _results = IR.Type[consumers,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("result_number", result_number),] - - return IR.create_operation( - "transform.get_consumers_of_result", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_consumers_of_result(target; consumers::IR.Type, result_number, location=Location()) + results = IR.Type[consumers, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("result_number", result_number), ] + + IR.create_operation( + "transform.get_consumers_of_result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2349,24 +1913,18 @@ a block argument), the transform silently fails. The return handle points to only the subset of successfully produced computational operations, which can be empty. """ -function get_producer_of_operand( - target::Value; producer::IR.Type, operand_number, location=Location() -) - _results = IR.Type[producer,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("operand_number", operand_number),] - - return IR.create_operation( - "transform.get_producer_of_operand", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_producer_of_operand(target; producer::IR.Type, operand_number, location=Location()) + results = IR.Type[producer, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("operand_number", operand_number), ] + + IR.create_operation( + "transform.get_producer_of_operand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2382,30 +1940,20 @@ and so on. If `deduplicate` is set, do not add the given Payload IR operation more than once to the final list regardless of it coming from the same or different handles. Consumes the operands and produces a new handle. """ -function merge_handles( - handles::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - deduplicate=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[handles...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(deduplicate) && - push!(_attributes, namedattribute("deduplicate", deduplicate)) - - return IR.create_operation( - "transform.merge_handles", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function merge_handles(handles; result=nothing::Union{Nothing, IR.Type}, deduplicate=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(handles)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(deduplicate) && push!(attributes, namedattribute("deduplicate", deduplicate)) + + IR.create_operation( + "transform.merge_handles", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2427,22 +1975,18 @@ The transformation is considered successful regardless of whether some Payload IR ops actually matched the pattern and only fails if the pattern could not be looked up or compiled. """ -function pdl_match(root::Value; matched::IR.Type, pattern_name, location=Location()) - _results = IR.Type[matched,] - _operands = Value[root,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pattern_name", pattern_name),] - - return IR.create_operation( - "transform.pdl_match", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pdl_match(root; matched::IR.Type, pattern_name, location=Location()) + results = IR.Type[matched, ] + operands = Value[value(root), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("pattern_name", pattern_name), ] + + IR.create_operation( + "transform.pdl_match", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2455,24 +1999,20 @@ specified, the top-level op is dumped. This op is useful for printf-style debugging. """ -function print(target=nothing::Union{Nothing,Value}; name=nothing, location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(target) && push!(_operands, target) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "transform.print", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function print(target=nothing; name=nothing, location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(target) && push!(operands, value(target)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "transform.print", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2501,24 +2041,18 @@ MergeHandlesOp may be used to deduplicate the associated list of payload IR ops when necessary. Furthermore, a combination of ReplicateOp and MergeHandlesOp can be used to construct arbitrary lists with repetitions. """ -function replicate( - pattern::Value, handles::Vector{Value}; replicated::Vector{IR.Type}, location=Location() -) - _results = IR.Type[replicated...,] - _operands = Value[pattern, handles...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.replicate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function replicate(pattern, handles; replicated::Vector{IR.Type}, location=Location()) + results = IR.Type[replicated..., ] + operands = Value[value(pattern), value.(handles)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.replicate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2553,31 +2087,19 @@ The body of the sequence terminates with an implicit or explicit `transform.yield` op. The operands of the terminator are returned as the results of the sequence op. """ -function sequence( - root=nothing::Union{Nothing,Value}; - results::Vector{IR.Type}, - failure_propagation_mode, - body::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute( - "failure_propagation_mode", failure_propagation_mode - ),] - !isnothing(root) && push!(_operands, root) - - return IR.create_operation( - "transform.sequence", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sequence(root=nothing; results_::Vector{IR.Type}, failure_propagation_mode, body::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("failure_propagation_mode", failure_propagation_mode), ] + !isnothing(root) && push!(operands, value(root)) + + IR.create_operation( + "transform.sequence", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2595,24 +2117,18 @@ This operation succeeds and returns `num_result_handles` if the statically specified `num_result_handles` corresponds to the dynamic number of operations contained in the source `handle`. Otherwise it silently fails. """ -function split_handles( - handle::Value; results::Vector{IR.Type}, num_result_handles, location=Location() -) - _results = IR.Type[results...,] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("num_result_handles", num_result_handles),] - - return IR.create_operation( - "transform.split_handles", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function split_handles(handle; results_::Vector{IR.Type}, num_result_handles, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("num_result_handles", num_result_handles), ] + + IR.create_operation( + "transform.split_handles", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2652,25 +2168,19 @@ available. This op is a possible top-level Transform IR op, the argument of its entry block corresponds to either the root op of the payload IR or the ops associated with its operand when provided. """ -function with_pdl_patterns( - root=nothing::Union{Nothing,Value}; body::Region, location=Location() -) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(root) && push!(_operands, root) - - return IR.create_operation( - "transform.with_pdl_patterns", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function with_pdl_patterns(root=nothing; body::Region, location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(root) && push!(operands, value(root)) + + IR.create_operation( + "transform.with_pdl_patterns", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2681,27 +2191,22 @@ This terminator operation yields operation handles from regions of the transform IR ops back to the containing op. It is not itself associated with any transformation on the payload IR and is used for flow purposes only. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -2715,47 +2220,24 @@ At this time, the transform is all or nothing. This is usally a late step that is run after bufferization as part of the process of lowering to e.g. LLVM or NVVM. """ -function vector_lower_vectors( - target::Value; - results::IR.Type, - contraction_lowering=nothing, - multireduction_lowering=nothing, - split_transfers=nothing, - transpose_lowering=nothing, - transpose_avx2_lowering=nothing, - unroll_vector_transfers=nothing, - location=Location(), -) - _results = IR.Type[results,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(contraction_lowering) && - push!(_attributes, namedattribute("contraction_lowering", contraction_lowering)) - !isnothing(multireduction_lowering) && push!( - _attributes, namedattribute("multireduction_lowering", multireduction_lowering) - ) - !isnothing(split_transfers) && - push!(_attributes, namedattribute("split_transfers", split_transfers)) - !isnothing(transpose_lowering) && - push!(_attributes, namedattribute("transpose_lowering", transpose_lowering)) - !isnothing(transpose_avx2_lowering) && push!( - _attributes, namedattribute("transpose_avx2_lowering", transpose_avx2_lowering) - ) - !isnothing(unroll_vector_transfers) && push!( - _attributes, namedattribute("unroll_vector_transfers", unroll_vector_transfers) - ) - - return IR.create_operation( - "transform.vector.lower_vectors", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vector_lower_vectors(target; results_::IR.Type, contraction_lowering=nothing, multireduction_lowering=nothing, split_transfers=nothing, transpose_lowering=nothing, transpose_avx2_lowering=nothing, unroll_vector_transfers=nothing, location=Location()) + results = IR.Type[results_, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(contraction_lowering) && push!(attributes, namedattribute("contraction_lowering", contraction_lowering)) + !isnothing(multireduction_lowering) && push!(attributes, namedattribute("multireduction_lowering", multireduction_lowering)) + !isnothing(split_transfers) && push!(attributes, namedattribute("split_transfers", split_transfers)) + !isnothing(transpose_lowering) && push!(attributes, namedattribute("transpose_lowering", transpose_lowering)) + !isnothing(transpose_avx2_lowering) && push!(attributes, namedattribute("transpose_avx2_lowering", transpose_avx2_lowering)) + !isnothing(unroll_vector_transfers) && push!(attributes, namedattribute("unroll_vector_transfers", unroll_vector_transfers)) + + IR.create_operation( + "transform.vector.lower_vectors", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/Vector.jl b/src/Dialects/16/Vector.jl index 6873bb8e..5bcd7756 100644 --- a/src/Dialects/16/Vector.jl +++ b/src/Dialects/16/Vector.jl @@ -1,7 +1,6 @@ module vector -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -62,22 +61,18 @@ equal. %7 = vector.bitcast %6 : vector to vector ``` """ -function bitcast(source::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(source; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -112,22 +107,18 @@ shaped vector with the same element type is always legal. %2 = vector.broadcast %1 : vector<16xf32> to vector<4x16xf32> ``` """ -function broadcast(source::Value; vector::IR.Type, location=Location()) - _results = IR.Type[vector,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.broadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function broadcast(source; vector::IR.Type, location=Location()) + results = IR.Type[vector, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.broadcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -162,28 +153,18 @@ vector.compressstore %base[%i, %j], %mask, %value : memref, vector<16xi1>, vector<16xf32> ``` """ -function compressstore( - base::Value, - indices::Vector{Value}, - mask::Value, - valueToStore::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[base, indices..., mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.compressstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function compressstore(base, indices, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.compressstore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -355,36 +336,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...] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function contract(lhs, rhs, acc, masks; result_0::IR.Type, indexing_maps, iterator_types, kind=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(lhs), value(rhs), value(acc), value.(masks)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) + + IR.create_operation( + "vector.contract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -418,22 +382,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.create_mask", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_mask(operands_; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.create_mask", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -468,29 +428,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.expandload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expandload(base, indices, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.expandload", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -516,29 +465,19 @@ https://llvm.org/docs/LangRef.html#extractelement-instruction %2 = vector.extractelement %z[]: vector ``` """ -function extractelement( - vector::Value, - position=nothing::Union{Nothing,Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[vector,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(position) && push!(_operands, position) - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "vector.extractelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extractelement(vector, position=nothing; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(position) && push!(operands, value(position)) + + IR.create_operation( + "vector.extractelement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -555,25 +494,19 @@ the proper position. Degenerates to an element type in the 0-D case. %2 = vector.extract %0[3, 3, 3]: vector<4x8x16xf32> ``` """ -function extract( - vector::Value; result_0=nothing::Union{Nothing,IR.Type}, position, location=Location() -) - _results = IR.Type[] - _operands = Value[vector,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("position", position),] - !isnothing(result_0) && push!(_results, result_0) - - return IR.create_operation( - "vector.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extract(vector; result_0=nothing::Union{Nothing, IR.Type}, position, location=Location()) + results = IR.Type[] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + !isnothing(result_0) && push!(results, result_0) + + IR.create_operation( + "vector.extract", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -603,28 +536,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract_strided_slice(vector; result_0::IR.Type, offsets, sizes, strides, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -645,29 +568,19 @@ to the `llvm.fma.*` intrinsic. %3 = vector.fma %0, %1, %2: vector<8x16xf32> ``` """ -function fma( - lhs::Value, - rhs::Value, - acc::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs, acc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "vector.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fma(lhs, rhs, acc; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "vector.fma", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -696,24 +609,18 @@ http://llvm.org/docs/LangRef.html#llvm-matrix-transpose-intrinsic : (vector<16xf32>) -> vector<16xf32> ``` """ -function flat_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( - "vector.flat_transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function flat_transpose(matrix; res::IR.Type, rows, columns, location=Location()) + results = IR.Type[res, ] + operands = Value[value(matrix), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -746,30 +653,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gather(base, indices, index_vec, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(index_vec), value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.gather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -794,30 +689,20 @@ 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=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(position) && push!(_operands, position) - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "vector.insertelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insertelement(source, dest, position=nothing; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(position) && push!(operands, value(position)) + !isnothing(result) && push!(results, result) + + IR.create_operation( + "vector.insertelement", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -835,29 +720,19 @@ position. Degenerates to a scalar source type when n = 0. %5 = vector.insert %3, %4[3, 3, 3] : f32 into vector<4x8x16xf32> ``` """ -function insert( - source::Value, - dest::Value; - res=nothing::Union{Nothing,IR.Type}, - position, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("position", position),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "vector.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert(source, dest; res=nothing::Union{Nothing, IR.Type}, position, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "vector.insert", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -883,32 +758,19 @@ the proper location as specified by the offsets. vector<2x4xf32> into vector<16x4x8xf32> ``` """ -function insert_strided_slice( - source::Value, - dest::Value; - res=nothing::Union{Nothing,IR.Type}, - offsets, - strides, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("offsets", offsets), namedattribute("strides", strides) - ] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "vector.insert_strided_slice", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert_strided_slice(source, dest; res=nothing::Union{Nothing, IR.Type}, offsets, strides, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("offsets", offsets), namedattribute("strides", strides), ] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "vector.insert_strided_slice", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -968,22 +830,18 @@ Example 6: Explicit out-of-bound vector load. %result = vector.load %memref[%c0] : memref<7xf32>, vector<8xf32> ``` """ -function load(base::Value, indices::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(base, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1035,29 +893,19 @@ Examples: vector.mask %mask { vector.transfer_write %val, %t0[%idx] : vector<16xf32>, tensor } : vector<16xi1> -> tensor ``` """ -function mask( - mask::Value, - passthru=nothing::Union{Nothing,Value}; - results::Vector{IR.Type}, - maskRegion::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[mask,] - _owned_regions = Region[maskRegion,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(passthru) && push!(_operands, passthru) - - return IR.create_operation( - "vector.mask", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mask(mask, passthru=nothing; results_::Vector{IR.Type}, maskRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(mask), ] + owned_regions = Region[maskRegion, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(passthru) && push!(operands, value(passthru)) + + IR.create_operation( + "vector.mask", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1089,29 +937,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.maskedload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maskedload(base, indices, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.maskedload", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1143,28 +980,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(), -) - _results = IR.Type[] - _operands = Value[base, indices..., mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.maskedstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maskedstore(base, indices, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.maskedstore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1195,34 +1022,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matrix_multiply(lhs, rhs; res::IR.Type, lhs_rows, lhs_columns, rhs_columns, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(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( + "vector.matrix_multiply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1243,32 +1054,19 @@ Takes an initial accumulator operand. vector<4x16xf32> into f32 ``` """ -function multi_reduction( - source::Value, - acc::Value; - dest=nothing::Union{Nothing,IR.Type}, - kind, - reduction_dims, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, acc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("kind", kind), namedattribute("reduction_dims", reduction_dims) - ] - !isnothing(dest) && push!(_results, dest) - - return IR.create_operation( - "vector.multi_reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function multi_reduction(source, acc; dest=nothing::Union{Nothing, IR.Type}, kind, reduction_dims, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dims", reduction_dims), ] + !isnothing(dest) && push!(results, dest) + + IR.create_operation( + "vector.multi_reduction", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1322,30 +1120,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(kind) && push!(_attributes, namedattribute("kind", kind)) - - return IR.create_operation( - "vector.outerproduct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function outerproduct(lhs, rhs, acc; result_0::IR.Type, kind=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(lhs), value(rhs), value.(acc)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) + + IR.create_operation( + "vector.outerproduct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1373,22 +1160,18 @@ value for all data types, opening/closing bracket, comma, newline). ``` """ -function print(source::Value; location=Location()) - _results = IR.Type[] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.print", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function print(source; location=Location()) + results = IR.Type[] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.print", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1414,29 +1197,19 @@ http://llvm.org/docs/LangRef.html#vector-reduction-intrinsics %4 = vector.reduction , %0, %1 : vector<16xf32> into f32 ``` """ -function reduction( - vector::Value, - acc=nothing::Union{Nothing,Value}; - dest::IR.Type, - kind, - location=Location(), -) - _results = IR.Type[dest,] - _operands = Value[vector,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - !isnothing(acc) && push!(_operands, acc) - - return IR.create_operation( - "vector.reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduction(vector, acc=nothing; dest::IR.Type, kind, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), ] + !isnothing(acc) && push!(operands, value(acc)) + + IR.create_operation( + "vector.reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1524,30 +1297,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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(vector, input_shape, output_shape; result::IR.Type, fixed_vector_sizes, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value.(input_shape)..., value.(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), ])) + + IR.create_operation( + "vector.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1575,22 +1337,18 @@ Invalid example: %1 = vector.scalable.extract %0[5] : vector<4xf32> from vector<[16]xf32> ``` """ -function scalable_extract(source::Value; res::IR.Type, pos, location=Location()) - _results = IR.Type[res,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pos", pos),] - - return IR.create_operation( - "vector.scalable.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scalable_extract(source; res::IR.Type, pos, location=Location()) + results = IR.Type[res, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("pos", pos), ] + + IR.create_operation( + "vector.scalable.extract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1622,29 +1380,19 @@ Invalid example: %2 = vector.scalable.insert %0, %1[5] : vector<4xf32> into vector<[16]xf32> ``` """ -function scalable_insert( - source::Value, - dest::Value; - res=nothing::Union{Nothing,IR.Type}, - pos, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pos", pos),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "vector.scalable.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function scalable_insert(source, dest; res=nothing::Union{Nothing, IR.Type}, pos, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("pos", pos), ] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "vector.scalable.insert", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1665,37 +1413,20 @@ reduction in the scan. vector<4x8x16x32xf32>, vector<4x16x32xf32> ``` """ -function scan( - source::Value, - initial_value::Value; - dest=nothing::Union{Nothing,IR.Type}, - accumulated_value=nothing::Union{Nothing,IR.Type}, - kind, - reduction_dim, - inclusive, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, initial_value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("kind", kind), - namedattribute("reduction_dim", reduction_dim), - namedattribute("inclusive", inclusive), - ] - !isnothing(dest) && push!(_results, dest) - !isnothing(accumulated_value) && push!(_results, accumulated_value) - - return IR.create_operation( - "vector.scan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function scan(source, initial_value; dest=nothing::Union{Nothing, IR.Type}, accumulated_value=nothing::Union{Nothing, IR.Type}, kind, reduction_dim, inclusive, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(initial_value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dim", reduction_dim), namedattribute("inclusive", inclusive), ] + !isnothing(dest) && push!(results, dest) + !isnothing(accumulated_value) && push!(results, accumulated_value) + + IR.create_operation( + "vector.scan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1732,29 +1463,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(), -) - _results = IR.Type[] - _operands = Value[base, indices..., index_vec, mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.scatter", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scatter(base, indices, index_vec, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(index_vec), value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.scatter", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1793,22 +1513,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.shape_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shape_cast(source; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.shape_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1847,25 +1563,19 @@ The legality rules are: : vector, vector ; yields vector<2xf32> ``` """ -function shuffle( - v1::Value, v2::Value; vector=nothing::Union{Nothing,IR.Type}, mask, location=Location() -) - _results = IR.Type[] - _operands = Value[v1, v2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mask", mask),] - !isnothing(vector) && push!(_results, vector) - - return IR.create_operation( - "vector.shuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shuffle(v1, v2; vector=nothing::Union{Nothing, IR.Type}, mask, location=Location()) + results = IR.Type[] + operands = Value[value(v1), value(v2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mask", mask), ] + !isnothing(vector) && push!(results, vector) + + IR.create_operation( + "vector.shuffle", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1882,22 +1592,18 @@ required to be of integer/index/float type. %t = vector.splat %s : vector<8x16xi32> ``` """ -function splat(input::Value; aggregate::IR.Type, location=Location()) - _results = IR.Type[aggregate,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.splat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function splat(input; aggregate::IR.Type, location=Location()) + results = IR.Type[aggregate, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.splat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1955,24 +1661,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() -) - _results = IR.Type[] - _operands = Value[valueToStore, base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(valueToStore, base, indices; location=Location()) + results = IR.Type[] + operands = Value[value(valueToStore), value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2148,36 +1848,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("permutation_map", permutation_map),] - !isnothing(mask) && push!(_operands, mask) - push!( - _attributes, operandsegmentsizes([1, length(indices), 1, isnothing(mask) ? 0 : 1]) - ) - !isnothing(in_bounds) && push!(_attributes, namedattribute("in_bounds", in_bounds)) - - return IR.create_operation( - "vector.transfer_read", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transfer_read(source, indices, padding, mask=nothing; vector::IR.Type, permutation_map, in_bounds=nothing, location=Location()) + results = IR.Type[vector, ] + operands = Value[value(source), value.(indices)..., value(padding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] + !isnothing(mask) && push!(operands, value(mask)) + push!(attributes, operandsegmentsizes([1, length(indices), 1, (mask==nothing) ? 0 : 1])) + !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) + + IR.create_operation( + "vector.transfer_read", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2280,37 +1965,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(), -) - _results = IR.Type[] - _operands = Value[vector, source, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("permutation_map", permutation_map),] - !isnothing(mask) && push!(_operands, mask) - push!( - _attributes, operandsegmentsizes([1, 1, length(indices), isnothing(mask) ? 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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transfer_write(vector, source, indices, mask=nothing; result=nothing::Union{Nothing, IR.Type}, permutation_map, in_bounds=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(vector), value(source), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] + !isnothing(mask) && push!(operands, value(mask)) + 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)) + + IR.create_operation( + "vector.transfer_write", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2340,22 +2010,18 @@ the transp array [i_1, .., i_n] must be a permutation of [0, .., n-1]. [c, f] ] ``` """ -function transpose(vector::Value; result::IR.Type, transp, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(vector; result::IR.Type, transp, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("transp", transp), ] + + IR.create_operation( + "vector.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2381,22 +2047,18 @@ operation ::= `vector.type_cast` ssa-use : memref-type to memref-type %VA = vector.type_cast %A : memref<5x4x3xf32> to memref> ``` """ -function type_cast(memref::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.type_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function type_cast(memref; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.type_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2502,29 +2164,18 @@ some_synchronization_primitive // Execute in parallel on all threads/lanes. ``` """ -function warp_execute_on_lane_0( - laneid::Value, - args::Vector{Value}; - results::Vector{IR.Type}, - warp_size, - warpRegion::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[laneid, args...] - _owned_regions = Region[warpRegion,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("warp_size", warp_size),] - - return IR.create_operation( - "vector.warp_execute_on_lane_0", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function warp_execute_on_lane_0(laneid, args; results_::Vector{IR.Type}, warp_size, warpRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(laneid), value.(args)..., ] + owned_regions = Region[warpRegion, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("warp_size", warp_size), ] + + IR.create_operation( + "vector.warp_execute_on_lane_0", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2539,22 +2190,18 @@ parent operation\'s results. If the parent operation defines no value the vector.yield may be omitted when printing the region. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/16/X86Vector.jl b/src/Dialects/16/X86Vector.jl index c45d602c..2c2d5665 100644 --- a/src/Dialects/16/X86Vector.jl +++ b/src/Dialects/16/X86Vector.jl @@ -1,32 +1,25 @@ module x86vector -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_dp_ps_256(a, b, c; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -48,25 +41,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_dot(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -74,25 +61,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_compress(a, src, k; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(src), value(k), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -111,33 +92,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_compress(k, a, src=nothing; dst=nothing::Union{Nothing, IR.Type}, constant_src=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(k), value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(src) && push!(operands, value(src)) + !isnothing(dst) && push!(results, dst) + !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) ) end @@ -155,31 +124,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_rndscale(src, k, a, imm, rounding; dst=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dst) && push!(results, dst) + + 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) ) end @@ -187,31 +144,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_rndscale_pd_512(src, k, a, imm, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -219,31 +164,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_rndscale_ps_512(src, k, a, imm, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -261,31 +194,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_scalef(src, a, b, k, rounding; dst=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dst) && push!(results, dst) + + 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) ) end @@ -293,31 +214,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_scalef_pd_512(src, a, b, k, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -325,31 +234,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_scalef_ps_512(src, a, b, k, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -357,25 +254,19 @@ end `avx_intr_rsqrt_ps_256` """ -function avx_intr_rsqrt_ps_256( - a::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_rsqrt_ps_256(a; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -383,23 +274,19 @@ end `avx_rsqrt` """ -function avx_rsqrt(a::Value; b=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[a,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(b) && push!(_results, b) - - return IR.create_operation( - "x86vector.avx.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_rsqrt(a; b=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(b) && push!(results, b) + + 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) ) end @@ -407,24 +294,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.intr.vp2intersect.d.512", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avx512_intr_vp2intersect_d_512(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.intr.vp2intersect.d.512", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -444,30 +325,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=nothing::Union{Nothing,IR.Type}, - k2=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(k1) && push!(_results, k1) - !isnothing(k2) && push!(_results, k2) - - return IR.create_operation( - "x86vector.avx512.vp2intersect", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_vp2intersect(a, b; k1::IR.Type, k2::IR.Type, location=Location()) + results = IR.Type[k1, k2, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.vp2intersect", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -475,24 +344,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.intr.vp2intersect.q.512", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avx512_intr_vp2intersect_q_512(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.intr.vp2intersect.q.512", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/AMDGPU.jl b/src/Dialects/17/AMDGPU.jl index c8b03ab9..29e64938 100644 --- a/src/Dialects/17/AMDGPU.jl +++ b/src/Dialects/17/AMDGPU.jl @@ -1,7 +1,6 @@ module amdgpu -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -67,52 +66,25 @@ order (that is, v[0] will go to arg[7:0], v[1] to arg[15:8] and so on). The negateA, negateB, and negateC flags are only supported for double-precision operations on gfx940+. """ -function mfma( - sourceA::Value, - sourceB::Value, - destC::Value; - destD::IR.Type, - m, - n, - k, - blocks, - cbsz=nothing, - abid=nothing, - blgp=nothing, - reducePrecision=nothing, - negateA=nothing, - negateB=nothing, - negateC=nothing, - location=Location(), -) - _results = IR.Type[destD,] - _operands = Value[sourceA, sourceB, destC] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("m", m), - namedattribute("n", n), - namedattribute("k", k), - namedattribute("blocks", blocks), - ] - !isnothing(cbsz) && push!(_attributes, namedattribute("cbsz", cbsz)) - !isnothing(abid) && push!(_attributes, namedattribute("abid", abid)) - !isnothing(blgp) && push!(_attributes, namedattribute("blgp", blgp)) - !isnothing(reducePrecision) && - push!(_attributes, namedattribute("reducePrecision", reducePrecision)) - !isnothing(negateA) && push!(_attributes, namedattribute("negateA", negateA)) - !isnothing(negateB) && push!(_attributes, namedattribute("negateB", negateB)) - !isnothing(negateC) && push!(_attributes, namedattribute("negateC", negateC)) - - return IR.create_operation( - "amdgpu.mfma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mfma(sourceA, sourceB, destC; destD::IR.Type, m, n, k, blocks, cbsz=nothing, abid=nothing, blgp=nothing, reducePrecision=nothing, negateA=nothing, negateB=nothing, negateC=nothing, location=Location()) + results = IR.Type[destD, ] + operands = Value[value(sourceA), value(sourceB), value(destC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("m", m), namedattribute("n", n), namedattribute("k", k), namedattribute("blocks", blocks), ] + !isnothing(cbsz) && push!(attributes, namedattribute("cbsz", cbsz)) + !isnothing(abid) && push!(attributes, namedattribute("abid", abid)) + !isnothing(blgp) && push!(attributes, namedattribute("blgp", blgp)) + !isnothing(reducePrecision) && push!(attributes, namedattribute("reducePrecision", reducePrecision)) + !isnothing(negateA) && push!(attributes, namedattribute("negateA", negateA)) + !isnothing(negateB) && push!(attributes, namedattribute("negateB", negateB)) + !isnothing(negateC) && push!(attributes, namedattribute("negateC", negateC)) + + IR.create_operation( + "amdgpu.mfma", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -135,41 +107,22 @@ Out of bounds atomic operations are ignored in hardware. See `amdgpu.raw_buffer_load` for a description of how the underlying instruction is constructed. """ -function raw_buffer_atomic_cmpswap( - src::Value, - cmp::Value, - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - value::IR.Type, - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[value,] - _operands = Value[src, cmp, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, 1, 1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_atomic_cmpswap", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_atomic_cmpswap(src, cmp, memref, indices, sgprOffset=nothing; value::IR.Type, boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(src), value(cmp), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, 1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_atomic_cmpswap", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -193,39 +146,22 @@ Out of bounds atomic operations are ignored in hardware. See `amdgpu.raw_buffer_load` for a description of how the underlying instruction is constructed. """ -function raw_buffer_atomic_fadd( - value::Value, - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, 1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_atomic_fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_atomic_fadd(value, memref, indices, sgprOffset=nothing; boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_atomic_fadd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -248,39 +184,22 @@ Out of bounds atomic operations are ignored in hardware. See `amdgpu.raw_buffer_load` for a description of how the underlying instruction is constructed. """ -function raw_buffer_atomic_fmax( - value::Value, - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, 1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_atomic_fmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_atomic_fmax(value, memref, indices, sgprOffset=nothing; boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_atomic_fmax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -303,39 +222,22 @@ Out of bounds atomic operations are ignored in hardware. See `amdgpu.raw_buffer_load` for a description of how the underlying instruction is constructed. """ -function raw_buffer_atomic_smax( - value::Value, - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, 1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_atomic_smax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_atomic_smax(value, memref, indices, sgprOffset=nothing; boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_atomic_smax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -358,39 +260,22 @@ Out of bounds atomic operations are ignored in hardware. See `amdgpu.raw_buffer_load` for a description of how the underlying instruction is constructed. """ -function raw_buffer_atomic_umin( - value::Value, - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, 1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_atomic_umin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_atomic_umin(value, memref, indices, sgprOffset=nothing; boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_atomic_umin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -426,39 +311,22 @@ are translated to intrinsic arguments as follows: to 2 to disable bounds checks, otherwise it is 3 - The cache coherency bits are off """ -function raw_buffer_load( - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - value::IR.Type, - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[value,] - _operands = Value[memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_load(memref, indices, sgprOffset=nothing; value::IR.Type, boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -482,39 +350,22 @@ components is partically completed is chipset-dependent. See `amdgpu.raw_buffer_load` for a description of how the underlying instruction is constructed. """ -function raw_buffer_store( - value::Value, - memref::Value, - indices::Vector{Value}, - sgprOffset=nothing::Union{Nothing,Value}; - boundsCheck=nothing, - indexOffset=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(sgprOffset) && push!(_operands, sgprOffset) - push!( - _attributes, - operandsegmentsizes([1, 1, length(indices), isnothing(sgprOffset) ? 0 : 1]), - ) - !isnothing(boundsCheck) && - push!(_attributes, namedattribute("boundsCheck", boundsCheck)) - !isnothing(indexOffset) && - push!(_attributes, namedattribute("indexOffset", indexOffset)) - - return IR.create_operation( - "amdgpu.raw_buffer_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function raw_buffer_store(value, memref, indices, sgprOffset=nothing; boundsCheck=nothing, indexOffset=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(sgprOffset) && push!(operands, value(sgprOffset)) + push!(attributes, operandsegmentsizes([1, 1, length(indices), (sgprOffset==nothing) ? 0 : 1])) + !isnothing(boundsCheck) && push!(attributes, namedattribute("boundsCheck", boundsCheck)) + !isnothing(indexOffset) && push!(attributes, namedattribute("indexOffset", indexOffset)) + + IR.create_operation( + "amdgpu.raw_buffer_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -535,37 +386,22 @@ containing only 8 valid values: The `clamp` flag is used to saturate the output of type T to numeric_limits::max() in case of overflow. """ -function wmma( - sourceA::Value, - sourceB::Value, - destC::Value; - destD::IR.Type, - subwordOffset=nothing, - unsignedA=nothing, - unsignedB=nothing, - clamp=nothing, - location=Location(), -) - _results = IR.Type[destD,] - _operands = Value[sourceA, sourceB, destC] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(subwordOffset) && - push!(_attributes, namedattribute("subwordOffset", subwordOffset)) - !isnothing(unsignedA) && push!(_attributes, namedattribute("unsignedA", unsignedA)) - !isnothing(unsignedB) && push!(_attributes, namedattribute("unsignedB", unsignedB)) - !isnothing(clamp) && push!(_attributes, namedattribute("clamp", clamp)) - - return IR.create_operation( - "amdgpu.wmma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wmma(sourceA, sourceB, destC; destD::IR.Type, subwordOffset=nothing, unsignedA=nothing, unsignedB=nothing, clamp=nothing, location=Location()) + results = IR.Type[destD, ] + operands = Value[value(sourceA), value(sourceB), value(destC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(subwordOffset) && push!(attributes, namedattribute("subwordOffset", subwordOffset)) + !isnothing(unsignedA) && push!(attributes, namedattribute("unsignedA", unsignedA)) + !isnothing(unsignedB) && push!(attributes, namedattribute("unsignedB", unsignedB)) + !isnothing(clamp) && push!(attributes, namedattribute("clamp", clamp)) + + IR.create_operation( + "amdgpu.wmma", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/AMX.jl b/src/Dialects/17/AMX.jl index 4df6ab3e..67b68f6a 100644 --- a/src/Dialects/17/AMX.jl +++ b/src/Dialects/17/AMX.jl @@ -1,38 +1,24 @@ module amx -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbf16ps", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbf16ps(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbf16ps", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -40,31 +26,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbssd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbssd(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbssd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -72,31 +45,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbsud", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbsud(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbsud", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -104,31 +64,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbusd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbusd(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbusd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -136,31 +83,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tdpbuud", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tdpbuud(operand_0, operand_1, operand_2, operand_3, operand_4, operand_5; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), value(operand_5), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tdpbuud", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -168,29 +102,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tileloadd64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tileloadd64(operand_0, operand_1, operand_2, operand_3; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tileloadd64", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -198,29 +121,18 @@ end `tilestored64` """ -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tilestored64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tilestored64(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tilestored64", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -228,22 +140,18 @@ end `tilezero` """ -function tilezero(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( - "amx.tilezero", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tilezero(operand_0, operand_1; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tilezero", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -261,22 +169,18 @@ corresponding tile configuration. %0 = amx.tile_load %arg0[%c0, %c0] : memref into vector<16x64xi8> ``` """ -function tile_load(base::Value, indices::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_load(base, indices; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -295,22 +199,18 @@ pairs of \"bf16\"). The operation is eventually lowered into the : vector<16x32xbf16>, vector<16x32xbf16>, vector<16x16xf32> ``` """ -function tile_mulf(lhs::Value, rhs::Value, acc::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_mulf(lhs, rhs, acc; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_mulf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -332,32 +232,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_muli(lhs, rhs, acc; res::IR.Type, isZextLhs=nothing, isZextRhs=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(isZextLhs) && push!(attributes, namedattribute("isZextLhs", isZextLhs)) + !isnothing(isZextRhs) && push!(attributes, namedattribute("isZextRhs", isZextRhs)) + + IR.create_operation( + "amx.tile_muli", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -375,22 +263,18 @@ corresponding tile configuration. amx.tile_store %arg1[%c0, %c0], %0 : memref, vector<16x64xi8> ``` """ -function tile_store(base::Value, indices::Vector{Value}, val::Value; location=Location()) - _results = IR.Type[] - _operands = Value[base, indices..., val] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "amx.tile_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_store(base, indices, val; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(val), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "amx.tile_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Affine.jl b/src/Dialects/17/Affine.jl index bd64c00d..74511107 100644 --- a/src/Dialects/17/Affine.jl +++ b/src/Dialects/17/Affine.jl @@ -1,7 +1,6 @@ module affine -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -26,22 +25,18 @@ have ‘index’ type. %2 = affine.apply affine_map<(i)[s0] -> (i+s0)> (%42)[%n] ``` """ -function apply(mapOperands::Vector{Value}; result_0::IR.Type, map, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply(mapOperands; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(mapOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.apply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -68,27 +63,18 @@ In the above example, `%indices:3` conceptually holds the following: %indices_2 = affine.apply #map2()[%linear_index] ``` """ -function delinearize_index( - linear_index::Value, - basis::Vector{Value}; - multi_index::Vector{IR.Type}, - location=Location(), -) - _results = IR.Type[multi_index...,] - _operands = Value[linear_index, basis...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.delinearize_index", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function delinearize_index(linear_index, basis; multi_index::Vector{IR.Type}, location=Location()) + results = IR.Type[multi_index..., ] + operands = Value[value(linear_index), value.(basis)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.delinearize_index", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -199,24 +185,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function for_(operand_0; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -290,28 +270,18 @@ func.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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.if", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function if_(operand_0; results_::Vector{IR.Type}, thenRegion::Region, elseRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[thenRegion, elseRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -343,22 +313,18 @@ Example 2: Uses `symbol` keyword for symbols `%n` and `%m`. %1 = affine.load %0[%i0 + symbol(%n), %i1 + symbol(%m)] : memref<100x100xf32> ``` """ -function 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.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(memref, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -374,22 +340,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map", map),] - - return IR.create_operation( - "affine.max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function max(operands_; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -415,22 +377,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map", map),] - - return IR.create_operation( - "affine.min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function min(operands_; result_0::IR.Type, map, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map", map), ] + + IR.create_operation( + "affine.min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -499,40 +457,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(mapOperands; results_::Vector{IR.Type}, reductions, lowerBoundsMap, lowerBoundsGroups, upperBoundsMap, upperBoundsGroups, steps, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[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), ] + + IR.create_operation( + "affine.parallel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -554,33 +490,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function prefetch(memref, indices; isWrite, localityHint, isDataCache, location=Location()) + results = IR.Type[] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -612,22 +533,18 @@ Example 2: Uses `symbol` keyword for symbols `%n` and `%m`. 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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, memref, indices; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -670,24 +587,18 @@ TODOs: * Consider adding a permutation map to permute the slice that is read from memory (see [vector.transfer_read](../Vector/#vectortransfer_read-mlirvectortransferreadop)). """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vector_load(memref, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.vector_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -732,24 +643,18 @@ TODOs: * Consider adding a permutation map to permute the slice that is written to memory (see [vector.transfer_write](../Vector/#vectortransfer_write-mlirvectortransferwriteop)). """ -function vector_store( - value::Value, memref::Value, indices::Vector{Value}; location=Location() -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.vector_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vector_store(value, memref, indices; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.vector_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -766,22 +671,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(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "affine.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "affine.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Arith.jl b/src/Dialects/17/Arith.jl index 6e683d07..de698463 100644 --- a/src/Dialects/17/Arith.jl +++ b/src/Dialects/17/Arith.jl @@ -1,7 +1,6 @@ module arith -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -28,30 +27,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.addf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function addf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.addf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -76,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.addi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function addi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.addi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -119,24 +102,18 @@ indicates no overflow. %x:2 = arith.addui_extended %y, %z : tensor<4x?xi8>, tensor<4x?xi1> ``` """ -function addui_extended( - lhs::Value, rhs::Value; sum::IR.Type, overflow::IR.Type, location=Location() -) - _results = IR.Type[sum, overflow] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.addui_extended", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function addui_extended(lhs, rhs; sum::IR.Type, overflow::IR.Type, location=Location()) + results = IR.Type[sum, overflow, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.addui_extended", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -161,25 +138,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.andi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function andi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.andi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -201,22 +172,18 @@ endianness for the source and target types (e.g. float is big-endian and 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -235,25 +202,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ceildivsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ceildivsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -274,25 +235,19 @@ behavior. %a = arith.ceildivui %b, %c : i64 ``` """ -function ceildivui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ceildivui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ceildivui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -323,29 +278,18 @@ attribute by the parser. %r3 = \"arith.cmpf\"(%0, %1) {predicate: 0} : (f8, f8) -> i1 ``` """ -function cmpf( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - predicate, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("predicate", predicate),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.cmpf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cmpf(lhs, rhs; result::IR.Type, predicate, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "arith.cmpf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -414,29 +358,18 @@ complement or large positives : (vector<4xi64>, vector<4xi64>) -> vector<4xi1> ``` """ -function cmpi( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - predicate, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("predicate", predicate),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.cmpi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cmpi(lhs, rhs; result::IR.Type, predicate, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "arith.cmpi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -481,30 +414,20 @@ end `divf` """ -function divf( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.divf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.divf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -530,25 +453,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.divsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.divsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -575,25 +492,19 @@ behavior. %x = arith.divui %y, %z : tensor<4x?xi8> ``` """ -function divui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.divui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.divui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -604,22 +515,18 @@ Cast a floating-point value to a larger floating-point-typed value. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extf(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -643,22 +550,18 @@ of the most-significant bit of the input. %5 = arith.extsi %0 : vector<2 x i32> to vector<2 x i64> ``` """ -function extsi(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extsi(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extsi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -681,22 +584,18 @@ The top-most (N - M) bits of the output are filled with zeros. %5 = arith.extui %0 : vector<2 x i32> to vector<2 x i64> ``` """ -function extui(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.extui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extui(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.extui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -707,22 +606,18 @@ Cast from a value interpreted as floating-point to the nearest (rounding 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.fptosi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptosi(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.fptosi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -733,22 +628,18 @@ Cast from a value interpreted as floating-point to the nearest (rounding 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.fptoui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptoui(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.fptoui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -768,25 +659,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.floordivsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function floordivsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.floordivsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -798,22 +683,18 @@ vectors. Index is an integer of platform-specific bit width. If casting to 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.index_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function index_cast(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.index_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -825,22 +706,18 @@ vectors. Index is an integer of platform-specific bit width. If casting to a wider integer, the value is zero-extended. If casting to a narrower integer, the value is truncated. """ -function index_castui(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.index_castui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function index_castui(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.index_castui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -863,30 +740,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.maxf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.maxf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -894,25 +761,19 @@ end `maxsi` """ -function maxsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.maxsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.maxsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -920,27 +781,21 @@ end `maxui` """ -function maxui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.maxui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end +function maxui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.maxui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) + ) +end """ `minf` @@ -961,30 +816,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.minf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.minf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -992,25 +837,19 @@ end `minsi` """ -function minsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.minsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.minsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1018,25 +857,19 @@ end `minui` """ -function minui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.minui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.minui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1064,30 +897,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.mulf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mulf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.mulf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1095,25 +918,19 @@ end `muli` """ -function muli( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.muli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function muli(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.muli", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1138,30 +955,20 @@ the same operands. %x:2 = arith.mulsi_extended %y, %z : tensor<4x?xi8> ``` """ -function mulsi_extended( - lhs::Value, - rhs::Value; - low=nothing::Union{Nothing,IR.Type}, - high=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(low) && push!(_results, low) - !isnothing(high) && push!(_results, high) - - return IR.create_operation( - "arith.mulsi_extended", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mulsi_extended(lhs, rhs; low=nothing::Union{Nothing, IR.Type}, high=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(low) && push!(results, low) + !isnothing(high) && push!(results, high) + + IR.create_operation( + "arith.mulsi_extended", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1186,30 +993,20 @@ the same operands. %x:2 = arith.mului_extended %y, %z : tensor<4x?xi8> ``` """ -function mului_extended( - lhs::Value, - rhs::Value; - low=nothing::Union{Nothing,IR.Type}, - high=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(low) && push!(_results, low) - !isnothing(high) && push!(_results, high) - - return IR.create_operation( - "arith.mului_extended", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mului_extended(lhs, rhs; low=nothing::Union{Nothing, IR.Type}, high=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(low) && push!(results, low) + !isnothing(high) && push!(results, high) + + IR.create_operation( + "arith.mului_extended", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1234,29 +1031,20 @@ It has no standard attributes. %x = arith.negf %y : tensor<4x?xf8> ``` """ -function negf( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.negf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function negf(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.negf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1281,25 +1069,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.ori", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ori(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.ori", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1307,30 +1089,20 @@ end `remf` """ -function remf( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.remf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.remf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1356,25 +1128,19 @@ behavior. %x = arith.remsi %y, %z : tensor<4x?xi8> ``` """ -function remsi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.remsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.remsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1400,25 +1166,19 @@ behavior. %x = arith.remui %y, %z : tensor<4x?xi8> ``` """ -function remui( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.remui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.remui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1430,22 +1190,18 @@ floating-point value. If the value cannot be exactly represented, it is 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.sitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sitofp(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.sitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1463,25 +1219,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shli(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shli", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1503,25 +1253,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shrsi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shrsi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shrsi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1540,25 +1284,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.shrui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shrui(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.shrui", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1586,30 +1324,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "arith.subf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "arith.subf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1617,25 +1345,19 @@ end `subi` """ -function subi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.subi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.subi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1647,22 +1369,18 @@ The destination type must be strictly narrower than the source type. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.truncf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function truncf(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.truncf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1684,22 +1402,18 @@ The top-most (N - M) bits of the input are discarded. %5 = arith.trunci %0 : vector<2 x i32> to vector<2 x i16> ``` """ -function trunci(in::Value; out::IR.Type, location=Location()) - _results = IR.Type[out,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.trunci", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function trunci(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.trunci", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1711,22 +1425,18 @@ floating-point value. If the value cannot be exactly represented, it is 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arith.uitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function uitofp(in; out::IR.Type, location=Location()) + results = IR.Type[out, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arith.uitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1751,25 +1461,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.xori", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function xori(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.xori", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1803,29 +1507,19 @@ or tensor is chosen. %vx = arith.select %cond, %vtrue, %vfalse : vector<42xf32> ``` """ -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "arith.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function select(condition, true_value, false_value; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(true_value), value(false_value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "arith.select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/17/ArmNeon.jl b/src/Dialects/17/ArmNeon.jl index d7f5eb0b..53a93149 100644 --- a/src/Dialects/17/ArmNeon.jl +++ b/src/Dialects/17/ArmNeon.jl @@ -1,7 +1,6 @@ module arm_neon -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -15,22 +14,18 @@ vector to the destination SIMD&FP register. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.intr.smull", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_smull(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.intr.smull", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -46,22 +41,18 @@ corresponding entry of `a`: 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.2d.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function _2d_sdot(a, b, c; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.2d.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -75,22 +66,18 @@ where vector operands are partitioned into groups of four elements. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_neon.intr.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdot(a, b, c; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_neon.intr.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/ArmSME.jl b/src/Dialects/17/ArmSME.jl index 9c0df82f..ee543417 100644 --- a/src/Dialects/17/ArmSME.jl +++ b/src/Dialects/17/ArmSME.jl @@ -1,7 +1,6 @@ module arm_sme -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -42,22 +41,18 @@ look at the vector op uses and also lower them. Canonicalization will look through `arm_sme.cast_tile_to_vector` and fold the cast away if it comes from a `arm_sme.cast_vector_to_tile`. """ -function cast_tile_to_vector(tile_id::Value; vector::IR.Type, location=Location()) - _results = IR.Type[vector,] - _operands = Value[tile_id,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.cast_tile_to_vector", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast_tile_to_vector(tile_id; vector::IR.Type, location=Location()) + results = IR.Type[vector, ] + operands = Value[value(tile_id), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.cast_tile_to_vector", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -89,22 +84,18 @@ scf.for %vnum = %c0 to %num_vectors step %c1 { Canonicalization will look through `arm_sme.cast_vector_to_tile` and fold the cast away if it comes from a `arm_sme.cast_tile_to_vector`. """ -function cast_vector_to_tile(vector::Value; tile_id::IR.Type, location=Location()) - _results = IR.Type[tile_id,] - _operands = Value[vector,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.cast_vector_to_tile", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast_vector_to_tile(vector; tile_id::IR.Type, location=Location()) + results = IR.Type[tile_id, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.cast_vector_to_tile", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -160,28 +151,18 @@ end `intr_ld1b_horiz` """ -function intr_ld1b_horiz( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.ld1b.horiz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ld1b_horiz(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.ld1b.horiz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -189,28 +170,18 @@ end `intr_ld1b_vert` """ -function intr_ld1b_vert( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.ld1b.vert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ld1b_vert(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.ld1b.vert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -218,28 +189,18 @@ end `intr_ld1d_horiz` """ -function intr_ld1d_horiz( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.ld1d.horiz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ld1d_horiz(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.ld1d.horiz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -247,28 +208,18 @@ end `intr_ld1d_vert` """ -function intr_ld1d_vert( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.ld1d.vert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ld1d_vert(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.ld1d.vert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -276,28 +227,18 @@ end `intr_ld1h_horiz` """ -function intr_ld1h_horiz( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.ld1h.horiz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ld1h_horiz(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.ld1h.horiz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -305,28 +246,18 @@ end `intr_ld1h_vert` """ -function intr_ld1h_vert( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.ld1h.vert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ld1h_vert(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.ld1h.vert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -334,28 +265,18 @@ end `intr_ld1q_horiz` """ -function intr_ld1q_horiz( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.ld1q.horiz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ld1q_horiz(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.ld1q.horiz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -363,28 +284,18 @@ end `intr_ld1q_vert` """ -function intr_ld1q_vert( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.ld1q.vert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ld1q_vert(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.ld1q.vert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -392,28 +303,18 @@ end `intr_ld1w_horiz` """ -function intr_ld1w_horiz( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.ld1w.horiz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ld1w_horiz(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.ld1w.horiz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -421,28 +322,18 @@ end `intr_ld1w_vert` """ -function intr_ld1w_vert( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.ld1w.vert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ld1w_vert(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.ld1w.vert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -450,29 +341,18 @@ end `intr_mopa` """ -function intr_mopa( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.mopa", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_mopa(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.mopa", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -480,29 +360,18 @@ end `intr_mopa_wide` """ -function intr_mopa_wide( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.mopa.wide", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_mopa_wide(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.mopa.wide", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -510,29 +379,18 @@ end `intr_mops` """ -function intr_mops( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.mops", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_mops(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.mops", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -540,29 +398,18 @@ end `intr_mops_wide` """ -function intr_mops_wide( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.mops.wide", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_mops_wide(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.mops.wide", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -570,29 +417,18 @@ end `intr_smopa_wide` """ -function intr_smopa_wide( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.smopa.wide", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_smopa_wide(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.smopa.wide", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -600,29 +436,18 @@ end `intr_smops_wide` """ -function intr_smops_wide( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.smops.wide", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_smops_wide(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.smops.wide", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -630,28 +455,18 @@ end `intr_st1b_horiz` """ -function intr_st1b_horiz( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.st1b.horiz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_st1b_horiz(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.st1b.horiz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -659,28 +474,18 @@ end `intr_st1b_vert` """ -function intr_st1b_vert( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.st1b.vert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_st1b_vert(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.st1b.vert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -688,28 +493,18 @@ end `intr_st1d_horiz` """ -function intr_st1d_horiz( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.st1d.horiz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_st1d_horiz(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.st1d.horiz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -717,28 +512,18 @@ end `intr_st1d_vert` """ -function intr_st1d_vert( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.st1d.vert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_st1d_vert(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.st1d.vert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -746,28 +531,18 @@ end `intr_st1h_horiz` """ -function intr_st1h_horiz( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.st1h.horiz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_st1h_horiz(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.st1h.horiz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -775,28 +550,18 @@ end `intr_st1h_vert` """ -function intr_st1h_vert( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.st1h.vert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_st1h_vert(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.st1h.vert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -804,28 +569,18 @@ end `intr_st1q_horiz` """ -function intr_st1q_horiz( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.st1q.horiz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_st1q_horiz(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.st1q.horiz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -833,28 +588,18 @@ end `intr_st1q_vert` """ -function intr_st1q_vert( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.st1q.vert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_st1q_vert(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.st1q.vert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -862,28 +607,18 @@ end `intr_st1w_horiz` """ -function intr_st1w_horiz( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.st1w.horiz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_st1w_horiz(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.st1w.horiz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -891,28 +626,18 @@ end `intr_st1w_vert` """ -function intr_st1w_vert( - operand_0::Value, - operand_1::Value, - operand_2::Value, - operand_3::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0, operand_1, operand_2, operand_3] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.st1w.vert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_st1w_vert(operand_0, operand_1, operand_2, operand_3; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.st1w.vert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -920,22 +645,18 @@ end `intr_str` """ -function intr_str(operand_0::Value, operand_1::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand_0, operand_1] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.str", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_str(operand_0, operand_1; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.str", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -943,29 +664,18 @@ end `intr_sumopa_wide` """ -function intr_sumopa_wide( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.sumopa.wide", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sumopa_wide(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.sumopa.wide", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -973,29 +683,18 @@ end `intr_sumops_wide` """ -function intr_sumops_wide( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.sumops.wide", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sumops_wide(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.sumops.wide", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1003,29 +702,18 @@ end `intr_umopa_wide` """ -function intr_umopa_wide( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.umopa.wide", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_umopa_wide(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.umopa.wide", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1033,29 +721,18 @@ end `intr_umops_wide` """ -function intr_umops_wide( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.umops.wide", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_umops_wide(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.umops.wide", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1063,29 +740,18 @@ end `intr_usmopa_wide` """ -function intr_usmopa_wide( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.usmopa.wide", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_usmopa_wide(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.usmopa.wide", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1093,29 +759,18 @@ end `intr_usmops_wide` """ -function intr_usmops_wide( - 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.usmops.wide", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_usmops_wide(operand_0, operand_1, operand_2, operand_3, operand_4; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), value(operand_1), value(operand_2), value(operand_3), value(operand_4), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.usmops.wide", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1169,22 +824,18 @@ end `intr_zero` """ -function intr_zero(operand_0::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand_0,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.intr.zero", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_zero(operand_0; location=Location()) + results = IR.Type[] + operands = Value[value(operand_0), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.intr.zero", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1212,24 +863,18 @@ Example 3: Load a 128-bit element ZA tile from memory. %tile = arm_sme.tile_load %base[%c0, %c0] : memref, vector<[1]x[1]xi128> ``` """ -function tile_load( - base::Value, indices::Vector{Value}; result::IR.Type, location=Location() -) - _results = IR.Type[result,] - _operands = Value[base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.tile_load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_load(base, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.tile_load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1258,24 +903,18 @@ Example 3: Store a 128-bit element ZA tile to memory. arm_sme.tile_store %tile, %base[%c0, %c0] : vector<[1]x[1]xi128>, memref ``` """ -function tile_store( - valueToStore::Value, base::Value, indices::Vector{Value}; location=Location() -) - _results = IR.Type[] - _operands = Value[valueToStore, base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sme.tile_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile_store(valueToStore, base, indices; location=Location()) + results = IR.Type[] + operands = Value[value(valueToStore), value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sme.tile_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/ArmSVE.jl b/src/Dialects/17/ArmSVE.jl index 3dee6dd7..9b6f7da5 100644 --- a/src/Dialects/17/ArmSVE.jl +++ b/src/Dialects/17/ArmSVE.jl @@ -1,31 +1,24 @@ module arm_sve -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fadd(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fadd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -36,24 +29,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.addf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_addf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.addf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -61,24 +48,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_add(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.add", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -89,24 +70,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.addi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_addi(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.addi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -114,24 +89,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fdiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fdiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -142,24 +111,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -167,24 +130,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fmul(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -195,24 +152,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.mulf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_mulf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.mulf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -220,24 +171,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_mul(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.mul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -248,24 +193,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.muli", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_muli(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.muli", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -273,24 +212,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sdiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -301,24 +234,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divi_signed", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divi_signed(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divi_signed", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -326,24 +253,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.fsub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_fsub(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.fsub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -354,24 +275,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.subf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_subf(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.subf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -379,24 +294,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sub(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -407,24 +316,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.subi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_subi(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.subi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -432,24 +335,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.udiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_udiv(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.udiv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -460,24 +357,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.masked.divi_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function masked_divi_unsigned(mask, src1, src2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(mask), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.masked.divi_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -485,24 +376,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_sdot(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -520,22 +405,18 @@ to the overlapping element of the first vector input. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.sdot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sdot(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.sdot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -543,24 +424,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.smmla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_smmla(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.smmla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -581,22 +456,18 @@ the result to the first input using modular arithmetic. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.smmla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function smmla(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.smmla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -604,24 +475,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.udot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_udot(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.udot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -639,22 +504,18 @@ to the overlapping element of the first vector input. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.udot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function udot(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.udot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -662,24 +523,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.intr.ummla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function intr_ummla(operand_0, operand_1, operand_2; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(operand_0), value(operand_1), value(operand_2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.intr.ummla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -700,22 +555,18 @@ the result to the first input using modular arithmetic. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "arm_sve.ummla", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ummla(acc, src1, src2; dst::IR.Type, location=Location()) + results = IR.Type[dst, ] + operands = Value[value(acc), value(src1), value(src2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "arm_sve.ummla", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Async.jl b/src/Dialects/17/Async.jl index 84750ab3..f0f83ac2 100644 --- a/src/Dialects/17/Async.jl +++ b/src/Dialects/17/Async.jl @@ -1,7 +1,6 @@ module async -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -19,25 +18,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add_to_group(operand, group; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(group), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + 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) ) end @@ -61,22 +54,18 @@ group become ready. async.await_all %0 ``` """ -function await_all(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.await_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function await_all(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.await_all", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -96,23 +85,19 @@ async.await %0 : !async.token %2 = async.await %1 : !async.value ``` """ -function await(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "async.await", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function await(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "async.await", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -130,24 +115,18 @@ is encoded as a symbol reference attribute named \"callee\". %2 = async.call @my_add(%0, %1) : (f32, f32) -> !async.value ``` """ -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( - "async.call", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operands_; result_0::Vector{IR.Type}, callee, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + + IR.create_operation( + "async.call", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -157,23 +136,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()) - _results = IR.Type[] - _operands = Value[id,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(handle) && push!(_results, handle) - - return IR.create_operation( - "async.coro.begin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function coro_begin(id; handle=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(id), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(handle) && push!(results, handle) + + 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) ) end @@ -184,22 +159,18 @@ The `async.coro.end` marks the point where a coroutine needs to return control back to the caller if it is not an initial invocation of the 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.end", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_end(handle; location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.end", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -209,22 +180,18 @@ end The `async.coro.free` deallocates the coroutine frame created by the async.coro.begin operation. """ -function coro_free(id::Value, handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[id, handle] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.free", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_free(id, handle; location=Location()) + results = IR.Type[] + operands = Value[value(id), value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.free", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -258,25 +225,19 @@ end The `async.coro.saves` saves the coroutine state. """ -function coro_save( - handle::Value; state=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(state) && push!(_results, state) - - return IR.create_operation( - "async.coro.save", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function coro_save(handle; state=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(state) && push!(results, state) + + 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) ) end @@ -292,28 +253,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(), -) - _results = IR.Type[] - _operands = Value[state,] - _owned_regions = Region[] - _successors = Block[suspendDest, resumeDest, cleanupDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.coro.suspend", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coro_suspend(state; suspendDest::Block, resumeDest::Block, cleanupDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(state), ] + owned_regions = Region[] + successors = Block[suspendDest, resumeDest, cleanupDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "async.coro.suspend", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -334,25 +285,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() -) - _results = IR.Type[] - _operands = Value[size,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "async.create_group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function create_group(size; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(size), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -397,30 +342,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}, - bodyOperands::Vector{Value}; - token::IR.Type, - bodyResults::Vector{IR.Type}, - bodyRegion::Region, - location=Location(), -) - _results = IR.Type[token, bodyResults...] - _operands = Value[dependencies..., bodyOperands...] - _owned_regions = Region[bodyRegion,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dependencies), length(bodyOperands)])) - - return IR.create_operation( - "async.execute", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function execute(dependencies, bodyOperands; token::IR.Type, bodyResults::Vector{IR.Type}, bodyRegion::Region, location=Location()) + results = IR.Type[token, bodyResults..., ] + operands = Value[value.(dependencies)..., value.(bodyOperands)..., ] + owned_regions = Region[bodyRegion, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dependencies), length(bodyOperands), ])) + + IR.create_operation( + "async.execute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -501,22 +435,18 @@ async.func @foo() : !async.token { } ``` """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -526,22 +456,18 @@ end The `async.runtime.add_ref` operation adds a reference(s) to async value (token, value or group). """ -function runtime_add_ref(operand::Value; count, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("count", count),] - - return IR.create_operation( - "async.runtime.add_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_add_ref(operand; count, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("count", count), ] + + IR.create_operation( + "async.runtime.add_ref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -551,25 +477,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_add_to_group(operand, group; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(group), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + 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) ) end @@ -580,22 +500,18 @@ The `async.runtime.await_and_resume` operation awaits for the operand to become available or error and resumes the coroutine on a thread managed by the runtime. """ -function runtime_await_and_resume(operand::Value, handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand, handle] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.await_and_resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_await_and_resume(operand, handle; location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.await_and_resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -605,22 +521,18 @@ end The `async.runtime.await` operation blocks the caller thread until the operand becomes available or error. """ -function runtime_await(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.await", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_await(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.await", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -630,25 +542,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_create_group(size; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(size), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -683,22 +589,18 @@ end The `async.runtime.drop_ref` operation drops a reference(s) to async value (token, value or group). """ -function runtime_drop_ref(operand::Value; count, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("count", count),] - - return IR.create_operation( - "async.runtime.drop_ref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_drop_ref(operand; count, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("count", count), ] + + IR.create_operation( + "async.runtime.drop_ref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -710,25 +612,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_is_error(operand; is_error=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(is_error) && push!(results, is_error) + + 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) ) end @@ -738,25 +634,18 @@ end The `async.runtime.load` operation loads the value from the runtime async.value storage. """ -function runtime_load( - storage::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[storage,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "async.runtime.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function runtime_load(storage; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(storage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -794,22 +683,18 @@ end The `async.runtime.resume` operation resumes the coroutine on a thread managed by the runtime. """ -function runtime_resume(handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_resume(handle; location=Location()) + results = IR.Type[] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -819,22 +704,18 @@ end The `async.runtime.set_available` operation switches async token or value state to available. """ -function runtime_set_available(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.set_available", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_set_available(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.set_available", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -844,22 +725,18 @@ end The `async.runtime.set_error` operation switches async token or value state to error. """ -function runtime_set_error(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.set_error", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_set_error(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.set_error", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -869,22 +746,18 @@ end The `async.runtime.store` operation stores the value into the runtime async.value storage. """ -function runtime_store(value::Value, storage::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value, storage] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.runtime.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function runtime_store(value, storage; location=Location()) + results = IR.Type[] + operands = Value[value(value), value(storage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.runtime.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -894,22 +767,18 @@ end The `async.yield` is a special terminator operation for the block inside `async.execute` operation. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "async.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "async.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Bufferization.jl b/src/Dialects/17/Bufferization.jl index c6f443ad..1ebb5a52 100644 --- a/src/Dialects/17/Bufferization.jl +++ b/src/Dialects/17/Bufferization.jl @@ -1,7 +1,6 @@ module bufferization -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -58,39 +57,22 @@ return %0 : tensor Note: An `alloc_tensor` with a `copy` should also be expressed as an `alloc_tensor` without `copy`, followed by a `copy_tensor`. """ -function alloc_tensor( - dynamic_sizes::Vector{Value}, - copy=nothing::Union{Nothing,Value}; - size_hint=nothing::Union{Nothing,Value}, - result::IR.Type, - memory_space=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[dynamic_sizes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(copy) && push!(_operands, copy) - !isnothing(size_hint) && push!(_operands, size_hint) - push!( - _attributes, - operandsegmentsizes([ - length(dynamic_sizes), isnothing(copy) ? 0 : 1, isnothing(size_hint) ? 0 : 1 - ]), - ) - !isnothing(memory_space) && - push!(_attributes, namedattribute("memory_space", memory_space)) - - return IR.create_operation( - "bufferization.alloc_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloc_tensor(dynamic_sizes, copy=nothing; size_hint=nothing, result::IR.Type, memory_space=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(dynamic_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(copy) && push!(operands, value(copy)) + !isnothing(size_hint) && push!(operands, value(size_hint)) + push!(attributes, operandsegmentsizes([length(dynamic_sizes), (copy==nothing) ? 0 : 1(size_hint==nothing) ? 0 : 1])) + !isnothing(memory_space) && push!(attributes, namedattribute("memory_space", memory_space)) + + IR.create_operation( + "bufferization.alloc_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -110,22 +92,18 @@ views or create an actual copy. Mutating the source or result 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.clone", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clone(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.clone", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -135,25 +113,19 @@ end Copy the contents of the source tensor into the destination tensor. This operation is guaranteed to bufferize to a memory copy. """ -function copy_tensor( - source::Value, dest::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "bufferization.copy_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function copy_tensor(source, dest; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "bufferization.copy_tensor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -184,33 +156,20 @@ Deallocation will be called on `%a0` if `%cond0` is \'true\' and neither `%r0` or `%r1` are aliases of `%a0`. `%a1` will be deallocated when `%cond1` is set to \'true\' and none of `%r0`, %r1` and `%a0` are aliases. """ -function dealloc( - memrefs::Vector{Value}, - conditions::Vector{Value}, - retained::Vector{Value}; - updatedConditions=nothing::Union{Nothing,Vector{IR.Type}}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[memrefs..., conditions..., retained...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([length(memrefs), length(conditions), length(retained)]), - ) - !isnothing(updatedConditions) && push!(_results, updatedConditions...) - - return IR.create_operation( - "bufferization.dealloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function dealloc(memrefs, conditions, retained; updatedConditions=nothing::Union{Nothing, Vector{IR.Type}}, location=Location()) + results = IR.Type[] + operands = Value[value.(memrefs)..., value.(conditions)..., value.(retained)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(memrefs), length(conditions), length(retained), ])) + !isnothing(updatedConditions) && push!(results, updatedConditions...) + + IR.create_operation( + "bufferization.dealloc", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -240,22 +199,18 @@ tensor returns undefined results. bufferization.dealloc_tensor %tensor : tensor<1024x1024xf64, #CSR> ``` """ -function dealloc_tensor(tensor::Value; location=Location()) - _results = IR.Type[] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "bufferization.dealloc_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dealloc_tensor(tensor; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "bufferization.dealloc_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -277,23 +232,19 @@ The `read_only` attribute can optionally be set, indicating to the bufferization that the buffer returned by this op (or an alias created from the returned buffer) will not be written to. """ -function to_memref(tensor::Value; memref::IR.Type, read_only=nothing, location=Location()) - _results = IR.Type[memref,] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(read_only) && push!(_attributes, namedattribute("read_only", read_only)) - - return IR.create_operation( - "bufferization.to_memref", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function to_memref(tensor; memref::IR.Type, read_only=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(read_only) && push!(attributes, namedattribute("read_only", read_only)) + + IR.create_operation( + "bufferization.to_memref", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -340,31 +291,20 @@ bufferization. If there are non-bufferizable ops in the IR and `allowUnknownOps` is set, they may be part of the resulting IR and not fold away. However, such IR is no longer bufferizable with One-Shot Bufferize. """ -function to_tensor( - memref::Value; - result=nothing::Union{Nothing,IR.Type}, - restrict=nothing, - writable=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(restrict) && push!(_attributes, namedattribute("restrict", restrict)) - !isnothing(writable) && push!(_attributes, namedattribute("writable", writable)) - - return IR.create_operation( - "bufferization.to_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function to_tensor(memref; result::IR.Type, restrict=nothing, writable=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(restrict) && push!(attributes, namedattribute("restrict", restrict)) + !isnothing(writable) && push!(attributes, namedattribute("writable", writable)) + + IR.create_operation( + "bufferization.to_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Builtin.jl b/src/Dialects/17/Builtin.jl index 2ac242d8..5991a853 100644 --- a/src/Dialects/17/Builtin.jl +++ b/src/Dialects/17/Builtin.jl @@ -1,7 +1,6 @@ module builtin -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -81,24 +80,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "builtin.unrealized_conversion_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function unrealized_conversion_cast(inputs; outputs::Vector{IR.Type}, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "builtin.unrealized_conversion_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Complex.jl b/src/Dialects/17/Complex.jl index f689ea48..96c12c83 100644 --- a/src/Dialects/17/Complex.jl +++ b/src/Dialects/17/Complex.jl @@ -1,7 +1,6 @@ module complex -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -15,23 +14,18 @@ The `abs` op takes a single complex number and computes its absolute value. %a = complex.abs %b : complex ``` """ -function abs(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function abs(complex; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.abs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -46,25 +40,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -79,23 +67,18 @@ The `angle` op takes a single complex number and computes its argument value wit %a = complex.angle %b : complex ``` """ -function angle(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.angle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function angle(complex; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.angle", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -111,25 +94,19 @@ atan2(y, x) = -i * log((x + i * y) / sqrt(x**2 + y**2)) %a = complex.atan2 %b, %c : complex ``` """ -function atan2( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.atan2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atan2(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.atan2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -143,22 +120,18 @@ end %a = complex.bitcast %b : complex -> i64 ``` """ -function bitcast(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -174,23 +147,19 @@ complex conjugate. %a = complex.conj %b: complex ``` """ -function conj(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.conj", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function conj(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.conj", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -237,23 +206,19 @@ it, i.e. `cos(x)`, where `x` is the input value. %a = complex.cos %b : complex ``` """ -function cos(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cos(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -269,22 +234,18 @@ floating-point operands, the real and the imaginary part. %a = complex.create %b, %c : complex ``` """ -function create(real::Value, imaginary::Value; complex::IR.Type, location=Location()) - _results = IR.Type[complex,] - _operands = Value[real, imaginary] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "complex.create", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create(real, imaginary; complex::IR.Type, location=Location()) + results = IR.Type[complex, ] + operands = Value[value(real), value(imaginary), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.create", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -298,25 +259,19 @@ division: %a = complex.div %b, %c : complex ``` """ -function div( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function div(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.div", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -331,25 +286,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function eq(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.eq", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -366,23 +315,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -403,23 +348,19 @@ complex.expm1(x) := complex.exp(x) - 1 %a = complex.expm1 %b : complex ``` """ -function expm1(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.expm1", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function expm1(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.expm1", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -434,23 +375,18 @@ The `im` op takes a single complex number and extracts the imaginary part. %a = complex.im %b : complex ``` """ -function im(complex::Value; imaginary=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(imaginary) && push!(_results, imaginary) - - return IR.create_operation( - "complex.im", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function im(complex; imaginary::IR.Type, location=Location()) + results = IR.Type[imaginary, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.im", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -468,23 +404,19 @@ approximately equal to 2.718281. %a = complex.log1p %b : complex ``` """ -function log1p(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.log1p", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log1p(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.log1p", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -501,23 +433,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -530,25 +458,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -563,23 +485,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.neg", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function neg(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.neg", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -595,25 +513,19 @@ equal. %a = complex.neq %b, %c : complex ``` """ -function neq( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.neq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function neq(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.neq", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -629,25 +541,19 @@ exponent. %a = complex.pow %b, %c : complex ``` """ -function pow( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function pow(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.pow", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -662,23 +568,18 @@ The `re` op takes a single complex number and extracts the real part. %a = complex.re %b : complex ``` """ -function re(complex::Value; real=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(real) && push!(_results, real) - - return IR.create_operation( - "complex.re", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function re(complex; real::IR.Type, location=Location()) + results = IR.Type[real, ] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "complex.re", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -693,23 +594,19 @@ The `rsqrt` operation computes reciprocal of square root. %a = complex.rsqrt %b : complex ``` """ -function rsqrt(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rsqrt(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.rsqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -725,23 +622,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()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sign(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -757,23 +650,19 @@ it, i.e. `sin(x)`, where `x` is the input value. %a = complex.sin %b : complex ``` """ -function sin(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sin(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -788,23 +677,19 @@ The `sqrt` operation takes a complex number and returns its square root. %a = complex.sqrt %b : complex ``` """ -function sqrt(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sqrt(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -819,25 +704,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sub(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.sub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -853,23 +732,19 @@ it, i.e. `tan(x)`, where `x` is the input value. %a = complex.tan %b : complex ``` """ -function tan(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.tan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tan(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.tan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -885,23 +760,19 @@ tangent. %a = complex.tanh %b : complex ``` """ -function tanh(complex::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[complex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "complex.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tanh(complex; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(complex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "complex.tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/17/ControlFlow.jl b/src/Dialects/17/ControlFlow.jl index 23faa5a7..c4177c61 100644 --- a/src/Dialects/17/ControlFlow.jl +++ b/src/Dialects/17/ControlFlow.jl @@ -1,7 +1,6 @@ module cf -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,22 +17,18 @@ runtime to propagate the error to the user. assert %b, \"Expected ... to be true\" ``` """ -function assert(arg::Value; msg, location=Location()) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("msg", msg),] - - return IR.create_operation( - "cf.assert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assert(arg; msg, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("msg", msg), ] + + IR.create_operation( + "cf.assert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -54,22 +49,18 @@ target block. ^bb3(%3: tensor<*xf32>): ``` """ -function br(destOperands::Vector{Value}; dest::Block, location=Location()) - _results = IR.Type[] - _operands = Value[destOperands...,] - _owned_regions = Region[] - _successors = Block[dest,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "cf.br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function br(destOperands; dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(destOperands)..., ] + owned_regions = Region[] + successors = Block[dest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "cf.br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -101,33 +92,19 @@ func.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(), -) - _results = IR.Type[] - _operands = Value[condition, trueDestOperands..., falseDestOperands...] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands)]), - ) - - return IR.create_operation( - "cf.cond_br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cond_br(condition, trueDestOperands, falseDestOperands; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueDestOperands)..., value.(falseDestOperands)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands), ])) + + IR.create_operation( + "cf.cond_br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -150,38 +127,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(), -) - _results = IR.Type[] - _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)]) - ) - !isnothing(case_values) && - push!(_attributes, namedattribute("case_values", case_values)) - - return IR.create_operation( - "cf.switch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch(flag, defaultOperands, caseOperands; case_values=nothing, case_operand_segments, defaultDestination::Block, caseDestinations::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(flag), value.(defaultOperands)..., value.(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), ])) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) + + IR.create_operation( + "cf.switch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/EmitC.jl b/src/Dialects/17/EmitC.jl index 313d1d4e..a5c4e6d1 100644 --- a/src/Dialects/17/EmitC.jl +++ b/src/Dialects/17/EmitC.jl @@ -1,7 +1,6 @@ module emitc -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -23,22 +22,18 @@ int32_t v5 = v1 + v2; float* v6 = v3 + v4; ``` """ -function add(lhs::Value, rhs::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "emitc.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function add(lhs, rhs; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "emitc.add", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -60,22 +55,18 @@ can be applied to a single operand. ``` """ -function apply(operand::Value; result::IR.Type, applicableOperator, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply(operand; result::IR.Type, applicableOperator, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("applicableOperator", applicableOperator), ] + + IR.create_operation( + "emitc.apply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -98,32 +89,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...,] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operands_; result_0::Vector{IR.Type}, callee, args=nothing, template_args=nothing, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + !isnothing(args) && push!(attributes, namedattribute("args", args)) + !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 ) end @@ -145,22 +124,18 @@ and EmitC types. !emitc.ptr> to !emitc.ptr ``` """ -function cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "emitc.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "emitc.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -224,22 +199,18 @@ int32_t v5 = v1 / v2; float v6 = v3 / v4; ``` """ -function div(operand_0::Value, operand_1::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[operand_0, operand_1] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "emitc.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function div(operand_0, operand_1; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "emitc.div", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -305,22 +276,18 @@ int32_t v5 = v1 * v2; float v6 = v3 * v4; ``` """ -function mul(operand_0::Value, operand_1::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[operand_0, operand_1] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "emitc.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mul(operand_0, operand_1; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "emitc.mul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -341,22 +308,18 @@ be applied. int32_t v5 = v1 % v2; ``` """ -function rem(operand_0::Value, operand_1::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[operand_0, operand_1] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "emitc.rem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rem(operand_0, operand_1; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(operand_0), value(operand_1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "emitc.rem", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -382,22 +345,18 @@ float* v8 = v3 - v4; ptrdiff_t v9 = v5 - v6; ``` """ -function sub(lhs::Value, rhs::Value; result_0::IR.Type, location=Location()) - _results = IR.Type[result_0,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "emitc.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sub(lhs, rhs; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "emitc.sub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Func.jl b/src/Dialects/17/Func.jl index a95ab39a..7cf884b6 100644 --- a/src/Dialects/17/Func.jl +++ b/src/Dialects/17/Func.jl @@ -1,7 +1,6 @@ module func -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -21,27 +20,18 @@ Function values can be created with the %result = func.call_indirect %func(%0, %1) : (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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "func.call_indirect", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call_indirect(callee, callee_operands; results_::Vector{IR.Type}, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(callee), value.(callee_operands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "func.call_indirect", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -59,24 +49,18 @@ symbol reference attribute named \"callee\". %2 = func.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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("callee", callee),] - - return IR.create_operation( - "func.call", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operands_; result_0::Vector{IR.Type}, callee, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + + IR.create_operation( + "func.call", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -209,22 +193,18 @@ func.func @foo() : (i32, f8) { } ``` """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "func.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "func.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/GPU.jl b/src/Dialects/17/GPU.jl index fe604145..3215f9db 100644 --- a/src/Dialects/17/GPU.jl +++ b/src/Dialects/17/GPU.jl @@ -1,7 +1,6 @@ module gpu -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -29,32 +28,21 @@ accumulation as code region. The accumulation operation must be one of: If `uniform` flag is set 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, - uniform=nothing, - body::Region, - location=Location(), -) - _results = IR.Type[] - _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)) - !isnothing(uniform) && push!(_attributes, namedattribute("uniform", uniform)) - - return IR.create_operation( - "gpu.all_reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function all_reduce(value; result_0=nothing::Union{Nothing, IR.Type}, op=nothing, uniform=nothing, body::Region, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result_0) && push!(results, result_0) + !isnothing(op) && push!(attributes, namedattribute("op", op)) + !isnothing(uniform) && push!(attributes, namedattribute("uniform", uniform)) + + 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) ) end @@ -80,38 +68,21 @@ memory accessible both on host and on device. %memref, %token = gpu.alloc async [%dep] host_shared (%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}, - hostShared=nothing, - 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) - ]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - !isnothing(hostShared) && push!(_attributes, namedattribute("hostShared", hostShared)) - - return IR.create_operation( - "gpu.alloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloc(asyncDependencies, dynamicSizes, symbolOperands; memref::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, hostShared=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(asyncDependencies)..., value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(asyncDependencies), length(dynamicSizes), length(symbolOperands), ])) + !isnothing(asyncToken) && push!(results, asyncToken) + !isnothing(hostShared) && push!(attributes, namedattribute("hostShared", hostShared)) + + IR.create_operation( + "gpu.alloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -240,31 +211,19 @@ that case, it returns a !gpu.async.token in addition to the environment. %spmat, %token = gpu.create_2to4_spmat async [%dep] %rows, %cols, %mem : memref ``` """ -function create_2to4_spmat( - asyncDependencies::Vector{Value}, - rows::Value, - cols::Value, - memref::Value; - spMat::IR.Type, - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[spMat,] - _operands = Value[asyncDependencies..., rows, cols, memref] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.create_2to4_spmat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_2to4_spmat(asyncDependencies, rows, cols, memref; spMat::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[spMat, ] + operands = Value[value.(asyncDependencies)..., value(rows), value(cols), value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.create_2to4_spmat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -290,33 +249,19 @@ that case, it returns a !gpu.async.token in addition to the environment. %values : memref, memref ``` """ -function create_coo_aos( - asyncDependencies::Vector{Value}, - rows::Value, - cols::Value, - nnz::Value, - idxs::Value, - values::Value; - spmat::IR.Type, - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[spmat,] - _operands = Value[asyncDependencies..., rows, cols, nnz, idxs, values] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.create_coo_aos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_coo_aos(asyncDependencies, rows, cols, nnz, idxs, values; spmat::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[spmat, ] + operands = Value[value.(asyncDependencies)..., value(rows), value(cols), value(nnz), value(idxs), value(values), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.create_coo_aos", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -340,34 +285,19 @@ that case, it returns a !gpu.async.token in addition to the environment. %colIdx, %values : memref, memref, memref ``` """ -function create_coo( - asyncDependencies::Vector{Value}, - rows::Value, - cols::Value, - nnz::Value, - rowIdxs::Value, - colIdxs::Value, - values::Value; - spmat::IR.Type, - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[spmat,] - _operands = Value[asyncDependencies..., rows, cols, nnz, rowIdxs, colIdxs, values] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.create_coo", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_coo(asyncDependencies, rows, cols, nnz, rowIdxs, colIdxs, values; spmat::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[spmat, ] + operands = Value[value.(asyncDependencies)..., value(rows), value(cols), value(nnz), value(rowIdxs), value(colIdxs), value(values), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.create_coo", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -391,34 +321,19 @@ that case, it returns a !gpu.async.token in addition to the environment. %colIdx, %values : memref, memref, memref ``` """ -function create_csr( - asyncDependencies::Vector{Value}, - rows::Value, - cols::Value, - nnz::Value, - rowPos::Value, - colIdxs::Value, - values::Value; - spmat::IR.Type, - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[spmat,] - _operands = Value[asyncDependencies..., rows, cols, nnz, rowPos, colIdxs, values] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.create_csr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_csr(asyncDependencies, rows, cols, nnz, rowPos, colIdxs, values; spmat::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[spmat, ] + operands = Value[value.(asyncDependencies)..., value(rows), value(cols), value(nnz), value(rowPos), value(colIdxs), value(values), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.create_csr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -440,31 +355,20 @@ that case, it returns a !gpu.async.token in addition to the environment. %dmat, %token = gpu.create_dn_tensor async [%dep] %mem, %dims : index, index into memref ``` """ -function create_dn_tensor( - asyncDependencies::Vector{Value}, - memref::Value, - dims::Vector{Value}; - dnTensor::IR.Type, - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[dnTensor,] - _operands = Value[asyncDependencies..., memref, dims...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(asyncDependencies), 1, length(dims)])) - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.create_dn_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_dn_tensor(asyncDependencies, memref, dims; dnTensor::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[dnTensor, ] + operands = Value[value.(asyncDependencies)..., value(memref), value.(dims)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, length(dims), ])) + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.create_dn_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -488,28 +392,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(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies..., memref] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.dealloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dealloc(asyncDependencies, memref; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.dealloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -530,28 +425,19 @@ that case, it returns a !gpu.async.token in addition to the environment. %token = gpu.destroy_dn_tensor async [%dep] %dnTensor ``` """ -function destroy_dn_tensor( - asyncDependencies::Vector{Value}, - dnTensor::Value; - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies..., dnTensor] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.destroy_dn_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function destroy_dn_tensor(asyncDependencies, dnTensor; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(dnTensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.destroy_dn_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -572,28 +458,19 @@ that case, it returns a !gpu.async.token in addition to the environment. %token = gpu.destroy_sp_mat async [%dep] %spmat ``` """ -function destroy_sp_mat( - asyncDependencies::Vector{Value}, - spmat::Value; - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies..., spmat] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.destroy_sp_mat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function destroy_sp_mat(asyncDependencies, spmat; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(spmat), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.destroy_sp_mat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -823,22 +700,18 @@ Writes from the host are guaranteed to be visible to device kernels that are launched afterwards. Writes from the device are guaranteed to be visible on the host after synchronizing with the device kernel completion. """ -function host_register(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.host_register", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function host_register(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.host_register", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -850,22 +723,18 @@ This op unmaps the provided host buffer from the device address space. This operation may not be supported in every environment, there is not yet a way to check at runtime whether this feature is supported. """ -function host_unregister(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.host_unregister", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function host_unregister(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.host_unregister", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -980,60 +849,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}; - kernelOperands::Vector{Value}, - asyncToken=nothing::Union{Nothing,IR.Type}, - kernel, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - asyncDependencies..., - gridSizeX, - gridSizeY, - gridSizeZ, - blockSizeX, - blockSizeY, - blockSizeZ, - kernelOperands..., - ] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kernel", kernel),] - !isnothing(dynamicSharedMemorySize) && push!(_operands, dynamicSharedMemorySize) - push!( - _attributes, - operandsegmentsizes([ - length(asyncDependencies), - 1, - 1, - 1, - 1, - 1, - 1, - isnothing(dynamicSharedMemorySize) ? 0 : 1, - length(kernelOperands), - ]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.launch_func", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function launch_func(asyncDependencies, gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ, dynamicSharedMemorySize=nothing; kernelOperands, asyncToken=nothing::Union{Nothing, IR.Type}, kernel, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(gridSizeX), value(gridSizeY), value(gridSizeZ), value(blockSizeX), value(blockSizeY), value(blockSizeZ), value.(kernelOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kernel", kernel), ] + !isnothing(dynamicSharedMemorySize) && push!(operands, value(dynamicSharedMemorySize)) + push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1length(kernelOperands), ])) + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.launch_func", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1128,57 +958,21 @@ 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( - asyncDependencies::Vector{Value}, - gridSizeX::Value, - gridSizeY::Value, - gridSizeZ::Value, - blockSizeX::Value, - blockSizeY::Value, - blockSizeZ::Value, - dynamicSharedMemorySize=nothing::Union{Nothing,Value}; - asyncToken=nothing::Union{Nothing,IR.Type}, - body::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - asyncDependencies..., - gridSizeX, - gridSizeY, - gridSizeZ, - blockSizeX, - blockSizeY, - blockSizeZ, - ] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(dynamicSharedMemorySize) && push!(_operands, dynamicSharedMemorySize) - push!( - _attributes, - operandsegmentsizes([ - length(asyncDependencies), - 1, - 1, - 1, - 1, - 1, - 1, - isnothing(dynamicSharedMemorySize) ? 0 : 1, - ]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.launch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function launch(asyncDependencies, gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ, dynamicSharedMemorySize=nothing; asyncToken=nothing::Union{Nothing, IR.Type}, body::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(gridSizeX), value(gridSizeY), value(gridSizeZ), value(blockSizeX), value(blockSizeY), value(blockSizeZ), ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dynamicSharedMemorySize) && push!(operands, value(dynamicSharedMemorySize)) + push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, 1, 1, 1, (dynamicSharedMemorySize==nothing) ? 0 : 1])) + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.launch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1200,29 +994,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function memcpy(asyncDependencies, dst, src; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(dst), value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.memcpy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1244,29 +1028,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function memset(asyncDependencies, dst, value; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(dst), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.memset", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1334,22 +1108,18 @@ scalar arguments that should be printed. The format string is a C-style printf string, subject to any restrictions imposed by one\'s target platform. """ -function printf(args::Vector{Value}; format, location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("format", format),] - - return IR.create_operation( - "gpu.printf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function printf(args; format, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("format", format), ] + + IR.create_operation( + "gpu.printf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1360,22 +1130,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1401,36 +1167,21 @@ The matrix arguments can also be associated with one of the following operators: NON_TRANSPOSE, TRANSPOSE, CONJUGATE_TRANSPOSE. The default value is NON_TRANSPOSE. """ -function sddmm_buffer_size( - asyncDependencies::Vector{Value}, - dnmatA::Value, - dnmatB::Value, - spmatC::Value; - bufferSz::IR.Type, - asyncToken=nothing::Union{Nothing,IR.Type}, - modeA=nothing, - modeB=nothing, - computeType, - location=Location(), -) - _results = IR.Type[bufferSz,] - _operands = Value[asyncDependencies..., dnmatA, dnmatB, spmatC] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("computeType", computeType),] - !isnothing(asyncToken) && push!(_results, asyncToken) - !isnothing(modeA) && push!(_attributes, namedattribute("modeA", modeA)) - !isnothing(modeB) && push!(_attributes, namedattribute("modeB", modeB)) - - return IR.create_operation( - "gpu.sddmm_buffer_size", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sddmm_buffer_size(asyncDependencies, dnmatA, dnmatB, spmatC; bufferSz::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, modeA=nothing, modeB=nothing, computeType, location=Location()) + results = IR.Type[bufferSz, ] + operands = Value[value.(asyncDependencies)..., value(dnmatA), value(dnmatB), value(spmatC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("computeType", computeType), ] + !isnothing(asyncToken) && push!(results, asyncToken) + !isnothing(modeA) && push!(attributes, namedattribute("modeA", modeA)) + !isnothing(modeB) && push!(attributes, namedattribute("modeB", modeB)) + + IR.create_operation( + "gpu.sddmm_buffer_size", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1456,36 +1207,21 @@ The matrix arguments can also be associated with one of the following operators: NON_TRANSPOSE, TRANSPOSE, CONJUGATE_TRANSPOSE. The default value is NON_TRANSPOSE. """ -function sddmm( - asyncDependencies::Vector{Value}, - dnmatA::Value, - dnmatB::Value, - spmatC::Value, - buffer::Value; - asyncToken=nothing::Union{Nothing,IR.Type}, - modeA=nothing, - modeB=nothing, - computeType, - location=Location(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies..., dnmatA, dnmatB, spmatC, buffer] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("computeType", computeType),] - !isnothing(asyncToken) && push!(_results, asyncToken) - !isnothing(modeA) && push!(_attributes, namedattribute("modeA", modeA)) - !isnothing(modeB) && push!(_attributes, namedattribute("modeB", modeB)) - - return IR.create_operation( - "gpu.sddmm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sddmm(asyncDependencies, dnmatA, dnmatB, spmatC, buffer; asyncToken=nothing::Union{Nothing, IR.Type}, modeA=nothing, modeB=nothing, computeType, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(dnmatA), value(dnmatB), value(spmatC), value(buffer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("computeType", computeType), ] + !isnothing(asyncToken) && push!(results, asyncToken) + !isnothing(modeA) && push!(attributes, namedattribute("modeA", modeA)) + !isnothing(modeB) && push!(attributes, namedattribute("modeB", modeB)) + + IR.create_operation( + "gpu.sddmm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1496,22 +1232,18 @@ Operation that sets the current default GPU, using a zero-based index into the set of GPUs on the system. The default GPU setting may be thread-local. """ -function set_default_device(devIndex::Value; location=Location()) - _results = IR.Type[] - _operands = Value[devIndex,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.set_default_device", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function set_default_device(devIndex; location=Location()) + results = IR.Type[] + operands = Value[value(devIndex), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.set_default_device", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1536,32 +1268,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; - shuffleResult=nothing::Union{Nothing,IR.Type}, - valid=nothing::Union{Nothing,IR.Type}, - mode, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, offset, width] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mode", mode),] - !isnothing(shuffleResult) && push!(_results, shuffleResult) - !isnothing(valid) && push!(_results, valid) - - return IR.create_operation( - "gpu.shuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shuffle(value, offset, width; shuffleResult=nothing::Union{Nothing, IR.Type}, valid=nothing::Union{Nothing, IR.Type}, mode, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(offset), value(width), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mode", mode), ] + !isnothing(shuffleResult) && push!(results, shuffleResult) + !isnothing(valid) && push!(results, valid) + + IR.create_operation( + "gpu.shuffle", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1587,36 +1307,21 @@ is NON_TRANSPOSE. %bufferszs, %token = gpu.spmm_buffer_size async [%dep] %spmatA{TRANSPOSE}, %dnmatB{TRANSPOSE}, %dnmatC : i64 into f32 ``` """ -function spmm_buffer_size( - asyncDependencies::Vector{Value}, - spmatA::Value, - dnmatB::Value, - dnmatC::Value; - bufferSzs::Vector{IR.Type}, - asyncToken=nothing::Union{Nothing,IR.Type}, - modeA=nothing, - modeB=nothing, - computeType, - location=Location(), -) - _results = IR.Type[bufferSzs...,] - _operands = Value[asyncDependencies..., spmatA, dnmatB, dnmatC] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("computeType", computeType),] - !isnothing(asyncToken) && push!(_results, asyncToken) - !isnothing(modeA) && push!(_attributes, namedattribute("modeA", modeA)) - !isnothing(modeB) && push!(_attributes, namedattribute("modeB", modeB)) - - return IR.create_operation( - "gpu.spmm_buffer_size", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function spmm_buffer_size(asyncDependencies, spmatA, dnmatB, dnmatC; bufferSzs::Vector{IR.Type}, asyncToken=nothing::Union{Nothing, IR.Type}, modeA=nothing, modeB=nothing, computeType, location=Location()) + results = IR.Type[bufferSzs..., ] + operands = Value[value.(asyncDependencies)..., value(spmatA), value(dnmatB), value(dnmatC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("computeType", computeType), ] + !isnothing(asyncToken) && push!(results, asyncToken) + !isnothing(modeA) && push!(attributes, namedattribute("modeA", modeA)) + !isnothing(modeB) && push!(attributes, namedattribute("modeB", modeB)) + + IR.create_operation( + "gpu.spmm_buffer_size", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1642,40 +1347,22 @@ is NON_TRANSPOSE. %token = gpu.spmm async [%dep] %spmatA{TRANSPOSE}, %dnmatB{TRANSPOSE}, %dnmatC, %buffers : type(\$buffers) into f32 ``` """ -function spmm( - asyncDependencies::Vector{Value}, - spmatA::Value, - dnmatB::Value, - dnmatC::Value, - buffers::Vector{Value}; - asyncToken=nothing::Union{Nothing,IR.Type}, - modeA=nothing, - modeB=nothing, - computeType, - location=Location(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies..., spmatA, dnmatB, dnmatC, buffers...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("computeType", computeType),] - push!( - _attributes, - operandsegmentsizes([length(asyncDependencies), 1, 1, 1, length(buffers)]), - ) - !isnothing(asyncToken) && push!(_results, asyncToken) - !isnothing(modeA) && push!(_attributes, namedattribute("modeA", modeA)) - !isnothing(modeB) && push!(_attributes, namedattribute("modeB", modeB)) - - return IR.create_operation( - "gpu.spmm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function spmm(asyncDependencies, spmatA, dnmatB, dnmatC, buffers; asyncToken=nothing::Union{Nothing, IR.Type}, modeA=nothing, modeB=nothing, computeType, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(spmatA), value(dnmatB), value(dnmatC), value.(buffers)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("computeType", computeType), ] + push!(attributes, operandsegmentsizes([length(asyncDependencies), 1, 1, 1, length(buffers), ])) + !isnothing(asyncToken) && push!(results, asyncToken) + !isnothing(modeA) && push!(attributes, namedattribute("modeA", modeA)) + !isnothing(modeB) && push!(attributes, namedattribute("modeB", modeB)) + + IR.create_operation( + "gpu.spmm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1701,34 +1388,20 @@ is NON_TRANSPOSE. %buffersz, %token = gpu.spmv_buffer_size async [%dep] %spmatA{TRANSPOSE}, %dnX, %dnY into f32 ``` """ -function spmv_buffer_size( - asyncDependencies::Vector{Value}, - spmatA::Value, - dnX::Value, - dnY::Value; - bufferSz::IR.Type, - asyncToken=nothing::Union{Nothing,IR.Type}, - modeA=nothing, - computeType, - location=Location(), -) - _results = IR.Type[bufferSz,] - _operands = Value[asyncDependencies..., spmatA, dnX, dnY] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("computeType", computeType),] - !isnothing(asyncToken) && push!(_results, asyncToken) - !isnothing(modeA) && push!(_attributes, namedattribute("modeA", modeA)) - - return IR.create_operation( - "gpu.spmv_buffer_size", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function spmv_buffer_size(asyncDependencies, spmatA, dnX, dnY; bufferSz::IR.Type, asyncToken=nothing::Union{Nothing, IR.Type}, modeA=nothing, computeType, location=Location()) + results = IR.Type[bufferSz, ] + operands = Value[value.(asyncDependencies)..., value(spmatA), value(dnX), value(dnY), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("computeType", computeType), ] + !isnothing(asyncToken) && push!(results, asyncToken) + !isnothing(modeA) && push!(attributes, namedattribute("modeA", modeA)) + + IR.create_operation( + "gpu.spmv_buffer_size", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1754,34 +1427,20 @@ is NON_TRANSPOSE. %token = gpu.spmv async [%dep] %spmatA{TRANSPOSE}, %dnX, %dnY : memref into bf16 ``` """ -function spmv( - asyncDependencies::Vector{Value}, - spmatA::Value, - dnX::Value, - dnY::Value, - buffer::Value; - asyncToken=nothing::Union{Nothing,IR.Type}, - modeA=nothing, - computeType, - location=Location(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies..., spmatA, dnX, dnY, buffer] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("computeType", computeType),] - !isnothing(asyncToken) && push!(_results, asyncToken) - !isnothing(modeA) && push!(_attributes, namedattribute("modeA", modeA)) - - return IR.create_operation( - "gpu.spmv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function spmv(asyncDependencies, spmatA, dnX, dnY, buffer; asyncToken=nothing::Union{Nothing, IR.Type}, modeA=nothing, computeType, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., value(spmatA), value(dnX), value(dnY), value(buffer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("computeType", computeType), ] + !isnothing(asyncToken) && push!(results, asyncToken) + !isnothing(modeA) && push!(attributes, namedattribute("modeA", modeA)) + + IR.create_operation( + "gpu.spmv", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1848,35 +1507,21 @@ 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}, - a_transpose=nothing, - b_transpose=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[opA, opB, opC] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(a_transpose) && - push!(_attributes, namedattribute("a_transpose", a_transpose)) - !isnothing(b_transpose) && - push!(_attributes, namedattribute("b_transpose", b_transpose)) - - return IR.create_operation( - "gpu.subgroup_mma_compute", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subgroup_mma_compute(opA, opB, opC; res=nothing::Union{Nothing, IR.Type}, a_transpose=nothing, b_transpose=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(opA), value(opB), value(opC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !isnothing(a_transpose) && push!(attributes, namedattribute("a_transpose", a_transpose)) + !isnothing(b_transpose) && push!(attributes, namedattribute("b_transpose", b_transpose)) + + 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) ) end @@ -1903,22 +1548,18 @@ This op is meant to be used along with `gpu.subgroup_mma_compute`. !gpu.mma_matrix<16x16xf32, \"COp\"> ``` """ -function subgroup_mma_constant_matrix(value::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_constant_matrix(value; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.subgroup_mma_constant_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1942,24 +1583,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, opType, location=Location() -) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("opType", opType),] - - return IR.create_operation( - "gpu.subgroup_mma_elementwise", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_elementwise(args; res::IR.Type, opType, location=Location()) + results = IR.Type[res, ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("opType", opType), ] + + IR.create_operation( + "gpu.subgroup_mma_elementwise", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1991,30 +1626,19 @@ 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, - transpose=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[srcMemref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("leadDimension", leadDimension),] - !isnothing(transpose) && push!(_attributes, namedattribute("transpose", transpose)) - - return IR.create_operation( - "gpu.subgroup_mma_load_matrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_load_matrix(srcMemref, indices; res::IR.Type, leadDimension, transpose=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(srcMemref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] + !isnothing(transpose) && push!(attributes, namedattribute("transpose", transpose)) + + IR.create_operation( + "gpu.subgroup_mma_load_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2041,30 +1665,19 @@ 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, - transpose=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[src, dstMemref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("leadDimension", leadDimension),] - !isnothing(transpose) && push!(_attributes, namedattribute("transpose", transpose)) - - return IR.create_operation( - "gpu.subgroup_mma_store_matrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subgroup_mma_store_matrix(src, dstMemref, indices; leadDimension, transpose=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(dstMemref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("leadDimension", leadDimension), ] + !isnothing(transpose) && push!(attributes, namedattribute("transpose", transpose)) + + IR.create_operation( + "gpu.subgroup_mma_store_matrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2083,30 +1696,20 @@ subgroup. The result is equal for all work items of a subgroup. If `uniform` flag is set either none or all work items of a subgroup need to execute this op in convergence. """ -function subgroup_reduce( - value::Value; - result_0=nothing::Union{Nothing,IR.Type}, - op, - uniform=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("op", op),] - !isnothing(result_0) && push!(_results, result_0) - !isnothing(uniform) && push!(_attributes, namedattribute("uniform", uniform)) - - return IR.create_operation( - "gpu.subgroup_reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function subgroup_reduce(value; result_0=nothing::Union{Nothing, IR.Type}, op, uniform=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("op", op), ] + !isnothing(result_0) && push!(results, result_0) + !isnothing(uniform) && push!(attributes, namedattribute("uniform", uniform)) + + IR.create_operation( + "gpu.subgroup_reduce", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2234,27 +1837,19 @@ once this op completes. Example usage: gpu.wait [%t0, %t1] ``` """ -function wait( - asyncDependencies::Vector{Value}; - asyncToken=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[asyncDependencies...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(asyncToken) && push!(_results, asyncToken) - - return IR.create_operation( - "gpu.wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wait(asyncDependencies; asyncToken=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(asyncDependencies)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncToken) && push!(results, asyncToken) + + IR.create_operation( + "gpu.wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2270,22 +1865,18 @@ in gpu ops. It returns values to the immediately enclosing gpu op. gpu.yield %f0, %f1 : f32, f32 ``` """ -function yield(values::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[values...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "gpu.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(values; location=Location()) + results = IR.Type[] + operands = Value[value.(values)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "gpu.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/IRDL.jl b/src/Dialects/17/IRDL.jl index df885abc..59a40a04 100644 --- a/src/Dialects/17/IRDL.jl +++ b/src/Dialects/17/IRDL.jl @@ -1,7 +1,6 @@ module irdl -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -33,25 +32,19 @@ The above program defines a type `complex` inside the dialect `cmath` that can has one parameter that must be 32-bit long and a float (in other words, that must be `f32`). """ -function all_of( - args::Vector{Value}; output=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "irdl.all_of", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function all_of(args; output=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "irdl.all_of", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -80,25 +73,19 @@ The above program defines a type `complex` inside the dialect `cmath` that can have a single type parameter that can be either `i32`, `i64`, `f32` or `f32`. """ -function any_of( - args::Vector{Value}; output=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "irdl.any_of", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function any_of(args; output=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "irdl.any_of", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -212,24 +199,18 @@ irdl.dialect @example { The operation will expect an arbitrary attribute \"attr1\" and an attribute \"attr2\" with value `i64`. """ -function attributes( - attributeValues::Vector{Value}; attributeValueNames, location=Location() -) - _results = IR.Type[] - _operands = Value[attributeValues...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("attributeValueNames", attributeValueNames),] - - return IR.create_operation( - "irdl.attributes", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function attributes_(attributeValues; attributeValueNames, location=Location()) + results = IR.Type[] + operands = Value[value.(attributeValues)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("attributeValueNames", attributeValueNames), ] + + IR.create_operation( + "irdl.attributes", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -395,22 +376,18 @@ When more than one operand is marked as optional or variadic, the operation will expect a \'operandSegmentSizes\' attribute that defines the number of operands in each segment. """ -function operands(args::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "irdl.operands", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operands_(args; location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "irdl.operands", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -485,22 +462,18 @@ irdl.dialect @cmath { The above program defines a type `complex` inside the dialect `cmath`. The type has a single parameter that should be either `i32` or `i64`. """ -function parameters(args::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "irdl.parameters", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parameters(args; location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "irdl.parameters", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -531,28 +504,19 @@ irdl.dialect @cmath { The above program defines an operation `norm` inside the dialect `cmath` that for any `T` takes a `cmath.complex` with parameter `T` and returns a `T`. """ -function parametric( - args::Vector{Value}; - output=nothing::Union{Nothing,IR.Type}, - base_type, - location=Location(), -) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("base_type", base_type),] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "irdl.parametric", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function parametric(args; output=nothing::Union{Nothing, IR.Type}, base_type, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("base_type", base_type), ] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "irdl.parametric", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -594,22 +558,18 @@ When more than one result is marked as optional or variadic, the operation will expect a \'resultSegmentSizes\' attribute that defines the number of results in each segment. """ -function results(args::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "irdl.results", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function results_(args; location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "irdl.results", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Index.jl b/src/Dialects/17/Index.jl index ab08f30f..ad6d11c2 100644 --- a/src/Dialects/17/Index.jl +++ b/src/Dialects/17/Index.jl @@ -1,7 +1,6 @@ module index -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -16,25 +15,19 @@ The `index.add` operation takes two index values and computes their sum. %c = index.add %a, %b ``` """ -function add( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -51,25 +44,19 @@ and. %c = index.and %a, %b ``` """ -function and( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function and(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.and", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -126,22 +113,18 @@ truncated. %1 = index.casts %b : i64 to index ``` """ -function casts(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "index.casts", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function casts(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "index.casts", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -163,22 +146,18 @@ truncated. %1 = index.castu %b : i64 to index ``` """ -function castu(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "index.castu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function castu(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "index.castu", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -198,25 +177,19 @@ Note: division by zero and signed division overflow are undefined behaviour. %c = index.ceildivs %a, %b ``` """ -function ceildivs( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.ceildivs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivs(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.ceildivs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -236,25 +209,19 @@ Note: division by zero is undefined behaviour. %c = index.ceildivu %a, %b ``` """ -function ceildivu( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.ceildivu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceildivu(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.ceildivu", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -291,29 +258,19 @@ The result is `1` if the comparison is true and `0` otherwise. %2 = index.cmp ne(%a, %b) ``` """ -function cmp( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - pred, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pred", pred),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.cmp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cmp(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, pred, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("pred", pred), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.cmp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -365,25 +322,19 @@ Note: division by zero and signed division overflow are undefined behaviour. %c = index.divs %a, %b ``` """ -function divs( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.divs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divs(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.divs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -403,25 +354,19 @@ Note: division by zero is undefined behaviour. %c = index.divu %a, %b ``` """ -function divu( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.divu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function divu(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.divu", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -441,25 +386,19 @@ Note: division by zero and signed division overflow are undefined behaviour. %c = index.floordivs %a, %b ``` """ -function floordivs( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.floordivs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function floordivs(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.floordivs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -476,25 +415,19 @@ maximum value. Treats the leading bit as the sign, i.e. `max(-2, 6) = 6`. %c = index.maxs %a, %b ``` """ -function maxs( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.maxs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxs(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.maxs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -512,25 +445,19 @@ unsigned maximum value. Treats the leading bit as the most significant, i.e. %c = index.maxu %a, %b ``` """ -function maxu( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.maxu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function maxu(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.maxu", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -547,25 +474,19 @@ minimum value. Treats the leading bit as the sign, i.e. `min(-2, 6) = -2`. %c = index.mins %a, %b ``` """ -function mins( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.mins", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mins(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.mins", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -583,25 +504,19 @@ unsigned minimum value. Treats the leading bit as the most significant, i.e. %c = index.minu %a, %b ``` """ -function minu( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.minu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function minu(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.minu", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -617,25 +532,19 @@ The `index.mul` operation takes two index values and computes their product. %c = index.mul %a, %b ``` """ -function mul( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -652,25 +561,19 @@ or. %c = index.or %a, %b ``` """ -function or( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function or(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.or", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -687,25 +590,19 @@ remainder. Treats the leading bit as the sign, i.e. `6 % -2 = 0`. %c = index.rems %a, %b ``` """ -function rems( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.rems", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rems(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.rems", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -723,25 +620,19 @@ unsigned remainder. Treats the leading bit as the most significant, i.e. %c = index.remu %a, %b ``` """ -function remu( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.remu", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function remu(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.remu", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -760,25 +651,19 @@ index bitwidth, the operation is undefined. %c = index.shl %a, %b ``` """ -function shl( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.shl", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shl(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.shl", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -797,25 +682,19 @@ greater than the index bitwidth, the operation is undefined. %c = index.shrs %a, %b ``` """ -function shrs( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.shrs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shrs(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.shrs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -834,25 +713,19 @@ bitwidth, the operation is undefined. %c = index.shru %a, %b ``` """ -function shru( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.shru", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shru(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.shru", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -902,25 +775,19 @@ of the first from the second operand. %c = index.sub %a, %b ``` """ -function sub( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sub(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.sub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -937,25 +804,19 @@ xor. %c = index.xor %a, %b ``` """ -function xor( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "index.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function xor(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "index.xor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/17/LLVMIR.jl b/src/Dialects/17/LLVMIR.jl index 32e597d1..fc747e70 100644 --- a/src/Dialects/17/LLVMIR.jl +++ b/src/Dialects/17/LLVMIR.jl @@ -1,32 +1,25 @@ module llvm -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `ashr` """ -function ashr( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.ashr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ashr(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.ashr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -34,25 +27,19 @@ end `add` """ -function add( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -60,22 +47,18 @@ end `addrspacecast` """ -function addrspacecast(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.addrspacecast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function addrspacecast(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.addrspacecast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -131,32 +114,21 @@ end `alloca` """ -function alloca( - arraySize::Value; - res::IR.Type, - alignment=nothing, - elem_type=nothing, - inalloca=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[arraySize,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - !isnothing(elem_type) && push!(_attributes, namedattribute("elem_type", elem_type)) - !isnothing(inalloca) && push!(_attributes, namedattribute("inalloca", inalloca)) - - return IR.create_operation( - "llvm.alloca", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca(arraySize; res::IR.Type, alignment=nothing, elem_type=nothing, inalloca=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arraySize), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(elem_type) && push!(attributes, namedattribute("elem_type", elem_type)) + !isnothing(inalloca) && push!(attributes, namedattribute("inalloca", inalloca)) + + IR.create_operation( + "llvm.alloca", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -164,25 +136,19 @@ end `and` """ -function and( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function and(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.and", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -190,53 +156,26 @@ end `cmpxchg` """ -function cmpxchg( - ptr::Value, - cmp::Value, - val::Value; - res=nothing::Union{Nothing,IR.Type}, - success_ordering, - failure_ordering, - syncscope=nothing, - alignment=nothing, - weak=nothing, - volatile_=nothing, - access_groups=nothing, - alias_scopes=nothing, - noalias_scopes=nothing, - tbaa=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ptr, cmp, val] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("success_ordering", success_ordering), - namedattribute("failure_ordering", failure_ordering), - ] - !isnothing(res) && push!(_results, res) - !isnothing(syncscope) && push!(_attributes, namedattribute("syncscope", syncscope)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - !isnothing(weak) && push!(_attributes, namedattribute("weak", weak)) - !isnothing(volatile_) && push!(_attributes, namedattribute("volatile_", volatile_)) - !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(tbaa) && push!(_attributes, namedattribute("tbaa", tbaa)) - - return IR.create_operation( - "llvm.cmpxchg", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cmpxchg(ptr, cmp, val; res::IR.Type, success_ordering, failure_ordering, syncscope=nothing, alignment=nothing, weak=nothing, volatile_=nothing, access_groups=nothing, alias_scopes=nothing, noalias_scopes=nothing, tbaa=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(ptr), value(cmp), value(val), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("success_ordering", success_ordering), namedattribute("failure_ordering", failure_ordering), ] + !isnothing(syncscope) && push!(attributes, namedattribute("syncscope", syncscope)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(weak) && push!(attributes, namedattribute("weak", weak)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !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(tbaa) && push!(attributes, namedattribute("tbaa", tbaa)) + + IR.create_operation( + "llvm.cmpxchg", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -244,49 +183,25 @@ end `atomicrmw` """ -function atomicrmw( - ptr::Value, - val::Value; - res=nothing::Union{Nothing,IR.Type}, - bin_op, - ordering, - syncscope=nothing, - alignment=nothing, - volatile_=nothing, - access_groups=nothing, - alias_scopes=nothing, - noalias_scopes=nothing, - tbaa=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ptr, val] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("bin_op", bin_op), namedattribute("ordering", ordering) - ] - !isnothing(res) && push!(_results, res) - !isnothing(syncscope) && push!(_attributes, namedattribute("syncscope", syncscope)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - !isnothing(volatile_) && push!(_attributes, namedattribute("volatile_", volatile_)) - !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(tbaa) && push!(_attributes, namedattribute("tbaa", tbaa)) - - return IR.create_operation( - "llvm.atomicrmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atomicrmw(ptr, val; res::IR.Type, bin_op, ordering, syncscope=nothing, alignment=nothing, volatile_=nothing, access_groups=nothing, alias_scopes=nothing, noalias_scopes=nothing, tbaa=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(ptr), value(val), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("bin_op", bin_op), namedattribute("ordering", ordering), ] + !isnothing(syncscope) && push!(attributes, namedattribute("syncscope", syncscope)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !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(tbaa) && push!(attributes, namedattribute("tbaa", tbaa)) + + IR.create_operation( + "llvm.atomicrmw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -294,22 +209,18 @@ end `bitcast` """ -function bitcast(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -317,26 +228,19 @@ end `br` """ -function br( - destOperands::Vector{Value}; loop_annotation=nothing, dest::Block, location=Location() -) - _results = IR.Type[] - _operands = Value[destOperands...,] - _owned_regions = Region[] - _successors = Block[dest,] - _attributes = NamedAttribute[] - !isnothing(loop_annotation) && - push!(_attributes, namedattribute("loop_annotation", loop_annotation)) - - return IR.create_operation( - "llvm.br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function br(destOperands; loop_annotation=nothing, dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(destOperands)..., ] + owned_regions = Region[] + successors = Block[dest, ] + attributes = NamedAttribute[] + !isnothing(loop_annotation) && push!(attributes, namedattribute("loop_annotation", loop_annotation)) + + IR.create_operation( + "llvm.br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -369,46 +273,26 @@ llvm.call @bar(%0) : (f32) -> () llvm.call %1(%0) : !llvm.ptr, (f32) -> () ``` """ -function call( - operand_0::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - callee=nothing, - fastmathFlags=nothing, - branch_weights=nothing, - access_groups=nothing, - alias_scopes=nothing, - noalias_scopes=nothing, - tbaa=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_0...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(callee) && push!(_attributes, namedattribute("callee", callee)) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - !isnothing(branch_weights) && - push!(_attributes, namedattribute("branch_weights", branch_weights)) - !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(tbaa) && push!(_attributes, namedattribute("tbaa", tbaa)) - - return IR.create_operation( - "llvm.call", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function call(operand_0; result=nothing::Union{Nothing, IR.Type}, callee=nothing, fastmathFlags=nothing, branch_weights=nothing, access_groups=nothing, alias_scopes=nothing, noalias_scopes=nothing, tbaa=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !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(tbaa) && push!(attributes, namedattribute("tbaa", tbaa)) + + IR.create_operation( + "llvm.call", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -482,39 +366,21 @@ end `cond_br` """ -function cond_br( - condition::Value, - trueDestOperands::Vector{Value}, - falseDestOperands::Vector{Value}; - branch_weights=nothing, - loop_annotation=nothing, - trueDest::Block, - falseDest::Block, - location=Location(), -) - _results = IR.Type[] - _operands = Value[condition, trueDestOperands..., falseDestOperands...] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands)]), - ) - !isnothing(branch_weights) && - push!(_attributes, namedattribute("branch_weights", branch_weights)) - !isnothing(loop_annotation) && - push!(_attributes, namedattribute("loop_annotation", loop_annotation)) - - return IR.create_operation( - "llvm.cond_br", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cond_br(condition, trueDestOperands, falseDestOperands; branch_weights=nothing, loop_annotation=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueDestOperands)..., value.(falseDestOperands)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([1, length(trueDestOperands), length(falseDestOperands), ])) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) + !isnothing(loop_annotation) && push!(attributes, namedattribute("loop_annotation", loop_annotation)) + + IR.create_operation( + "llvm.cond_br", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -571,25 +437,18 @@ end `extractelement` """ -function extractelement( - vector::Value, position::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[vector, position] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.extractelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extractelement(vector, position; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(vector), value(position), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.extractelement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -597,22 +456,18 @@ end `extractvalue` """ -function extractvalue(container::Value; res::IR.Type, position, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extractvalue(container; res::IR.Type, position, location=Location()) + results = IR.Type[res, ] + operands = Value[value(container), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + + IR.create_operation( + "llvm.extractvalue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -620,31 +475,20 @@ end `fadd` """ -function fadd( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fadd(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -652,32 +496,19 @@ end `fcmp` """ -function fcmp( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - predicate, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("predicate", predicate),] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.fcmp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fcmp(lhs, rhs; res::IR.Type, predicate, fastmathFlags=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(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 ) end @@ -685,31 +516,20 @@ end `fdiv` """ -function fdiv( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fdiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -717,31 +537,20 @@ end `fmul` """ -function fmul( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fmul(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -749,30 +558,20 @@ end `fneg` """ -function fneg( - operand::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fneg(operand; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -780,45 +579,37 @@ end `fpext` """ -function fpext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fpext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end +function fpext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fpext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `fptosi` """ -function fptosi(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptosi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptosi(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptosi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -826,22 +617,18 @@ end `fptoui` """ -function fptoui(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptoui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptoui(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptoui", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -849,22 +636,18 @@ end `fptrunc` """ -function fptrunc(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.fptrunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fptrunc(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.fptrunc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -872,31 +655,20 @@ end `frem` """ -function frem( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function frem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -904,31 +676,20 @@ end `fsub` """ -function fsub( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fsub(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !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) ) end @@ -960,23 +721,19 @@ end `freeze` """ -function freeze(val::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[val,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.freeze", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function freeze(val; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(val), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.freeze", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1007,32 +764,20 @@ Examples: : (!llvm.ptr) -> !llvm.ptr ``` """ -function getelementptr( - base::Value, - dynamicIndices::Vector{Value}; - res::IR.Type, - rawConstantIndices, - elem_type=nothing, - inbounds=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[base, dynamicIndices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("rawConstantIndices", rawConstantIndices),] - !isnothing(elem_type) && push!(_attributes, namedattribute("elem_type", elem_type)) - !isnothing(inbounds) && push!(_attributes, namedattribute("inbounds", inbounds)) - - return IR.create_operation( - "llvm.getelementptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function getelementptr(base, dynamicIndices; res::IR.Type, rawConstantIndices, elem_type=nothing, inbounds=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(base), value.(dynamicIndices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("rawConstantIndices", rawConstantIndices), ] + !isnothing(elem_type) && push!(attributes, namedattribute("elem_type", elem_type)) + !isnothing(inbounds) && push!(attributes, namedattribute("inbounds", inbounds)) + + IR.create_operation( + "llvm.getelementptr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1272,29 +1017,18 @@ end `icmp` """ -function icmp( - lhs::Value, - rhs::Value; - res=nothing::Union{Nothing,IR.Type}, - predicate, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("predicate", predicate),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.icmp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function icmp(lhs, rhs; res::IR.Type, predicate, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "llvm.icmp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1308,43 +1042,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(), -) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function inline_asm(operands_; 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[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + 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(asm_dialect) && push!(attributes, namedattribute("asm_dialect", asm_dialect)) + !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 ) end @@ -1352,29 +1066,19 @@ end `insertelement` """ -function insertelement( - vector::Value, - value::Value, - position::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[vector, value, position] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.insertelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insertelement(vector, value, position; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(vector), value(value), value(position), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.insertelement", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1382,29 +1086,19 @@ end `insertvalue` """ -function insertvalue( - container::Value, - value::Value; - res=nothing::Union{Nothing,IR.Type}, - position, - location=Location(), -) - _results = IR.Type[] - _operands = Value[container, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("position", position),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.insertvalue", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insertvalue(container, value; res=nothing::Union{Nothing, IR.Type}, position, location=Location()) + results = IR.Type[] + operands = Value[value(container), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.insertvalue", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1412,22 +1106,18 @@ end `inttoptr` """ -function inttoptr(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.inttoptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function inttoptr(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.inttoptr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1435,41 +1125,21 @@ end `invoke` """ -function invoke( - callee_operands::Vector{Value}, - normalDestOperands::Vector{Value}, - unwindDestOperands::Vector{Value}; - result_0::Vector{IR.Type}, - callee=nothing, - branch_weights=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) - ]), - ) - !isnothing(callee) && push!(_attributes, namedattribute("callee", callee)) - !isnothing(branch_weights) && - push!(_attributes, namedattribute("branch_weights", branch_weights)) - - return IR.create_operation( - "llvm.invoke", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function invoke(callee_operands, normalDestOperands, unwindDestOperands; result_0::Vector{IR.Type}, callee=nothing, branch_weights=nothing, normalDest::Block, unwindDest::Block, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(callee_operands)..., value.(normalDestOperands)..., value.(unwindDestOperands)..., ] + owned_regions = Region[] + successors = Block[normalDest, unwindDest, ] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(callee_operands), length(normalDestOperands), length(unwindDestOperands), ])) + !isnothing(callee) && push!(attributes, namedattribute("callee", callee)) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) + + IR.create_operation( + "llvm.invoke", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1574,25 +1244,19 @@ end `lshr` """ -function lshr( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.lshr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function lshr(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.lshr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1600,25 +1264,19 @@ end `landingpad` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function landingpad(operand_0; res::IR.Type, cleanup=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value.(operand_0)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(cleanup) && push!(attributes, namedattribute("cleanup", cleanup)) + + IR.create_operation( + "llvm.landingpad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1648,48 +1306,27 @@ Examples: See the following link for more details: https://llvm.org/docs/LangRef.html#load-instruction """ -function load( - addr::Value; - res::IR.Type, - alignment=nothing, - volatile_=nothing, - nontemporal=nothing, - ordering=nothing, - syncscope=nothing, - access_groups=nothing, - alias_scopes=nothing, - noalias_scopes=nothing, - tbaa=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - !isnothing(volatile_) && push!(_attributes, namedattribute("volatile_", volatile_)) - !isnothing(nontemporal) && - push!(_attributes, namedattribute("nontemporal", nontemporal)) - !isnothing(ordering) && push!(_attributes, namedattribute("ordering", ordering)) - !isnothing(syncscope) && push!(_attributes, namedattribute("syncscope", syncscope)) - !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(tbaa) && push!(_attributes, namedattribute("tbaa", tbaa)) - - return IR.create_operation( - "llvm.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(addr; res::IR.Type, alignment=nothing, volatile_=nothing, nontemporal=nothing, ordering=nothing, syncscope=nothing, access_groups=nothing, alias_scopes=nothing, noalias_scopes=nothing, tbaa=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(addr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) + !isnothing(ordering) && push!(attributes, namedattribute("ordering", ordering)) + !isnothing(syncscope) && push!(attributes, namedattribute("syncscope", syncscope)) + !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(tbaa) && push!(attributes, namedattribute("tbaa", tbaa)) + + IR.create_operation( + "llvm.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1729,25 +1366,19 @@ end `mul` """ -function mul( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1792,25 +1423,19 @@ end `or` """ -function or( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function or(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.or", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1853,22 +1478,18 @@ end `ptrtoint` """ -function ptrtoint(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.ptrtoint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ptrtoint(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.ptrtoint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1876,22 +1497,18 @@ end `resume` """ -function resume(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function resume(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.resume", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1899,23 +1516,19 @@ end `return_` """ -function return_(arg=nothing::Union{Nothing,Value}; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(arg) && push!(_operands, arg) - - return IR.create_operation( - "llvm.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(arg=nothing; location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(arg) && push!(operands, value(arg)) + + IR.create_operation( + "llvm.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1923,25 +1536,19 @@ end `sdiv` """ -function sdiv( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.sdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sdiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.sdiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1949,22 +1556,18 @@ end `sext` """ -function sext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.sext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.sext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1972,22 +1575,18 @@ end `sitofp` """ -function sitofp(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.sitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sitofp(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.sitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1995,25 +1594,19 @@ end `srem` """ -function srem( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.srem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function srem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.srem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2021,32 +1614,20 @@ end `select` """ -function select( - condition::Value, - trueValue::Value, - falseValue::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[condition, trueValue, falseValue] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function select(condition, trueValue, falseValue; res=nothing::Union{Nothing, IR.Type}, fastmathFlags=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(trueValue), value(falseValue), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + !isnothing(fastmathFlags) && push!(attributes, namedattribute("fastmathFlags", fastmathFlags)) + + IR.create_operation( + "llvm.select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2054,25 +1635,19 @@ end `shl` """ -function shl( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.shl", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shl(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.shl", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2080,22 +1655,18 @@ end `shufflevector` """ -function shufflevector(v1::Value, v2::Value; res::IR.Type, mask, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shufflevector(v1, v2; res::IR.Type, mask, location=Location()) + results = IR.Type[res, ] + operands = Value[value(v1), value(v2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mask", mask), ] + + IR.create_operation( + "llvm.shufflevector", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2125,48 +1696,27 @@ llvm.store %val, %ptr atomic monotonic {alignment = 8 : i64} See the following link for more details: https://llvm.org/docs/LangRef.html#store-instruction """ -function store( - value::Value, - addr::Value; - alignment=nothing, - volatile_=nothing, - nontemporal=nothing, - ordering=nothing, - syncscope=nothing, - access_groups=nothing, - alias_scopes=nothing, - noalias_scopes=nothing, - tbaa=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, addr] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - !isnothing(volatile_) && push!(_attributes, namedattribute("volatile_", volatile_)) - !isnothing(nontemporal) && - push!(_attributes, namedattribute("nontemporal", nontemporal)) - !isnothing(ordering) && push!(_attributes, namedattribute("ordering", ordering)) - !isnothing(syncscope) && push!(_attributes, namedattribute("syncscope", syncscope)) - !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(tbaa) && push!(_attributes, namedattribute("tbaa", tbaa)) - - return IR.create_operation( - "llvm.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, addr; alignment=nothing, volatile_=nothing, nontemporal=nothing, ordering=nothing, syncscope=nothing, access_groups=nothing, alias_scopes=nothing, noalias_scopes=nothing, tbaa=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(addr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + !isnothing(volatile_) && push!(attributes, namedattribute("volatile_", volatile_)) + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) + !isnothing(ordering) && push!(attributes, namedattribute("ordering", ordering)) + !isnothing(syncscope) && push!(attributes, namedattribute("syncscope", syncscope)) + !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(tbaa) && push!(attributes, namedattribute("tbaa", tbaa)) + + IR.create_operation( + "llvm.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2174,25 +1724,19 @@ end `sub` """ -function sub( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sub(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.sub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2200,41 +1744,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(), -) - _results = IR.Type[] - _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)]) - ) - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch(value, defaultOperands, caseOperands; case_values=nothing, case_operand_segments, branch_weights=nothing, defaultDestination::Block, caseDestinations::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), value.(defaultOperands)..., value.(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), ])) + !isnothing(case_values) && push!(attributes, namedattribute("case_values", case_values)) + !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 ) end @@ -2242,22 +1766,18 @@ end `trunc` """ -function trunc(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.trunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function trunc(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.trunc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2265,25 +1785,19 @@ end `udiv` """ -function udiv( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.udiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function udiv(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.udiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2291,22 +1805,18 @@ end `uitofp` """ -function uitofp(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.uitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function uitofp(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.uitofp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2314,25 +1824,19 @@ end `urem` """ -function urem( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.urem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function urem(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.urem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2397,25 +1901,19 @@ end `xor` """ -function xor( - lhs::Value, rhs::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function xor(lhs, rhs; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "llvm.xor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2423,7560 +1921,18 @@ end `zext` """ -function zext(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.zext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType -import ..Dialects: namedattribute, operandsegmentsizes - -""" -`intr_abs` - -""" -function intr_abs(in::Value; res::IR.Type, is_int_min_poison, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("is_int_min_poison", is_int_min_poison),] - - return IR.create_operation( - "llvm.intr.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_annotation` - -""" -function intr_annotation( - integer::Value, - annotation::Value, - fileName::Value, - line::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[integer, annotation, fileName, line] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.annotation", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_assume` - -""" -function intr_assume(cond::Value; location=Location()) - _results = IR.Type[] - _operands = Value[cond,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.assume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_bitreverse` - -""" -function intr_bitreverse( - in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.bitreverse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_bswap` - -""" -function intr_bswap(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.bswap", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`call_intrinsic` - -Call the specified llvm intrinsic. If the intrinsic is overloaded, use -the MLIR function type of this op to determine which intrinsic to call. -""" -function call_intrinsic( - args::Vector{Value}; - results::Vector{IR.Type}, - intrin, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("intrin", intrin),] - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.call_intrinsic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_copysign` - -""" -function intr_copysign( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.copysign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_coro_align` - -""" -function intr_coro_align(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.align", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_begin` - -""" -function intr_coro_begin(token::Value, mem::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_end` - -""" -function intr_coro_end(handle::Value, unwind::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_free` - -""" -function intr_coro_free(id::Value, handle::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.id", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_resume` - -""" -function intr_coro_resume(handle::Value; location=Location()) - _results = IR.Type[] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.resume", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_save` - -""" -function intr_coro_save(handle::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.save", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_size` - -""" -function intr_coro_size(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.coro.size", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_coro_suspend` - -""" -function intr_coro_suspend(save::Value, final::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_cos` - -""" -function intr_cos( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_ctlz` - -""" -function intr_ctlz(in::Value; res::IR.Type, is_zero_poison, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("is_zero_poison", is_zero_poison),] - - return IR.create_operation( - "llvm.intr.ctlz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_cttz` - -""" -function intr_cttz(in::Value; res::IR.Type, is_zero_poison, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("is_zero_poison", is_zero_poison),] - - return IR.create_operation( - "llvm.intr.cttz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_ctpop` - -""" -function intr_ctpop(in::Value; res=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.ctpop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_dbg_declare` - -""" -function intr_dbg_declare(addr::Value; varInfo, location=Location()) - _results = IR.Type[] - _operands = Value[addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("varInfo", varInfo),] - - return IR.create_operation( - "llvm.intr.dbg.declare", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_dbg_label` - -""" -function intr_dbg_label(; label, location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("label", label),] - - return IR.create_operation( - "llvm.intr.dbg.label", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_dbg_value` - -""" -function intr_dbg_value(value::Value; varInfo, location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("varInfo", varInfo),] - - return IR.create_operation( - "llvm.intr.dbg.value", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_debugtrap` - -""" -function intr_debugtrap(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.debugtrap", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_eh_typeid_for` - -""" -function intr_eh_typeid_for(type_info::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_exp2` - -""" -function intr_exp2( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.exp2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_exp` - -""" -function intr_exp( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_expect` - -""" -function intr_expect( - val::Value, expected::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[val, expected] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.expect", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_expect_with_probability` - -""" -function intr_expect_with_probability( - val::Value, - expected::Value; - res=nothing::Union{Nothing,IR.Type}, - prob, - location=Location(), -) - _results = IR.Type[] - _operands = Value[val, expected] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("prob", prob),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.expect.with.probability", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_fabs` - -""" -function intr_fabs( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.fabs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_ceil` - -""" -function intr_ceil( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_floor` - -""" -function intr_floor( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_fma` - -""" -function intr_fma( - a::Value, - b::Value, - c::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_fmuladd` - -""" -function intr_fmuladd( - a::Value, - b::Value, - c::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.fmuladd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_trunc` - -""" -function intr_trunc( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.trunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_fshl` - -""" -function intr_fshl( - a::Value, b::Value, c::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.fshl", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_fshr` - -""" -function intr_fshr( - a::Value, b::Value, c::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.fshr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_get_active_lane_mask` - -""" -function intr_get_active_lane_mask(base::Value, n::Value; res::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_is_constant` - -""" -function intr_is_constant( - val::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[val,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.is.constant", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_is_fpclass` - -""" -function intr_is_fpclass(in::Value; res::IR.Type, bit, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("bit", bit),] - - return IR.create_operation( - "llvm.intr.is.fpclass", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_lifetime_end` - -""" -function intr_lifetime_end(ptr::Value; size, location=Location()) - _results = IR.Type[] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("size", size),] - - return IR.create_operation( - "llvm.intr.lifetime.end", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_lifetime_start` - -""" -function intr_lifetime_start(ptr::Value; size, location=Location()) - _results = IR.Type[] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("size", size),] - - return IR.create_operation( - "llvm.intr.lifetime.start", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_llrint` - -""" -function intr_llrint(val::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[val,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.llrint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_llround` - -""" -function intr_llround(val::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[val,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.llround", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_log2` - -""" -function intr_log2( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.log2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_log10` - -""" -function intr_log10( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.log10", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_log` - -""" -function intr_log( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_lrint` - -""" -function intr_lrint(val::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[val,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.lrint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_lround` - -""" -function intr_lround(val::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[val,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.lround", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_masked_store` - -""" -function intr_masked_store( - value::Value, data::Value, mask::Value; alignment, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_matrix_column_major_store` - -""" -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_matrix_transpose` - -""" -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_maxnum` - -""" -function intr_maxnum( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.maxnum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_maximum` - -""" -function intr_maximum( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.maximum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_memcpy_inline` - -""" -function intr_memcpy_inline( - dst::Value, - src::Value; - len, - isVolatile, - access_groups=nothing, - alias_scopes=nothing, - noalias_scopes=nothing, - tbaa=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[dst, src] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("len", len), namedattribute("isVolatile", isVolatile) - ] - !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(tbaa) && push!(_attributes, namedattribute("tbaa", tbaa)) - - return IR.create_operation( - "llvm.intr.memcpy.inline", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_memcpy` - -""" -function intr_memcpy( - dst::Value, - src::Value, - len::Value; - isVolatile, - access_groups=nothing, - alias_scopes=nothing, - noalias_scopes=nothing, - tbaa=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[dst, src, len] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("isVolatile", isVolatile),] - !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(tbaa) && push!(_attributes, namedattribute("tbaa", tbaa)) - - return IR.create_operation( - "llvm.intr.memcpy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_memmove` - -""" -function intr_memmove( - dst::Value, - src::Value, - len::Value; - isVolatile, - access_groups=nothing, - alias_scopes=nothing, - noalias_scopes=nothing, - tbaa=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[dst, src, len] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("isVolatile", isVolatile),] - !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(tbaa) && push!(_attributes, namedattribute("tbaa", tbaa)) - - return IR.create_operation( - "llvm.intr.memmove", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_memset` - -""" -function intr_memset( - dst::Value, - val::Value, - len::Value; - isVolatile, - access_groups=nothing, - alias_scopes=nothing, - noalias_scopes=nothing, - tbaa=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[dst, val, len] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("isVolatile", isVolatile),] - !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(tbaa) && push!(_attributes, namedattribute("tbaa", tbaa)) - - return IR.create_operation( - "llvm.intr.memset", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_minnum` - -""" -function intr_minnum( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.minnum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_minimum` - -""" -function intr_minimum( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.minimum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_nearbyint` - -""" -function intr_nearbyint( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.nearbyint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_experimental_noalias_scope_decl` - -""" -function intr_experimental_noalias_scope_decl(; scope, location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("scope", scope),] - - return IR.create_operation( - "llvm.intr.experimental.noalias.scope.decl", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_powi` - -""" -function intr_powi( - val::Value, power::Value; res::IR.Type, fastmathFlags=nothing, location=Location() -) - _results = IR.Type[res,] - _operands = Value[val, power] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.powi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_pow` - -""" -function intr_pow( - a::Value, - b::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_prefetch` - -""" -function intr_prefetch(addr::Value; rw, hint, cache, location=Location()) - _results = IR.Type[] - _operands = Value[addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("rw", rw), - namedattribute("hint", hint), - namedattribute("cache", cache), - ] - - return IR.create_operation( - "llvm.intr.prefetch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_ptr_annotation` - -""" -function intr_ptr_annotation( - ptr::Value, - annotation::Value, - fileName::Value, - line::Value, - attr::Value; - res=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ptr, annotation, fileName, line, attr] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.ptr.annotation", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_rint` - -""" -function intr_rint( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.rint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_roundeven` - -""" -function intr_roundeven( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.roundeven", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_round` - -""" -function intr_round( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_sadd_sat` - -""" -function intr_sadd_sat( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.sadd.sat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.sadd.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_smax` - -""" -function intr_smax( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_smin` - -""" -function intr_smin( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.smul.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_ssa_copy` - -""" -function intr_ssa_copy( - operand::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.ssa.copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_sshl_sat` - -""" -function intr_sshl_sat( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.sshl.sat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_ssub_sat` - -""" -function intr_ssub_sat( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.ssub.sat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.ssub.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_sin` - -""" -function intr_sin( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_sqrt` - -""" -function intr_sqrt( - in::Value; - res=nothing::Union{Nothing,IR.Type}, - fastmathFlags=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_stackrestore` - -""" -function intr_stackrestore(ptr::Value; location=Location()) - _results = IR.Type[] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.stackrestore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_stacksave` - -""" -function intr_stacksave(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.stacksave", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_experimental_stepvector` - -""" -function intr_experimental_stepvector(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.experimental.stepvector", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_threadlocal_address` - -""" -function intr_threadlocal_address(global_::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[global_,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.threadlocal.address", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_trap` - -""" -function intr_trap(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.trap", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_uadd_sat` - -""" -function intr_uadd_sat( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.uadd.sat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.uadd.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_ubsantrap` - -""" -function intr_ubsantrap(; failureKind, location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("failureKind", failureKind),] - - return IR.create_operation( - "llvm.intr.ubsantrap", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_umax` - -""" -function intr_umax( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_umin` - -""" -function intr_umin( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.umul.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_ushl_sat` - -""" -function intr_ushl_sat( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.ushl.sat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_usub_sat` - -""" -function intr_usub_sat( - a::Value, b::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.usub.sat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.usub.with.overflow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_ashr` - -""" -function intr_vp_ashr( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.ashr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_add` - -""" -function intr_vp_add( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_and` - -""" -function intr_vp_and( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fadd` - -""" -function intr_vp_fadd( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fdiv` - -""" -function intr_vp_fdiv( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fmuladd` - -""" -function intr_vp_fmuladd( - op1::Value, - op2::Value, - op3::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[op1, op2, op3, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fmuladd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fmul` - -""" -function intr_vp_fmul( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fneg` - -""" -function intr_vp_fneg(op::Value, mask::Value, evl::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[op, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fneg", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fpext` - -""" -function intr_vp_fpext( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fpext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fptosi` - -""" -function intr_vp_fptosi( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fptosi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fptoui` - -""" -function intr_vp_fptoui( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fptoui", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fptrunc` - -""" -function intr_vp_fptrunc( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fptrunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_frem` - -""" -function intr_vp_frem( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.frem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fsub` - -""" -function intr_vp_fsub( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fsub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_fma` - -""" -function intr_vp_fma( - op1::Value, - op2::Value, - op3::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[op1, op2, op3, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_inttoptr` - -""" -function intr_vp_inttoptr( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.inttoptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_lshr` - -""" -function intr_vp_lshr( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.lshr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_load` - -""" -function intr_vp_load( - ptr::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[ptr, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_merge` - -""" -function intr_vp_merge( - cond::Value, - true_val::Value, - false_val::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[cond, true_val, false_val, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.merge", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_mul` - -""" -function intr_vp_mul( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_or` - -""" -function intr_vp_or( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_ptrtoint` - -""" -function intr_vp_ptrtoint( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.ptrtoint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_add` - -""" -function intr_vp_reduce_add( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_and` - -""" -function intr_vp_reduce_and( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fadd` - -""" -function intr_vp_reduce_fadd( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fmax` - -""" -function intr_vp_reduce_fmax( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fmin` - -""" -function intr_vp_reduce_fmin( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fmin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_fmul` - -""" -function intr_vp_reduce_fmul( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.fmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_mul` - -""" -function intr_vp_reduce_mul( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_or` - -""" -function intr_vp_reduce_or( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_smax` - -""" -function intr_vp_reduce_smax( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.smax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_smin` - -""" -function intr_vp_reduce_smin( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.smin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_umax` - -""" -function intr_vp_reduce_umax( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.umax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_umin` - -""" -function intr_vp_reduce_umin( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.umin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_reduce_xor` - -""" -function intr_vp_reduce_xor( - satrt_value::Value, - val::Value, - mask::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[satrt_value, val, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.reduce.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sdiv` - -""" -function intr_vp_sdiv( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sdiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sext` - -""" -function intr_vp_sext( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sitofp` - -""" -function intr_vp_sitofp( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_srem` - -""" -function intr_vp_srem( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.srem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_select` - -""" -function intr_vp_select( - cond::Value, - true_val::Value, - false_val::Value, - evl::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[cond, true_val, false_val, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_shl` - -""" -function intr_vp_shl( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.shl", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_store` - -""" -function intr_vp_store(val::Value, ptr::Value, mask::Value, evl::Value; location=Location()) - _results = IR.Type[] - _operands = Value[val, ptr, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_experimental_vp_strided_load` - -""" -function intr_experimental_vp_strided_load( - ptr::Value, stride::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[ptr, stride, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.experimental.vp.strided.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_experimental_vp_strided_store` - -""" -function intr_experimental_vp_strided_store( - val::Value, ptr::Value, stride::Value, mask::Value, evl::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[val, ptr, stride, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.experimental.vp.strided.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_sub` - -""" -function intr_vp_sub( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_trunc` - -""" -function intr_vp_trunc( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.trunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_udiv` - -""" -function intr_vp_udiv( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.udiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_uitofp` - -""" -function intr_vp_uitofp( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.uitofp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_urem` - -""" -function intr_vp_urem( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.urem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_xor` - -""" -function intr_vp_xor( - lhs::Value, rhs::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[lhs, rhs, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vp_zext` - -""" -function intr_vp_zext( - src::Value, mask::Value, evl::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[src, mask, evl] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vp.zext", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vacopy` - -""" -function intr_vacopy(dest_list::Value, src_list::Value; location=Location()) - _results = IR.Type[] - _operands = Value[dest_list, src_list] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vacopy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vaend` - -""" -function intr_vaend(arg_list::Value; location=Location()) - _results = IR.Type[] - _operands = Value[arg_list,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vaend", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vastart` - -""" -function intr_vastart(arg_list::Value; location=Location()) - _results = IR.Type[] - _operands = Value[arg_list,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vastart", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_var_annotation` - -""" -function intr_var_annotation( - val::Value, - annotation::Value, - fileName::Value, - line::Value, - attr::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[val, annotation, fileName, line, attr] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.var.annotation", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_masked_compressstore` - -""" -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.masked.compressstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.masked.expandload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "llvm.intr.masked.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_masked_scatter` - -""" -function intr_masked_scatter( - value::Value, ptrs::Value, mask::Value; alignment, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_extract` - -""" -function intr_vector_extract(srcvec::Value; res::IR.Type, pos, location=Location()) - _results = IR.Type[res,] - _operands = Value[srcvec,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pos", pos),] - - return IR.create_operation( - "llvm.intr.vector.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_insert` - -""" -function intr_vector_insert( - srcvec::Value, - dstvec::Value; - res=nothing::Union{Nothing,IR.Type}, - pos, - location=Location(), -) - _results = IR.Type[] - _operands = Value[srcvec, dstvec] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pos", pos),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "llvm.intr.vector.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`intr_vector_reduce_add` - -""" -function intr_vector_reduce_add(in::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_and` - -""" -function intr_vector_reduce_and(in::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fadd` - -""" -function intr_vector_reduce_fadd( - start_value::Value, input::Value; res::IR.Type, reassoc=nothing, location=Location() -) - _results = IR.Type[res,] - _operands = Value[start_value, input] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fmax` - -""" -function intr_vector_reduce_fmax( - in::Value; res::IR.Type, fastmathFlags=nothing, location=Location() -) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.vector.reduce.fmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fmaximum` - -""" -function intr_vector_reduce_fmaximum( - in::Value; res::IR.Type, fastmathFlags=nothing, location=Location() -) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.vector.reduce.fmaximum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fmin` - -""" -function intr_vector_reduce_fmin( - in::Value; res::IR.Type, fastmathFlags=nothing, location=Location() -) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.vector.reduce.fmin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fminimum` - -""" -function intr_vector_reduce_fminimum( - in::Value; res::IR.Type, fastmathFlags=nothing, location=Location() -) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(fastmathFlags) && - push!(_attributes, namedattribute("fastmathFlags", fastmathFlags)) - - return IR.create_operation( - "llvm.intr.vector.reduce.fminimum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_fmul` - -""" -function intr_vector_reduce_fmul( - start_value::Value, input::Value; res::IR.Type, reassoc=nothing, location=Location() -) - _results = IR.Type[res,] - _operands = Value[start_value, input] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_mul` - -""" -function intr_vector_reduce_mul(in::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_or` - -""" -function intr_vector_reduce_or(in::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_smax` - -""" -function intr_vector_reduce_smax(in::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.smax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_smin` - -""" -function intr_vector_reduce_smin(in::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.smin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_umax` - -""" -function intr_vector_reduce_umax(in::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.umax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_umin` - -""" -function intr_vector_reduce_umin(in::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.umin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vector_reduce_xor` - -""" -function intr_vector_reduce_xor(in::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[in,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vector.reduce.xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`intr_vscale` - -""" -function intr_vscale(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "llvm.intr.vscale", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType -import ..Dialects: namedattribute, operandsegmentsizes - -""" -`barrier0` - -""" -function barrier0(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.barrier0", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ntid_x` - -""" -function read_ptx_sreg_ntid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ntid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ntid_y` - -""" -function read_ptx_sreg_ntid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ntid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ntid_z` - -""" -function read_ptx_sreg_ntid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ntid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ctaid_x` - -""" -function read_ptx_sreg_ctaid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ctaid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ctaid_y` - -""" -function read_ptx_sreg_ctaid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ctaid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_ctaid_z` - -""" -function read_ptx_sreg_ctaid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.ctaid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`cp_async_bulk_tensor_shared_cluster_global` - -""" -function cp_async_bulk_tensor_shared_cluster_global( - dstMem::Value, - tmaDescriptor::Value, - mbar::Value, - coordinates::Vector{Value}; - location=Location(), -) - _results = IR.Type[] - _operands = Value[dstMem, tmaDescriptor, mbar, coordinates...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.cp.async.bulk.tensor.shared.cluster.global", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`cp_async_commit_group` - -""" -function cp_async_commit_group(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.cp.async.commit.group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`cp_async_shared_global` - -""" -function cp_async_shared_global( - dst::Value, - src::Value, - cpSize=nothing::Union{Nothing,Value}; - size, - modifier, - location=Location(), -) - _results = IR.Type[] - _operands = Value[dst, src] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("size", size), namedattribute("modifier", modifier) - ] - !isnothing(cpSize) && push!(_operands, cpSize) - - return IR.create_operation( - "nvvm.cp.async.shared.global", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`cp_async_wait_group` - -""" -function cp_async_wait_group(; n, location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("n", n),] - - return IR.create_operation( - "nvvm.cp.async.wait.group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_nctaid_x` - -""" -function read_ptx_sreg_nctaid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.nctaid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_nctaid_y` - -""" -function read_ptx_sreg_nctaid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.nctaid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_nctaid_z` - -""" -function read_ptx_sreg_nctaid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.nctaid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_laneid` - -""" -function read_ptx_sreg_laneid(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.laneid", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`ldmatrix` - -""" -function ldmatrix(ptr::Value; res::IR.Type, num, layout, location=Location()) - _results = IR.Type[res,] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("num", num), namedattribute("layout", layout) - ] - - return IR.create_operation( - "nvvm.ldmatrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_arrive_expect_tx` - -""" -function mbarrier_arrive_expect_tx(addr::Value, txcount::Value; location=Location()) - _results = IR.Type[] - _operands = Value[addr, txcount] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.arrive.expect_tx", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_arrive_expect_tx_shared` - -""" -function mbarrier_arrive_expect_tx_shared(addr::Value, txcount::Value; location=Location()) - _results = IR.Type[] - _operands = Value[addr, txcount] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.arrive.expect_tx.shared", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_arrive_nocomplete` - -""" -function mbarrier_arrive_nocomplete( - addr::Value, count::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[addr, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.arrive.nocomplete", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_arrive_nocomplete_shared` - -""" -function mbarrier_arrive_nocomplete_shared( - addr::Value, count::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[addr, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.arrive.nocomplete.shared", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_arrive` - -""" -function mbarrier_arrive(addr::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.arrive", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_arrive_shared` - -""" -function mbarrier_arrive_shared(addr::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.arrive.shared", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_init` - -""" -function mbarrier_init(addr::Value, count::Value; location=Location()) - _results = IR.Type[] - _operands = Value[addr, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.init", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_init_shared` - -""" -function mbarrier_init_shared(addr::Value, count::Value; location=Location()) - _results = IR.Type[] - _operands = Value[addr, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.init.shared", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_inval` - -""" -function mbarrier_inval(addr::Value; location=Location()) - _results = IR.Type[] - _operands = Value[addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.inval", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_inval_shared` - -""" -function mbarrier_inval_shared(addr::Value; location=Location()) - _results = IR.Type[] - _operands = Value[addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.inval.shared", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_test_wait` - -""" -function mbarrier_test_wait(addr::Value, state::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[addr, state] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.test.wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_test_wait_shared` - -""" -function mbarrier_test_wait_shared( - addr::Value, state::Value; res::IR.Type, location=Location() -) - _results = IR.Type[res,] - _operands = Value[addr, state] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.test.wait.shared", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_try_wait_parity` - -""" -function mbarrier_try_wait_parity( - addr::Value, phase::Value, ticks::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[addr, phase, ticks] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.try_wait.parity", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mbarrier_try_wait_parity_shared` - -""" -function mbarrier_try_wait_parity_shared( - addr::Value, phase::Value, ticks::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[addr, phase, ticks] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.mbarrier.try_wait.parity.shared", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mma_sync` - -The `nvvm.mma.sync` operation collectively performs the operation -`D = matmul(A, B) + C` using all threads in a warp. - -All the threads in the warp must execute the same `mma.sync` operation. - -For each possible multiplicand PTX data type, there are one or more possible -instruction shapes given as \"mMnNkK\". The below table describes the posssibilities -as well as the types required for the operands. Note that the data type for -C (the accumulator) and D (the result) can vary independently when there are -multiple possibilities in the \"C/D Type\" column. - -When an optional attribute cannot be immediately inferred from the types of -the operands and the result during parsing or validation, an error will be -raised. - -`b1Op` is only relevant when the binary (b1) type is given to -`multiplicandDataType`. It specifies how the multiply-and-acumulate is -performed and is either `xor_popc` or `and_poc`. The default is `xor_popc`. - -`intOverflowBehavior` is only relevant when the `multiplicandType` attribute -is one of `u8, s8, u4, s4`, this attribute describes how overflow is handled -in the accumulator. When the attribute is `satfinite`, the accumulator values -are clamped in the int32 range on overflow. This is the default behavior. -Alternatively, accumulator behavior `wrapped` can also be specified, in -which case overflow wraps from one end of the range to the other. - -`layoutA` and `layoutB` are required and should generally be set to -`#nvvm.mma_layout` and `#nvvm.mma_layout` respectively, but other -combinations are possible for certain layouts according to the table below. - -``` -| A/B Type | Shape | ALayout | BLayout | A Type | B Type | C/D Type | -|----------|-----------|---------|---------|----------|----------|-------------------| -| f64 | .m8n8k4 | row | col | 1x f64 | 1x f64 | 2x f64 | -| f16 | .m8n8k4 | row/col | row/col | 2x f16x2 | 2x f16x2 | 4x f16x2 or 8xf32 | -| | .m16n8k8 | row | col | 2x f16x2 | 1x f16x2 | 2x f16x2 or 4 f32 | -| | .m16n8k16 | row | col | 4x f16x2 | 2x f16x2 | 2x f16x2 or 4 f32 | -| bf16 | .m16n8k8 | row | col | 2x f16x2 | 1x f16x2 | 2x f16x2 or 4 f32 | -| | .m16n8k16 | row | col | 4x f16x2 | 2x f16x2 | 2x f16x2 or 4 f32 | -| tf32 | .m16n8k4 | row | col | 2x i32 | 1x i32 | 4x f32 | -| | .m16n8k8 | row | col | 4x i32 | 2x i32 | 2x f16x2 or 4 f32 | -| u8/s8 | .m8n8k16 | row | col | 1x i32 | 1x i32 | 2x i32 | -| | .m16n8k16 | row | col | 2x i32 | 1x i32 | 4x i32 | -| | .m16n8k32 | row | col | 4x i32 | 2x i32 | 4x i32 | -| u4/s4 | .m8n8k32 | row | col | 1x i32 | 1x i32 | 2x i32 | -| | m16n8k32 | row | col | 2x i32 | 1x i32 | 4x i32 | -| | m16n8k64 | row | col | 4x i32 | 2x i32 | 4x i32 | -| b1 | m8n8k128 | row | col | 1x i32 | 1x i32 | 2x i32 | -| | m16n8k128 | row | col | 2x i32 | 1x i32 | 4x i32 | -``` - - -# Example -```mlir - -%128 = nvvm.mma.sync A[%120, %121, %122, %123] - B[%124, %125] - C[%126, %127] - {layoutA = #nvvm.mma_layout, - layoutB = #nvvm.mma_layout, - shape = {k = 16 : i32, m = 16 : i32, n = 8 : i32}} - : (vector<2xf16>, vector<2xf16>, vector<2xf16>) - -> !llvm.struct<(vector<2xf16>, vector<2xf16>)> -``` -""" -function mma_sync( - operandA::Vector{Value}, - operandB::Vector{Value}, - operandC::Vector{Value}; - res::IR.Type, - shape, - b1Op=nothing, - intOverflowBehavior=nothing, - layoutA, - layoutB, - multiplicandAPtxType=nothing, - multiplicandBPtxType=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[operandA..., operandB..., operandC...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("shape", shape), - namedattribute("layoutA", layoutA), - namedattribute("layoutB", layoutB), - ] - push!( - _attributes, - operandsegmentsizes([length(operandA), length(operandB), length(operandC)]), - ) - !isnothing(b1Op) && push!(_attributes, namedattribute("b1Op", b1Op)) - !isnothing(intOverflowBehavior) && - push!(_attributes, namedattribute("intOverflowBehavior", intOverflowBehavior)) - !isnothing(multiplicandAPtxType) && - push!(_attributes, namedattribute("multiplicandAPtxType", multiplicandAPtxType)) - !isnothing(multiplicandBPtxType) && - push!(_attributes, namedattribute("multiplicandBPtxType", multiplicandBPtxType)) - - return IR.create_operation( - "nvvm.mma.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`rcp_approx_ftz_f` - -""" -function rcp_approx_ftz_f(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.rcp.approx.ftz.f", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`redux_sync` - -""" -function redux_sync( - val::Value, mask_and_clamp::Value; res::IR.Type, kind, location=Location() -) - _results = IR.Type[res,] - _operands = Value[val, mask_and_clamp] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - - return IR.create_operation( - "nvvm.redux.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`shfl_sync` - -""" -function shfl_sync( - dst::Value, - val::Value, - offset::Value, - mask_and_clamp::Value; - res::IR.Type, - kind, - return_value_and_is_valid=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[dst, val, offset, mask_and_clamp] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - !isnothing(return_value_and_is_valid) && push!( - _attributes, - namedattribute("return_value_and_is_valid", return_value_and_is_valid), - ) - - return IR.create_operation( - "nvvm.shfl.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`bar_warp_sync` - -""" -function bar_warp_sync(mask::Value; location=Location()) - _results = IR.Type[] - _operands = Value[mask,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.bar.warp.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_tid_x` - -""" -function read_ptx_sreg_tid_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.tid.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_tid_y` - -""" -function read_ptx_sreg_tid_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.tid.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_tid_z` - -""" -function read_ptx_sreg_tid_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.tid.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`vote_ballot_sync` - -""" -function vote_ballot_sync(mask::Value, pred::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[mask, pred] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.vote.ballot.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_load` - -""" -function wmma_load( - ptr::Value, - stride::Value; - res::IR.Type, - m, - n, - k, - layout, - eltype, - frag, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[ptr, stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("m", m), - namedattribute("n", n), - namedattribute("k", k), - namedattribute("layout", layout), - namedattribute("eltype", eltype), - namedattribute("frag", frag), - ] - - return IR.create_operation( - "nvvm.wmma.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_mma` - -""" -function wmma_mma( - args::Vector{Value}; - res::IR.Type, - m, - n, - k, - layoutA, - layoutB, - eltypeA, - eltypeB, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("m", m), - namedattribute("n", n), - namedattribute("k", k), - namedattribute("layoutA", layoutA), - namedattribute("layoutB", layoutB), - namedattribute("eltypeA", eltypeA), - namedattribute("eltypeB", eltypeB), - ] - - return IR.create_operation( - "nvvm.wmma.mma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_store` - -""" -function wmma_store( - ptr::Value, - args::Vector{Value}, - stride::Value; - m, - n, - k, - layout, - eltype, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ptr, args..., stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("m", m), - namedattribute("n", n), - namedattribute("k", k), - namedattribute("layout", layout), - namedattribute("eltype", eltype), - ] - - return IR.create_operation( - "nvvm.wmma.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`read_ptx_sreg_warpsize` - -""" -function read_ptx_sreg_warpsize(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.read.ptx.sreg.warpsize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wgmma_fence_aligned` - -Enforce an ordering of register accesses between warpgroup level matrix -multiplication and other operations. -See for more information: -https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#asynchronous-warpgroup-level-matrix-instructions-wgmma-fence -""" -function wgmma_fence_aligned(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.wgmma.fence.aligned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wgmma_commit_group_sync_aligned` - -Commits all prior uncommitted warpgroup level matrix multiplication operations. -See for more information: -https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#asynchronous-warpgroup-level-matrix-instructions-wgmma-commit-group -""" -function wgmma_commit_group_sync_aligned(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvvm.wgmma.commit.group.sync.aligned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wgmma_wait_group_sync_aligned` - -Signal the completion of a preceding warpgroup operation. -See for more information: -https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#asynchronous-warpgroup-level-matrix-instructions-wgmma-wait-group -""" -function wgmma_wait_group_sync_aligned(; group, location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("group", group),] - - return IR.create_operation( - "nvvm.wgmma.wait.group.sync.aligned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType -import ..Dialects: namedattribute, operandsegmentsizes - -""" -`barrier` - -""" -function barrier(; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.barrier", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_dim_x` - -""" -function workgroup_dim_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.dim.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_dim_y` - -""" -function workgroup_dim_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.dim.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_dim_z` - -""" -function workgroup_dim_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.dim.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_id_x` - -""" -function workgroup_id_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.id.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_id_y` - -""" -function workgroup_id_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.id.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workgroup_id_z` - -""" -function workgroup_id_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workgroup.id.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`grid_dim_x` - -""" -function grid_dim_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.grid.dim.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`grid_dim_y` - -""" -function grid_dim_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.grid.dim.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`grid_dim_z` - -""" -function grid_dim_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.grid.dim.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`buffer_load` - -""" -function buffer_load( - rsrc::Value, - vindex::Value, - offset::Value, - glc::Value, - slc::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[rsrc, vindex, offset, glc, slc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.buffer.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`buffer_store` - -""" -function buffer_store( - vdata::Value, - rsrc::Value, - vindex::Value, - offset::Value, - glc::Value, - slc::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, vindex, offset, glc, slc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.buffer.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_atomic_cmpswap` - -""" -function raw_buffer_atomic_cmpswap( - src::Value, - cmp::Value, - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[src, cmp, rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.atomic.cmpswap", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_atomic_fadd` - -""" -function raw_buffer_atomic_fadd( - vdata::Value, - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.atomic.fadd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_atomic_fmax` - -""" -function raw_buffer_atomic_fmax( - vdata::Value, - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.atomic.fmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_atomic_smax` - -""" -function raw_buffer_atomic_smax( - vdata::Value, - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.atomic.smax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_atomic_umin` - -""" -function raw_buffer_atomic_umin( - vdata::Value, - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.atomic.umin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_load` - -""" -function raw_buffer_load( - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - res::IR.Type, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`raw_buffer_store` - -""" -function raw_buffer_store( - vdata::Value, - rsrc::Value, - offset::Value, - soffset::Value, - aux::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[vdata, rsrc, offset, soffset, aux] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.raw.buffer.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workitem_id_x` - -""" -function workitem_id_x(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workitem.id.x", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workitem_id_y` - -""" -function workitem_id_y(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workitem.id.y", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`workitem_id_z` - -""" -function workitem_id_z(; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.workitem.id.z", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x1f32` - -""" -function mfma_f32_4x4x1f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x1f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x2bf16` - -""" -function mfma_f32_4x4x2bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x2bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x4bf16_1k` - -""" -function mfma_f32_4x4x4bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x4bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_4x4x4f16` - -""" -function mfma_f32_4x4x4f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.4x4x4f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x1f32` - -""" -function mfma_f32_16x16x1f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x1f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x2bf16` - -""" -function mfma_f32_16x16x2bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x2bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x4bf16_1k` - -""" -function mfma_f32_16x16x4bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x4bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x4f16` - -""" -function mfma_f32_16x16x4f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x4f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x4f32` - -""" -function mfma_f32_16x16x4f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x4f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x8_xf32` - -""" -function mfma_f32_16x16x8_xf32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x8.xf32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x8bf16` - -""" -function mfma_f32_16x16x8bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x8bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x16bf16_1k` - -""" -function mfma_f32_16x16x16bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x16bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x16f16` - -""" -function mfma_f32_16x16x16f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x16f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x32_bf8_bf8` - -""" -function mfma_f32_16x16x32_bf8_bf8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x32.bf8.bf8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x32_bf8_fp8` - -""" -function mfma_f32_16x16x32_bf8_fp8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x32.bf8.fp8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x32_fp8_bf8` - -""" -function mfma_f32_16x16x32_fp8_bf8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x32.fp8.bf8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_16x16x32_fp8_fp8` - -""" -function mfma_f32_16x16x32_fp8_fp8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.16x16x32.fp8.fp8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x1f32` - -""" -function mfma_f32_32x32x1f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x1f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x2bf16` - -""" -function mfma_f32_32x32x2bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x2bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x2f32` - -""" -function mfma_f32_32x32x2f32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x2f32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4_xf32` - -""" -function mfma_f32_32x32x4_xf32(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4.xf32", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4bf16` - -""" -function mfma_f32_32x32x4bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4bf16_1k` - -""" -function mfma_f32_32x32x4bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x4f16` - -""" -function mfma_f32_32x32x4f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x4f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x8bf16_1k` - -""" -function mfma_f32_32x32x8bf16_1k(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x8bf16.1k", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x8f16` - -""" -function mfma_f32_32x32x8f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x8f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x16_bf8_bf8` - -""" -function mfma_f32_32x32x16_bf8_bf8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x16.bf8.bf8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x16_bf8_fp8` - -""" -function mfma_f32_32x32x16_bf8_fp8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x16.bf8.fp8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x16_fp8_bf8` - -""" -function mfma_f32_32x32x16_fp8_bf8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x16.fp8.bf8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f32_32x32x16_fp8_fp8` - -""" -function mfma_f32_32x32x16_fp8_fp8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f32.32x32x16.fp8.fp8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f64_4x4x4f64` - -""" -function mfma_f64_4x4x4f64(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f64.4x4x4f64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_f64_16x16x4f64` - -""" -function mfma_f64_16x16x4f64(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.f64.16x16x4f64", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_4x4x4i8` - -""" -function mfma_i32_4x4x4i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.4x4x4i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_16x16x4i8` - -""" -function mfma_i32_16x16x4i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.16x16x4i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_16x16x16i8` - -""" -function mfma_i32_16x16x16i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.16x16x16i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_16x16x32_i8` - -""" -function mfma_i32_16x16x32_i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.16x16x32.i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_32x32x4i8` - -""" -function mfma_i32_32x32x4i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.32x32x4i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_32x32x8i8` - -""" -function mfma_i32_32x32x8i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.32x32x8i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`mfma_i32_32x32x16_i8` - -""" -function mfma_i32_32x32x16_i8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.mfma.i32.32x32x16.i8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_bf16_16x16x16_bf16` - -""" -function wmma_bf16_16x16x16_bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.wmma.bf16.16x16x16.bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_f16_16x16x16_f16` - -""" -function wmma_f16_16x16x16_f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.wmma.f16.16x16x16.f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_f32_16x16x16_bf16` - -""" -function wmma_f32_16x16x16_bf16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.wmma.f32.16x16x16.bf16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_f32_16x16x16_f16` - -""" -function wmma_f32_16x16x16_f16(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.wmma.f32.16x16x16.f16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_i32_16x16x16_iu4` - -""" -function wmma_i32_16x16x16_iu4(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.wmma.i32.16x16x16.iu4", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -""" -`wmma_i32_16x16x16_iu8` - -""" -function wmma_i32_16x16x16_iu8(args::Vector{Value}; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "rocdl.wmma.i32.16x16x16.iu8", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function zext(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "llvm.zext", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Linalg.jl b/src/Dialects/17/Linalg.jl index 03e1008d..f26d6310 100644 --- a/src/Dialects/17/Linalg.jl +++ b/src/Dialects/17/Linalg.jl @@ -1,7 +1,6 @@ module linalg -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -81,24 +80,18 @@ of the transformation calling the tiling to ensure that the provided sizes for each dimension make sense with respect to the semantic of softmax. """ -function softmax( - input::Value, output::Value; result::Vector{IR.Type}, dimension, location=Location() -) - _results = IR.Type[result...,] - _operands = Value[input, output] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dimension", dimension),] - - return IR.create_operation( - "linalg.softmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function softmax(input, output; result::Vector{IR.Type}, dimension, location=Location()) + results = IR.Type[result..., ] + operands = Value[value(input), value(output), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), ] + + IR.create_operation( + "linalg.softmax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -115,27 +108,22 @@ in `linalg` generic ops. It returns values to the immediately enclosing linalg.yield %f0, %f1 : f32, f32 ``` """ -function yield(values::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[values...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "linalg.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(values; location=Location()) + results = IR.Type[] + operands = Value[value.(values)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "linalg.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -143,29 +131,19 @@ import ..Dialects: namedattribute, operandsegmentsizes No numeric casting is performed on the input operand. """ -function abs( - 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.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function abs(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.abs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -180,29 +158,19 @@ passes can take that into account when lowering this code. For example, a `linalg.broadcast` + `linalg.add` sequence can be lowered to a `linalg.generic` with different affine maps for the two operands. """ -function add( - 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.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function add(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.add", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -212,29 +180,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_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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -246,29 +204,19 @@ has its non-batch dimensions transposed. Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. """ -function batch_matmul_transpose_a( - 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_transpose_a", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_matmul_transpose_a(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matmul_transpose_a", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -280,29 +228,19 @@ has its non-batch dimensions transposed. Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. """ -function batch_matmul_transpose_b( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{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_transpose_b", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_matmul_transpose_b(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matmul_transpose_b", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -312,29 +250,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.batch_matvec", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_matvec(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -346,29 +274,19 @@ The partial multiplication results are reduced into a 2D output. Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. """ -function batch_reduce_matmul( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{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_reduce_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function batch_reduce_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.batch_reduce_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -385,29 +303,18 @@ Broadcast the input into the given shape by adding `dimensions`. dimensions = [1] ``` """ -function broadcast( - input::Value, - init::Value; - result::Vector{IR.Type}, - dimensions, - region::Region, - location=Location(), -) - _results = IR.Type[result...,] - _operands = Value[input, init] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dimensions", dimensions),] - - return IR.create_operation( - "linalg.broadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function broadcast(input, init; result::Vector{IR.Type}, dimensions, region::Region, location=Location()) + results = IR.Type[result..., ] + operands = Value[value(input), value(init), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimensions", dimensions), ] + + IR.create_operation( + "linalg.broadcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -416,29 +323,19 @@ end No numeric casting is performed on the input operand. """ -function ceil( - 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.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ceil(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.ceil", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -452,33 +349,21 @@ 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_1d_ncw_fcw( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_1d_ncw_fcw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_1d_ncw_fcw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_1d_ncw_fcw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -488,33 +373,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_1d_nwc_wcf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_1d_nwc_wcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_1d_nwc_wcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -524,29 +397,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_1d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_1d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_1d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -560,33 +423,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nchw_fchw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nchw_fchw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nchw_fchw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -600,33 +451,21 @@ 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_ngchw_fgchw( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_ngchw_fgchw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_ngchw_fgchw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_ngchw_fgchw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -640,33 +479,21 @@ 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_fhwc( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nhwc_fhwc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nhwc_fhwc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nhwc_fhwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -680,33 +507,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nhwc_hwcf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nhwc_hwcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nhwc_hwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -721,33 +536,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_2d_nhwc_hwcf_q", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d_nhwc_hwcf_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_2d_nhwc_hwcf_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -757,29 +560,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_2d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -789,33 +582,21 @@ 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_ncdhw_fcdhw( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_3d_ncdhw_fcdhw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_3d_ncdhw_fcdhw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_3d_ncdhw_fcdhw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -825,33 +606,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_3d_ndhwc_dhwcf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_3d_ndhwc_dhwcf(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_3d_ndhwc_dhwcf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -862,33 +631,21 @@ Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. This includes the zero point offsets common to quantized operations. """ -function conv_3d_ndhwc_dhwcf_q( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.conv_3d_ndhwc_dhwcf_q", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_3d_ndhwc_dhwcf_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.conv_3d_ndhwc_dhwcf_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -898,29 +655,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.conv_3d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv_3d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.conv_3d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -930,31 +677,20 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function copy( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - cast=nothing, - 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)])) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function copy(inputs, outputs; result_tensors::Vector{IR.Type}, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.copy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -965,33 +701,21 @@ 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_ncw_cw( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_1d_ncw_cw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_1d_ncw_cw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_1d_ncw_cw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1002,33 +726,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_1d_nwc_wc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_1d_nwc_wc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_1d_nwc_wc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1038,33 +750,21 @@ 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_1d_nwc_wcm( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_1d_nwc_wcm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_1d_nwc_wcm(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_1d_nwc_wcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1075,33 +775,21 @@ Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions. """ -function depthwise_conv_2d_nchw_chw( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nchw_chw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nchw_chw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nchw_chw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1112,33 +800,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1148,33 +824,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwc_q", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwc_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwc_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1184,33 +848,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwcm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwcm(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1220,33 +872,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_2d_nhwc_hwcm_q", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_2d_nhwc_hwcm_q(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_2d_nhwc_hwcm_q", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1257,33 +897,21 @@ Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions. """ -function depthwise_conv_3d_ncdhw_cdhw( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_3d_ncdhw_cdhw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_3d_ncdhw_cdhw(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_3d_ncdhw_cdhw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1294,33 +922,21 @@ Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. Multiplier is set to 1 which is a special case for most depthwise convolutions. """ -function depthwise_conv_3d_ndhwc_dhwc( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_3d_ndhwc_dhwc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_3d_ndhwc_dhwc(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_3d_ndhwc_dhwc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1330,33 +946,21 @@ 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_3d_ndhwc_dhwcm( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.depthwise_conv_3d_ndhwc_dhwcm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv_3d_ndhwc_dhwcm(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.depthwise_conv_3d_ndhwc_dhwcm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1373,29 +977,19 @@ passes can take that into account when lowering this code. For example, a `linalg.broadcast` + `linalg.div` sequence can be lowered to a `linalg.generic` with different affine maps for the two operands. """ -function div( - 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.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function div(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.div", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1412,29 +1006,19 @@ passes can take that into account when lowering this code. For example, a `linalg.broadcast` + `linalg.div` sequence can be lowered to a `linalg.generic` with different affine maps for the two operands. """ -function div_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.div_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function div_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.div_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1444,29 +1028,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.dot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dot(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.dot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1476,33 +1050,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function elemwise_binary( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - fun=nothing, - cast=nothing, - 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)])) - !isnothing(fun) && push!(_attributes, namedattribute("fun", fun)) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.elemwise_binary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function elemwise_binary(inputs, outputs; result_tensors::Vector{IR.Type}, fun=nothing, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(fun) && push!(attributes, namedattribute("fun", fun)) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.elemwise_binary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1512,33 +1074,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function elemwise_unary( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - fun=nothing, - cast=nothing, - 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)])) - !isnothing(fun) && push!(_attributes, namedattribute("fun", fun)) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.elemwise_unary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function elemwise_unary(inputs, outputs; result_tensors::Vector{IR.Type}, fun=nothing, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(fun) && push!(attributes, namedattribute("fun", fun)) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.elemwise_unary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1547,29 +1097,19 @@ end No numeric casting is performed on the input operand. """ -function exp( - 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.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function exp(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.exp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1580,29 +1120,19 @@ Works for arbitrary ranked output tensors since the operation performs scalar accesses only and is thus rank polymorphic. Numeric casting is performed on the value operand, promoting it to the same data type as the output. """ -function fill( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{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", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fill(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.fill", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1617,29 +1147,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.fill_rng_2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fill_rng_2d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -1648,29 +1168,19 @@ end No numeric casting is performed on the input operand. """ -function floor( - 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.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function floor(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.floor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1773,39 +1283,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,] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("indexing_maps", indexing_maps), - namedattribute("iterator_types", iterator_types), - ] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - !isnothing(doc) && push!(_attributes, namedattribute("doc", doc)) - !isnothing(library_call) && - push!(_attributes, namedattribute("library_call", library_call)) - - return IR.create_operation( - "linalg.generic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generic(inputs, outputs; 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[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(doc) && push!(attributes, namedattribute("doc", doc)) + !isnothing(library_call) && push!(attributes, namedattribute("library_call", library_call)) + + IR.create_operation( + "linalg.generic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1814,29 +1306,19 @@ end No numeric casting is performed on the input operand. """ -function log( - 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.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function log(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.log", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1867,28 +1349,18 @@ The example above will be printed as: outs(%init: tensor<64xf32>) ``` """ -function map( - inputs::Vector{Value}, - init::Value; - result::Vector{IR.Type}, - mapper::Region, - location=Location(), -) - _results = IR.Type[result...,] - _operands = Value[inputs..., init] - _owned_regions = Region[mapper,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "linalg.map", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function map(inputs, init; result::Vector{IR.Type}, mapper::Region, location=Location()) + results = IR.Type[result..., ] + operands = Value[value.(inputs)..., value(init), ] + owned_regions = Region[mapper, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "linalg.map", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1898,31 +1370,20 @@ 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}, - cast=nothing, - 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)])) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul(inputs, outputs; result_tensors::Vector{IR.Type}, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1934,31 +1395,20 @@ transposed. Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. """ -function matmul_transpose_a( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - cast=nothing, - 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)])) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.matmul_transpose_a", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul_transpose_a(inputs, outputs; result_tensors::Vector{IR.Type}, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.matmul_transpose_a", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1970,31 +1420,20 @@ transposed. Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. """ -function matmul_transpose_b( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - cast=nothing, - 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)])) - !isnothing(cast) && push!(_attributes, namedattribute("cast", cast)) - - return IR.create_operation( - "linalg.matmul_transpose_b", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul_transpose_b(inputs, outputs; result_tensors::Vector{IR.Type}, cast=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(cast) && push!(attributes, namedattribute("cast", cast)) + + IR.create_operation( + "linalg.matmul_transpose_b", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2004,29 +1443,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matmul_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matmul_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2036,29 +1465,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.matvec", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matvec(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.matvec", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2073,29 +1492,19 @@ passes can take that into account when lowering this code. For example, a `linalg.broadcast` + `linalg.div` sequence can be lowered to a `linalg.generic` with different affine maps for the two operands. """ -function max( - 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.max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function max(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2110,29 +1519,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.mmt4d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mmt4d(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.mmt4d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2147,29 +1546,19 @@ passes can take that into account when lowering this code. For example, a `linalg.broadcast` + `linalg.mul` sequence can be lowered to a `linalg.generic` with different affine maps for the two operands. """ -function mul( - 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.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.mul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2178,29 +1567,19 @@ end No numeric casting is performed on the input operand. """ -function negf( - 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.negf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function negf(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.negf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2210,33 +1589,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nchw_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nchw_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nchw_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2250,33 +1617,21 @@ Layout: Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nchw_sum( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nchw_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nchw_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nchw_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2286,33 +1641,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_ncw_max( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ncw_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ncw_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ncw_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2326,33 +1669,21 @@ Layout: Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_ncw_sum( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ncw_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ncw_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ncw_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2362,33 +1693,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ndhwc_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ndhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2398,33 +1717,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ndhwc_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_min(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ndhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2434,33 +1741,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_ndhwc_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_ndhwc_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_ndhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2470,33 +1765,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2506,33 +1789,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_max_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_max_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_max_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2542,33 +1813,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_min(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2578,33 +1837,21 @@ 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_min_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_min_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_min_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2618,33 +1865,21 @@ Layout: 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=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nhwc_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nhwc_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nhwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2654,33 +1889,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nwc_max( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nwc_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nwc_max(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nwc_max", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2690,33 +1913,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nwc_max_unsigned( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nwc_max_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nwc_max_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nwc_max_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2726,33 +1937,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nwc_min( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nwc_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nwc_min(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nwc_min", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2762,33 +1961,21 @@ end Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nwc_min_unsigned( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nwc_min_unsigned", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nwc_min_unsigned(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nwc_min_unsigned", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2802,33 +1989,21 @@ Layout: Numeric casting is performed on the input operand, promoting it to the same data type as the accumulator/output. """ -function pooling_nwc_sum( - inputs::Vector{Value}, - outputs::Vector{Value}; - result_tensors::Vector{IR.Type}, - strides=nothing, - dilations=nothing, - 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)])) - !isnothing(strides) && push!(_attributes, namedattribute("strides", strides)) - !isnothing(dilations) && push!(_attributes, namedattribute("dilations", dilations)) - - return IR.create_operation( - "linalg.pooling_nwc_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pooling_nwc_sum(inputs, outputs; result_tensors::Vector{IR.Type}, strides=nothing, dilations=nothing, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + !isnothing(strides) && push!(attributes, namedattribute("strides", strides)) + !isnothing(dilations) && push!(attributes, namedattribute("dilations", dilations)) + + IR.create_operation( + "linalg.pooling_nwc_sum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2840,29 +2015,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.quantized_batch_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function quantized_batch_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -2874,29 +2039,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.quantized_matmul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function quantized_matmul(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.quantized_matmul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2931,29 +2086,18 @@ The example above will be printed as: dimensions = [1] ``` """ -function reduce( - inputs::Vector{Value}, - inits::Vector{Value}; - result_0::Vector{IR.Type}, - dimensions, - combiner::Region, - location=Location(), -) - _results = IR.Type[result_0...,] - _operands = Value[inputs..., inits...] - _owned_regions = Region[combiner,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dimensions", dimensions),] - - return IR.create_operation( - "linalg.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce(inputs, inits; result_0::Vector{IR.Type}, dimensions, combiner::Region, location=Location()) + results = IR.Type[result_0..., ] + operands = Value[value.(inputs)..., value.(inits)..., ] + owned_regions = Region[combiner, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimensions", dimensions), ] + + IR.create_operation( + "linalg.reduce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2968,29 +2112,19 @@ passes can take that into account when lowering this code. For example, a `linalg.broadcast` + `linalg.sub` sequence can be lowered to a `linalg.generic` with different affine maps for the two operands. """ -function sub( - 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.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sub(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.sub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3011,29 +2145,18 @@ operation only that produces a transposed \"view\". permutation = [1, 0] ``` """ -function transpose( - input::Value, - init::Value; - result::Vector{IR.Type}, - permutation, - region::Region, - location=Location(), -) - _results = IR.Type[result...,] - _operands = Value[input, init] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("permutation", permutation),] - - return IR.create_operation( - "linalg.transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(input, init; result::Vector{IR.Type}, permutation, region::Region, location=Location()) + results = IR.Type[result..., ] + operands = Value[value(input), value(init), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation", permutation), ] + + IR.create_operation( + "linalg.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3043,29 +2166,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(inputs), length(outputs)])) - - return IR.create_operation( - "linalg.vecmat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function vecmat(inputs, outputs; result_tensors::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result_tensors..., ] + operands = Value[value.(inputs)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(inputs), length(outputs), ])) + + IR.create_operation( + "linalg.vecmat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/MLProgram.jl b/src/Dialects/17/MLProgram.jl index 877a3cde..a261f33d 100644 --- a/src/Dialects/17/MLProgram.jl +++ b/src/Dialects/17/MLProgram.jl @@ -1,7 +1,6 @@ module ml_program -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -110,28 +109,18 @@ without additional consideration to evaluation order constraints. ordering (%token -> !ml_program.token) : tensor ``` """ -function global_load_graph( - consumeTokens::Vector{Value}; - result::IR.Type, - produceToken::IR.Type, - global_, - location=Location(), -) - _results = IR.Type[result, produceToken] - _operands = Value[consumeTokens...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("global", global_),] - - return IR.create_operation( - "ml_program.global_load_graph", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function global_load_graph(consumeTokens; result::IR.Type, produceToken::IR.Type, global_, location=Location()) + results = IR.Type[result, produceToken, ] + operands = Value[value.(consumeTokens)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] + + IR.create_operation( + "ml_program.global_load_graph", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -256,28 +245,18 @@ without additional consideration to evaluation order constraints. ordering (%in_token -> !ml_program.token) : tensor ``` """ -function global_store_graph( - value::Value, - consumeTokens::Vector{Value}; - produceToken::IR.Type, - global_, - location=Location(), -) - _results = IR.Type[produceToken,] - _operands = Value[value, consumeTokens...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("global", global_),] - - return IR.create_operation( - "ml_program.global_store_graph", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function global_store_graph(value, consumeTokens; produceToken::IR.Type, global_, location=Location()) + results = IR.Type[produceToken, ] + operands = Value[value(value), value.(consumeTokens)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] + + IR.create_operation( + "ml_program.global_store_graph", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -301,22 +280,18 @@ without additional consideration to evaluation order constraints. See ml_program.global_store @foobar = %0 : tensor ``` """ -function global_store(value::Value; global_, location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("global", global_),] - - return IR.create_operation( - "ml_program.global_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function global_store(value; global_, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("global", global_), ] + + IR.create_operation( + "ml_program.global_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -329,22 +304,18 @@ The operation takes variable number of operands and produces no results. The operand number and types must match the signature of the function that contains the operation. """ -function output(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "ml_program.output", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function output(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "ml_program.output", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -357,22 +328,18 @@ The operation takes variable number of operands and produces no results. The operand number and types must match the signature of the function that contains the operation. """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "ml_program.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "ml_program.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Math.jl b/src/Dialects/17/Math.jl index b1c6b5e9..a4b71cfb 100644 --- a/src/Dialects/17/Math.jl +++ b/src/Dialects/17/Math.jl @@ -1,7 +1,6 @@ module math -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,29 +17,20 @@ of the same type. %a = math.absf %b : f64 ``` """ -function absf( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.absf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function absf(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.absf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -58,23 +48,19 @@ same type. %a = math.absi %b : i64 ``` """ -function absi(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.absi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function absi(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.absi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -105,30 +91,20 @@ See also https://en.wikipedia.org/wiki/Atan2 %a = math.atan2 %b, %c : f32 ``` """ -function atan2( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.atan2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atan2(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.atan2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -152,29 +128,20 @@ one result of the same type. It has no standard attributes. %a = math.atan %b : f64 ``` """ -function atan( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.atan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atan(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.atan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -194,29 +161,20 @@ of the same type. It has no standard attributes. Note: This op is not equivalent to powf(..., 1/3.0). """ -function cbrt( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.cbrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cbrt(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.cbrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -240,29 +198,20 @@ result of the same type. It has no standard attributes. %a = math.ceil %b : f64 ``` """ -function ceil( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ceil(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.ceil", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -287,30 +236,20 @@ tensor or vector). It has no standard attributes. %a = math.copysign %b, %c : f64 ``` """ -function copysign( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.copysign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function copysign(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.copysign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -334,29 +273,20 @@ result of the same type. It has no standard attributes. %a = math.cos %b : f64 ``` """ -function cos( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cos(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -373,23 +303,19 @@ It operates on scalar, tensor or vector. %a = math.ctlz %b : i32 ``` """ -function ctlz(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ctlz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ctlz(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ctlz", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -406,23 +332,19 @@ It operates on scalar, tensor or vector. %a = math.cttz %b : i32 ``` """ -function cttz(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.cttz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cttz(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.cttz", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -439,23 +361,19 @@ It operates on scalar, tensor or vector. %a = math.ctpop %b : i32 ``` """ -function ctpop(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ctpop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ctpop(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ctpop", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -479,29 +397,20 @@ the same type. It has no standard attributes. %a = math.erf %b : f64 ``` """ -function erf( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.erf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function erf(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.erf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -525,29 +434,20 @@ attributes. %a = math.exp2 %b : f64 ``` """ -function exp2( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.exp2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp2(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.exp2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -573,29 +473,20 @@ standard attributes. %a = math.expm1 %b : f64 ``` """ -function expm1( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.expm1", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function expm1(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.expm1", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -619,29 +510,20 @@ attributes. %a = math.exp %b : f64 ``` """ -function exp( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function exp(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -677,30 +559,20 @@ The result is a vector of: %a = math.fpowi %base, %power : f64, i32 ``` """ -function fpowi( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.fpowi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fpowi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.fpowi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -724,29 +596,20 @@ result of the same type. It has no standard attributes. %a = math.floor %b : f64 ``` """ -function floor( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function floor(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.floor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -775,31 +638,20 @@ 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}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fma(a, b, c; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.fma", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -823,25 +675,50 @@ must have the same type. %a = math.ipowi %b, %c : i32 ``` """ -function ipowi( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "math.ipowi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ipowi(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "math.ipowi", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) + ) +end + +""" +`log10` + +Computes the base-10 logarithm of the given value. It takes one operand of +floating point type (i.e., scalar, tensor or vector) and returns one result of +the same type. + +# Example + +```mlir +// Scalar log10 operation. +%y = math.log10 %x : f64 +``` +""" +function log10(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.log10", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -861,29 +738,20 @@ log1p(x) := log(1 + x) %y = math.log1p %x : f64 ``` """ -function log1p( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.log1p", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log1p(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.log1p", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -901,69 +769,20 @@ the same type. %y = math.log2 %x : f64 ``` """ -function log2( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.log2", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), - ) -end - -""" -`log10` - -Computes the base-10 logarithm of the given value. It takes one operand of -floating point type (i.e., scalar, tensor or vector) and returns one result of -the same type. - -# Example - -```mlir -// Scalar log10 operation. -%y = math.log10 %x : f64 -``` -""" -function log10( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.log10", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log2(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.log2", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -981,29 +800,20 @@ the same type. %y = math.log %x : f64 ``` """ -function log( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function log(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1027,30 +837,20 @@ must have the same type. %a = math.powf %b, %c : f64 ``` """ -function powf( - lhs::Value, - rhs::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.powf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function powf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.powf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1077,29 +877,20 @@ rounding direction. %a = math.roundeven %b : f64 ``` """ -function roundeven( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.roundeven", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function roundeven(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.roundeven", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1126,29 +917,20 @@ rounding direction. %a = math.round %b : f64 ``` """ -function round( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function round(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.round", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1166,29 +948,20 @@ one result of the same type. It has no standard attributes. %a = math.rsqrt %b : f64 ``` """ -function rsqrt( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rsqrt(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.rsqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1212,29 +985,20 @@ result of the same type. It has no standard attributes. %a = math.sin %b : f64 ``` """ -function sin( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sin(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1252,29 +1016,20 @@ the same type. It has no standard attributes. %a = math.sqrt %b : f64 ``` """ -function sqrt( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function sqrt(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1292,29 +1047,20 @@ result of the same type. It has no standard attributes. %a = math.tan %b : f64 ``` """ -function tan( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.tan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tan(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.tan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1332,29 +1078,20 @@ result of the same type. It has no standard attributes. %a = math.tanh %b : f64 ``` """ -function tanh( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function tanh(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1380,29 +1117,20 @@ than the operand, regardless of the current rounding direction. %a = math.trunc %b : f64 ``` """ -function trunc( - operand::Value; - result=nothing::Union{Nothing,IR.Type}, - fastmath=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(fastmath) && push!(_attributes, namedattribute("fastmath", fastmath)) - - return IR.create_operation( - "math.trunc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function trunc(operand; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(fastmath) && push!(attributes, namedattribute("fastmath", fastmath)) + + IR.create_operation( + "math.trunc", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end diff --git a/src/Dialects/17/MemRef.jl b/src/Dialects/17/MemRef.jl index f10cbaaa..2f82dc50 100644 --- a/src/Dialects/17/MemRef.jl +++ b/src/Dialects/17/MemRef.jl @@ -1,7 +1,6 @@ module memref -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -14,22 +13,18 @@ the buffer isn\'t aligned to the given alignment, the behavior is undefined. This operation doesn\'t affect the semantics of a correct program. It\'s for optimization only, and the optimization is best-effort. """ -function assume_alignment(memref::Value; alignment, location=Location()) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("alignment", alignment),] - - return IR.create_operation( - "memref.assume_alignment", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assume_alignment(memref; alignment, location=Location()) + results = IR.Type[] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("alignment", alignment), ] + + IR.create_operation( + "memref.assume_alignment", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -50,30 +45,19 @@ 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=nothing::Union{Nothing,IR.Type}, - kind, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "memref.atomic_rmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function atomic_rmw(value, memref, indices; result=nothing::Union{Nothing, IR.Type}, kind, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "memref.atomic_rmw", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -83,22 +67,18 @@ end \"memref.atomic_yield\" yields an SSA value from a GenericAtomicRMWOp region. """ -function atomic_yield(result::Value; location=Location()) - _results = IR.Type[] - _operands = Value[result,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.atomic_yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_yield(result; location=Location()) + results = IR.Type[] + operands = Value[value(result), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.atomic_yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -116,22 +96,18 @@ memref.copy %arg0, %arg1 : memref to memref Source and destination are expected to have the same element type and shape. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function copy(source, target; location=Location()) + results = IR.Type[] + operands = Value[value(source), value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.copy", location; + operands, owned_regions, successors, attributes, + results=results, + 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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.generic_atomic_rmw", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generic_atomic_rmw(memref, indices; result::IR.Type, atomic_body::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[atomic_body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.generic_atomic_rmw", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -222,31 +188,19 @@ techniques. This is possible because of the [restrictions on dimensions and symbols](Affine.md/#restrictions-on-dimensions-and-symbols) in these contexts. """ -function load( - memref::Value, - indices::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - nontemporal=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(nontemporal) && - push!(_attributes, namedattribute("nontemporal", nontemporal)) - - return IR.create_operation( - "memref.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function load(memref, indices; result::IR.Type, nontemporal=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) + + IR.create_operation( + "memref.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -291,30 +245,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands)])) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.alloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloc(dynamicSizes, symbolOperands; memref::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "memref.alloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -355,30 +299,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - push!(_attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands)])) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.alloca", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca(dynamicSizes, symbolOperands; memref::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[memref, ] + operands = Value[value.(dynamicSizes)..., value.(symbolOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(dynamicSizes), length(symbolOperands), ])) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "memref.alloca", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -447,22 +381,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()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.alloca_scope.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alloca_scope_return(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.alloca_scope.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -522,22 +452,18 @@ Erase rank information. %5 = memref.cast %1 : memref<4x?xf32> to memref<*xf32> ``` """ -function cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -584,22 +510,18 @@ only if the corresponding start dimension in the source type is dynamic. Note: This op currently assumes that the inner strides are of the source/result layout map are the faster-varying ones. """ -function collapse_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function collapse_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "memref.collapse_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -618,22 +540,18 @@ alloc\'d memref (e.g. memrefs returned by `view` operations). memref.dealloc %0 : memref<8x64xf32, affine_map<(d0, d1) -> (d0, d1), 1>> ``` """ -function dealloc(memref::Value; location=Location()) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dealloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dealloc(memref; location=Location()) + results = IR.Type[] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dealloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -662,25 +580,19 @@ The specified memref type is that of the first operand. %y = \"memref.dim\"(%A, %c1) : (memref<4 x ? x f32>, index) -> index ``` """ -function dim( - source::Value, index::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[source, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "memref.dim", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function dim(source, index; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "memref.dim", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -731,22 +643,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dma_start", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dma_start(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dma_start", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -770,24 +678,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() -) - _results = IR.Type[] - _operands = Value[tagMemRef, tagIndices..., numElements] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.dma_wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dma_wait(tagMemRef, tagIndices, numElements; location=Location()) + results = IR.Type[] + operands = Value[value(tagMemRef), value.(tagIndices)..., value(numElements), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.dma_wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -833,22 +735,18 @@ group. Same for strides. Note: This op currently assumes that the inner strides are of the source/result layout map are the faster-varying ones. """ -function expand_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "memref.expand_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -874,25 +772,19 @@ as a pointer is explicitly discouraged. call @foo(%2) : (!llvm.ptr) ->() ``` """ -function extract_aligned_pointer_as_index( - source::Value; aligned_pointer=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(aligned_pointer) && push!(_results, aligned_pointer) - - return IR.create_operation( - "memref.extract_aligned_pointer_as_index", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extract_aligned_pointer_as_index(source; aligned_pointer=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(aligned_pointer) && push!(results, aligned_pointer) + + IR.create_operation( + "memref.extract_aligned_pointer_as_index", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -940,33 +832,22 @@ This makes lowering more progressive and brings the following benefits: : memref to memref ``` """ -function extract_strided_metadata( - source::Value; - base_buffer=nothing::Union{Nothing,IR.Type}, - offset=nothing::Union{Nothing,IR.Type}, - sizes=nothing::Union{Nothing,Vector{IR.Type}}, - strides=nothing::Union{Nothing,Vector{IR.Type}}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(base_buffer) && push!(_results, base_buffer) - !isnothing(offset) && push!(_results, offset) - !isnothing(sizes) && push!(_results, sizes...) - !isnothing(strides) && push!(_results, strides...) - - return IR.create_operation( - "memref.extract_strided_metadata", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extract_strided_metadata(source; base_buffer=nothing::Union{Nothing, IR.Type}, offset=nothing::Union{Nothing, IR.Type}, sizes=nothing::Union{Nothing, Vector{IR.Type}}, strides=nothing::Union{Nothing, Vector{IR.Type}}, location=Location()) + results = IR.Type[] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(base_buffer) && push!(results, base_buffer) + !isnothing(offset) && push!(results, offset) + !isnothing(sizes) && push!(results, sizes...) + !isnothing(strides) && push!(results, strides...) + + IR.create_operation( + "memref.extract_strided_metadata", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1101,22 +982,18 @@ If the source and target address spaces are the same, this operation is a noop. : memref<*xmemref, 5> to memref<*xmemref, 3> ``` """ -function memory_space_cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.memory_space_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function memory_space_cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.memory_space_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1138,33 +1015,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function prefetch(memref, indices; isWrite, localityHint, isDataCache, location=Location()) + results = IR.Type[] + operands = Value[value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1180,23 +1042,19 @@ The `memref.rank` operation takes a memref operand and returns its rank. %1 = memref.rank %arg1 : memref ``` """ -function rank(memref::Value; result_0=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result_0) && push!(_results, result_0) - - return IR.create_operation( - "memref.rank", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rank(memref; result_0=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result_0) && push!(results, result_0) + + IR.create_operation( + "memref.rank", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1258,30 +1116,20 @@ behavior. %5 = memref.load %old[%index] // undefined behavior ``` """ -function realloc( - source::Value, - dynamicResultSize=nothing::Union{Nothing,Value}; - result_0::IR.Type, - alignment=nothing, - location=Location(), -) - _results = IR.Type[result_0,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(dynamicResultSize) && push!(_operands, dynamicResultSize) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "memref.realloc", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function realloc(source, dynamicResultSize=nothing; result_0::IR.Type, alignment=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dynamicResultSize) && push!(operands, value(dynamicResultSize)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "memref.realloc", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1323,40 +1171,19 @@ means that `%dst`\'s descriptor will be: %dst.strides = %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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reinterpret_cast(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "memref.reinterpret_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1395,22 +1222,18 @@ Result type is unranked. : (memref<*xf32>, memref) to memref<*xf32> ``` """ -function reshape(source::Value, shape::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source, shape] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(source, shape; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1444,30 +1267,19 @@ techniques. This is possible because of the [restrictions on dimensions and symbols](Affine.md/#restrictions-on-dimensions-and-symbols) in these contexts. """ -function store( - value::Value, - memref::Value, - indices::Vector{Value}; - nontemporal=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, memref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(nontemporal) && - push!(_attributes, namedattribute("nontemporal", nontemporal)) - - return IR.create_operation( - "memref.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(value, memref, indices; nontemporal=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(memref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(nontemporal) && push!(attributes, namedattribute("nontemporal", nontemporal)) + + IR.create_operation( + "memref.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1484,22 +1296,18 @@ transformation. %1 = memref.transpose %0 (i, j) -> (j, i) : memref to memref (d1 * s0 + d0)>> ``` """ -function transpose(in::Value; result_0::IR.Type, permutation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(in; result_0::IR.Type, permutation, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(in), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation", permutation), ] + + IR.create_operation( + "memref.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1541,28 +1349,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.view", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function view(source, byte_shift, sizes; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(source), value(byte_shift), value.(sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.view", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1699,40 +1497,19 @@ Example 5: memref<8x16x4xf32> to memref<6x3xf32, strided<[4, 1], offset: 210>> ``` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function subview(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "memref.subview", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1751,22 +1528,18 @@ element types of these must match, and are specified by the memref type. 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "memref.tensor_store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tensor_store(tensor, memref; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "memref.tensor_store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/NVGPU.jl b/src/Dialects/17/NVGPU.jl index fdbfcc1c..cc1048f7 100644 --- a/src/Dialects/17/NVGPU.jl +++ b/src/Dialects/17/NVGPU.jl @@ -1,7 +1,6 @@ module nvgpu -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -54,40 +53,21 @@ nvgpu.device_async_wait %token2 memref<4x5xf32> to memref<2x7x5xf32, 3> ``` """ -function device_async_copy( - dst::Value, - dstIndices::Vector{Value}, - src::Value, - srcIndices::Vector{Value}, - srcElements=nothing::Union{Nothing,Value}; - asyncToken::IR.Type, - dstElements, - bypassL1=nothing, - location=Location(), -) - _results = IR.Type[asyncToken,] - _operands = Value[dst, dstIndices..., src, srcIndices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dstElements", dstElements),] - !isnothing(srcElements) && push!(_operands, srcElements) - push!( - _attributes, - operandsegmentsizes([ - 1, length(dstIndices), 1, length(srcIndices), isnothing(srcElements) ? 0 : 1 - ]), - ) - !isnothing(bypassL1) && push!(_attributes, namedattribute("bypassL1", bypassL1)) - - return IR.create_operation( - "nvgpu.device_async_copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function device_async_copy(dst, dstIndices, src, srcIndices, srcElements=nothing; asyncToken::IR.Type, dstElements, bypassL1=nothing, location=Location()) + results = IR.Type[asyncToken, ] + operands = Value[value(dst), value.(dstIndices)..., value(src), value.(srcIndices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dstElements", dstElements), ] + !isnothing(srcElements) && push!(operands, value(srcElements)) + push!(attributes, operandsegmentsizes([1, length(dstIndices), 1, length(srcIndices), (srcElements==nothing) ? 0 : 1])) + !isnothing(bypassL1) && push!(attributes, namedattribute("bypassL1", bypassL1)) + + IR.create_operation( + "nvgpu.device_async_copy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -111,24 +91,18 @@ Groups are executed in the order they are created. %0 = nvgpu.device_async_create_group ``` """ -function device_async_create_group( - inputTokens::Vector{Value}; asyncToken::IR.Type, location=Location() -) - _results = IR.Type[asyncToken,] - _operands = Value[inputTokens...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvgpu.device_async_create_group", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function device_async_create_group(inputTokens; asyncToken::IR.Type, location=Location()) + results = IR.Type[asyncToken, ] + operands = Value[value.(inputTokens)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "nvgpu.device_async_create_group", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -150,23 +124,19 @@ completed). nvgpu.device_async_wait %0 ``` """ -function device_async_wait(asyncDependencies::Value; numGroups=nothing, location=Location()) - _results = IR.Type[] - _operands = Value[asyncDependencies,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(numGroups) && push!(_attributes, namedattribute("numGroups", numGroups)) - - return IR.create_operation( - "nvgpu.device_async_wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function device_async_wait(asyncDependencies; numGroups=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(asyncDependencies), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(numGroups) && push!(attributes, namedattribute("numGroups", numGroups)) + + IR.create_operation( + "nvgpu.device_async_wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -188,31 +158,18 @@ https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-mat memref -> vector<4x2xf16> ``` """ -function ldmatrix( - srcMemref::Value, - indices::Vector{Value}; - res::IR.Type, - transpose, - numTiles, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[srcMemref, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("transpose", transpose), namedattribute("numTiles", numTiles) - ] - - return IR.create_operation( - "nvgpu.ldmatrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ldmatrix(srcMemref, indices; res::IR.Type, transpose, numTiles, location=Location()) + results = IR.Type[res, ] + operands = Value[value(srcMemref), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("transpose", transpose), namedattribute("numTiles", numTiles), ] + + IR.create_operation( + "nvgpu.ldmatrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -233,22 +190,18 @@ The `\$txCount` specifies the number of element to the expect-tx operation. nvgpu.mbarrier.arrive.expect_tx %barrier, %ic0 : !nvgpu.mbarrier.barrier> ``` """ -function mbarrier_arrive_expect_tx(barrier::Value, txcount::Value; location=Location()) - _results = IR.Type[] - _operands = Value[barrier, txcount] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvgpu.mbarrier.arrive.expect_tx", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mbarrier_arrive_expect_tx(barrier, txcount; location=Location()) + results = IR.Type[] + operands = Value[value(barrier), value(txcount), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "nvgpu.mbarrier.arrive.expect_tx", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -265,24 +218,18 @@ The Op does not cause the `nvgpu.mbarrier` to complete its current phase. %token = nvgpu.mbarrier.arrive.noComplete %barrier, %count : !nvgpu.mbarrier.barrier> -> !nvgpu.mbarrier.token ``` """ -function mbarrier_arrive_nocomplete( - barrier::Value, count::Value; token::IR.Type, location=Location() -) - _results = IR.Type[token,] - _operands = Value[barrier, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvgpu.mbarrier.arrive.nocomplete", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mbarrier_arrive_nocomplete(barrier, count; token::IR.Type, location=Location()) + results = IR.Type[token, ] + operands = Value[value(barrier), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "nvgpu.mbarrier.arrive.nocomplete", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -300,22 +247,18 @@ https://docs.nvidia.com/cuda/parallel-thread-execution/#arrive-on-operation-on-m %token = nvgpu.mbarrier.arrive %barrier : !nvgpu.mbarrier.barrier> -> !nvgpu.mbarrier.token ``` """ -function mbarrier_arrive(barrier::Value; token::IR.Type, location=Location()) - _results = IR.Type[token,] - _operands = Value[barrier,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvgpu.mbarrier.arrive", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mbarrier_arrive(barrier; token::IR.Type, location=Location()) + results = IR.Type[token, ] + operands = Value[value(barrier), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "nvgpu.mbarrier.arrive", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -364,22 +307,18 @@ The Op initializes the `mbarrier` object with the given number of threads. nvgpu.mbarrier.init %barrier, %num_threads : !nvgpu.mbarrier.barrier> ``` """ -function mbarrier_init(barrier::Value, count::Value; location=Location()) - _results = IR.Type[] - _operands = Value[barrier, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvgpu.mbarrier.init", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mbarrier_init(barrier, count; location=Location()) + results = IR.Type[] + operands = Value[value(barrier), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "nvgpu.mbarrier.init", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -394,24 +333,18 @@ non-blocking instruction which tests for the completion of the phase. %isComplete = nvgpu.mbarrier.test.wait %barrier, %token : !nvgpu.mbarrier.barrier>, !nvgpu.mbarrier.token ``` """ -function mbarrier_test_wait( - barrier::Value, token::Value; waitComplete::IR.Type, location=Location() -) - _results = IR.Type[waitComplete,] - _operands = Value[barrier, token] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvgpu.mbarrier.test.wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mbarrier_test_wait(barrier, token; waitComplete::IR.Type, location=Location()) + results = IR.Type[waitComplete, ] + operands = Value[value(barrier), value(token), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "nvgpu.mbarrier.test.wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -428,24 +361,18 @@ OR before the phase completes following a system-dependent time limit. nvgpu.mbarrier.try_wait.parity %barrier, %phase, %ticks : !nvgpu.mbarrier.barrier> ``` """ -function mbarrier_try_wait_parity( - barrier::Value, phase::Value, ticks::Value; location=Location() -) - _results = IR.Type[] - _operands = Value[barrier, phase, ticks] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvgpu.mbarrier.try_wait.parity", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mbarrier_try_wait_parity(barrier, phase, ticks; location=Location()) + results = IR.Type[] + operands = Value[value(barrier), value(phase), value(ticks), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "nvgpu.mbarrier.try_wait.parity", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -473,36 +400,20 @@ nvgpu.mma.sp.sync (%a, %b, %c) metadata (%meta) {mmaShape = [16, 8, 32]} : (vector<4x2xf16>, vector<2x2xf16>, vector<2x2xf16>) -> vector<2x2xf16> ``` """ -function mma_sp_sync( - matrixA::Value, - matrixB::Value, - matrixC::Value, - sparseMetadata::Value; - res::IR.Type, - mmaShape, - sparsitySelector=nothing, - tf32Enabled=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[matrixA, matrixB, matrixC, sparseMetadata] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mmaShape", mmaShape),] - !isnothing(sparsitySelector) && - push!(_attributes, namedattribute("sparsitySelector", sparsitySelector)) - !isnothing(tf32Enabled) && - push!(_attributes, namedattribute("tf32Enabled", tf32Enabled)) - - return IR.create_operation( - "nvgpu.mma.sp.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mma_sp_sync(matrixA, matrixB, matrixC, sparseMetadata; res::IR.Type, mmaShape, sparsitySelector=nothing, tf32Enabled=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(matrixA), value(matrixB), value(matrixC), value(sparseMetadata), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mmaShape", mmaShape), ] + !isnothing(sparsitySelector) && push!(attributes, namedattribute("sparsitySelector", sparsitySelector)) + !isnothing(tf32Enabled) && push!(attributes, namedattribute("tf32Enabled", tf32Enabled)) + + IR.create_operation( + "nvgpu.mma.sp.sync", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -528,32 +439,19 @@ This operation is meant to follow the semantic of described here: (vector<4x2xf16>, vector<2x2xf16>, vector<2x2xf32>) -> vector<2x2xf32> ``` """ -function mma_sync( - matrixA::Value, - matrixB::Value, - matrixC::Value; - res::IR.Type, - mmaShape, - tf32Enabled=nothing, - location=Location(), -) - _results = IR.Type[res,] - _operands = Value[matrixA, matrixB, matrixC] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mmaShape", mmaShape),] - !isnothing(tf32Enabled) && - push!(_attributes, namedattribute("tf32Enabled", tf32Enabled)) - - return IR.create_operation( - "nvgpu.mma.sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mma_sync(matrixA, matrixB, matrixC; res::IR.Type, mmaShape, tf32Enabled=nothing, location=Location()) + results = IR.Type[res, ] + operands = Value[value(matrixA), value(matrixB), value(matrixC), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mmaShape", mmaShape), ] + !isnothing(tf32Enabled) && push!(attributes, namedattribute("tf32Enabled", tf32Enabled)) + + IR.create_operation( + "nvgpu.mma.sync", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -568,28 +466,18 @@ tile shape. The descriptor is created by `nvgpu.tma.create.descriptor` The Op uses `\$barrier` mbarrier based completion mechanism. """ -function tma_async_load( - dst::Value, - barrier::Value, - tensorMapDescriptor::Value, - coordinates::Vector{Value}; - location=Location(), -) - _results = IR.Type[] - _operands = Value[dst, barrier, tensorMapDescriptor, coordinates...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvgpu.tma.async.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tma_async_load(dst, barrier, tensorMapDescriptor, coordinates; location=Location()) + results = IR.Type[] + operands = Value[value(dst), value(barrier), value(tensorMapDescriptor), value.(coordinates)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "nvgpu.tma.async.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -607,24 +495,18 @@ The `boxDimensions` is the size of the tiled memory region in each dimension. For more information see below: https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TENSOR__MEMORY.html """ -function tma_create_descriptor( - tensor::Value, boxDimensions::Vector{Value}; tensorMap::IR.Type, location=Location() -) - _results = IR.Type[tensorMap,] - _operands = Value[tensor, boxDimensions...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "nvgpu.tma.create.descriptor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tma_create_descriptor(tensor, boxDimensions; tensorMap::IR.Type, location=Location()) + results = IR.Type[tensorMap, ] + operands = Value[value(tensor), value.(boxDimensions)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "nvgpu.tma.create.descriptor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/OpenACC.jl b/src/Dialects/17/OpenACC.jl index 7b8c8dc7..69635699 100644 --- a/src/Dialects/17/OpenACC.jl +++ b/src/Dialects/17/OpenACC.jl @@ -1,7 +1,6 @@ module acc -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -26,40 +25,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function attach( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.attach", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function attach(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.attach", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -85,40 +68,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function copyin( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.copyin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function copyin(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.copyin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -143,37 +110,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function copyout( - accPtr::Value, - varPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[accPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtr) && push!(_operands, varPtr) - push!(_attributes, operandsegmentsizes([1, isnothing(varPtr) ? 0 : 1, length(bounds)])) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.copyout", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function copyout(accPtr, varPtr=nothing; bounds, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(accPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtr) && push!(operands, value(varPtr)) + push!(attributes, operandsegmentsizes([1, (varPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.copyout", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -199,40 +153,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function create( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.create", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.create", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -273,48 +211,25 @@ integer :: array(1:10) acc.bounds lb(1) ub(9) extent(9) startIdx(1) ``` """ -function bounds( - lowerbound=nothing::Union{Nothing,Value}; - upperbound=nothing::Union{Nothing,Value}, - extent=nothing::Union{Nothing,Value}, - stride=nothing::Union{Nothing,Value}, - startIdx=nothing::Union{Nothing,Value}, - result::IR.Type, - strideInBytes=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(lowerbound) && push!(_operands, lowerbound) - !isnothing(upperbound) && push!(_operands, upperbound) - !isnothing(extent) && push!(_operands, extent) - !isnothing(stride) && push!(_operands, stride) - !isnothing(startIdx) && push!(_operands, startIdx) - push!( - _attributes, - operandsegmentsizes([ - isnothing(lowerbound) ? 0 : 1, - isnothing(upperbound) ? 0 : 1, - isnothing(extent) ? 0 : 1, - isnothing(stride) ? 0 : 1, - isnothing(startIdx) ? 0 : 1, - ]), - ) - !isnothing(strideInBytes) && - push!(_attributes, namedattribute("strideInBytes", strideInBytes)) - - return IR.create_operation( - "acc.bounds", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bounds(lowerbound=nothing; upperbound=nothing, extent=nothing, stride=nothing, startIdx=nothing, result::IR.Type, strideInBytes=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(lowerbound) && push!(operands, value(lowerbound)) + !isnothing(upperbound) && push!(operands, value(upperbound)) + !isnothing(extent) && push!(operands, value(extent)) + !isnothing(stride) && push!(operands, value(stride)) + !isnothing(startIdx) && push!(operands, value(startIdx)) + push!(attributes, operandsegmentsizes([(lowerbound==nothing) ? 0 : 1(upperbound==nothing) ? 0 : 1(extent==nothing) ? 0 : 1(stride==nothing) ? 0 : 1(startIdx==nothing) ? 0 : 1])) + !isnothing(strideInBytes) && push!(attributes, namedattribute("strideInBytes", strideInBytes)) + + IR.create_operation( + "acc.bounds", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -336,50 +251,25 @@ acc.data present(%a: memref<10x10xf32>, %b: memref<10x10xf32>, } ``` """ -function data( - ifCond=nothing::Union{Nothing,Value}; - async=nothing::Union{Nothing,Value}, - waitDevnum=nothing::Union{Nothing,Value}, - waitOperands::Vector{Value}, - dataClauseOperands::Vector{Value}, - asyncAttr=nothing, - waitAttr=nothing, - defaultAttr=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[waitOperands..., dataClauseOperands...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(ifCond) && push!(_operands, ifCond) - !isnothing(async) && push!(_operands, async) - !isnothing(waitDevnum) && push!(_operands, waitDevnum) - push!( - _attributes, - operandsegmentsizes([ - isnothing(ifCond) ? 0 : 1, - isnothing(async) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(waitOperands), - length(dataClauseOperands), - ]), - ) - !isnothing(asyncAttr) && push!(_attributes, namedattribute("asyncAttr", asyncAttr)) - !isnothing(waitAttr) && push!(_attributes, namedattribute("waitAttr", waitAttr)) - !isnothing(defaultAttr) && - push!(_attributes, namedattribute("defaultAttr", defaultAttr)) - - return IR.create_operation( - "acc.data", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function data(ifCond=nothing; async=nothing, waitDevnum=nothing, waitOperands, dataClauseOperands, asyncAttr=nothing, waitAttr=nothing, defaultAttr=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(dataClauseOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(async) && push!(operands, value(async)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(async==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(dataClauseOperands), ])) + !isnothing(asyncAttr) && push!(attributes, namedattribute("asyncAttr", asyncAttr)) + !isnothing(waitAttr) && push!(attributes, namedattribute("waitAttr", waitAttr)) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + + IR.create_operation( + "acc.data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -405,40 +295,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function declare_device_resident( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.declare_device_resident", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function declare_device_resident(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.declare_device_resident", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -456,22 +330,18 @@ Example showing `acc declare create(a)`: acc.declare_enter dataOperands(%0 : !llvm.ptr) ``` """ -function declare_enter(dataClauseOperands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[dataClauseOperands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "acc.declare_enter", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function declare_enter(dataClauseOperands; location=Location()) + results = IR.Type[] + operands = Value[value.(dataClauseOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "acc.declare_enter", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -490,22 +360,18 @@ acc.declare_exit dataOperands(%0 : !llvm.ptr) acc.delete accPtr(%0 : !llvm.ptr) {dataClause = #acc} ``` """ -function declare_exit(dataClauseOperands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[dataClauseOperands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "acc.declare_exit", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function declare_exit(dataClauseOperands; location=Location()) + results = IR.Type[] + operands = Value[value.(dataClauseOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "acc.declare_exit", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -531,40 +397,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function declare_link( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.declare_link", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function declare_link(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.declare_link", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -589,37 +439,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function delete( - accPtr::Value, - varPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[accPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtr) && push!(_operands, varPtr) - push!(_attributes, operandsegmentsizes([1, isnothing(varPtr) ? 0 : 1, length(bounds)])) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.delete", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function delete(accPtr, varPtr=nothing; bounds, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(accPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtr) && push!(operands, value(varPtr)) + push!(attributes, operandsegmentsizes([1, (varPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.delete", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -644,37 +481,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function detach( - accPtr::Value, - varPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[accPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtr) && push!(_operands, varPtr) - push!(_attributes, operandsegmentsizes([1, isnothing(varPtr) ? 0 : 1, length(bounds)])) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.detach", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function detach(accPtr, varPtr=nothing; bounds, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(accPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtr) && push!(operands, value(varPtr)) + push!(attributes, operandsegmentsizes([1, (varPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.detach", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -700,40 +524,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function deviceptr( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.deviceptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function deviceptr(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.deviceptr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -748,46 +556,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}, - dataClauseOperands::Vector{Value}, - async=nothing, - wait=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[waitOperands..., dataClauseOperands...] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(waitOperands), - length(dataClauseOperands), - ]), - ) - !isnothing(async) && push!(_attributes, namedattribute("async", async)) - !isnothing(wait) && push!(_attributes, namedattribute("wait", wait)) - - return IR.create_operation( - "acc.enter_data", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function enter_data(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, dataClauseOperands, async=nothing, wait=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(dataClauseOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(dataClauseOperands), ])) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + + IR.create_operation( + "acc.enter_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -802,48 +588,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}, - dataClauseOperands::Vector{Value}, - async=nothing, - wait=nothing, - finalize=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[waitOperands..., dataClauseOperands...] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(waitOperands), - length(dataClauseOperands), - ]), - ) - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function exit_data(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, dataClauseOperands, async=nothing, wait=nothing, finalize=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(dataClauseOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(dataClauseOperands), ])) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + !isnothing(finalize) && push!(attributes, namedattribute("finalize", finalize)) + + IR.create_operation( + "acc.exit_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -869,40 +632,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function firstprivate( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.firstprivate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function firstprivate(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.firstprivate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1006,40 +753,24 @@ that is any of the valid `mlir::acc::DataClause` entries. done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function getdeviceptr( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.getdeviceptr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function getdeviceptr(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.getdeviceptr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1138,34 +869,21 @@ acc.host_data dataOperands(%0 : !llvm.ptr) { } ``` """ -function host_data( - ifCond=nothing::Union{Nothing,Value}; - dataClauseOperands::Vector{Value}, - ifPresent=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[dataClauseOperands...,] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(ifCond) && push!(_operands, ifCond) - push!( - _attributes, - operandsegmentsizes([isnothing(ifCond) ? 0 : 1, length(dataClauseOperands)]), - ) - !isnothing(ifPresent) && push!(_attributes, namedattribute("ifPresent", ifPresent)) - - return IR.create_operation( - "acc.host_data", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function host_data(ifCond=nothing; dataClauseOperands, ifPresent=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(dataClauseOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1length(dataClauseOperands), ])) + !isnothing(ifPresent) && push!(attributes, namedattribute("ifPresent", ifPresent)) + + IR.create_operation( + "acc.host_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1173,46 +891,30 @@ end `init` The \"acc.init\" operation represents the OpenACC init executable -directive. - -# Example - -```mlir -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(), -) - _results = IR.Type[] - _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), - isnothing(deviceNumOperand) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - - return IR.create_operation( - "acc.init", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +directive. + +# Example + +```mlir +acc.init +acc.init device_num(%dev1 : i32) +``` +""" +function init(deviceTypeOperands, deviceNumOperand=nothing; ifCond=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(deviceTypeOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(deviceNumOperand) && push!(operands, value(deviceNumOperand)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + 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 ) end @@ -1232,60 +934,28 @@ acc.kernels num_gangs(%c10) num_workers(%c10) } ``` """ -function kernels( - async=nothing::Union{Nothing,Value}; - waitOperands::Vector{Value}, - numGangs::Vector{Value}, - numWorkers=nothing::Union{Nothing,Value}, - vectorLength=nothing::Union{Nothing,Value}, - ifCond=nothing::Union{Nothing,Value}, - selfCond=nothing::Union{Nothing,Value}, - dataClauseOperands::Vector{Value}, - asyncAttr=nothing, - waitAttr=nothing, - selfAttr=nothing, - defaultAttr=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[waitOperands..., numGangs..., dataClauseOperands...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(async) && push!(_operands, async) - !isnothing(numWorkers) && push!(_operands, numWorkers) - !isnothing(vectorLength) && push!(_operands, vectorLength) - !isnothing(ifCond) && push!(_operands, ifCond) - !isnothing(selfCond) && push!(_operands, selfCond) - push!( - _attributes, - operandsegmentsizes([ - isnothing(async) ? 0 : 1, - length(waitOperands), - length(numGangs), - isnothing(numWorkers) ? 0 : 1, - isnothing(vectorLength) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - isnothing(selfCond) ? 0 : 1, - length(dataClauseOperands), - ]), - ) - !isnothing(asyncAttr) && push!(_attributes, namedattribute("asyncAttr", asyncAttr)) - !isnothing(waitAttr) && push!(_attributes, namedattribute("waitAttr", waitAttr)) - !isnothing(selfAttr) && push!(_attributes, namedattribute("selfAttr", selfAttr)) - !isnothing(defaultAttr) && - push!(_attributes, namedattribute("defaultAttr", defaultAttr)) - - return IR.create_operation( - "acc.kernels", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function kernels(async=nothing; waitOperands, numGangs, numWorkers=nothing, vectorLength=nothing, ifCond=nothing, selfCond=nothing, dataClauseOperands, asyncAttr=nothing, waitAttr=nothing, selfAttr=nothing, defaultAttr=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(numGangs)..., value.(dataClauseOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(async) && push!(operands, value(async)) + !isnothing(numWorkers) && push!(operands, value(numWorkers)) + !isnothing(vectorLength) && push!(operands, value(vectorLength)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(selfCond) && push!(operands, value(selfCond)) + push!(attributes, operandsegmentsizes([(async==nothing) ? 0 : 1length(waitOperands), length(numGangs), (numWorkers==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1(selfCond==nothing) ? 0 : 1length(dataClauseOperands), ])) + !isnothing(asyncAttr) && push!(attributes, namedattribute("asyncAttr", asyncAttr)) + !isnothing(waitAttr) && push!(attributes, namedattribute("waitAttr", waitAttr)) + !isnothing(selfAttr) && push!(attributes, namedattribute("selfAttr", selfAttr)) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + + IR.create_operation( + "acc.kernels", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1309,73 +979,33 @@ acc.loop gang vector { } attributes { collapse = 3 } ``` """ -function loop( - gangNum=nothing::Union{Nothing,Value}; - gangDim=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, - hasGang=nothing, - hasWorker=nothing, - hasVector=nothing, - privatizations=nothing, - reductionRecipes=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(gangDim) && push!(_operands, gangDim) - !isnothing(gangStatic) && push!(_operands, gangStatic) - !isnothing(workerNum) && push!(_operands, workerNum) - !isnothing(vectorLength) && push!(_operands, vectorLength) - push!( - _attributes, - operandsegmentsizes([ - isnothing(gangNum) ? 0 : 1, - isnothing(gangDim) ? 0 : 1, - isnothing(gangStatic) ? 0 : 1, - isnothing(workerNum) ? 0 : 1, - isnothing(vectorLength) ? 0 : 1, - length(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(hasGang) && push!(_attributes, namedattribute("hasGang", hasGang)) - !isnothing(hasWorker) && push!(_attributes, namedattribute("hasWorker", hasWorker)) - !isnothing(hasVector) && push!(_attributes, namedattribute("hasVector", hasVector)) - !isnothing(privatizations) && - push!(_attributes, namedattribute("privatizations", privatizations)) - !isnothing(reductionRecipes) && - push!(_attributes, namedattribute("reductionRecipes", reductionRecipes)) - - return IR.create_operation( - "acc.loop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop(gangNum=nothing; gangDim=nothing, gangStatic=nothing, workerNum=nothing, vectorLength=nothing, tileOperands, privateOperands, reductionOperands, results_::Vector{IR.Type}, collapse=nothing, seq=nothing, independent=nothing, auto_=nothing, hasGang=nothing, hasWorker=nothing, hasVector=nothing, privatizations=nothing, reductionRecipes=nothing, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(tileOperands)..., value.(privateOperands)..., value.(reductionOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(gangNum) && push!(operands, value(gangNum)) + !isnothing(gangDim) && push!(operands, value(gangDim)) + !isnothing(gangStatic) && push!(operands, value(gangStatic)) + !isnothing(workerNum) && push!(operands, value(workerNum)) + !isnothing(vectorLength) && push!(operands, value(vectorLength)) + push!(attributes, operandsegmentsizes([(gangNum==nothing) ? 0 : 1(gangDim==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(hasGang) && push!(attributes, namedattribute("hasGang", hasGang)) + !isnothing(hasWorker) && push!(attributes, namedattribute("hasWorker", hasWorker)) + !isnothing(hasVector) && push!(attributes, namedattribute("hasVector", hasVector)) + !isnothing(privatizations) && push!(attributes, namedattribute("privatizations", privatizations)) + !isnothing(reductionRecipes) && push!(attributes, namedattribute("reductionRecipes", reductionRecipes)) + + IR.create_operation( + "acc.loop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1401,40 +1031,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function nocreate( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.nocreate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function nocreate(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.nocreate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1453,82 +1067,31 @@ acc.parallel num_gangs(%c10) num_workers(%c10) } ``` """ -function parallel( - async=nothing::Union{Nothing,Value}; - waitOperands::Vector{Value}, - numGangs::Vector{Value}, - numWorkers=nothing::Union{Nothing,Value}, - vectorLength=nothing::Union{Nothing,Value}, - ifCond=nothing::Union{Nothing,Value}, - selfCond=nothing::Union{Nothing,Value}, - reductionOperands::Vector{Value}, - gangPrivateOperands::Vector{Value}, - gangFirstPrivateOperands::Vector{Value}, - dataClauseOperands::Vector{Value}, - asyncAttr=nothing, - waitAttr=nothing, - selfAttr=nothing, - reductionRecipes=nothing, - privatizations=nothing, - firstprivatizations=nothing, - defaultAttr=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - waitOperands..., - numGangs..., - reductionOperands..., - gangPrivateOperands..., - gangFirstPrivateOperands..., - dataClauseOperands..., - ] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(async) && push!(_operands, async) - !isnothing(numWorkers) && push!(_operands, numWorkers) - !isnothing(vectorLength) && push!(_operands, vectorLength) - !isnothing(ifCond) && push!(_operands, ifCond) - !isnothing(selfCond) && push!(_operands, selfCond) - push!( - _attributes, - operandsegmentsizes([ - isnothing(async) ? 0 : 1, - length(waitOperands), - length(numGangs), - isnothing(numWorkers) ? 0 : 1, - isnothing(vectorLength) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - isnothing(selfCond) ? 0 : 1, - length(reductionOperands), - length(gangPrivateOperands), - length(gangFirstPrivateOperands), - length(dataClauseOperands), - ]), - ) - !isnothing(asyncAttr) && push!(_attributes, namedattribute("asyncAttr", asyncAttr)) - !isnothing(waitAttr) && push!(_attributes, namedattribute("waitAttr", waitAttr)) - !isnothing(selfAttr) && push!(_attributes, namedattribute("selfAttr", selfAttr)) - !isnothing(reductionRecipes) && - push!(_attributes, namedattribute("reductionRecipes", reductionRecipes)) - !isnothing(privatizations) && - push!(_attributes, namedattribute("privatizations", privatizations)) - !isnothing(firstprivatizations) && - push!(_attributes, namedattribute("firstprivatizations", firstprivatizations)) - !isnothing(defaultAttr) && - push!(_attributes, namedattribute("defaultAttr", defaultAttr)) - - return IR.create_operation( - "acc.parallel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(async=nothing; waitOperands, numGangs, numWorkers=nothing, vectorLength=nothing, ifCond=nothing, selfCond=nothing, reductionOperands, gangPrivateOperands, gangFirstPrivateOperands, dataClauseOperands, asyncAttr=nothing, waitAttr=nothing, selfAttr=nothing, reductionRecipes=nothing, privatizations=nothing, firstprivatizations=nothing, defaultAttr=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(numGangs)..., value.(reductionOperands)..., value.(gangPrivateOperands)..., value.(gangFirstPrivateOperands)..., value.(dataClauseOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(async) && push!(operands, value(async)) + !isnothing(numWorkers) && push!(operands, value(numWorkers)) + !isnothing(vectorLength) && push!(operands, value(vectorLength)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(selfCond) && push!(operands, value(selfCond)) + push!(attributes, operandsegmentsizes([(async==nothing) ? 0 : 1length(waitOperands), length(numGangs), (numWorkers==nothing) ? 0 : 1(vectorLength==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1(selfCond==nothing) ? 0 : 1length(reductionOperands), length(gangPrivateOperands), length(gangFirstPrivateOperands), length(dataClauseOperands), ])) + !isnothing(asyncAttr) && push!(attributes, namedattribute("asyncAttr", asyncAttr)) + !isnothing(waitAttr) && push!(attributes, namedattribute("waitAttr", waitAttr)) + !isnothing(selfAttr) && push!(attributes, namedattribute("selfAttr", selfAttr)) + !isnothing(reductionRecipes) && push!(attributes, namedattribute("reductionRecipes", reductionRecipes)) + !isnothing(privatizations) && push!(attributes, namedattribute("privatizations", privatizations)) + !isnothing(firstprivatizations) && push!(attributes, namedattribute("firstprivatizations", firstprivatizations)) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + + IR.create_operation( + "acc.parallel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1554,40 +1117,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function present( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.present", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function present(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.present", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1613,40 +1160,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function private( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.private", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function private(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.private", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1731,40 +1262,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function reduction( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduction(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1870,73 +1385,29 @@ acc.serial private(%c : memref<10xf32>) { } ``` """ -function serial( - async=nothing::Union{Nothing,Value}; - waitOperands::Vector{Value}, - ifCond=nothing::Union{Nothing,Value}, - selfCond=nothing::Union{Nothing,Value}, - reductionOperands::Vector{Value}, - gangPrivateOperands::Vector{Value}, - gangFirstPrivateOperands::Vector{Value}, - dataClauseOperands::Vector{Value}, - asyncAttr=nothing, - waitAttr=nothing, - selfAttr=nothing, - reductionRecipes=nothing, - privatizations=nothing, - firstprivatizations=nothing, - defaultAttr=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - waitOperands..., - reductionOperands..., - gangPrivateOperands..., - gangFirstPrivateOperands..., - dataClauseOperands..., - ] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(async) && push!(_operands, async) - !isnothing(ifCond) && push!(_operands, ifCond) - !isnothing(selfCond) && push!(_operands, selfCond) - push!( - _attributes, - operandsegmentsizes([ - isnothing(async) ? 0 : 1, - length(waitOperands), - isnothing(ifCond) ? 0 : 1, - isnothing(selfCond) ? 0 : 1, - length(reductionOperands), - length(gangPrivateOperands), - length(gangFirstPrivateOperands), - length(dataClauseOperands), - ]), - ) - !isnothing(asyncAttr) && push!(_attributes, namedattribute("asyncAttr", asyncAttr)) - !isnothing(waitAttr) && push!(_attributes, namedattribute("waitAttr", waitAttr)) - !isnothing(selfAttr) && push!(_attributes, namedattribute("selfAttr", selfAttr)) - !isnothing(reductionRecipes) && - push!(_attributes, namedattribute("reductionRecipes", reductionRecipes)) - !isnothing(privatizations) && - push!(_attributes, namedattribute("privatizations", privatizations)) - !isnothing(firstprivatizations) && - push!(_attributes, namedattribute("firstprivatizations", firstprivatizations)) - !isnothing(defaultAttr) && - push!(_attributes, namedattribute("defaultAttr", defaultAttr)) - - return IR.create_operation( - "acc.serial", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function serial(async=nothing; waitOperands, ifCond=nothing, selfCond=nothing, reductionOperands, gangPrivateOperands, gangFirstPrivateOperands, dataClauseOperands, asyncAttr=nothing, waitAttr=nothing, selfAttr=nothing, reductionRecipes=nothing, privatizations=nothing, firstprivatizations=nothing, defaultAttr=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(reductionOperands)..., value.(gangPrivateOperands)..., value.(gangFirstPrivateOperands)..., value.(dataClauseOperands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(async) && push!(operands, value(async)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(selfCond) && push!(operands, value(selfCond)) + push!(attributes, operandsegmentsizes([(async==nothing) ? 0 : 1length(waitOperands), (ifCond==nothing) ? 0 : 1(selfCond==nothing) ? 0 : 1length(reductionOperands), length(gangPrivateOperands), length(gangFirstPrivateOperands), length(dataClauseOperands), ])) + !isnothing(asyncAttr) && push!(attributes, namedattribute("asyncAttr", asyncAttr)) + !isnothing(waitAttr) && push!(attributes, namedattribute("waitAttr", waitAttr)) + !isnothing(selfAttr) && push!(attributes, namedattribute("selfAttr", selfAttr)) + !isnothing(reductionRecipes) && push!(attributes, namedattribute("reductionRecipes", reductionRecipes)) + !isnothing(privatizations) && push!(attributes, namedattribute("privatizations", privatizations)) + !isnothing(firstprivatizations) && push!(attributes, namedattribute("firstprivatizations", firstprivatizations)) + !isnothing(defaultAttr) && push!(attributes, namedattribute("defaultAttr", defaultAttr)) + + IR.create_operation( + "acc.serial", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1953,37 +1424,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(), -) - _results = IR.Type[] - _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), - isnothing(deviceNumOperand) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - - return IR.create_operation( - "acc.shutdown", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shutdown(deviceTypeOperands, deviceNumOperand=nothing; ifCond=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(deviceTypeOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(deviceNumOperand) && push!(operands, value(deviceNumOperand)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + 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 ) end @@ -2036,40 +1491,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function update_device( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.update_device", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function update_device(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.update_device", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2094,37 +1533,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function update_host( - accPtr::Value, - varPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[accPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtr) && push!(_operands, varPtr) - push!(_attributes, operandsegmentsizes([1, isnothing(varPtr) ? 0 : 1, length(bounds)])) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.update_host", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function update_host(accPtr, varPtr=nothing; bounds, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(accPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtr) && push!(operands, value(varPtr)) + push!(attributes, operandsegmentsizes([1, (varPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.update_host", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2142,50 +1568,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}, - dataClauseOperands::Vector{Value}, - async=nothing, - wait=nothing, - ifPresent=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[waitOperands..., deviceTypeOperands..., dataClauseOperands...] - _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([ - isnothing(ifCond) ? 0 : 1, - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - length(waitOperands), - length(deviceTypeOperands), - length(dataClauseOperands), - ]), - ) - !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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function update(ifCond=nothing; asyncOperand=nothing, waitDevnum=nothing, waitOperands, deviceTypeOperands, dataClauseOperands, async=nothing, wait=nothing, ifPresent=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., value.(deviceTypeOperands)..., value.(dataClauseOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ifCond) && push!(operands, value(ifCond)) + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + push!(attributes, operandsegmentsizes([(ifCond==nothing) ? 0 : 1(asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1length(waitOperands), length(deviceTypeOperands), length(dataClauseOperands), ])) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + !isnothing(wait) && push!(attributes, namedattribute("wait", wait)) + !isnothing(ifPresent) && push!(attributes, namedattribute("ifPresent", ifPresent)) + + IR.create_operation( + "acc.update", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2211,40 +1612,24 @@ counters (2.6.7). done to satisfy \"Variables with Implicitly Determined Data Attributes\" in 2.6.2. - `name`: Holds the name of variable as specified in user clause (including bounds). """ -function use_device( - varPtr::Value, - varPtrPtr=nothing::Union{Nothing,Value}; - bounds::Vector{Value}, - accPtr::IR.Type, - dataClause=nothing, - structured=nothing, - implicit=nothing, - name=nothing, - location=Location(), -) - _results = IR.Type[accPtr,] - _operands = Value[varPtr, bounds...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(varPtrPtr) && push!(_operands, varPtrPtr) - push!( - _attributes, operandsegmentsizes([1, isnothing(varPtrPtr) ? 0 : 1, length(bounds)]) - ) - !isnothing(dataClause) && push!(_attributes, namedattribute("dataClause", dataClause)) - !isnothing(structured) && push!(_attributes, namedattribute("structured", structured)) - !isnothing(implicit) && push!(_attributes, namedattribute("implicit", implicit)) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "acc.use_device", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function use_device(varPtr, varPtrPtr=nothing; bounds, accPtr::IR.Type, dataClause=nothing, structured=nothing, implicit=nothing, name=nothing, location=Location()) + results = IR.Type[accPtr, ] + operands = Value[value(varPtr), value.(bounds)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(varPtrPtr) && push!(operands, value(varPtrPtr)) + push!(attributes, operandsegmentsizes([1, (varPtrPtr==nothing) ? 0 : 1length(bounds), ])) + !isnothing(dataClause) && push!(attributes, namedattribute("dataClause", dataClause)) + !isnothing(structured) && push!(attributes, namedattribute("structured", structured)) + !isnothing(implicit) && push!(attributes, namedattribute("implicit", implicit)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "acc.use_device", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2261,42 +1646,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(), -) - _results = IR.Type[] - _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), - isnothing(asyncOperand) ? 0 : 1, - isnothing(waitDevnum) ? 0 : 1, - isnothing(ifCond) ? 0 : 1, - ]), - ) - !isnothing(async) && push!(_attributes, namedattribute("async", async)) - - return IR.create_operation( - "acc.wait", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wait(waitOperands, asyncOperand=nothing; waitDevnum=nothing, ifCond=nothing, async=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(waitOperands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(asyncOperand) && push!(operands, value(asyncOperand)) + !isnothing(waitDevnum) && push!(operands, value(waitDevnum)) + !isnothing(ifCond) && push!(operands, value(ifCond)) + push!(attributes, operandsegmentsizes([length(waitOperands), (asyncOperand==nothing) ? 0 : 1(waitDevnum==nothing) ? 0 : 1(ifCond==nothing) ? 0 : 1])) + !isnothing(async) && push!(attributes, namedattribute("async", async)) + + IR.create_operation( + "acc.wait", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2307,22 +1673,18 @@ end acc ops (parallel and loop). It returns values to the immediately enclosing acc op. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "acc.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "acc.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/OpenMP.jl b/src/Dialects/17/OpenMP.jl index ff554ded..9f2d3477 100644 --- a/src/Dialects/17/OpenMP.jl +++ b/src/Dialects/17/OpenMP.jl @@ -1,7 +1,6 @@ module omp -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -76,32 +75,20 @@ optimization. `memory_order` indicates the memory ordering behavior of the construct. It can be one of `seq_cst`, `acquire` or `relaxed`. """ -function atomic_read( - x::Value, - v::Value; - element_type, - hint_val=nothing, - memory_order_val=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x, v] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("element_type", element_type),] - !isnothing(hint_val) && push!(_attributes, namedattribute("hint_val", hint_val)) - !isnothing(memory_order_val) && - push!(_attributes, namedattribute("memory_order_val", memory_order_val)) - - return IR.create_operation( - "omp.atomic.read", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_read(x, v; element_type, hint_val=nothing, memory_order_val=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(v), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("element_type", element_type), ] + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + + IR.create_operation( + "omp.atomic.read", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -135,31 +122,20 @@ the core update operation is directly translated like regular operations by the host dialect. The front-end must handle semantic checks for allowed operations. """ -function atomic_update( - x::Value; - hint_val=nothing, - memory_order_val=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(hint_val) && push!(_attributes, namedattribute("hint_val", hint_val)) - !isnothing(memory_order_val) && - push!(_attributes, namedattribute("memory_order_val", memory_order_val)) - - return IR.create_operation( - "omp.atomic.update", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_update(x; hint_val=nothing, memory_order_val=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + + IR.create_operation( + "omp.atomic.update", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -180,31 +156,20 @@ optimization. `memory_order` indicates the memory ordering behavior of the construct. It can be one of `seq_cst`, `release` or `relaxed`. """ -function atomic_write( - address::Value, - value::Value; - hint_val=nothing, - memory_order_val=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[address, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(hint_val) && push!(_attributes, namedattribute("hint_val", hint_val)) - !isnothing(memory_order_val) && - push!(_attributes, namedattribute("memory_order_val", memory_order_val)) - - return IR.create_operation( - "omp.atomic.write", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function atomic_write(address, value; hint_val=nothing, memory_order_val=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(address), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(hint_val) && push!(attributes, namedattribute("hint_val", hint_val)) + !isnothing(memory_order_val) && push!(attributes, namedattribute("memory_order_val", memory_order_val)) + + IR.create_operation( + "omp.atomic.write", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -239,29 +204,19 @@ end The cancel construct activates cancellation of the innermost enclosing region of the type specified. """ -function cancel( - if_expr=nothing::Union{Nothing,Value}; - cancellation_construct_type_val, - location=Location(), -) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute( - "cancellation_construct_type_val", cancellation_construct_type_val - ),] - !isnothing(if_expr) && push!(_operands, if_expr) - - return IR.create_operation( - "omp.cancel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cancel(if_expr=nothing; cancellation_construct_type_val, location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("cancellation_construct_type_val", cancellation_construct_type_val), ] + !isnothing(if_expr) && push!(operands, value(if_expr)) + + IR.create_operation( + "omp.cancel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -354,22 +309,18 @@ makes a thread’s temporary view of memory consistent with memory and enforces an order on the memory operations of the variables explicitly specified or implied. """ -function flush(varList::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[varList...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.flush", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function flush(varList; location=Location()) + results = IR.Type[] + operands = Value[value.(varList)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.flush", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -416,31 +367,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ordered(depend_vec_vars; depend_type_val=nothing, num_loops_val=nothing, location=Location()) + results = IR.Type[] + operands = Value[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)) + + IR.create_operation( + "omp.ordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -507,47 +447,23 @@ threads complete. 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}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}, - reduction_vars::Vector{Value}, - reductions=nothing, - proc_bind_val=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[allocate_vars..., allocators_vars..., reduction_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([ - isnothing(if_expr_var) ? 0 : 1, - isnothing(num_threads_var) ? 0 : 1, - length(allocate_vars), - length(allocators_vars), - length(reduction_vars), - ]), - ) - !isnothing(reductions) && push!(_attributes, namedattribute("reductions", reductions)) - !isnothing(proc_bind_val) && - push!(_attributes, namedattribute("proc_bind_val", proc_bind_val)) - - return IR.create_operation( - "omp.parallel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(if_expr_var=nothing; num_threads_var=nothing, allocate_vars, allocators_vars, reduction_vars, reductions=nothing, proc_bind_val=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(allocate_vars)..., value.(allocators_vars)..., value.(reduction_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr_var) && push!(operands, value(if_expr_var)) + !isnothing(num_threads_var) && push!(operands, value(num_threads_var)) + push!(attributes, operandsegmentsizes([(if_expr_var==nothing) ? 0 : 1(num_threads_var==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), length(reduction_vars), ])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !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 ) end @@ -612,22 +528,18 @@ entity for a reduction requested in some ancestor. The reduction is identified by the accumulator, but the value of the accumulator may not be updated immediately. """ -function reduction(operand::Value, accumulator::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand, accumulator] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduction(operand, accumulator; location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(accumulator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -684,38 +596,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( - 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[reduction_vars..., allocate_vars..., allocators_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - 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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sections(reduction_vars, allocate_vars, allocators_vars; reductions=nothing, nowait=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(reduction_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(reduction_vars), length(allocate_vars), length(allocators_vars), ])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.sections", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -764,56 +659,25 @@ for (%i1, %i2) : index = (%c0, %c0) to (%c10, %c10) step (%c1, %c1) { } ``` """ -function simdloop( - lowerBound::Vector{Value}, - upperBound::Vector{Value}, - step::Vector{Value}, - aligned_vars::Vector{Value}, - if_expr=nothing::Union{Nothing,Value}; - nontemporal_vars::Vector{Value}, - alignment_values=nothing, - order_val=nothing, - simdlen=nothing, - safelen=nothing, - inclusive=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - lowerBound..., upperBound..., step..., aligned_vars..., nontemporal_vars... - ] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(if_expr) && push!(_operands, if_expr) - push!( - _attributes, - operandsegmentsizes([ - length(lowerBound), - length(upperBound), - length(step), - length(aligned_vars), - isnothing(if_expr) ? 0 : 1, - length(nontemporal_vars), - ]), - ) - !isnothing(alignment_values) && - push!(_attributes, namedattribute("alignment_values", alignment_values)) - !isnothing(order_val) && push!(_attributes, namedattribute("order_val", order_val)) - !isnothing(simdlen) && push!(_attributes, namedattribute("simdlen", simdlen)) - !isnothing(safelen) && push!(_attributes, namedattribute("safelen", safelen)) - !isnothing(inclusive) && push!(_attributes, namedattribute("inclusive", inclusive)) - - return IR.create_operation( - "omp.simdloop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function simdloop(lowerBound, upperBound, step, aligned_vars, if_expr=nothing; nontemporal_vars, alignment_values=nothing, order_val=nothing, simdlen=nothing, safelen=nothing, inclusive=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(aligned_vars)..., value.(nontemporal_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(aligned_vars), (if_expr==nothing) ? 0 : 1length(nontemporal_vars), ])) + !isnothing(alignment_values) && push!(attributes, namedattribute("alignment_values", alignment_values)) + !isnothing(order_val) && push!(attributes, namedattribute("order_val", order_val)) + !isnothing(simdlen) && push!(attributes, namedattribute("simdlen", simdlen)) + !isnothing(safelen) && push!(attributes, namedattribute("safelen", safelen)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + + IR.create_operation( + "omp.simdloop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -826,32 +690,20 @@ master thread), in the context of its implicit task. The other threads in the team, which do not execute the block, wait at an implicit barrier at the end of the single construct unless a nowait clause is specified. """ -function single( - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}; - nowait=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[allocate_vars..., allocators_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, operandsegmentsizes([length(allocate_vars), length(allocators_vars)]) - ) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.single", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function single(allocate_vars, allocators_vars; nowait=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(allocate_vars), length(allocators_vars), ])) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.single", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -875,45 +727,24 @@ even if the target task is not yet completed. TODO: is_device_ptr, depend, defaultmap, in_reduction """ -function target( - if_expr=nothing::Union{Nothing,Value}; - device=nothing::Union{Nothing,Value}, - thread_limit=nothing::Union{Nothing,Value}, - map_operands::Vector{Value}, - nowait=nothing, - map_types=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[map_operands...,] - _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([ - isnothing(if_expr) ? 0 : 1, - isnothing(device) ? 0 : 1, - isnothing(thread_limit) ? 0 : 1, - length(map_operands), - ]), - ) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - !isnothing(map_types) && push!(_attributes, namedattribute("map_types", map_types)) - - return IR.create_operation( - "omp.target", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function target(if_expr=nothing; device=nothing, thread_limit=nothing, map_operands, nowait=nothing, map_types=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(map_operands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(device) && push!(operands, value(device)) + !isnothing(thread_limit) && push!(operands, value(thread_limit)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1(thread_limit==nothing) ? 0 : 1length(map_operands), ])) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(map_types) && push!(attributes, namedattribute("map_types", map_types)) + + IR.create_operation( + "omp.target", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -948,43 +779,21 @@ The \$map_types specifies the types and modifiers for the map clause. TODO: depend clause and map_type_modifier values iterator and mapper. """ -function target_data( - if_expr=nothing::Union{Nothing,Value}; - device=nothing::Union{Nothing,Value}, - use_device_ptr::Vector{Value}, - use_device_addr::Vector{Value}, - map_operands::Vector{Value}, - map_types, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[use_device_ptr..., use_device_addr..., map_operands...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map_types", map_types),] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(device) && push!(_operands, device) - push!( - _attributes, - operandsegmentsizes([ - isnothing(if_expr) ? 0 : 1, - isnothing(device) ? 0 : 1, - length(use_device_ptr), - length(use_device_addr), - length(map_operands), - ]), - ) - - return IR.create_operation( - "omp.target_data", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function target_data(if_expr=nothing; device=nothing, use_device_ptr, use_device_addr, map_operands, map_types, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(use_device_ptr)..., value.(use_device_addr)..., value.(map_operands)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("map_types", map_types), ] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(device) && push!(operands, value(device)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1length(use_device_ptr), length(use_device_addr), length(map_operands), ])) + + IR.create_operation( + "omp.target_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1012,38 +821,22 @@ The \$map_types specifies the types and modifiers for the map clause. TODO: depend clause and map_type_modifier values iterator and mapper. """ -function target_enter_data( - if_expr=nothing::Union{Nothing,Value}; - device=nothing::Union{Nothing,Value}, - map_operands::Vector{Value}, - nowait=nothing, - map_types, - location=Location(), -) - _results = IR.Type[] - _operands = Value[map_operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map_types", map_types),] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(device) && push!(_operands, device) - push!( - _attributes, - operandsegmentsizes([ - isnothing(if_expr) ? 0 : 1, isnothing(device) ? 0 : 1, length(map_operands) - ]), - ) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.target_enter_data", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function target_enter_data(if_expr=nothing; device=nothing, map_operands, nowait=nothing, map_types, location=Location()) + results = IR.Type[] + operands = Value[value.(map_operands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map_types", map_types), ] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(device) && push!(operands, value(device)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1length(map_operands), ])) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.target_enter_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1071,38 +864,22 @@ The \$map_types specifies the types and modifiers for the map clause. TODO: depend clause and map_type_modifier values iterator and mapper. """ -function target_exit_data( - if_expr=nothing::Union{Nothing,Value}; - device=nothing::Union{Nothing,Value}, - map_operands::Vector{Value}, - nowait=nothing, - map_types, - location=Location(), -) - _results = IR.Type[] - _operands = Value[map_operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("map_types", map_types),] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(device) && push!(_operands, device) - push!( - _attributes, - operandsegmentsizes([ - isnothing(if_expr) ? 0 : 1, isnothing(device) ? 0 : 1, length(map_operands) - ]), - ) - !isnothing(nowait) && push!(_attributes, namedattribute("nowait", nowait)) - - return IR.create_operation( - "omp.target_exit_data", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function target_exit_data(if_expr=nothing; device=nothing, map_operands, nowait=nothing, map_types, location=Location()) + results = IR.Type[] + operands = Value[value.(map_operands)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("map_types", map_types), ] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(device) && push!(operands, value(device)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(device==nothing) ? 0 : 1length(map_operands), ])) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + + IR.create_operation( + "omp.target_exit_data", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1130,37 +907,20 @@ The `allocators_vars` and `allocate_vars` arguments are a variadic list of values that specify the memory allocator to be used to obtain storage for private values. """ -function taskgroup( - task_reduction_vars::Vector{Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}; - task_reductions=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[task_reduction_vars..., allocate_vars..., allocators_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - length(task_reduction_vars), length(allocate_vars), length(allocators_vars) - ]), - ) - !isnothing(task_reductions) && - push!(_attributes, namedattribute("task_reductions", task_reductions)) - - return IR.create_operation( - "omp.taskgroup", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function taskgroup(task_reduction_vars, allocate_vars, allocators_vars; task_reductions=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(task_reduction_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([length(task_reduction_vars), length(allocate_vars), length(allocators_vars), ])) + !isnothing(task_reductions) && push!(attributes, namedattribute("task_reductions", task_reductions)) + + IR.create_operation( + "omp.taskgroup", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1262,80 +1022,30 @@ construct. Thus, the taskloop construct creates an implicit taskgroup region. If the `nogroup` clause is present, no implicit taskgroup region is created. """ -function taskloop( - lowerBound::Vector{Value}, - upperBound::Vector{Value}, - step::Vector{Value}, - if_expr=nothing::Union{Nothing,Value}; - final_expr=nothing::Union{Nothing,Value}, - in_reduction_vars::Vector{Value}, - reduction_vars::Vector{Value}, - priority=nothing::Union{Nothing,Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}, - grain_size=nothing::Union{Nothing,Value}, - num_tasks=nothing::Union{Nothing,Value}, - inclusive=nothing, - untied=nothing, - mergeable=nothing, - in_reductions=nothing, - reductions=nothing, - nogroup=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - lowerBound..., - upperBound..., - step..., - in_reduction_vars..., - reduction_vars..., - allocate_vars..., - allocators_vars..., - ] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(final_expr) && push!(_operands, final_expr) - !isnothing(priority) && push!(_operands, priority) - !isnothing(grain_size) && push!(_operands, grain_size) - !isnothing(num_tasks) && push!(_operands, num_tasks) - push!( - _attributes, - operandsegmentsizes([ - length(lowerBound), - length(upperBound), - length(step), - isnothing(if_expr) ? 0 : 1, - isnothing(final_expr) ? 0 : 1, - length(in_reduction_vars), - length(reduction_vars), - isnothing(priority) ? 0 : 1, - length(allocate_vars), - length(allocators_vars), - isnothing(grain_size) ? 0 : 1, - isnothing(num_tasks) ? 0 : 1, - ]), - ) - !isnothing(inclusive) && push!(_attributes, namedattribute("inclusive", inclusive)) - !isnothing(untied) && push!(_attributes, namedattribute("untied", untied)) - !isnothing(mergeable) && push!(_attributes, namedattribute("mergeable", mergeable)) - !isnothing(in_reductions) && - push!(_attributes, namedattribute("in_reductions", in_reductions)) - !isnothing(reductions) && push!(_attributes, namedattribute("reductions", reductions)) - !isnothing(nogroup) && push!(_attributes, namedattribute("nogroup", nogroup)) - - return IR.create_operation( - "omp.taskloop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function taskloop(lowerBound, upperBound, step, if_expr=nothing; final_expr=nothing, in_reduction_vars, reduction_vars, priority=nothing, allocate_vars, allocators_vars, grain_size=nothing, num_tasks=nothing, inclusive=nothing, untied=nothing, mergeable=nothing, in_reductions=nothing, reductions=nothing, nogroup=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(in_reduction_vars)..., value.(reduction_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(final_expr) && push!(operands, value(final_expr)) + !isnothing(priority) && push!(operands, value(priority)) + !isnothing(grain_size) && push!(operands, value(grain_size)) + !isnothing(num_tasks) && push!(operands, value(num_tasks)) + push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), (if_expr==nothing) ? 0 : 1(final_expr==nothing) ? 0 : 1length(in_reduction_vars), length(reduction_vars), (priority==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), (grain_size==nothing) ? 0 : 1(num_tasks==nothing) ? 0 : 1])) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + !isnothing(untied) && push!(attributes, namedattribute("untied", untied)) + !isnothing(mergeable) && push!(attributes, namedattribute("mergeable", mergeable)) + !isnothing(in_reductions) && push!(attributes, namedattribute("in_reductions", in_reductions)) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(nogroup) && push!(attributes, namedattribute("nogroup", nogroup)) + + IR.create_operation( + "omp.taskloop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1385,58 +1095,26 @@ The `allocators_vars` and `allocate_vars` arguments are a variadic list of values that specify the memory allocator to be used to obtain storage for private values. """ -function task( - if_expr=nothing::Union{Nothing,Value}; - final_expr=nothing::Union{Nothing,Value}, - in_reduction_vars::Vector{Value}, - priority=nothing::Union{Nothing,Value}, - depend_vars::Vector{Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}, - untied=nothing, - mergeable=nothing, - in_reductions=nothing, - depends=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - in_reduction_vars..., depend_vars..., allocate_vars..., allocators_vars... - ] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(final_expr) && push!(_operands, final_expr) - !isnothing(priority) && push!(_operands, priority) - push!( - _attributes, - operandsegmentsizes([ - isnothing(if_expr) ? 0 : 1, - isnothing(final_expr) ? 0 : 1, - length(in_reduction_vars), - isnothing(priority) ? 0 : 1, - length(depend_vars), - length(allocate_vars), - length(allocators_vars), - ]), - ) - !isnothing(untied) && push!(_attributes, namedattribute("untied", untied)) - !isnothing(mergeable) && push!(_attributes, namedattribute("mergeable", mergeable)) - !isnothing(in_reductions) && - push!(_attributes, namedattribute("in_reductions", in_reductions)) - !isnothing(depends) && push!(_attributes, namedattribute("depends", depends)) - - return IR.create_operation( - "omp.task", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function task(if_expr=nothing; final_expr=nothing, in_reduction_vars, priority=nothing, depend_vars, allocate_vars, allocators_vars, untied=nothing, mergeable=nothing, in_reductions=nothing, depends=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(in_reduction_vars)..., value.(depend_vars)..., value.(allocate_vars)..., value.(allocators_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(final_expr) && push!(operands, value(final_expr)) + !isnothing(priority) && push!(operands, value(priority)) + push!(attributes, operandsegmentsizes([(if_expr==nothing) ? 0 : 1(final_expr==nothing) ? 0 : 1length(in_reduction_vars), (priority==nothing) ? 0 : 1length(depend_vars), length(allocate_vars), length(allocators_vars), ])) + !isnothing(untied) && push!(attributes, namedattribute("untied", untied)) + !isnothing(mergeable) && push!(attributes, namedattribute("mergeable", mergeable)) + !isnothing(in_reductions) && push!(attributes, namedattribute("in_reductions", in_reductions)) + !isnothing(depends) && push!(attributes, namedattribute("depends", depends)) + + IR.create_operation( + "omp.task", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1512,50 +1190,24 @@ The \$allocators_vars and \$allocate_vars parameters are a variadic list of values that specify the memory allocator to be used to obtain storage for private values. """ -function teams( - num_teams_lower=nothing::Union{Nothing,Value}; - num_teams_upper=nothing::Union{Nothing,Value}, - if_expr=nothing::Union{Nothing,Value}, - thread_limit=nothing::Union{Nothing,Value}, - allocate_vars::Vector{Value}, - allocators_vars::Vector{Value}, - reduction_vars::Vector{Value}, - reductions=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[allocate_vars..., allocators_vars..., reduction_vars...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(num_teams_lower) && push!(_operands, num_teams_lower) - !isnothing(num_teams_upper) && push!(_operands, num_teams_upper) - !isnothing(if_expr) && push!(_operands, if_expr) - !isnothing(thread_limit) && push!(_operands, thread_limit) - push!( - _attributes, - operandsegmentsizes([ - isnothing(num_teams_lower) ? 0 : 1, - isnothing(num_teams_upper) ? 0 : 1, - isnothing(if_expr) ? 0 : 1, - isnothing(thread_limit) ? 0 : 1, - length(allocate_vars), - length(allocators_vars), - length(reduction_vars), - ]), - ) - !isnothing(reductions) && push!(_attributes, namedattribute("reductions", reductions)) - - return IR.create_operation( - "omp.teams", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function teams(num_teams_lower=nothing; num_teams_upper=nothing, if_expr=nothing, thread_limit=nothing, allocate_vars, allocators_vars, reduction_vars, reductions=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(allocate_vars)..., value.(allocators_vars)..., value.(reduction_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(num_teams_lower) && push!(operands, value(num_teams_lower)) + !isnothing(num_teams_upper) && push!(operands, value(num_teams_upper)) + !isnothing(if_expr) && push!(operands, value(if_expr)) + !isnothing(thread_limit) && push!(operands, value(thread_limit)) + push!(attributes, operandsegmentsizes([(num_teams_lower==nothing) ? 0 : 1(num_teams_upper==nothing) ? 0 : 1(if_expr==nothing) ? 0 : 1(thread_limit==nothing) ? 0 : 1length(allocate_vars), length(allocators_vars), length(reduction_vars), ])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + + IR.create_operation( + "omp.teams", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1604,22 +1256,18 @@ this operation. The `sym_addr` refers to the address of the symbol, which is a pointer to the original variable. """ -function threadprivate(sym_addr::Value; tls_addr::IR.Type, location=Location()) - _results = IR.Type[tls_addr,] - _operands = Value[sym_addr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.threadprivate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function threadprivate(sym_addr; tls_addr::IR.Type, location=Location()) + results = IR.Type[tls_addr, ] + operands = Value[value(sym_addr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.threadprivate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1684,72 +1332,28 @@ 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}, - 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, - nowait=nothing, - ordered_val=nothing, - order_val=nothing, - inclusive=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[ - lowerBound..., - upperBound..., - step..., - 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(linear_vars), - length(linear_step_vars), - length(reduction_vars), - isnothing(schedule_chunk_var) ? 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(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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function wsloop(lowerBound, upperBound, step, linear_vars, linear_step_vars, reduction_vars, schedule_chunk_var=nothing; reductions=nothing, schedule_val=nothing, schedule_modifier=nothing, simd_modifier=nothing, nowait=nothing, ordered_val=nothing, order_val=nothing, inclusive=nothing, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(linear_vars)..., value.(linear_step_vars)..., value.(reduction_vars)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(schedule_chunk_var) && push!(operands, value(schedule_chunk_var)) + push!(attributes, operandsegmentsizes([length(lowerBound), length(upperBound), length(step), length(linear_vars), length(linear_step_vars), length(reduction_vars), (schedule_chunk_var==nothing) ? 0 : 1])) + !isnothing(reductions) && push!(attributes, namedattribute("reductions", reductions)) + !isnothing(schedule_val) && push!(attributes, namedattribute("schedule_val", schedule_val)) + !isnothing(schedule_modifier) && push!(attributes, namedattribute("schedule_modifier", schedule_modifier)) + !isnothing(simd_modifier) && push!(attributes, namedattribute("simd_modifier", simd_modifier)) + !isnothing(nowait) && push!(attributes, namedattribute("nowait", nowait)) + !isnothing(ordered_val) && push!(attributes, namedattribute("ordered_val", ordered_val)) + !isnothing(order_val) && push!(attributes, namedattribute("order_val", order_val)) + !isnothing(inclusive) && push!(attributes, namedattribute("inclusive", inclusive)) + + IR.create_operation( + "omp.wsloop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1760,22 +1364,18 @@ end terminates the region. The semantics of how the values are yielded is defined by the parent operation. """ -function yield(results::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "omp.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "omp.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/PDL.jl b/src/Dialects/17/PDL.jl index d819792d..8e458b94 100644 --- a/src/Dialects/17/PDL.jl +++ b/src/Dialects/17/PDL.jl @@ -1,7 +1,6 @@ module pdl -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,22 +17,18 @@ entities. pdl.apply_native_constraint \"myConstraint\"(%input, %attr, %op : !pdl.value, !pdl.attribute, !pdl.operation) ``` """ -function apply_native_constraint(args::Vector{Value}; name, location=Location()) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl.apply_native_constraint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_native_constraint(args; name, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl.apply_native_constraint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -65,24 +60,18 @@ void registerNativeRewrite(PDLPatternModule &pdlModule) { } ``` """ -function apply_native_rewrite( - args::Vector{Value}; results::Vector{IR.Type}, name, location=Location() -) - _results = IR.Type[results...,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl.apply_native_rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_native_rewrite(args; results_::Vector{IR.Type}, name, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl.apply_native_rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -111,29 +100,20 @@ defined within a `pdl.rewrite` region, the constant value must be specified. %attr = pdl.attribute = \"hello\" ``` """ -function attribute( - valueType=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(valueType) && push!(_operands, valueType) - !isnothing(value) && push!(_attributes, namedattribute("value", value)) - - return IR.create_operation( - "pdl.attribute", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function attribute(valueType=nothing; attr::IR.Type, value=nothing, location=Location()) + results = IR.Type[attr, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(valueType) && push!(operands, value(valueType)) + !isnothing(value) && push!(attributes, namedattribute("value", value)) + + IR.create_operation( + "pdl.attribute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -150,22 +130,18 @@ operation correspond with the `eraseOp` method on a `PatternRewriter`. pdl.erase %root ``` """ -function erase(opValue::Value; location=Location()) - _results = IR.Type[] - _operands = Value[opValue,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl.erase", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function erase(opValue; location=Location()) + results = IR.Type[] + operands = Value[value(opValue), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl.erase", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -190,25 +166,19 @@ may partially constrain an operand by specifying an expected value type %operand = pdl.operand : %type ``` """ -function operand( - valueType=nothing::Union{Nothing,Value}; value::IR.Type, location=Location() -) - _results = IR.Type[value,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(valueType) && push!(_operands, valueType) - - return IR.create_operation( - "pdl.operand", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operand(valueType=nothing; value::IR.Type, location=Location()) + results = IR.Type[value, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(valueType) && push!(operands, value(valueType)) + + IR.create_operation( + "pdl.operand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -233,25 +203,19 @@ operands by specifying expected value types (via `pdl.types` operations). %typed_operands = pdl.operands : %types ``` """ -function operands( - valueType=nothing::Union{Nothing,Value}; value::IR.Type, location=Location() -) - _results = IR.Type[value,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(valueType) && push!(_operands, valueType) - - return IR.create_operation( - "pdl.operands", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operands_(valueType=nothing; value::IR.Type, location=Location()) + results = IR.Type[value, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(valueType) && push!(operands, value(valueType)) + + IR.create_operation( + "pdl.operands", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -352,37 +316,20 @@ def MyOp { %op = pdl.operation \"foo.op\" -> (%result, %otherResults : !pdl.type, !pdl.range) ``` """ -function operation( - operandValues::Vector{Value}, - attributeValues::Vector{Value}, - typeValues::Vector{Value}; - op::IR.Type, - opName=nothing, - attributeValueNames, - location=Location(), -) - _results = IR.Type[op,] - _operands = Value[operandValues..., attributeValues..., typeValues...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("attributeValueNames", attributeValueNames),] - push!( - _attributes, - operandsegmentsizes([ - length(operandValues), length(attributeValues), length(typeValues) - ]), - ) - !isnothing(opName) && push!(_attributes, namedattribute("opName", opName)) - - return IR.create_operation( - "pdl.operation", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function operation(operandValues, attributeValues, typeValues; op::IR.Type, opName=nothing, attributeValueNames, location=Location()) + results = IR.Type[op, ] + operands = Value[value.(operandValues)..., value.(attributeValues)..., value.(typeValues)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("attributeValueNames", attributeValueNames), ] + push!(attributes, operandsegmentsizes([length(operandValues), length(attributeValues), length(typeValues), ])) + !isnothing(opName) && push!(attributes, namedattribute("opName", opName)) + + IR.create_operation( + "pdl.operation", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -457,22 +404,18 @@ determine how to extract the underlying elements. If we can\'t, e.g. if there are multiple sub ranges used for construction, we won\'t be able to determine their sizes during constraint time. """ -function range(arguments::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[arguments...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl.range", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function range(arguments; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl.range", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -501,32 +444,20 @@ pdl.replace %root with (%vals : !pdl.range) pdl.replace %root with %otherOp ``` """ -function replace( - opValue::Value, - replOperation=nothing::Union{Nothing,Value}; - replValues::Vector{Value}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[opValue, replValues...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(replOperation) && push!(_operands, replOperation) - push!( - _attributes, - operandsegmentsizes([1, isnothing(replOperation) ? 0 : 1, length(replValues)]), - ) - - return IR.create_operation( - "pdl.replace", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function replace(opValue, replOperation=nothing; replValues, location=Location()) + results = IR.Type[] + operands = Value[value(opValue), value.(replValues)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(replOperation) && push!(operands, value(replOperation)) + 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 ) end @@ -552,22 +483,18 @@ as defined by the ODS definition of the operation. // the IR snippet, `%pdl_result` would correspond to `%result_1`. ``` """ -function result(parent::Value; val::IR.Type, index, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function result(parent; val::IR.Type, index, location=Location()) + results = IR.Type[val, ] + operands = Value[value(parent), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl.result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -600,23 +527,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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(index) && push!(_attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl.results", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function results_(parent; val::IR.Type, index=nothing, location=Location()) + results = IR.Type[val, ] + operands = Value[value(parent), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl.results", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -659,31 +582,21 @@ pdl.rewrite { } ``` """ -function rewrite( - root=nothing::Union{Nothing,Value}; - externalArgs::Vector{Value}, - name=nothing, - bodyRegion::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[externalArgs...,] - _owned_regions = Region[bodyRegion,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(root) && push!(_operands, root) - push!(_attributes, operandsegmentsizes([isnothing(root) ? 0 : 1, length(externalArgs)])) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "pdl.rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rewrite(root=nothing; externalArgs, name=nothing, bodyRegion::Region, location=Location()) + results = IR.Type[] + operands = Value[value.(externalArgs)..., ] + owned_regions = Region[bodyRegion, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(root) && push!(operands, value(root)) + push!(attributes, operandsegmentsizes([(root==nothing) ? 0 : 1length(externalArgs), ])) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "pdl.rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/PDLInterp.jl b/src/Dialects/17/PDLInterp.jl index 23673f60..a6c76ec9 100644 --- a/src/Dialects/17/PDLInterp.jl +++ b/src/Dialects/17/PDLInterp.jl @@ -1,7 +1,6 @@ module pdl_interp -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -20,24 +19,18 @@ otherwise the false destination is taken. pdl_interp.apply_constraint \"myConstraint\"(%input, %attr, %op : !pdl.value, !pdl.attribute, !pdl.operation) -> ^matchDest, ^failureDest ``` """ -function apply_constraint( - args::Vector{Value}; name, trueDest::Block, falseDest::Block, location=Location() -) - _results = IR.Type[] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.apply_constraint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_constraint(args; name, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.apply_constraint", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -63,24 +56,18 @@ pdl_interp.apply_rewrite \"rewriter\"(%root : !pdl.operation) pdl_interp.apply_rewrite \"rewriter\"(%root : !pdl.operation, %value : !pdl.value) ``` """ -function apply_rewrite( - args::Vector{Value}; results::Vector{IR.Type}, name, location=Location() -) - _results = IR.Type[results...,] - _operands = Value[args...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.apply_rewrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_rewrite(args; results_::Vector{IR.Type}, name, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.apply_rewrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -97,24 +84,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.are_equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function are_equal(lhs, rhs; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.are_equal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -163,24 +144,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_attribute(attribute; constantValue, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(attribute), ] + owned_regions = Region[] + 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 ) end @@ -203,31 +178,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( - inputOp::Value; - count, - compareAtLeast=nothing, - trueDest::Block, - falseDest::Block, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_operand_count(inputOp; count, compareAtLeast=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -244,24 +207,18 @@ destination, otherwise the false destination is taken. pdl_interp.check_operation_name of %op is \"foo.op\" -> ^matchDest, ^failureDest ``` """ -function check_operation_name( - inputOp::Value; name, trueDest::Block, falseDest::Block, location=Location() -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.check_operation_name", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_operation_name(inputOp; name, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -284,31 +241,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( - inputOp::Value; - count, - compareAtLeast=nothing, - trueDest::Block, - falseDest::Block, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_result_count(inputOp; count, compareAtLeast=nothing, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -325,24 +270,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_type(value; type, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -359,24 +298,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function check_types(value; types, trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -462,42 +395,20 @@ to this operation. %op = pdl_interp.create_operation \"foo.op\"(%arg0 : !pdl.value) {\"attrA\" = %attr0} -> ``` """ -function create_operation( - inputOperands::Vector{Value}, - inputAttributes::Vector{Value}, - inputResultTypes::Vector{Value}; - resultOp::IR.Type, - name, - inputAttributeNames, - inferredResultTypes=nothing, - location=Location(), -) - _results = IR.Type[resultOp,] - _operands = Value[inputOperands..., inputAttributes..., inputResultTypes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("name", name), - namedattribute("inputAttributeNames", inputAttributeNames), - ] - push!( - _attributes, - operandsegmentsizes([ - length(inputOperands), length(inputAttributes), length(inputResultTypes) - ]), - ) - !isnothing(inferredResultTypes) && - push!(_attributes, namedattribute("inferredResultTypes", inferredResultTypes)) - - return IR.create_operation( - "pdl_interp.create_operation", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_operation(inputOperands, inputAttributes, inputResultTypes; resultOp::IR.Type, name, inputAttributeNames, inferredResultTypes=nothing, location=Location()) + results = IR.Type[resultOp, ] + operands = Value[value.(inputOperands)..., value.(inputAttributes)..., value.(inputResultTypes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), namedattribute("inputAttributeNames", inputAttributeNames), ] + push!(attributes, operandsegmentsizes([length(inputOperands), length(inputAttributes), length(inputResultTypes), ])) + !isnothing(inferredResultTypes) && push!(attributes, namedattribute("inferredResultTypes", inferredResultTypes)) + + IR.create_operation( + "pdl_interp.create_operation", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -522,22 +433,18 @@ or `!pdl.range` entities. %valueRange = pdl_interp.create_range : !pdl.range ``` """ -function create_range(arguments::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[arguments...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.create_range", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_range(arguments; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.create_range", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -616,22 +523,18 @@ marked as erased. The semantics of this operation correspond with the pdl_interp.erase %root ``` """ -function erase(inputOp::Value; location=Location()) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.erase", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function erase(inputOp; location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.erase", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -648,22 +551,18 @@ at the specified index. If the index is out of range, returns null. %ops = pdl_interp.extract 1 of %values : !pdl.value ``` """ -function extract(range::Value; result::IR.Type, index, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract(range; result::IR.Type, index, location=Location()) + results = IR.Type[result, ] + operands = Value[value(range), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.extract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -717,22 +616,18 @@ pdl_interp.foreach %op : !pdl.operation in %ops { } -> ^next ``` """ -function foreach(values::Value; region::Region, successor::Block, location=Location()) - _results = IR.Type[] - _operands = Value[values,] - _owned_regions = Region[region,] - _successors = Block[successor,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.foreach", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach(values; region::Region, successor::Block, location=Location()) + results = IR.Type[] + operands = Value[value(values), ] + owned_regions = Region[region, ] + successors = Block[successor, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.foreach", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -797,22 +692,18 @@ returned. %attr = pdl_interp.get_attribute \"attr\" of %op ``` """ -function get_attribute(inputOp::Value; attribute::IR.Type, name, location=Location()) - _results = IR.Type[attribute,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - - return IR.create_operation( - "pdl_interp.get_attribute", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_attribute(inputOp; attribute::IR.Type, name, location=Location()) + results = IR.Type[attribute, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + + IR.create_operation( + "pdl_interp.get_attribute", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -828,22 +719,18 @@ specific attribute. %type = pdl_interp.get_attribute_type of %attr ``` """ -function get_attribute_type(value::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_attribute_type(value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_attribute_type", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -861,22 +748,18 @@ or range of operand results, null is returned. %op = pdl_interp.get_defining_op of %value : !pdl.value ``` """ -function get_defining_op(value::Value; inputOp::IR.Type, location=Location()) - _results = IR.Type[inputOp,] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.get_defining_op", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_defining_op(value; inputOp::IR.Type, location=Location()) + results = IR.Type[inputOp, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_defining_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -893,22 +776,18 @@ null value is returned. %operand = pdl_interp.get_operand 1 of %op ``` """ -function get_operand(inputOp::Value; value::IR.Type, index, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("index", index),] - - return IR.create_operation( - "pdl_interp.get_operand", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_operand(inputOp; value::IR.Type, index, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.get_operand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -935,23 +814,19 @@ the returned operand group corresponds to all operands of the operation. %operands = pdl_interp.get_operands of %op : !pdl.range ``` """ -function get_operands(inputOp::Value; value::IR.Type, index=nothing, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(index) && push!(_attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl_interp.get_operands", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_operands(inputOp; value::IR.Type, index=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl_interp.get_operands", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -968,22 +843,18 @@ null value is returned. %result = pdl_interp.get_result 1 of %op ``` """ -function get_result(inputOp::Value; value::IR.Type, index, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("index", index),] - - return IR.create_operation( - "pdl_interp.get_result", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_result(inputOp; value::IR.Type, index, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("index", index), ] + + IR.create_operation( + "pdl_interp.get_result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1010,23 +881,19 @@ the returned operand group corresponds to all results of the operation. %results = pdl_interp.get_results of %op : !pdl.range ``` """ -function get_results(inputOp::Value; value::IR.Type, index=nothing, location=Location()) - _results = IR.Type[value,] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(index) && push!(_attributes, namedattribute("index", index)) - - return IR.create_operation( - "pdl_interp.get_results", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_results(inputOp; value::IR.Type, index=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(inputOp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(index) && push!(attributes, namedattribute("index", index)) + + IR.create_operation( + "pdl_interp.get_results", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1047,22 +914,18 @@ similarly to ResultRange::getUsers. %ops = pdl_interp.get_users of %values : !pdl.range ``` """ -function get_users(value::Value; operations::IR.Type, location=Location()) - _results = IR.Type[operations,] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.get_users", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_users(value; operations::IR.Type, location=Location()) + results = IR.Type[operations, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_users", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1082,22 +945,18 @@ value or range thereof. %type = pdl_interp.get_value_type of %values : !pdl.range ``` """ -function get_value_type(value::Value; result::IR.Type, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_value_type(value; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.get_value_type", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1115,22 +974,18 @@ false destination is taken. 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,] - _owned_regions = Region[] - _successors = Block[trueDest, falseDest] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.is_not_null", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function is_not_null(value; trueDest::Block, falseDest::Block, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[trueDest, falseDest, ] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.is_not_null", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1149,37 +1004,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(), -) - _results = IR.Type[] - _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)])) - !isnothing(rootKind) && push!(_attributes, namedattribute("rootKind", rootKind)) - !isnothing(generatedOps) && - push!(_attributes, namedattribute("generatedOps", generatedOps)) - - return IR.create_operation( - "pdl_interp.record_match", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function record_match(inputs, matchedOps; rewriter, rootKind=nothing, generatedOps=nothing, benefit, dest::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(inputs)..., value.(matchedOps)..., ] + owned_regions = Region[] + 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)) + + IR.create_operation( + "pdl_interp.record_match", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1198,22 +1037,18 @@ values must match the number of results specified by the operation. pdl_interp.replace %root with (%val0, %val1 : !pdl.type, !pdl.type) ``` """ -function replace(inputOp::Value, replValues::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[inputOp, replValues...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "pdl_interp.replace", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function replace(inputOp, replValues; location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), value.(replValues)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "pdl_interp.replace", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1231,28 +1066,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_attribute(attribute; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(attribute), ] + owned_regions = Region[] + 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 ) end @@ -1270,28 +1095,18 @@ otherwise the default destination is taken. pdl_interp.switch_operand_count of %op to [10, 2] -> ^10Dest, ^2Dest, ^defaultDest ``` """ -function switch_operand_count( - inputOp::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[defaultDest, cases...] - _attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_operand_count", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_operand_count(inputOp; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -1309,28 +1124,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( - inputOp::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[defaultDest, cases...] - _attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_operation_name", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_operation_name(inputOp; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -1348,28 +1153,18 @@ otherwise the default destination is taken. pdl_interp.switch_result_count of %op to [0, 2](^0Dest, ^2Dest) -> ^defaultDest ``` """ -function switch_result_count( - inputOp::Value; - caseValues, - defaultDest::Block, - cases::Vector{Block}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[inputOp,] - _owned_regions = Region[] - _successors = Block[defaultDest, cases...] - _attributes = NamedAttribute[namedattribute("caseValues", caseValues),] - - return IR.create_operation( - "pdl_interp.switch_result_count", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_result_count(inputOp; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(inputOp), ] + owned_regions = Region[] + 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 ) end @@ -1387,24 +1182,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_type(value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end @@ -1422,24 +1211,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function switch_types(value; caseValues, defaultDest::Block, cases::Vector{Block}, location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + 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 ) end diff --git a/src/Dialects/17/Quant.jl b/src/Dialects/17/Quant.jl index 623de142..682ed123 100644 --- a/src/Dialects/17/Quant.jl +++ b/src/Dialects/17/Quant.jl @@ -1,7 +1,6 @@ module quant -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,22 +17,18 @@ Especially early in transformation, it is common to have `dcast`s on all operands to ops that must operate with the expressed type (typically math ops prior to lowering to target-specific, quantized kernels). """ -function dcast(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.dcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function dcast(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.dcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -61,22 +56,18 @@ required. In addition, it is also common to have an identity `qcast` it is legal to use a quantized representation (but is not known to be acceptable). """ -function qcast(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.qcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function qcast(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.qcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -101,22 +92,18 @@ tensor<4xi8> -> tensor<4x!quant<\"uniform[i8:f32]{1.0}\">> vector<4xi8> -> vector<4x!quant<\"uniform[i8:f32]{1.0}\">> ``` """ -function scast(arg::Value; res::IR.Type, location=Location()) - _results = IR.Type[res,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "quant.scast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scast(arg; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "quant.scast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/SCF.jl b/src/Dialects/17/SCF.jl index 3e6c060b..c565401a 100644 --- a/src/Dialects/17/SCF.jl +++ b/src/Dialects/17/SCF.jl @@ -1,7 +1,6 @@ module scf -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -12,22 +11,18 @@ of the `scf.while` construct. If its first argument is true, the \"after\" region of `scf.while` is executed, with the remaining arguments forwarded 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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.condition", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function condition(condition, args; location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(args)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.condition", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -185,30 +180,18 @@ func.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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function for_(lowerBound, upperBound, step, initArgs; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(lowerBound), value(upperBound), value(step), value.(initArgs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -374,50 +357,20 @@ Example with privatized tensors: } ``` """ -function forall( - dynamicLowerBound::Vector{Value}, - dynamicUpperBound::Vector{Value}, - dynamicStep::Vector{Value}, - outputs::Vector{Value}; - results::Vector{IR.Type}, - staticLowerBound, - staticUpperBound, - staticStep, - mapping=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[ - dynamicLowerBound..., dynamicUpperBound..., dynamicStep..., outputs... - ] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("staticLowerBound", staticLowerBound), - namedattribute("staticUpperBound", staticUpperBound), - namedattribute("staticStep", staticStep), - ] - push!( - _attributes, - operandsegmentsizes([ - length(dynamicLowerBound), - length(dynamicUpperBound), - length(dynamicStep), - length(outputs), - ]), - ) - !isnothing(mapping) && push!(_attributes, namedattribute("mapping", mapping)) - - return IR.create_operation( - "scf.forall", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function forall(dynamicLowerBound, dynamicUpperBound, dynamicStep, outputs; results_::Vector{IR.Type}, staticLowerBound, staticUpperBound, staticStep, mapping=nothing, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(dynamicLowerBound)..., value.(dynamicUpperBound)..., value.(dynamicStep)..., value.(outputs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("staticLowerBound", staticLowerBound), namedattribute("staticUpperBound", staticUpperBound), namedattribute("staticStep", staticStep), ] + push!(attributes, operandsegmentsizes([length(dynamicLowerBound), length(dynamicUpperBound), length(dynamicStep), length(outputs), ])) + !isnothing(mapping) && push!(attributes, namedattribute("mapping", mapping)) + + IR.create_operation( + "scf.forall", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -472,28 +425,18 @@ scf.if %b { The types of the yielded values must match the result types of the `scf.if`. """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function if_(condition; results_::Vector{IR.Type}, thenRegion::Region, elseRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(condition), ] + owned_regions = Region[thenRegion, elseRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -558,29 +501,18 @@ default { } ``` """ -function index_switch( - arg::Value; - results::Vector{IR.Type}, - cases, - defaultRegion::Region, - caseRegions::Vector{Region}, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[arg,] - _owned_regions = Region[defaultRegion, caseRegions...] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("cases", cases),] - - return IR.create_operation( - "scf.index_switch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function index_switch(arg; results_::Vector{IR.Type}, cases, defaultRegion::Region, caseRegions::Vector{Region}, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(arg), ] + owned_regions = Region[defaultRegion, caseRegions..., ] + successors = Block[] + attributes = NamedAttribute[namedattribute("cases", cases), ] + + IR.create_operation( + "scf.index_switch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -630,36 +562,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,] - _successors = Block[] - _attributes = NamedAttribute[] - push!( - _attributes, - operandsegmentsizes([ - length(lowerBound), length(upperBound), length(step), length(initVals) - ]), - ) - - return IR.create_operation( - "scf.parallel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel(lowerBound, upperBound, step, initVals; results_::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(lowerBound)..., value.(upperBound)..., value.(step)..., value.(initVals)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + 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 ) end @@ -699,22 +614,18 @@ scf.reduce(%operand) : f32 { } ``` """ -function reduce(operand::Value; reductionOperator::Region, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[reductionOperator,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce(operand; reductionOperator::Region, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[reductionOperator, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.reduce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -729,22 +640,18 @@ the operand of \"scf.reduce\". Example for the custom format: scf.reduce.return %res : f32 ``` """ -function reduce_return(result::Value; location=Location()) - _results = IR.Type[] - _operands = Value[result,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.reduce.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce_return(result; location=Location()) + results = IR.Type[] + operands = Value[value(result), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.reduce.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -862,28 +769,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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.while", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function while_(inits; results_::Vector{IR.Type}, before::Region, after::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(inits)..., ] + owned_regions = Region[before, after, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.while", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -900,22 +797,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()) - _results = IR.Type[] - _operands = Value[results...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "scf.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(results_; location=Location()) + results = IR.Type[] + operands = Value[value.(results_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "scf.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/SPIRV.jl b/src/Dialects/17/SPIRV.jl index 25983e40..27f9f1b0 100644 --- a/src/Dialects/17/SPIRV.jl +++ b/src/Dialects/17/SPIRV.jl @@ -1,7 +1,6 @@ module spirv -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -46,24 +45,18 @@ access-chain-op ::= ssa-id `=` `spirv.AccessChain` ssa-use %3 = spirv.Load \"Function\" %2 [\"Volatile\"] : !spirv.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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.AccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AccessChain(base_ptr, indices; component_ptr::IR.Type, location=Location()) + results = IR.Type[component_ptr, ] + operands = Value[value(base_ptr), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.AccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -147,31 +140,18 @@ atomic-and-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicAnd(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicAnd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -221,35 +201,18 @@ atomic-compare-exchange-op ::= : !spirv.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] - _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( - "spirv.AtomicCompareExchange", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicCompareExchange(pointer, value, comparator; result::IR.Type, memory_scope, equal_semantics, unequal_semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), value(comparator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("equal_semantics", equal_semantics), namedattribute("unequal_semantics", unequal_semantics), ] + + IR.create_operation( + "spirv.AtomicCompareExchange", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -277,35 +240,18 @@ atomic-compare-exchange-weak-op ::= : !spirv.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] - _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( - "spirv.AtomicCompareExchangeWeak", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicCompareExchangeWeak(pointer, value, comparator; result::IR.Type, memory_scope, equal_semantics, unequal_semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), value(comparator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("equal_semantics", equal_semantics), namedattribute("unequal_semantics", unequal_semantics), ] + + IR.create_operation( + "spirv.AtomicCompareExchangeWeak", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -342,31 +288,18 @@ atomic-exchange-op ::= : !spirv.ptr ``` """ -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( - "spirv.AtomicExchange", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicExchange(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicExchange", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -403,31 +336,18 @@ atomic-iadd-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicIAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIAdd(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicIAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -463,26 +383,18 @@ atomic-idecrement-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicIDecrement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIDecrement(pointer; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicIDecrement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -517,26 +429,18 @@ atomic-iincrement-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicIIncrement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicIIncrement(pointer; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicIIncrement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -574,31 +478,18 @@ atomic-isub-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicISub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicISub(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicISub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -635,31 +526,18 @@ atomic-or-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicOr(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicOr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -697,31 +575,18 @@ atomic-smax-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicSMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicSMax(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicSMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -759,31 +624,18 @@ atomic-smin-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicSMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicSMin(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicSMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -821,31 +673,18 @@ atomic-umax-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicUMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicUMax(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicUMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -883,31 +722,18 @@ atomic-umin-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicUMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicUMin(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicUMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -945,31 +771,18 @@ atomic-xor-op ::= !spirv.ptr ``` """ -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( - "spirv.AtomicXor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function AtomicXor(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.AtomicXor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1005,25 +818,19 @@ Results are computed per component. %3 = spirv.BitCount %1: vector<4xi32> ``` """ -function BitCount( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitCount", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitCount(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitCount", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1069,30 +876,19 @@ The type of Base and Insert must be the same as Result Type. %0 = spirv.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(), -) - _results = IR.Type[] - _operands = Value[base, insert, offset, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitFieldInsert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldInsert(base, insert, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(insert), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitFieldInsert", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1138,29 +934,19 @@ The type of Base must be the same as Result Type. %0 = spirv.BitFieldSExtract %base, %offset, %count : vector<3xi32>, i8, i8 ``` """ -function BitFieldSExtract( - base::Value, - offset::Value, - count::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[base, offset, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitFieldSExtract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldSExtract(base, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitFieldSExtract", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1188,29 +974,19 @@ bitfield-extract-u-op ::= ssa-id `=` `spirv.BitFieldUExtract` ssa-use %0 = spirv.BitFieldUExtract %base, %offset, %count : vector<3xi32>, i8, i8 ``` """ -function BitFieldUExtract( - base::Value, - offset::Value, - count::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[base, offset, count] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitFieldUExtract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitFieldUExtract(base, offset, count; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(base), value(offset), value(count), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitFieldUExtract", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1242,25 +1018,19 @@ The type of Base must be the same as Result Type. %3 = spirv.BitReverse %1 : vector<4xi32> ``` """ -function BitReverse( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitReverse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitReverse(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitReverse", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1303,22 +1073,18 @@ bitcast-op ::= ssa-id `=` `spirv.Bitcast` ssa-use %1 = spirv.Bitcast %0 : !spirv.ptr to !spirv.ptr ``` """ -function Bitcast(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.Bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Bitcast(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1348,28 +1114,19 @@ Results are computed per component, and within each component, per bit. %2 = spirv.BitwiseAnd %0, %1 : vector<4xi32> ``` """ -function BitwiseAnd( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitwiseAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseAnd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitwiseAnd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1399,28 +1156,19 @@ Results are computed per component, and within each component, per bit. %2 = spirv.BitwiseOr %0, %1 : vector<4xi32> ``` """ -function BitwiseOr( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitwiseOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseOr(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitwiseOr", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1450,28 +1198,19 @@ Results are computed per component, and within each component, per bit. %2 = spirv.BitwiseXor %0, %1 : vector<4xi32> ``` """ -function BitwiseXor( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.BitwiseXor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function BitwiseXor(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.BitwiseXor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1509,36 +1248,20 @@ spirv.BranchConditional %condition, ^true_branch, ^false_branch spirv.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(), -) - _results = IR.Type[] - _operands = Value[condition, trueTargetOperands..., falseTargetOperands...] - _owned_regions = Region[] - _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( - "spirv.BranchConditional", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function BranchConditional(condition, trueTargetOperands, falseTargetOperands; branch_weights=nothing, trueTarget::Block, falseTarget::Block, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value.(trueTargetOperands)..., value.(falseTargetOperands)..., ] + owned_regions = Region[] + successors = Block[trueTarget, falseTarget, ] + attributes = NamedAttribute[] + push!(attributes, operandsegmentsizes([1, length(trueTargetOperands), length(falseTargetOperands), ])) + !isnothing(branch_weights) && push!(attributes, namedattribute("branch_weights", branch_weights)) + + IR.create_operation( + "spirv.BranchConditional", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1562,22 +1285,18 @@ spirv.Branch ^target spirv.Branch ^target(%0, %1: i32, f32) ``` """ -function Branch(targetOperands::Vector{Value}; target::Block, location=Location()) - _results = IR.Type[] - _operands = Value[targetOperands...,] - _owned_regions = Region[] - _successors = Block[target,] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.Branch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Branch(targetOperands; target::Block, location=Location()) + results = IR.Type[] + operands = Value[value.(targetOperands)..., ] + owned_regions = Region[] + successors = Block[target, ] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Branch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1606,25 +1325,19 @@ ceil-op ::= ssa-id `=` `spirv.CL.ceil` ssa-use `:` %3 = spirv.CL.ceil %1 : vector<3xf16> ``` """ -function CL_ceil( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_ceil(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.ceil", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1653,23 +1366,19 @@ cos-op ::= ssa-id `=` `spirv.CL.cos` ssa-use `:` %3 = spirv.CL.cos %1 : vector<3xf16> ``` """ -function CL_cos(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_cos(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1698,23 +1407,19 @@ erf-op ::= ssa-id `=` `spirv.CL.erf` ssa-use `:` %3 = spirv.CL.erf %1 : vector<3xf16> ``` """ -function CL_erf(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.erf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_erf(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.erf", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1743,23 +1448,19 @@ exp-op ::= ssa-id `=` `spirv.CL.exp` ssa-use `:` %3 = spirv.CL.exp %1 : vector<3xf16> ``` """ -function CL_exp(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_exp(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1788,25 +1489,19 @@ abs-op ::= ssa-id `=` `spirv.CL.fabs` ssa-use `:` %3 = spirv.CL.fabs %1 : vector<3xf16> ``` """ -function CL_fabs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.fabs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_fabs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.fabs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1836,25 +1531,19 @@ fmax-op ::= ssa-id `=` `spirv.CL.fmax` ssa-use `:` %3 = spirv.CL.fmax %0, %1 : vector<3xf16> ``` """ -function CL_fmax( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.fmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_fmax(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.fmax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1883,25 +1572,19 @@ fmin-op ::= ssa-id `=` `spirv.CL.fmin` ssa-use `:` %3 = spirv.CL.fmin %0, %1 : vector<3xf16> ``` """ -function CL_fmin( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.fmin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_fmin(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.fmin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1930,25 +1613,19 @@ floor-op ::= ssa-id `=` `spirv.CL.floor` ssa-use `:` %3 = spirv.CL.ceifloorl %1 : vector<3xf16> ``` """ -function CL_floor( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_floor(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.floor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1975,29 +1652,19 @@ fma-op ::= ssa-id `=` `spirv.CL.fma` ssa-use, ssa-use, ssa-use `:` %1 = spirv.CL.fma %a, %b, %c : vector<3xf16> ``` """ -function CL_fma( - x::Value, - y::Value, - z::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_fma(x, y, z; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.fma", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2026,23 +1693,19 @@ log-op ::= ssa-id `=` `spirv.CL.log` ssa-use `:` %3 = spirv.CL.log %1 : vector<3xf16> ``` """ -function CL_log(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_log(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2072,25 +1735,19 @@ pow-op ::= ssa-id `=` `spirv.CL.pow` ssa-use `:` %3 = spirv.CL.pow %0, %1 : vector<3xf16> ``` """ -function CL_pow( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_pow(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.pow", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2115,24 +1772,18 @@ when the end of the format string is encountered. %0 = spirv.CL.printf %0 %1 %2 : (!spirv.ptr, (i32, i32)) -> i32 ``` """ -function CL_printf( - format::Value, arguments::Vector{Value}; result::IR.Type, location=Location() -) - _results = IR.Type[result,] - _operands = Value[format, arguments...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.CL.printf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CL_printf(format, arguments; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(format), value.(arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.CL.printf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2161,25 +1812,19 @@ rint-op ::= ssa-id `=` `spirv.CL.rint` ssa-use `:` %1 = spirv.CL.rint %1 : vector<3xf16> ``` """ -function CL_rint( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.rint", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_rint(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.rint", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2207,25 +1852,19 @@ round-op ::= ssa-id `=` `spirv.CL.round` ssa-use `:` %3 = spirv.CL.round %0 : vector<3xf16> ``` """ -function CL_round( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_round(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.round", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2254,25 +1893,19 @@ rsqrt-op ::= ssa-id `=` `spirv.CL.rsqrt` ssa-use `:` %3 = spirv.CL.rsqrt %1 : vector<3xf16> ``` """ -function CL_rsqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_rsqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.rsqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2301,25 +1934,19 @@ abs-op ::= ssa-id `=` `spirv.CL.s_abs` ssa-use `:` %3 = spirv.CL.s_abs %1 : vector<3xi16> ``` """ -function CL_s_abs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.s_abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_s_abs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.s_abs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2345,25 +1972,19 @@ smax-op ::= ssa-id `=` `spirv.CL.s_max` ssa-use `:` %3 = spirv.CL.s_max %0, %1 : vector<3xi16> ``` """ -function CL_s_max( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.s_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_s_max(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.s_max", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2389,25 +2010,19 @@ smin-op ::= ssa-id `=` `spirv.CL.s_min` ssa-use `:` %3 = spirv.CL.s_min %0, %1 : vector<3xi16> ``` """ -function CL_s_min( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.s_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_s_min(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.s_min", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2436,23 +2051,19 @@ sin-op ::= ssa-id `=` `spirv.CL.sin` ssa-use `:` %3 = spirv.CL.sin %1 : vector<3xf16> ``` """ -function CL_sin(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_sin(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2481,25 +2092,19 @@ sqrt-op ::= ssa-id `=` `spirv.CL.sqrt` ssa-use `:` %3 = spirv.CL.sqrt %1 : vector<3xf16> ``` """ -function CL_sqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_sqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2528,25 +2133,19 @@ tanh-op ::= ssa-id `=` `spirv.CL.tanh` ssa-use `:` %3 = spirv.CL.tanh %1 : vector<3xf16> ``` """ -function CL_tanh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_tanh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2572,25 +2171,19 @@ umax-op ::= ssa-id `=` `spirv.CL.u_max` ssa-use `:` %3 = spirv.CL.u_max %0, %1 : vector<3xi16> ``` """ -function CL_u_max( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.u_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_u_max(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.u_max", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2616,25 +2209,19 @@ umin-op ::= ssa-id `=` `spirv.CL.u_min` ssa-use `:` %3 = spirv.CL.u_min %0, %1 : vector<3xi16> ``` """ -function CL_u_min( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.CL.u_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function CL_u_min(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.CL.u_min", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -2672,24 +2259,18 @@ composite-construct-op ::= ssa-id `=` `spirv.CompositeConstruct` %0 = spirv.CompositeConstruct %1, %2, %3 : vector<3xf32> ``` """ -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( - "spirv.CompositeConstruct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CompositeConstruct(constituents; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(constituents)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.CompositeConstruct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2722,26 +2303,20 @@ composite-extract-op ::= ssa-id `=` `spirv.CompositeExtract` ssa-use %2 = spirv.CompositeExtract %1[1 : i32] : !spirv.array<4x!spirv.array<4xf32>> ``` """ -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( - "spirv.CompositeExtract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end +function CompositeExtract(composite; component::IR.Type, indices, location=Location()) + results = IR.Type[component, ] + operands = Value[value(composite), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indices", indices), ] + + IR.create_operation( + "spirv.CompositeExtract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `CompositeInsert` @@ -2772,24 +2347,18 @@ composite-insert-op ::= ssa-id `=` `spirv.CompositeInsert` ssa-use, ssa-use %0 = spirv.CompositeInsert %object, %composite[1 : i32] : f32 into !spirv.array<4xf32> ``` """ -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( - "spirv.CompositeInsert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CompositeInsert(object, composite; result::IR.Type, indices, location=Location()) + results = IR.Type[result, ] + operands = Value[value(object), value(composite), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indices", indices), ] + + IR.create_operation( + "spirv.CompositeInsert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2942,22 +2511,18 @@ convert-f-to-s-op ::= ssa-id `=` `spirv.ConvertFToSOp` ssa-use %3 = spirv.ConvertFToS %2 : vector<3xf32> to vector<3xi32> ``` """ -function ConvertFToS(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ConvertFToS", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertFToS(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ConvertFToS", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2986,22 +2551,18 @@ convert-f-to-u-op ::= ssa-id `=` `spirv.ConvertFToUOp` ssa-use %3 = spirv.ConvertFToU %2 : vector<3xf32> to vector<3xi32> ``` """ -function ConvertFToU(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ConvertFToU", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertFToU(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ConvertFToU", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3030,22 +2591,18 @@ ptr-to-u-convert-op ::= ssa-id `=` `spirv.ConvertPtrToUOp` ssa-use %1 = spirv.ConvertPtrToU %0 : !spirv.ptr to i32 ``` """ -function ConvertPtrToU(pointer::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[pointer,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ConvertPtrToU", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertPtrToU(pointer; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ConvertPtrToU", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3073,22 +2630,18 @@ convert-s-to-f-op ::= ssa-id `=` `spirv.ConvertSToFOp` ssa-use %3 = spirv.ConvertSToF %2 : vector<3xi32> to vector<3xf32> ``` """ -function ConvertSToF(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ConvertSToF", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertSToF(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ConvertSToF", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3116,22 +2669,18 @@ convert-u-to-f-op ::= ssa-id `=` `spirv.ConvertUToFOp` ssa-use %3 = spirv.ConvertUToF %2 : vector<3xi32> to vector<3xf32> ``` """ -function ConvertUToF(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ConvertUToF", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertUToF(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ConvertUToF", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3161,22 +2710,18 @@ u-to-ptr-convert-op ::= ssa-id `=` `spirv.ConvertUToPtr` ssa-use %1 = spirv.ConvertUToPtr %0 : i32 to !spirv.ptr ``` """ -function ConvertUToPtr(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ConvertUToPtr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ConvertUToPtr(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ConvertUToPtr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3209,37 +2754,22 @@ copy-memory-op ::= `spirv.CopyMemory ` storage-class ssa-use spirv.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(), -) - _results = IR.Type[] - _operands = Value[target, source] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !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( - "spirv.CopyMemory", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function CopyMemory(target, source; memory_access=nothing, alignment=nothing, source_memory_access=nothing, source_alignment=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(target), value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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)) + + IR.create_operation( + "spirv.CopyMemory", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3281,31 +2811,18 @@ atomic-fadd-op ::= !spirv.ptr ``` """ -function EXT_AtomicFAdd( - 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( - "spirv.EXT.AtomicFAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function EXT_AtomicFAdd(pointer, value; result::IR.Type, memory_scope, semantics, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("memory_scope", memory_scope), namedattribute("semantics", semantics), ] + + IR.create_operation( + "spirv.EXT.AtomicFAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3449,28 +2966,19 @@ fadd-op ::= ssa-id `=` `spirv.FAdd` ssa-use, ssa-use %5 = spirv.FAdd %2, %3 : vector<4xf32> ``` """ -function FAdd( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FAdd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3499,22 +3007,18 @@ f-convert-op ::= ssa-id `=` `spirv.FConvertOp` ssa-use %3 = spirv.FConvertOp %2 : vector<3xf32> to vector<3xf64> ``` """ -function FConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.FConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3544,28 +3048,19 @@ fdiv-op ::= ssa-id `=` `spirv.FDiv` ssa-use, ssa-use %5 = spirv.FDiv %2, %3 : vector<4xf32> ``` """ -function FDiv( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3596,28 +3091,19 @@ fmod-op ::= ssa-id `=` `spirv.FMod` ssa-use, ssa-use %5 = spirv.FMod %2, %3 : vector<4xf32> ``` """ -function FMod( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3647,28 +3133,19 @@ fmul-op ::= `spirv.FMul` ssa-use, ssa-use %5 = spirv.FMul %2, %3 : vector<4xf32> ``` """ -function FMul( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FMul(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3696,25 +3173,19 @@ fmul-op ::= `spirv.FNegate` ssa-use `:` float-scalar-vector-type %3 = spirv.FNegate %2 : vector<4xf32> ``` """ -function FNegate( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FNegate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FNegate(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FNegate", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -3744,28 +3215,18 @@ fordequal-op ::= ssa-id `=` `spirv.FOrdEqual` ssa-use, ssa-use %5 = spirv.FOrdEqual %2, %3 : vector<4xf32> ``` """ -function FOrdEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3795,28 +3256,18 @@ fordgte-op ::= ssa-id `=` `spirv.FOrdGreaterThanEqual` ssa-use, ssa-use %5 = spirv.FOrdGreaterThanEqual %2, %3 : vector<4xf32> ``` """ -function FOrdGreaterThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3846,28 +3297,18 @@ fordgt-op ::= ssa-id `=` `spirv.FOrdGreaterThan` ssa-use, ssa-use %5 = spirv.FOrdGreaterThan %2, %3 : vector<4xf32> ``` """ -function FOrdGreaterThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3897,28 +3338,18 @@ fordlte-op ::= ssa-id `=` `spirv.FOrdLessThanEqual` ssa-use, ssa-use %5 = spirv.FOrdLessThanEqual %2, %3 : vector<4xf32> ``` """ -function FOrdLessThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3948,28 +3379,18 @@ fordlt-op ::= ssa-id `=` `spirv.FOrdLessThan` ssa-use, ssa-use %5 = spirv.FOrdLessThan %2, %3 : vector<4xf32> ``` """ -function FOrdLessThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3999,28 +3420,18 @@ fordneq-op ::= ssa-id `=` `spirv.FOrdNotEqual` ssa-use, ssa-use %5 = spirv.FOrdNotEqual %2, %3 : vector<4xf32> ``` """ -function FOrdNotEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FOrdNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FOrdNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FOrdNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4052,28 +3463,19 @@ frem-op ::= ssa-id `=` `spirv.FRemOp` ssa-use, ssa-use %5 = spirv.FRemOp %2, %3 : vector<4xf32> ``` """ -function FRem( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FRem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FRem(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FRem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4102,28 +3504,19 @@ fsub-op ::= ssa-id `=` `spirv.FRemOp` ssa-use, ssa-use %5 = spirv.FRemOp %2, %3 : vector<4xf32> ``` """ -function FSub( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FSub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FSub(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.FSub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4153,28 +3546,18 @@ funordequal-op ::= ssa-id `=` `spirv.FUnordEqual` ssa-use, ssa-use %5 = spirv.FUnordEqual %2, %3 : vector<4xf32> ``` """ -function FUnordEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4204,28 +3587,18 @@ funordgte-op ::= ssa-id `=` `spirv.FUnordGreaterThanEqual` ssa-use, ssa-use %5 = spirv.FUnordGreaterThanEqual %2, %3 : vector<4xf32> ``` """ -function FUnordGreaterThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4255,28 +3628,18 @@ funordgt-op ::= ssa-id `=` `spirv.FUnordGreaterThan` ssa-use, ssa-use %5 = spirv.FUnordGreaterThan %2, %3 : vector<4xf32> ``` """ -function FUnordGreaterThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4306,28 +3669,18 @@ funordlte-op ::= ssa-id `=` `spirv.FUnordLessThanEqual` ssa-use, ssa-use %5 = spirv.FUnordLessThanEqual %2, %3 : vector<4xf32> ``` """ -function FUnordLessThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4357,28 +3710,18 @@ funordlt-op ::= ssa-id `=` `spirv.FUnordLessThan` ssa-use, ssa-use %5 = spirv.FUnordLessThan %2, %3 : vector<4xf32> ``` """ -function FUnordLessThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4408,28 +3751,18 @@ funordneq-op ::= ssa-id `=` `spirv.FUnordNotEqual` ssa-use, ssa-use %5 = spirv.FUnordNotEqual %2, %3 : vector<4xf32> ``` """ -function FUnordNotEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.FUnordNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function FUnordNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.FUnordNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4528,28 +3861,19 @@ spirv.FunctionCall @f_void(%arg0) : (i32) -> () %0 = spirv.FunctionCall @f_iadd(%arg0, %arg1) : (i32, i32) -> i32 ``` """ -function FunctionCall( - arguments::Vector{Value}; - return_value=nothing::Union{Nothing,IR.Type}, - callee, - location=Location(), -) - _results = IR.Type[] - _operands = Value[arguments...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("callee", callee),] - !isnothing(return_value) && push!(_results, return_value) - - return IR.create_operation( - "spirv.FunctionCall", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function FunctionCall(arguments; return_value=nothing::Union{Nothing, IR.Type}, callee, location=Location()) + results = IR.Type[] + operands = Value[value.(arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("callee", callee), ] + !isnothing(return_value) && push!(results, return_value) + + IR.create_operation( + "spirv.FunctionCall", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4582,25 +3906,19 @@ acos-op ::= ssa-id `=` `spirv.GL.Acos` ssa-use `:` %3 = spirv.GL.Acos %1 : vector<3xf16> ``` """ -function GL_Acos( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Acos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Acos(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Acos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4633,25 +3951,19 @@ asin-op ::= ssa-id `=` `spirv.GL.Asin` ssa-use `:` %3 = spirv.GL.Asin %1 : vector<3xf16> ``` """ -function GL_Asin( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Asin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Asin(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Asin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4684,25 +3996,19 @@ atan-op ::= ssa-id `=` `spirv.GL.Atan` ssa-use `:` %3 = spirv.GL.Atan %1 : vector<3xf16> ``` """ -function GL_Atan( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Atan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Atan(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Atan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4732,25 +4038,19 @@ ceil-op ::= ssa-id `=` `spirv.GL.Ceil` ssa-use `:` %3 = spirv.GL.Ceil %1 : vector<3xf16> ``` """ -function GL_Ceil( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Ceil(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Ceil", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4781,23 +4081,19 @@ cos-op ::= ssa-id `=` `spirv.GL.Cos` ssa-use `:` %3 = spirv.GL.Cos %1 : vector<3xf16> ``` """ -function GL_Cos(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Cos", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Cos(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Cos", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4828,25 +4124,19 @@ cosh-op ::= ssa-id `=` `spirv.GL.Cosh` ssa-use `:` %3 = spirv.GL.Cosh %1 : vector<3xf16> ``` """ -function GL_Cosh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Cosh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Cosh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Cosh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4877,23 +4167,19 @@ exp-op ::= ssa-id `=` `spirv.GL.Exp` ssa-use `:` %3 = spirv.GL.Exp %1 : vector<3xf16> ``` """ -function GL_Exp(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Exp(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Exp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4922,25 +4208,19 @@ abs-op ::= ssa-id `=` `spirv.GL.FAbs` ssa-use `:` %3 = spirv.GL.FAbs %1 : vector<3xf16> ``` """ -function GL_FAbs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FAbs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FAbs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FAbs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -4969,22 +4249,18 @@ fclamp-op ::= ssa-id `=` `spirv.GL.FClamp` ssa-use, ssa-use, ssa-use `:` %3 = spirv.GL.FClamp %x, %min, %max : vector<3xf16> ``` """ -function GL_FClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GL.FClamp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_FClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GL.FClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5014,25 +4290,19 @@ fmax-op ::= ssa-id `=` `spirv.GL.FMax` ssa-use `:` %3 = spirv.GL.FMax %0, %1 : vector<3xf16> ``` """ -function GL_FMax( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FMax(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5062,25 +4332,19 @@ fmin-op ::= ssa-id `=` `spirv.GL.FMin` ssa-use `:` %3 = spirv.GL.FMin %0, %1 : vector<3xf16> ``` """ -function GL_FMin( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FMin(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5102,29 +4366,19 @@ Result Type and the type of all operands must be the same type. Results are comp %0 = spirv.GL.FMix %x : vector<4xf32>, %y : vector<4xf32>, %a : vector<4xf32> -> vector<4xf32> ``` """ -function GL_FMix( - x::Value, - y::Value, - a::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x, y, a] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FMix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FMix(x, y, a; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(y), value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FMix", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5153,25 +4407,19 @@ sign-op ::= ssa-id `=` `spirv.GL.FSign` ssa-use `:` %3 = spirv.GL.FSign %1 : vector<3xf16> ``` """ -function GL_FSign( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FSign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FSign(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FSign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5188,25 +4436,19 @@ computed per component. This instruction is currently limited to 32-bit width components. """ -function GL_FindUMsb( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.FindUMsb", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_FindUMsb(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.FindUMsb", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5232,29 +4474,23 @@ floor-op ::= ssa-id `=` `spirv.GL.Floor` ssa-use `:` #### Example: ```mlir -%2 = spirv.GL.Floor %0 : f32 -%3 = spirv.GL.Floor %1 : vector<3xf16> -``` -""" -function GL_Floor( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +%2 = spirv.GL.Floor %0 : f32 +%3 = spirv.GL.Floor %1 : vector<3xf16> +``` +""" +function GL_Floor(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Floor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5293,22 +4529,18 @@ fma-op ::= ssa-id `=` `spirv.GL.Fma` ssa-use, ssa-use, ssa-use `:` %1 = spirv.GL.Fma %a, %b, %c : vector<3xf16> ``` """ -function GL_Fma(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GL.Fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_Fma(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GL.Fma", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5350,22 +4582,18 @@ frexpstruct-op ::= ssa-id `=` `spirv.GL.FrexpStruct` ssa-use `:` %3 = spirv.GL.FrexpStruct %0 : vector<3xf32> -> !spirv.struct, vector<3xi32>> ``` """ -function GL_FrexpStruct(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GL.FrexpStruct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_FrexpStruct(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GL.FrexpStruct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5394,25 +4622,19 @@ rsqrt-op ::= ssa-id `=` `spirv.GL.InverseSqrt` ssa-use `:` %3 = spirv.GL.InverseSqrt %1 : vector<3xf16> ``` """ -function GL_InverseSqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.InverseSqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_InverseSqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.InverseSqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5450,25 +4672,19 @@ component. %y = spirv.GL.Ldexp %x : vector<3xf32>, %exp : vector<3xi32> -> vector<3xf32> ``` """ -function GL_Ldexp( - x::Value, exp::Value; y=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[x, exp] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(y) && push!(_results, y) - - return IR.create_operation( - "spirv.GL.Ldexp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Ldexp(x, exp; y=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(exp), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(y) && push!(results, y) + + IR.create_operation( + "spirv.GL.Ldexp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5500,23 +4716,19 @@ log-op ::= ssa-id `=` `spirv.GL.Log` ssa-use `:` %3 = spirv.GL.Log %1 : vector<3xf16> ``` """ -function GL_Log(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Log(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Log", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5549,25 +4761,19 @@ pow-op ::= ssa-id `=` `spirv.GL.Pow` ssa-use `:` %3 = spirv.GL.Pow %0, %1 : vector<3xf16> ``` """ -function GL_Pow( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Pow(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Pow", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5598,25 +4804,19 @@ round-even-op ::= ssa-id `=` `spirv.GL.RoundEven` ssa-use `:` %3 = spirv.GL.RoundEven %1 : vector<3xf16> ``` """ -function GL_RoundEven( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.RoundEven", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_RoundEven(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.RoundEven", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5648,25 +4848,19 @@ round-op ::= ssa-id `=` `spirv.GL.Round` ssa-use `:` %3 = spirv.GL.Round %1 : vector<3xf16> ``` """ -function GL_Round( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Round", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Round(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Round", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5694,25 +4888,19 @@ abs-op ::= ssa-id `=` `spirv.GL.SAbs` ssa-use `:` %3 = spirv.GL.SAbs %1 : vector<3xi16> ``` """ -function GL_SAbs( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.SAbs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_SAbs(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.SAbs", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5740,22 +4928,18 @@ uclamp-op ::= ssa-id `=` `spirv.GL.UClamp` ssa-use, ssa-use, ssa-use `:` %3 = spirv.GL.SClamp %x, %min, %max : vector<3xsi16> ``` """ -function GL_SClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GL.SClamp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_SClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GL.SClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5784,25 +4968,19 @@ smax-op ::= ssa-id `=` `spirv.GL.SMax` ssa-use `:` %3 = spirv.GL.SMax %0, %1 : vector<3xi16> ``` """ -function GL_SMax( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.SMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_SMax(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.SMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5831,25 +5009,19 @@ smin-op ::= ssa-id `=` `spirv.GL.SMin` ssa-use `:` %3 = spirv.GL.SMin %0, %1 : vector<3xi16> ``` """ -function GL_SMin( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.SMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_SMin(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.SMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5877,25 +5049,19 @@ sign-op ::= ssa-id `=` `spirv.GL.SSign` ssa-use `:` %3 = spirv.GL.SSign %1 : vector<3xi16> ``` """ -function GL_SSign( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.SSign", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_SSign(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.SSign", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5926,23 +5092,19 @@ sin-op ::= ssa-id `=` `spirv.GL.Sin` ssa-use `:` %3 = spirv.GL.Sin %1 : vector<3xf16> ``` """ -function GL_Sin(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Sin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Sin(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Sin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5973,25 +5135,19 @@ sinh-op ::= ssa-id `=` `spirv.GL.Sinh` ssa-use `:` %3 = spirv.GL.Sinh %1 : vector<3xf16> ``` """ -function GL_Sinh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Sinh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Sinh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Sinh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6020,25 +5176,19 @@ sqrt-op ::= ssa-id `=` `spirv.GL.Sqrt` ssa-use `:` %3 = spirv.GL.Sqrt %1 : vector<3xf16> ``` """ -function GL_Sqrt( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Sqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Sqrt(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Sqrt", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6062,30 +5212,26 @@ restricted-float-scalar-vector-type ::= tan-op ::= ssa-id `=` `spirv.GL.Tan` ssa-use `:` restricted-float-scalar-vector-type ``` -#### Example: - -```mlir -%2 = spirv.GL.Tan %0 : f32 -%3 = spirv.GL.Tan %1 : vector<3xf16> -``` -""" -function GL_Tan(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Tan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +#### Example: + +```mlir +%2 = spirv.GL.Tan %0 : f32 +%3 = spirv.GL.Tan %1 : vector<3xf16> +``` +""" +function GL_Tan(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Tan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6116,25 +5262,19 @@ tanh-op ::= ssa-id `=` `spirv.GL.Tanh` ssa-use `:` %3 = spirv.GL.Tanh %1 : vector<3xf16> ``` """ -function GL_Tanh( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.Tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_Tanh(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.Tanh", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6162,22 +5302,18 @@ uclamp-op ::= ssa-id `=` `spirv.GL.UClamp` ssa-use, ssa-use, ssa-use `:` %3 = spirv.GL.UClamp %x, %min, %max : vector<3xui16> ``` """ -function GL_UClamp(x::Value, y::Value, z::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[x, y, z] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GL.UClamp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GL_UClamp(x, y, z; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(x), value(y), value(z), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GL.UClamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6206,25 +5342,19 @@ smax-op ::= ssa-id `=` `spirv.GL.UMax` ssa-use `:` %3 = spirv.GL.UMax %0, %1 : vector<3xi16> ``` """ -function GL_UMax( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.UMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_UMax(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.UMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6253,25 +5383,19 @@ smin-op ::= ssa-id `=` `spirv.GL.UMin` ssa-use `:` %3 = spirv.GL.UMin %0, %1 : vector<3xi16> ``` """ -function GL_UMin( - lhs::Value, rhs::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GL.UMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GL_UMin(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GL.UMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6297,22 +5421,18 @@ Workgroup, CrossWorkgroup, or Function. !spirv.ptr ``` """ -function GenericCastToPtrExplicit(pointer::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[pointer,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GenericCastToPtrExplicit", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GenericCastToPtrExplicit(pointer; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GenericCastToPtrExplicit", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6335,22 +5455,18 @@ Result Type and Pointer must point to the same type. !spirv.ptr ``` """ -function GenericCastToPtr(pointer::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[pointer,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.GenericCastToPtr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GenericCastToPtr(pointer; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.GenericCastToPtr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6479,29 +5595,19 @@ group-broadcast-op ::= ssa-id `=` `spirv.GroupBroadcast` scope ssa_use, vector<4xf32>, vector<3xi32> ``` """ -function GroupBroadcast( - value::Value, - localid::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, localid] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupBroadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupBroadcast(value, localid; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(localid), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupBroadcast", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6537,32 +5643,19 @@ op ::= ssa-id `=` `spirv.GroupFAdd` scope operation ssa-use %0 = spirv.GroupFAdd %value : f32 ``` """ -function GroupFAdd( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupFAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupFAdd(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupFAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6598,32 +5691,19 @@ op ::= ssa-id `=` `spirv.GroupFMax` scope operation ssa-use %0 = spirv.GroupFMax %value : f32 ``` """ -function GroupFMax( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupFMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupFMax(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupFMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6659,32 +5739,19 @@ op ::= ssa-id `=` `spirv.GroupFMin` scope operation ssa-use %0 = spirv.GroupFMin %value : f32 ``` """ -function GroupFMin( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupFMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupFMin(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupFMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6721,32 +5788,19 @@ op ::= ssa-id `=` `spirv.KHR.GroupFMul` scope operation ssa-use %0 = spirv.KHR.GroupFMul %value : f32 ``` """ -function KHR_GroupFMul( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.KHR.GroupFMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function KHR_GroupFMul(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.KHR.GroupFMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6782,32 +5836,19 @@ op ::= ssa-id `=` `spirv.GroupIAdd` scope operation ssa-use %0 = spirv.GroupIAdd %value : i32 ``` """ -function GroupIAdd( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupIAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupIAdd(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupIAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6844,32 +5885,19 @@ op ::= ssa-id `=` `spirv.KHR.GroupIMul` scope operation ssa-use %0 = spirv.KHR.GroupIMul %value : i32 ``` """ -function KHR_GroupIMul( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.KHR.GroupIMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function KHR_GroupIMul(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.KHR.GroupIMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -6902,24 +5930,18 @@ non-uniform-ballot-op ::= ssa-id `=` `spirv.GroupNonUniformBallot` scope %0 = spirv.GroupNonUniformBallot \"SubGroup\" %predicate : vector<4xi32> ``` """ -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( - "spirv.GroupNonUniformBallot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformBallot(predicate; result::IR.Type, execution_scope, location=Location()) + results = IR.Type[result, ] + operands = Value[value(predicate), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + + IR.create_operation( + "spirv.GroupNonUniformBallot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -6953,40 +5975,30 @@ group-non-uniform-broadcast-op ::= ssa-id `=` `:` integer-float-scalar-vector-type `,` integer-type ``` -#### Example: - -```mlir -%scalar_value = ... : f32 -%vector_value = ... : vector<4xf32> -%id = ... : i32 -%0 = spirv.GroupNonUniformBroadcast \"Subgroup\" %scalar_value, %id : f32, i32 -%1 = spirv.GroupNonUniformBroadcast \"Workgroup\" %vector_value, %id : - vector<4xf32>, i32 -``` -""" -function GroupNonUniformBroadcast( - value::Value, - id::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, id] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupNonUniformBroadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +#### Example: + +```mlir +%scalar_value = ... : f32 +%vector_value = ... : vector<4xf32> +%id = ... : i32 +%0 = spirv.GroupNonUniformBroadcast \"Subgroup\" %scalar_value, %id : f32, i32 +%1 = spirv.GroupNonUniformBroadcast \"Workgroup\" %vector_value, %id : + vector<4xf32>, i32 +``` +""" +function GroupNonUniformBroadcast(value, id; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(id), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupNonUniformBroadcast", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7075,33 +6087,19 @@ non-uniform-fadd-op ::= ssa-id `=` `spirv.GroupNonUniformFAdd` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformFAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFAdd(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformFAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7150,33 +6148,19 @@ non-uniform-fmax-op ::= ssa-id `=` `spirv.GroupNonUniformFMax` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformFMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformFMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7225,33 +6209,19 @@ non-uniform-fmin-op ::= ssa-id `=` `spirv.GroupNonUniformFMin` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformFMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformFMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7297,33 +6267,19 @@ non-uniform-fmul-op ::= ssa-id `=` `spirv.GroupNonUniformFMul` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformFMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformFMul(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformFMul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7367,33 +6323,19 @@ non-uniform-iadd-op ::= ssa-id `=` `spirv.GroupNonUniformIAdd` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformIAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformIAdd(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformIAdd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7437,33 +6379,19 @@ non-uniform-imul-op ::= ssa-id `=` `spirv.GroupNonUniformIMul` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformIMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformIMul(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformIMul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7507,33 +6435,19 @@ non-uniform-smax-op ::= ssa-id `=` `spirv.GroupNonUniformSMax` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformSMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformSMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformSMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7577,33 +6491,19 @@ non-uniform-smin-op ::= ssa-id `=` `spirv.GroupNonUniformSMin` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformSMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformSMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformSMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7632,29 +6532,19 @@ invocation or greater than or equal to the size of the group. %0 = spirv.GroupNonUniformShuffleDown %val, %delta : f32, i32 ``` """ -function GroupNonUniformShuffleDown( - value::Value, - delta::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, delta] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupNonUniformShuffleDown", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupNonUniformShuffleDown(value, delta; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(delta), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupNonUniformShuffleDown", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7681,29 +6571,19 @@ greater than or equal to the size of the group. %0 = spirv.GroupNonUniformShuffle %val, %id : f32, i32 ``` """ -function GroupNonUniformShuffle( - value::Value, - id::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, id] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupNonUniformShuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupNonUniformShuffle(value, id; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(id), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupNonUniformShuffle", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7731,29 +6611,19 @@ the selected lane is inactive. %0 = spirv.GroupNonUniformShuffleUp %val, %delta : f32, i32 ``` """ -function GroupNonUniformShuffleUp( - value::Value, - delta::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, delta] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupNonUniformShuffleUp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupNonUniformShuffleUp(value, delta; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(delta), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupNonUniformShuffleUp", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7781,29 +6651,19 @@ equal to the size of the group. %0 = spirv.GroupNonUniformShuffleXor %val, %mask : f32, i32 ``` """ -function GroupNonUniformShuffleXor( - value::Value, - mask::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, mask] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("execution_scope", execution_scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupNonUniformShuffleXor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupNonUniformShuffleXor(value, mask; result=nothing::Union{Nothing, IR.Type}, execution_scope, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(mask), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupNonUniformShuffleXor", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -7848,33 +6708,19 @@ non-uniform-umax-op ::= ssa-id `=` `spirv.GroupNonUniformUMax` scope operation %1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformUMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function GroupNonUniformUMax(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformUMax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7908,44 +6754,30 @@ non-uniform-umin-op ::= ssa-id `=` `spirv.GroupNonUniformUMin` scope operation ssa-use ( `cluster_size` `(` ssa_use `)` )? `:` integer-scalar-vector-type ``` - -#### Example: - -```mlir -%four = spirv.Constant 4 : i32 -%scalar = ... : i32 -%vector = ... : vector<4xi32> -%0 = spirv.GroupNonUniformUMin \"Workgroup\" \"Reduce\" %scalar : i32 -%1 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(cluster_size) && push!(_operands, cluster_size) - - return IR.create_operation( - "spirv.GroupNonUniformUMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, + +#### Example: + +```mlir +%four = spirv.Constant 4 : i32 +%scalar = ... : i32 +%vector = ... : vector<4xi32> +%0 = spirv.GroupNonUniformUMin \"Workgroup\" \"Reduce\" %scalar : i32 +%1 = spirv.GroupNonUniformUMin \"Subgroup\" \"ClusteredReduce\" %vector cluster_size(%four) : vector<4xi32> +``` +""" +function GroupNonUniformUMin(value, cluster_size=nothing; result::IR.Type, execution_scope, group_operation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(cluster_size) && push!(operands, value(cluster_size)) + + IR.create_operation( + "spirv.GroupNonUniformUMin", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -7982,32 +6814,19 @@ op ::= ssa-id `=` `spirv.GroupSMax` scope operation ssa-use %0 = spirv.GroupSMax %value : i32 ``` """ -function GroupSMax( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupSMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupSMax(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupSMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8044,32 +6863,19 @@ op ::= ssa-id `=` `spirv.GroupSMin` scope operation ssa-use %0 = spirv.GroupSMin %value : i32 ``` """ -function GroupSMin( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupSMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupSMin(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupSMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8105,32 +6911,19 @@ op ::= ssa-id `=` `spirv.GroupUMax` scope operation ssa-use %0 = spirv.GroupUMax %value : i32 ``` """ -function GroupUMax( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupUMax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupUMax(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupUMax", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8167,32 +6960,19 @@ op ::= ssa-id `=` `spirv.GroupUMin` scope operation ssa-use %0 = spirv.GroupUMin %value : i32 ``` """ -function GroupUMin( - x::Value; - result=nothing::Union{Nothing,IR.Type}, - execution_scope, - group_operation, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("execution_scope", execution_scope), - namedattribute("group_operation", group_operation), - ] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.GroupUMin", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function GroupUMin(x; result=nothing::Union{Nothing, IR.Type}, execution_scope, group_operation, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("execution_scope", execution_scope), namedattribute("group_operation", group_operation), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.GroupUMin", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8225,22 +7005,18 @@ the component width, and 0 otherwise. %2 = spirv.IAddCarry %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)> ``` """ -function IAddCarry(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( - "spirv.IAddCarry", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function IAddCarry(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.IAddCarry", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8275,28 +7051,19 @@ iadd-op ::= ssa-id `=` `spirv.IAdd` ssa-use, ssa-use ``` """ -function IAdd( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.IAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IAdd(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.IAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8326,28 +7093,18 @@ iequal-op ::= ssa-id `=` `spirv.IEqual` ssa-use, ssa-use ``` """ -function IEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.IEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.IEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8382,28 +7139,19 @@ imul-op ::= ssa-id `=` `spirv.IMul` ssa-use, ssa-use ``` """ -function IMul( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.IMul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IMul(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.IMul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8431,22 +7179,18 @@ convert-bf16-to-f-op ::= ssa-id `=` `spirv.INTEL.ConvertBF16ToF` ssa-use %3 = spirv.ConvertBF16ToF %2 : vector<3xi16> to vector<3xf32> ``` """ -function INTEL_ConvertBF16ToF(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.INTEL.ConvertBF16ToF", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function INTEL_ConvertBF16ToF(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.INTEL.ConvertBF16ToF", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8476,22 +7220,18 @@ convert-f-to-bf16-op ::= ssa-id `=` `spirv.INTEL.ConvertFToBF16` ssa-use %3 = spirv.ConvertFToBF16 %2 : vector<3xf32> to vector<3xi16> ``` """ -function INTEL_ConvertFToBF16(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.INTEL.ConvertFToBF16", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function INTEL_ConvertFToBF16(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.INTEL.ConvertFToBF16", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8525,36 +7265,20 @@ present, it is the same as specifying the memory operand None. !spirv.jointmatrix<8x16xi32, ColumnMajor, Subgroup> ``` """ -function INTEL_JointMatrixLoad( - pointer::Value, - stride::Value; - result::IR.Type, - layout, - scope, - memory_access=nothing, - alignment=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[pointer, stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("layout", layout), namedattribute("scope", scope) - ] - !isnothing(memory_access) && - push!(_attributes, namedattribute("memory_access", memory_access)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "spirv.INTEL.JointMatrixLoad", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function INTEL_JointMatrixLoad(pointer, stride; result::IR.Type, layout, scope, memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(stride), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("layout", layout), namedattribute("scope", scope), ] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spirv.INTEL.JointMatrixLoad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8592,30 +7316,19 @@ integer type. -> !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> ``` """ -function INTEL_JointMatrixMad( - a::Value, - b::Value, - c::Value; - result=nothing::Union{Nothing,IR.Type}, - scope, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("scope", scope),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.INTEL.JointMatrixMad", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function INTEL_JointMatrixMad(a, b, c; result=nothing::Union{Nothing, IR.Type}, scope, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("scope", scope), ] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.INTEL.JointMatrixMad", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -8653,36 +7366,20 @@ spirv.INTEL.JointMatrixStore %ptr, %m, %stride !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) ``` """ -function INTEL_JointMatrixStore( - pointer::Value, - object::Value, - stride::Value; - layout, - scope, - memory_access=nothing, - alignment=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[pointer, object, stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("layout", layout), namedattribute("scope", scope) - ] - !isnothing(memory_access) && - push!(_attributes, namedattribute("memory_access", memory_access)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "spirv.INTEL.JointMatrixStore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function INTEL_JointMatrixStore(pointer, object, stride; layout, scope, memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(pointer), value(object), value(stride), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("layout", layout), namedattribute("scope", scope), ] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spirv.INTEL.JointMatrixStore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8760,22 +7457,18 @@ subgroup-block-read-INTEL-op ::= ssa-id `=` `spirv.INTEL.SubgroupBlockRead` %0 = spirv.INTEL.SubgroupBlockRead \"StorageBuffer\" %ptr : i32 ``` """ -function INTEL_SubgroupBlockRead(ptr::Value; value::IR.Type, location=Location()) - _results = IR.Type[value,] - _operands = Value[ptr,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.INTEL.SubgroupBlockRead", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function INTEL_SubgroupBlockRead(ptr; value::IR.Type, location=Location()) + results = IR.Type[value, ] + operands = Value[value(ptr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.INTEL.SubgroupBlockRead", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8809,22 +7502,18 @@ subgroup-block-write-INTEL-op ::= ssa-id `=` `spirv.INTEL.SubgroupBlockWrite` spirv.INTEL.SubgroupBlockWrite \"StorageBuffer\" %ptr, %value : i32 ``` """ -function INTEL_SubgroupBlockWrite(ptr::Value, value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[ptr, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.INTEL.SubgroupBlockWrite", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function INTEL_SubgroupBlockWrite(ptr, value; location=Location()) + results = IR.Type[] + operands = Value[value(ptr), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.INTEL.SubgroupBlockWrite", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8848,34 +7537,24 @@ inot-equal-op ::= ssa-id `=` `spirv.INotEqual` ssa-use, ssa-use ``` #### Example: -```mlir -%4 = spirv.INotEqual %0, %1 : i32 -%5 = spirv.INotEqual %2, %3 : vector<4xi32> - -``` -""" -function INotEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.INotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +```mlir +%4 = spirv.INotEqual %0, %1 : i32 +%5 = spirv.INotEqual %2, %3 : vector<4xi32> + +``` +""" +function INotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.INotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8910,22 +7589,18 @@ otherwise. %2 = spirv.ISubBorrow %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)> ``` """ -function ISubBorrow(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( - "spirv.ISubBorrow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ISubBorrow(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ISubBorrow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -8960,28 +7635,19 @@ isub-op ::= `spirv.ISub` ssa-use, ssa-use ``` """ -function ISub( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ISub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ISub(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.ISub", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -9021,32 +7687,19 @@ image-operands ::= `\"None\"` | `\"Bias\"` | `\"Lod\"` | `\"Grad\"` %0 = spirv.ImageDrefGather %1 : !spirv.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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(imageoperands) && - push!(_attributes, namedattribute("imageoperands", imageoperands)) - - return IR.create_operation( - "spirv.ImageDrefGather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ImageDrefGather(sampledimage, coordinate, dref, operand_arguments; result::IR.Type, imageoperands=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(sampledimage), value(coordinate), value(dref), value.(operand_arguments)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(imageoperands) && push!(attributes, namedattribute("imageoperands", imageoperands)) + + IR.create_operation( + "spirv.ImageDrefGather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9066,25 +7719,18 @@ same as Result Type. %0 = spirv.Image %1 : !spirv.sampled_image> ``` """ -function Image( - sampledimage::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[sampledimage,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.Image", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Image(sampledimage; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(sampledimage), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Image", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9122,22 +7768,18 @@ See the client API specification for additional image type restrictions. %5 = spirv.ImageQuerySize %2 : !spirv.image -> vector<3xi32> ``` """ -function ImageQuerySize(image::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[image,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ImageQuerySize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ImageQuerySize(image; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(image), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ImageQuerySize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9163,28 +7805,18 @@ func @inbounds_ptr_access_chain(%arg0: !spirv.ptr, %arg1 : } ``` """ -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( - "spirv.InBoundsPtrAccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function InBoundsPtrAccessChain(base_ptr, element, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base_ptr), value(element), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.InBoundsPtrAccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9214,23 +7846,18 @@ isinf-op ::= ssa-id `=` `spirv.IsInf` ssa-use %3 = spirv.IsInf %1: vector<4xi32> ``` """ -function IsInf(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.IsInf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IsInf(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.IsInf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9260,23 +7887,18 @@ isnan-op ::= ssa-id `=` `spirv.IsNan` ssa-use %3 = spirv.IsNan %1: vector<4xi32> ``` """ -function IsNan(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.IsNan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function IsNan(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.IsNan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9297,22 +7919,18 @@ assumetruekhr-op ::= `spirv.KHR.AssumeTrue` ssa-use spirv.KHR.AssumeTrue %arg ``` """ -function KHR_AssumeTrue(condition::Value; location=Location()) - _results = IR.Type[] - _operands = Value[condition,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.KHR.AssumeTrue", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function KHR_AssumeTrue(condition; location=Location()) + results = IR.Type[] + operands = Value[value(condition), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.KHR.AssumeTrue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9408,31 +8026,19 @@ cooperative-matrix-load-op ::= ssa-id `=` `spirv.KHR.CooperativeMatrixLoad` as !spirv.KHR.coopmatrix<16x8xi32, Workgroup, MatrixA> ``` """ -function KHR_CooperativeMatrixLoad( - pointer::Value, - stride::Value; - result::IR.Type, - matrix_layout, - memory_operand=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[pointer, stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("matrix_layout", matrix_layout),] - !isnothing(memory_operand) && - push!(_attributes, namedattribute("memory_operand", memory_operand)) - - return IR.create_operation( - "spirv.KHR.CooperativeMatrixLoad", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function KHR_CooperativeMatrixLoad(pointer, stride; result::IR.Type, matrix_layout, memory_operand=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(stride), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("matrix_layout", matrix_layout), ] + !isnothing(memory_operand) && push!(attributes, namedattribute("memory_operand", memory_operand)) + + IR.create_operation( + "spirv.KHR.CooperativeMatrixLoad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9483,31 +8089,19 @@ inactive. !spirv.ptr, !spirv.coopmatrix<16x8xi32, Workgroup, MatrixA> ``` """ -function KHR_CooperativeMatrixStore( - pointer::Value, - object::Value, - stride::Value; - matrix_layout, - memory_operand=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[pointer, object, stride] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("matrix_layout", matrix_layout),] - !isnothing(memory_operand) && - push!(_attributes, namedattribute("memory_operand", memory_operand)) - - return IR.create_operation( - "spirv.KHR.CooperativeMatrixStore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function KHR_CooperativeMatrixStore(pointer, object, stride; matrix_layout, memory_operand=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(pointer), value(object), value(stride), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("matrix_layout", matrix_layout), ] + !isnothing(memory_operand) && push!(attributes, namedattribute("memory_operand", memory_operand)) + + IR.create_operation( + "spirv.KHR.CooperativeMatrixStore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9541,22 +8135,18 @@ subgroup-ballot-op ::= ssa-id `=` `spirv.KHR.SubgroupBallot` %0 = spirv.KHR.SubgroupBallot %predicate : vector<4xi32> ``` """ -function KHR_SubgroupBallot(predicate::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[predicate,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.KHR.SubgroupBallot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function KHR_SubgroupBallot(predicate; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(predicate), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.KHR.SubgroupBallot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9593,31 +8183,20 @@ load-op ::= ssa-id ` = spirv.Load ` storage-class ssa-use %3 = spirv.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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(memory_access) && - push!(_attributes, namedattribute("memory_access", memory_access)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "spirv.Load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Load(ptr; value::IR.Type, memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[value, ] + operands = Value[value(ptr), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spirv.Load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9646,28 +8225,18 @@ logical-and ::= `spirv.LogicalAnd` ssa-use `,` ssa-use %2 = spirv.LogicalAnd %0, %1 : vector<4xi1> ``` """ -function LogicalAnd( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.LogicalAnd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function LogicalAnd(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.LogicalAnd", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9696,28 +8265,18 @@ logical-equal ::= `spirv.LogicalEqual` ssa-use `,` ssa-use %2 = spirv.LogicalEqual %0, %1 : vector<4xi1> ``` """ -function LogicalEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.LogicalEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function LogicalEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.LogicalEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9735,39 +8294,29 @@ Result Type must be a scalar or vector of Boolean type. ``` -logical-not-equal ::= `spirv.LogicalNotEqual` ssa-use `,` ssa-use - `:` operand-type -``` - -#### Example: - -```mlir -%2 = spirv.LogicalNotEqual %0, %1 : i1 -%2 = spirv.LogicalNotEqual %0, %1 : vector<4xi1> -``` -""" -function LogicalNotEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.LogicalNotEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +logical-not-equal ::= `spirv.LogicalNotEqual` ssa-use `,` ssa-use + `:` operand-type +``` + +#### Example: + +```mlir +%2 = spirv.LogicalNotEqual %0, %1 : i1 +%2 = spirv.LogicalNotEqual %0, %1 : vector<4xi1> +``` +""" +function LogicalNotEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.LogicalNotEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9793,25 +8342,18 @@ logical-not ::= `spirv.LogicalNot` ssa-use `:` operand-type %2 = spirv.LogicalNot %0 : vector<4xi1> ``` """ -function LogicalNot( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.LogicalNot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function LogicalNot(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.LogicalNot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9840,28 +8382,18 @@ logical-or ::= `spirv.LogicalOr` ssa-use `,` ssa-use %2 = spirv.LogicalOr %0, %1 : vector<4xi1> ``` """ -function LogicalOr( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.LogicalOr", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function LogicalOr(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.LogicalOr", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9940,24 +8472,18 @@ ssa-use `:` matrix-type `,` matrix-type `->` matrix-type !spirv.matrix<4 x vector<4xf32>> ``` """ -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( - "spirv.MatrixTimesMatrix", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function MatrixTimesMatrix(leftmatrix, rightmatrix; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(leftmatrix), value(rightmatrix), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.MatrixTimesMatrix", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -9988,28 +8514,19 @@ ssa-use `:` matrix-type `,` float-type `->` matrix-type ``` """ -function MatrixTimesScalar( - matrix::Value, - scalar::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[matrix, scalar] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.MatrixTimesScalar", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function MatrixTimesScalar(matrix, scalar; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(matrix), value(scalar), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.MatrixTimesScalar", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -10269,31 +8786,19 @@ For example: : !spirv.ptr as !spirv.NV.coopmatrix<16x8xi32, Workgroup> ``` """ -function NV_CooperativeMatrixLoad( - 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( - "spirv.NV.CooperativeMatrixLoad", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function NV_CooperativeMatrixLoad(pointer, stride, columnmajor; result::IR.Type, memory_access=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), value(stride), value(columnmajor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + + IR.create_operation( + "spirv.NV.CooperativeMatrixLoad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10344,29 +8849,19 @@ For example: !spirv.NV.coopmatrix<8x16xi32, Subgroup> ``` """ -function NV_CooperativeMatrixMulAdd( - a::Value, - b::Value, - c::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b, c] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.NV.CooperativeMatrixMulAdd", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function NV_CooperativeMatrixMulAdd(a, b, c; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.NV.CooperativeMatrixMulAdd", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -10409,31 +8904,19 @@ For example: !spirv.ptr, !spirv.NV.coopmatrix<16x8xi32, Workgroup> ``` """ -function NV_CooperativeMatrixStore( - pointer::Value, - object::Value, - stride::Value, - columnmajor::Value; - memory_access=nothing, - location=Location(), -) - _results = IR.Type[] - _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( - "spirv.NV.CooperativeMatrixStore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function NV_CooperativeMatrixStore(pointer, object, stride, columnmajor; memory_access=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(pointer), value(object), value(stride), value(columnmajor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + + IR.create_operation( + "spirv.NV.CooperativeMatrixStore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10463,23 +8946,19 @@ Results are computed per component, and within each component, per bit. %3 = spirv.Not %1 : vector<4xi32> ``` """ -function Not(operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.Not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Not(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.Not", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -10510,28 +8989,18 @@ ordered-op ::= ssa-id `=` `spirv.Ordered` ssa-use, ssa-use %5 = spirv.Ordered %2, %3 : vector<4xf32> ``` """ -function Ordered( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.Ordered", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Ordered(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Ordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10580,28 +9049,18 @@ func @ptr_access_chain(%arg0: !spirv.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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.PtrAccessChain", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function PtrAccessChain(base_ptr, element, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base_ptr), value(element), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.PtrAccessChain", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10624,22 +9083,18 @@ Result Type and Pointer must point to the same type. !spirv.ptr ``` """ -function PtrCastToGeneric(pointer::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[pointer,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.PtrCastToGeneric", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function PtrCastToGeneric(pointer; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(pointer), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.PtrCastToGeneric", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10738,22 +9193,18 @@ return-value-op ::= `spirv.ReturnValue` ssa-use `:` spirv-type spirv.ReturnValue %0 : f32 ``` """ -function ReturnValue(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.ReturnValue", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ReturnValue(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ReturnValue", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10782,22 +9233,18 @@ s-convert-op ::= ssa-id `=` `spirv.SConvertOp` ssa-use %3 = spirv.SConvertOp %2 : vector<3xi32> to vector<3xi64> ``` """ -function SConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.SConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10829,28 +9276,19 @@ sdiv-op ::= ssa-id `=` `spirv.SDiv` ssa-use, ssa-use ``` """ -function SDiv( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.SDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -10893,30 +9331,19 @@ is undefined. %r = spirv.SDotAccSat %a, %b, %acc : (vector<4xi8>, vector<4xi8>, i32) -> i32 ``` """ -function SDotAccSat( - vector1::Value, - vector2::Value, - accumulator::Value; - result::IR.Type, - format=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2, accumulator] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.SDotAccSat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SDotAccSat(vector1, vector2, accumulator; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), value(accumulator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.SDotAccSat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -10945,34 +9372,28 @@ is the result width and R is computed with enough precision to avoid overflow and underflow. - -#### Example: - -```mlir -%r = spirv.SDot %a, %b {format = #spirv.packed_vector_format}: (i32, i32) -> i32 -%r = spirv.SDot %a, %b {format = #spirv.packed_vector_format}: (i32, i32) -> i64 -%r = spirv.SDot %a, %b : (vector<4xi8>, vector<4xi8>) -> i32 -``` -""" -function SDot( - vector1::Value, vector2::Value; result::IR.Type, format=nothing, location=Location() -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.SDot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, + +#### Example: + +```mlir +%r = spirv.SDot %a, %b {format = #spirv.packed_vector_format}: (i32, i32) -> i32 +%r = spirv.SDot %a, %b {format = #spirv.packed_vector_format}: (i32, i32) -> i64 +%r = spirv.SDot %a, %b : (vector<4xi8>, vector<4xi8>) -> i32 +``` +""" +function SDot(vector1, vector2; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.SDot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11002,28 +9423,18 @@ sgreater-than-equal-op ::= ssa-id `=` `spirv.SGreaterThanEqual` ssa-use, ssa-use ``` """ -function SGreaterThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11053,28 +9464,18 @@ sgreater-than-op ::= ssa-id `=` `spirv.SGreaterThan` ssa-use, ssa-use ``` """ -function SGreaterThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11104,28 +9505,18 @@ sless-than-equal-op ::= ssa-id `=` `spirv.SLessThanEqual` ssa-use, ssa-use ``` """ -function SLessThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SLessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SLessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SLessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11155,28 +9546,18 @@ sless-than-op ::= ssa-id `=` `spirv.SLessThan` ssa-use, ssa-use ``` """ -function SLessThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SLessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SLessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SLessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11209,28 +9590,19 @@ smod-op ::= ssa-id `=` `spirv.SMod` ssa-use, ssa-use ``` """ -function SMod( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.SMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -11259,24 +9631,18 @@ Member 1 of the result gets the high-order bits of the multiplication. %2 = spirv.SMulExtended %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)> ``` """ -function SMulExtended( - 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( - "spirv.SMulExtended", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SMulExtended(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.SMulExtended", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11300,25 +9666,19 @@ must equal the component width in Result Type. %3 = spirv.SNegate %2 : vector<4xi32> ``` """ -function SNegate( - operand::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SNegate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SNegate(operand; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.SNegate", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -11351,28 +9711,19 @@ srem-op ::= ssa-id `=` `spirv.SRem` ssa-use, ssa-use ``` """ -function SRem( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.SRem", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function SRem(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.SRem", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -11417,30 +9768,19 @@ is undefined. %r = spirv.SUDotAccSat %a, %b, %acc : (vector<4xi8>, vector<4xi8>, i32) -> i32 ``` """ -function SUDotAccSat( - vector1::Value, - vector2::Value, - accumulator::Value; - result::IR.Type, - format=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2, accumulator] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.SUDotAccSat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SUDotAccSat(vector1, vector2, accumulator; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), value(accumulator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.SUDotAccSat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11480,25 +9820,19 @@ avoid overflow and underflow. %r = spirv.SUDot %a, %b : (vector<4xi8>, vector<4xi8>) -> i32 ``` """ -function SUDot( - vector1::Value, vector2::Value; result::IR.Type, format=nothing, location=Location() -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.SUDot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function SUDot(vector1, vector2; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.SUDot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -11541,29 +9875,19 @@ select-op ::= ssa-id `=` `spirv.Select` ssa-use, ssa-use, ssa-use %3 = spirv.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(), -) - _results = IR.Type[] - _operands = Value[condition, true_value, false_value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.Select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Select(condition, true_value, false_value; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(condition), value(true_value), value(false_value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.Select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -11643,28 +9967,19 @@ shift-left-logical-op ::= ssa-id `=` `spirv.ShiftLeftLogical` %5 = spirv.ShiftLeftLogical %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftLeftLogical( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ShiftLeftLogical", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ShiftLeftLogical(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.ShiftLeftLogical", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -11701,28 +10016,19 @@ shift-right-arithmetic-op ::= ssa-id `=` `spirv.ShiftRightArithmetic` %5 = spirv.ShiftRightArithmetic %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftRightArithmetic( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ShiftRightArithmetic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ShiftRightArithmetic(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.ShiftRightArithmetic", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -11760,28 +10066,19 @@ shift-right-logical-op ::= ssa-id `=` `spirv.ShiftRightLogical` %5 = spirv.ShiftRightLogical %3, %4 : vector<3xi32>, vector<3xi16> ``` """ -function ShiftRightLogical( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ShiftRightLogical", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ShiftRightLogical(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.ShiftRightLogical", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -12013,27 +10310,20 @@ spirv.Store \"Function\" %0, %1 [\"Volatile\"] : f32 spirv.Store \"Function\" %0, %1 [\"Aligned\", 4] : f32 ``` """ -function Store( - ptr::Value, value::Value; memory_access=nothing, alignment=nothing, location=Location() -) - _results = IR.Type[] - _operands = Value[ptr, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(memory_access) && - push!(_attributes, namedattribute("memory_access", memory_access)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "spirv.Store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Store(ptr, value; memory_access=nothing, alignment=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(ptr), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_access) && push!(attributes, namedattribute("memory_access", memory_access)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "spirv.Store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12063,24 +10353,20 @@ matrix-type %0 = spirv.Transpose %matrix: !spirv.matrix<2 x vector<3xf32>> -> !spirv.matrix<3 x vector<2xf32>> -``` -""" -function Transpose(matrix::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[matrix,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.Transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +``` +""" +function Transpose(matrix; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(matrix), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12110,22 +10396,18 @@ u-convert-op ::= ssa-id `=` `spirv.UConvertOp` ssa-use %3 = spirv.UConvertOp %2 : vector<3xi32> to vector<3xi64> ``` """ -function UConvert(operand::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.UConvert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UConvert(operand; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.UConvert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12156,28 +10438,19 @@ udiv-op ::= ssa-id `=` `spirv.UDiv` ssa-use, ssa-use ``` """ -function UDiv( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.UDiv", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UDiv(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.UDiv", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -12222,30 +10495,19 @@ is undefined. %r = spirv.UDotAccSat %a, %b, %acc : (vector<4xi8>, vector<4xi8>, i32) -> i32 ``` """ -function UDotAccSat( - vector1::Value, - vector2::Value, - accumulator::Value; - result::IR.Type, - format=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2, accumulator] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.UDotAccSat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UDotAccSat(vector1, vector2, accumulator; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), value(accumulator), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.UDotAccSat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12285,25 +10547,19 @@ overflow and underflow. %r = spirv.UDot %a, %b : (vector<4xi8>, vector<4xi8>) -> i32 ``` """ -function UDot( - vector1::Value, vector2::Value; result::IR.Type, format=nothing, location=Location() -) - _results = IR.Type[result,] - _operands = Value[vector1, vector2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(format) && push!(_attributes, namedattribute("format", format)) - - return IR.create_operation( - "spirv.UDot", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UDot(vector1, vector2; result::IR.Type, format=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(format) && push!(attributes, namedattribute("format", format)) + + IR.create_operation( + "spirv.UDot", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12333,28 +10589,18 @@ ugreater-than-equal-op ::= ssa-id `=` `spirv.UGreaterThanEqual` ssa-use, ssa-use ``` """ -function UGreaterThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.UGreaterThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UGreaterThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.UGreaterThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12384,28 +10630,18 @@ ugreater-than-op ::= ssa-id `=` `spirv.UGreaterThan` ssa-use, ssa-use ``` """ -function UGreaterThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.UGreaterThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UGreaterThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.UGreaterThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12435,28 +10671,18 @@ uless-than-equal-op ::= ssa-id `=` `spirv.ULessThanEqual` ssa-use, ssa-use ``` """ -function ULessThanEqual( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ULessThanEqual", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ULessThanEqual(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ULessThanEqual", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12486,28 +10712,18 @@ uless-than-op ::= ssa-id `=` `spirv.ULessThan` ssa-use, ssa-use ``` """ -function ULessThan( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.ULessThan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function ULessThan(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.ULessThan", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12538,28 +10754,19 @@ umod-op ::= ssa-id `=` `spirv.UMod` ssa-use, ssa-use ``` """ -function UMod( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.UMod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function UMod(operand1, operand2; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.UMod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -12589,24 +10796,18 @@ Member 1 of the result gets the high-order bits of the multiplication. %2 = spirv.UMulExtended %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)> ``` """ -function UMulExtended( - 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( - "spirv.UMulExtended", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function UMulExtended(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.UMulExtended", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12678,28 +10879,18 @@ unordered-op ::= ssa-id `=` `spirv.Unordered` ssa-use, ssa-use %5 = spirv.Unordered %2, %3 : vector<4xf32> ``` """ -function Unordered( - operand1::Value, - operand2::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand1, operand2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.Unordered", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function Unordered(operand1, operand2; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand1), value(operand2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.Unordered", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12767,28 +10958,19 @@ where `init` specifies initializer. %2 = spirv.Variable init(%0): !spirv.ptr ``` """ -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),] - !isnothing(initializer) && push!(_operands, initializer) - - return IR.create_operation( - "spirv.Variable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function Variable(initializer=nothing; 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), ] + !isnothing(initializer) && push!(operands, value(initializer)) + + IR.create_operation( + "spirv.Variable", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12814,25 +10996,18 @@ or equal to the number of components in Vector. %2 = spirv.VectorExtractDynamic %0[%1] : vector<8xf32>, i32 ``` """ -function VectorExtractDynamic( - vector::Value, index::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[vector, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.VectorExtractDynamic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function VectorExtractDynamic(vector, index; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.VectorExtractDynamic", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12870,29 +11045,19 @@ vector-insert-dynamic-op ::= `spirv.VectorInsertDynamic ` ssa-use `,` %2 = spirv.VectorInsertDynamic %scalar %0[%1] : f32, vector<8xf32>, i32 ``` """ -function VectorInsertDynamic( - vector::Value, - component::Value, - index::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[vector, component, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "spirv.VectorInsertDynamic", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function VectorInsertDynamic(vector, component, index; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(vector), value(component), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "spirv.VectorInsertDynamic", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -12933,24 +11098,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("components", components),] - - return IR.create_operation( - "spirv.VectorShuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function VectorShuffle(vector1, vector2; result::IR.Type, components, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector1), value(vector2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("components", components), ] + + IR.create_operation( + "spirv.VectorShuffle", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -12972,24 +11131,18 @@ Scalar must have the same type as the Component Type in Result Type. %0 = spirv.VectorTimesScalar %vector, %scalar : vector<4xf32> ``` """ -function VectorTimesScalar( - vector::Value, scalar::Value; result::IR.Type, location=Location() -) - _results = IR.Type[result,] - _operands = Value[vector, scalar] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.VectorTimesScalar", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function VectorTimesScalar(vector, scalar; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value(scalar), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.VectorTimesScalar", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -13012,22 +11165,18 @@ spirv.mlir.yield ::= `spirv.mlir.yield` ssa-id : spirv-type spirv.mlir.yield %0 ``` """ -function mlir_yield(operand::Value; location=Location()) - _results = IR.Type[] - _operands = Value[operand,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "spirv.mlir.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mlir_yield(operand; location=Location()) + results = IR.Type[] + operands = Value[value(operand), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "spirv.mlir.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Shape.jl b/src/Dialects/17/Shape.jl index 06993eed..62ba00c3 100644 --- a/src/Dialects/17/Shape.jl +++ b/src/Dialects/17/Shape.jl @@ -1,7 +1,6 @@ module shape -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -14,25 +13,19 @@ at least one of the operands can hold an error, i.e. if it is of type 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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function add(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.add", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -52,22 +45,18 @@ inputs have differing ranks or differ in extents of shared dimensions. %s1 = shape.any [?,?], [1,2] // [1,2] ``` """ -function any(inputs::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.any", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function any(inputs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.any", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -91,25 +80,19 @@ ready to execute. %wt = shape.assuming_all %w0, %w2 // Passing ``` """ -function assuming_all( - inputs::Vector{Value}; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.assuming_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function assuming_all(inputs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.assuming_all", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -123,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assuming(witness; results_::Vector{IR.Type}, doRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(witness), ] + owned_regions = Region[doRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.assuming", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -152,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()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.assuming_yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function assuming_yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.assuming_yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -194,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(error) && push!(_attributes, namedattribute("error", error)) - - return IR.create_operation( - "shape.broadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function broadcast(shapes; result::IR.Type, error=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(error) && push!(attributes, namedattribute("error", error)) + + IR.create_operation( + "shape.broadcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -227,22 +194,18 @@ concat([2,3], [4,5]) -> [2,3,4,5] concat([], []) -> [] concat([], [4,5,6]) -> [4,5,6] """ -function concat(lhs::Value, rhs::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.concat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function concat(lhs, rhs; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.concat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -360,25 +323,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_broadcastable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_broadcastable(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -395,25 +352,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_eq(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -436,25 +387,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() -) - _results = IR.Type[] - _operands = Value[pred,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("msg", msg),] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.cstr_require", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function cstr_require(pred; result=nothing::Union{Nothing, IR.Type}, msg, location=Location()) + results = IR.Type[] + operands = Value[value(pred), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("msg", msg), ] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -465,22 +410,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.debug_print", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function debug_print(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.debug_print", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -494,25 +435,19 @@ return type carries error information else the behavior is undefined. This is a convenience op that performs the equivalent of getting the extent of a shape (e.g., `dim(x, i) == get_extent(shape_of(x), i)`). """ -function dim( - value::Value, index::Value; extent=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[value, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(extent) && push!(_results, extent) - - return IR.create_operation( - "shape.dim", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function dim(value, index; extent=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(extent) && push!(results, extent) + + IR.create_operation( + "shape.dim", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -533,25 +468,19 @@ toward 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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function div(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.div", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -562,25 +491,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function from_extent_tensor(input; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -597,25 +520,19 @@ the shape. %s1 = shape.from_extents ``` """ -function from_extents( - extents::Vector{Value}; shape=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[extents...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(shape) && push!(_results, shape) - - return IR.create_operation( - "shape.from_extents", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function from_extents(extents; shape=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(extents)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(shape) && push!(results, shape) + + IR.create_operation( + "shape.from_extents", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -709,25 +626,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function get_extent(shape, dim; extent=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), value(dim), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(extent) && push!(results, extent) + + 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) ) end @@ -740,25 +651,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function index_to_size(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -780,25 +685,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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.is_broadcastable", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function is_broadcastable(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -810,25 +709,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function max(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.max", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -859,30 +752,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function meet(arg0, arg1; result=nothing::Union{Nothing, IR.Type}, error=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(arg0), value(arg1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(error) && push!(attributes, namedattribute("error", error)) + + IR.create_operation( + "shape.meet", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -894,25 +777,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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function min(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.min", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -926,25 +803,19 @@ at least one of the operands can hold an error, i.e. if it is of type 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() -) - _results = IR.Type[] - _operands = Value[lhs, rhs] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.mul", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function mul(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "shape.mul", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -957,25 +828,19 @@ type `size` and potential errors will be propagated. Otherwise, if the argument 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() -) - _results = IR.Type[] - _operands = Value[shape,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.num_elements", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function num_elements(shape; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -984,23 +849,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()) - _results = IR.Type[] - _operands = Value[shape,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(rank) && push!(_results, rank) - - return IR.create_operation( - "shape.rank", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rank(shape; rank=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(rank) && push!(results, rank) + + IR.create_operation( + "shape.rank", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1038,28 +899,18 @@ func.func @reduce(%shape : !shape.shape, %init : !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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduce(shape, initVals; result::Vector{IR.Type}, region::Region, location=Location()) + results = IR.Type[result..., ] + operands = Value[value(shape), value.(initVals)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.reduce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1070,22 +921,18 @@ The `shape.return` operation represents a return operation within a function. The operation takes variable number of operands and produces no results. """ -function return_(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.return", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function return_(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.return", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1098,25 +945,19 @@ regarded 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() -) - _results = IR.Type[] - _operands = Value[shapes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.shape_eq", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shape_eq(shapes; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value.(shapes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1126,23 +967,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()) - _results = IR.Type[] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "shape.shape_of", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shape_of(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1154,25 +991,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function size_to_index(arg; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1200,24 +1031,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.split_at", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function split_at(operand, index; head::IR.Type, tail::IR.Type, location=Location()) + results = IR.Type[head, tail, ] + operands = Value[value(operand), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.split_at", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1230,22 +1055,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.to_extent_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function to_extent_tensor(input; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.to_extent_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1267,22 +1088,18 @@ E.g., This operation is the complement of `shape_of` wrt ValueShape values. """ -function value_as_shape(arg::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.value_as_shape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function value_as_shape(arg; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.value_as_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1293,22 +1110,18 @@ The operation takes !shape.value_shape, a.k.a. (value, shape) tuple as an argument, and returns its value. The behavior is undefined for unknown and invalid arguments. """ -function value_of(arg::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[arg,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.value_of", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function value_of(arg; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(arg), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.value_of", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1347,28 +1160,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function with_shape(operand, shape; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(operand), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + 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) ) end @@ -1376,22 +1180,18 @@ end `yield` """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "shape.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "shape.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/SparseTensor.jl b/src/Dialects/17/SparseTensor.jl index d4fb7563..cea55067 100644 --- a/src/Dialects/17/SparseTensor.jl +++ b/src/Dialects/17/SparseTensor.jl @@ -1,7 +1,6 @@ module sparse_tensor -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -110,36 +109,20 @@ because we never use its values, only its sparse structure: } -> tensor ``` """ -function binary( - x::Value, - y::Value; - output::IR.Type, - left_identity=nothing, - right_identity=nothing, - overlapRegion::Region, - leftRegion::Region, - rightRegion::Region, - location=Location(), -) - _results = IR.Type[output,] - _operands = Value[x, y] - _owned_regions = Region[overlapRegion, leftRegion, rightRegion] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(left_identity) && - push!(_attributes, namedattribute("left_identity", left_identity)) - !isnothing(right_identity) && - push!(_attributes, namedattribute("right_identity", right_identity)) - - return IR.create_operation( - "sparse_tensor.binary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function binary(x, y; output::IR.Type, left_identity=nothing, right_identity=nothing, overlapRegion::Region, leftRegion::Region, rightRegion::Region, location=Location()) + results = IR.Type[output, ] + operands = Value[value(x), value(y), ] + owned_regions = Region[overlapRegion, leftRegion, rightRegion, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(left_identity) && push!(attributes, namedattribute("left_identity", left_identity)) + !isnothing(right_identity) && push!(attributes, namedattribute("right_identity", right_identity)) + + IR.create_operation( + "sparse_tensor.binary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -167,32 +150,19 @@ done \"in place\", and referencing the old SSA value is undefined behavior. : memref, memref, memref, tensor<4x4xf64, #CSR> ``` """ -function compress( - values::Value, - filled::Value, - added::Value, - count::Value, - tensor::Value, - lvlCoords::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[values, filled, added, count, tensor, lvlCoords...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "sparse_tensor.compress", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function compress(values, filled, added, count, tensor, lvlCoords; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(values), value(filled), value(added), value(count), value(tensor), value.(lvlCoords)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "sparse_tensor.compress", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -215,22 +185,18 @@ can be dynamically-sized. : tensor<64x64xf64, #CSR>, tensor<64x64xf64, #CSR> to tensor<128x64xf64, #CSR> ``` """ -function concatenate(inputs::Vector{Value}; result::IR.Type, dimension, location=Location()) - _results = IR.Type[result,] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dimension", dimension),] - - return IR.create_operation( - "sparse_tensor.concatenate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function concatenate(inputs; result::IR.Type, dimension, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), ] + + IR.create_operation( + "sparse_tensor.concatenate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -273,22 +239,18 @@ Examples: %4 = sparse_tensor.convert %d : tensor to tensor<100xf64, #SV> ``` """ -function convert(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.convert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function convert(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.convert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -326,29 +288,18 @@ side-effecting context that sets and resets the expanded arrays. : tensor<4x4xf64, #CSR> to memref, memref, memref ``` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand(tensor; values::IR.Type, filled::IR.Type, added::IR.Type, count::IR.Type, location=Location()) + results = IR.Type[values, filled, added, count, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.expand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -426,30 +377,19 @@ sparse_tensor.foreach in %0 {order=affine_map<(i,j)->(j,i)>}: tensor<2x3xf64> do ``` """ -function foreach( - tensor::Value, - initArgs::Vector{Value}; - results::Vector{IR.Type}, - order=nothing, - region::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[tensor, initArgs...] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(order) && push!(_attributes, namedattribute("order", order)) - - return IR.create_operation( - "sparse_tensor.foreach", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach(tensor, initArgs; results_::Vector{IR.Type}, order=nothing, region::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(tensor), value.(initArgs)..., ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(order) && push!(attributes, namedattribute("order", order)) + + IR.create_operation( + "sparse_tensor.foreach", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -465,30 +405,20 @@ Example of querying the size of the coordinates array for level 0: : !sparse_tensor.storage_specifier<#COO> ``` """ -function storage_specifier_get( - specifier::Value; - result=nothing::Union{Nothing,IR.Type}, - specifierKind, - level=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[specifier,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("specifierKind", specifierKind),] - !isnothing(result) && push!(_results, result) - !isnothing(level) && push!(_attributes, namedattribute("level", level)) - - return IR.create_operation( - "sparse_tensor.storage_specifier.get", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function storage_specifier_get(specifier; result=nothing::Union{Nothing, IR.Type}, specifierKind, level=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(specifier), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("specifierKind", specifierKind), ] + !isnothing(result) && push!(results, result) + !isnothing(level) && push!(attributes, namedattribute("level", level)) + + IR.create_operation( + "sparse_tensor.storage_specifier.get", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -521,29 +451,19 @@ This operation is scheduled to be unified with the dense counterpart %result = sparse_tensor.insert %val into %tensor[%i,%j] : tensor<1024x1024xf64, #CSR> ``` """ -function insert( - value::Value, - tensor::Value, - lvlCoords::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[value, tensor, lvlCoords...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "sparse_tensor.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert(value, tensor, lvlCoords; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(value), value(tensor), value.(lvlCoords)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "sparse_tensor.insert", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -575,29 +495,20 @@ Examples: %1 = sparse_tensor.load %0 hasInserts : tensor<16x32xf32, #CSR> ``` """ -function load( - tensor::Value; - result=nothing::Union{Nothing,IR.Type}, - hasInserts=nothing, - location=Location(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function load(tensor; result=nothing::Union{Nothing, IR.Type}, hasInserts=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(hasInserts) && push!(attributes, namedattribute("hasInserts", hasInserts)) + + 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) ) end @@ -623,22 +534,18 @@ symmetry support for operating on symmetric matrices is still TBD. 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.new", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function new(source; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.new", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -656,25 +563,19 @@ accurate nomenclature is used. %noe = sparse_tensor.number_of_entries %tensor : tensor<64x64xf64, #CSR> ``` """ -function number_of_entries( - tensor::Value; result=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "sparse_tensor.number_of_entries", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function number_of_entries(tensor; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "sparse_tensor.number_of_entries", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -697,22 +598,18 @@ is solely defined by side-effects and not SSA values. sparse_tensor.out %t, %dest : tensor<1024x1024xf64, #CSR>, !Dest ``` """ -function out(tensor::Value, dest::Value; location=Location()) - _results = IR.Type[] - _operands = Value[tensor, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.out", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function out(tensor, dest; location=Location()) + results = IR.Type[] + operands = Value[value(tensor), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.out", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -753,22 +650,18 @@ does not yet support them. // |0.0, 0.0, 0.0, 0.0| ``` """ -function pack(values::Value, levels::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[values, levels...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.pack", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pack(values, levels; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(values), value.(levels)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.pack", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -816,35 +709,22 @@ through the old SSA value after this operation is undefined behavior. : xindex, memref, f64 ``` """ -function push_back( - curSize::Value, - inBuffer::Value, - value::Value, - n=nothing::Union{Nothing,Value}; - outBuffer=nothing::Union{Nothing,IR.Type}, - newSize=nothing::Union{Nothing,IR.Type}, - inbounds=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[curSize, inBuffer, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(n) && push!(_operands, n) - !isnothing(outBuffer) && push!(_results, outBuffer) - !isnothing(newSize) && push!(_results, newSize) - !isnothing(inbounds) && push!(_attributes, namedattribute("inbounds", inbounds)) - - return IR.create_operation( - "sparse_tensor.push_back", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function push_back(curSize, inBuffer, value, n=nothing; outBuffer=nothing::Union{Nothing, IR.Type}, newSize=nothing::Union{Nothing, IR.Type}, inbounds=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(curSize), value(inBuffer), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(n) && push!(operands, value(n)) + !isnothing(outBuffer) && push!(results, outBuffer) + !isnothing(newSize) && push!(results, newSize) + !isnothing(inbounds) && push!(attributes, namedattribute("inbounds", inbounds)) + + IR.create_operation( + "sparse_tensor.push_back", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -890,30 +770,19 @@ Example of Matrix->Vector reduction using max(product(x_i), 100): } -> tensor ``` """ -function reduce( - x::Value, - y::Value, - identity::Value; - output=nothing::Union{Nothing,IR.Type}, - region::Region, - location=Location(), -) - _results = IR.Type[] - _operands = Value[x, y, identity] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "sparse_tensor.reduce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function reduce(x, y, identity; output=nothing::Union{Nothing, IR.Type}, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value(x), value(y), value(identity), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "sparse_tensor.reduce", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -967,25 +836,19 @@ Example of selecting lower triangle of a matrix: } -> tensor ``` """ -function select( - x::Value; output=nothing::Union{Nothing,IR.Type}, region::Region, location=Location() -) - _results = IR.Type[] - _operands = Value[x,] - _owned_regions = Region[region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "sparse_tensor.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function select(x; output=nothing::Union{Nothing, IR.Type}, region::Region, location=Location()) + results = IR.Type[] + operands = Value[value(x), ] + owned_regions = Region[region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "sparse_tensor.select", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1002,31 +865,20 @@ Example of updating the sizes of the coordinates array for level 0: : !sparse_tensor.storage_specifier<#COO> ``` """ -function storage_specifier_set( - specifier::Value, - value::Value; - result=nothing::Union{Nothing,IR.Type}, - specifierKind, - level=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[specifier, value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("specifierKind", specifierKind),] - !isnothing(result) && push!(_results, result) - !isnothing(level) && push!(_attributes, namedattribute("level", level)) - - return IR.create_operation( - "sparse_tensor.storage_specifier.set", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function storage_specifier_set(specifier, value; result=nothing::Union{Nothing, IR.Type}, specifierKind, level=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(specifier), value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("specifierKind", specifierKind), ] + !isnothing(result) && push!(results, result) + !isnothing(level) && push!(attributes, namedattribute("level", level)) + + IR.create_operation( + "sparse_tensor.storage_specifier.set", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1058,32 +910,20 @@ sparse_tensor.sort hybrid_quick_sort %n, %xy jointly %y1 : memref jointly memref ``` """ -function sort_coo( - n::Value, - xy::Value, - ys::Vector{Value}; - nx=nothing, - ny=nothing, - algorithm, - location=Location(), -) - _results = IR.Type[] - _operands = Value[n, xy, ys...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("algorithm", algorithm),] - !isnothing(nx) && push!(_attributes, namedattribute("nx", nx)) - !isnothing(ny) && push!(_attributes, namedattribute("ny", ny)) - - return IR.create_operation( - "sparse_tensor.sort_coo", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sort_coo(n, xy, ys; nx=nothing, ny=nothing, algorithm, location=Location()) + results = IR.Type[] + operands = Value[value(n), value(xy), value.(ys)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("algorithm", algorithm), ] + !isnothing(nx) && push!(attributes, namedattribute("nx", nx)) + !isnothing(ny) && push!(attributes, namedattribute("ny", ny)) + + IR.create_operation( + "sparse_tensor.sort_coo", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1128,25 +968,19 @@ sparse_tensor.sort hybrid_quick_sort %n, %x1, %x2 jointly y1, %y2 : memref, memref jointly memref, memref ``` """ -function sort( - n::Value, xs::Vector{Value}, ys::Vector{Value}; algorithm, location=Location() -) - _results = IR.Type[] - _operands = Value[n, xs..., ys...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("algorithm", algorithm),] - push!(_attributes, operandsegmentsizes([1, length(xs), length(ys)])) - - return IR.create_operation( - "sparse_tensor.sort", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sort(n, xs, ys; algorithm, location=Location()) + results = IR.Type[] + operands = Value[value(n), value.(xs)..., value.(ys)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("algorithm", algorithm), ] + push!(attributes, operandsegmentsizes([1, length(xs), length(ys), ])) + + IR.create_operation( + "sparse_tensor.sort", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1177,25 +1011,19 @@ is subject to change in the future. !sparse_tensor.storage_specifier<#CSR_SLICE> ``` """ -function storage_specifier_init( - source=nothing::Union{Nothing,Value}; result::IR.Type, location=Location() -) - _results = IR.Type[result,] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(source) && push!(_operands, source) - - return IR.create_operation( - "sparse_tensor.storage_specifier.init", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function storage_specifier_init(source=nothing; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(source) && push!(operands, value(source)) + + IR.create_operation( + "sparse_tensor.storage_specifier.init", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1224,22 +1052,18 @@ Writing into the result of this operation is undefined behavior. : tensor<64x64xf64, #COO> to memref ``` """ -function coordinates_buffer(tensor::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.coordinates_buffer", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coordinates_buffer(tensor; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.coordinates_buffer", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1263,22 +1087,18 @@ Writing into the result of this operation is undefined behavior. : tensor<64x64xf64, #CSR> to memref ``` """ -function coordinates(tensor::Value; result::IR.Type, level, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("level", level),] - - return IR.create_operation( - "sparse_tensor.coordinates", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function coordinates(tensor; result::IR.Type, level, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("level", level), ] + + IR.create_operation( + "sparse_tensor.coordinates", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1302,22 +1122,18 @@ Writing into the result of this operation is undefined behavior. : tensor<64x64xf64, #CSR> to memref ``` """ -function positions(tensor::Value; result::IR.Type, level, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("level", level),] - - return IR.create_operation( - "sparse_tensor.positions", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function positions(tensor; result::IR.Type, level, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("level", level), ] + + IR.create_operation( + "sparse_tensor.positions", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1342,25 +1158,19 @@ with `enable-runtime-library=false`). // %2 = %v2 ``` """ -function slice_offset( - slice::Value; offset=nothing::Union{Nothing,IR.Type}, dim, location=Location() -) - _results = IR.Type[] - _operands = Value[slice,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dim", dim),] - !isnothing(offset) && push!(_results, offset) - - return IR.create_operation( - "sparse_tensor.slice.offset", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function slice_offset(slice; offset=nothing::Union{Nothing, IR.Type}, dim, location=Location()) + results = IR.Type[] + operands = Value[value(slice), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dim", dim), ] + !isnothing(offset) && push!(results, offset) + + IR.create_operation( + "sparse_tensor.slice.offset", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1386,25 +1196,19 @@ with `enable-runtime-library=false`). ``` """ -function slice_stride( - slice::Value; stride=nothing::Union{Nothing,IR.Type}, dim, location=Location() -) - _results = IR.Type[] - _operands = Value[slice,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("dim", dim),] - !isnothing(stride) && push!(_results, stride) - - return IR.create_operation( - "sparse_tensor.slice.stride", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function slice_stride(slice; stride=nothing::Union{Nothing, IR.Type}, dim, location=Location()) + results = IR.Type[] + operands = Value[value(slice), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dim", dim), ] + !isnothing(stride) && push!(results, stride) + + IR.create_operation( + "sparse_tensor.slice.stride", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1427,22 +1231,18 @@ Writing into the result of this operation is undefined behavior. %1 = sparse_tensor.values %0 : tensor<64x64xf64, #CSR> to memref ``` """ -function values(tensor::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[tensor,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.values", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function values(tensor; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.values", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1530,28 +1330,18 @@ the output, while missing values are filled with 1): } -> tensor ``` """ -function unary( - x::Value; - output::IR.Type, - presentRegion::Region, - absentRegion::Region, - location=Location(), -) - _results = IR.Type[output,] - _operands = Value[x,] - _owned_regions = Region[presentRegion, absentRegion] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.unary", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function unary(x; output::IR.Type, presentRegion::Region, absentRegion::Region, location=Location()) + results = IR.Type[output, ] + operands = Value[value(x), ] + owned_regions = Region[presentRegion, absentRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.unary", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1587,31 +1377,18 @@ TODO: the current implementation does not yet support non-identity mappings. // %c_len = 6 (3x2) ``` """ -function unpack( - tensor::Value, - out_values::Value, - out_levels::Vector{Value}; - ret_values::IR.Type, - ret_levels::Vector{IR.Type}, - val_len::IR.Type, - lvl_lens::Vector{IR.Type}, - location=Location(), -) - _results = IR.Type[ret_values, ret_levels..., val_len, lvl_lens...] - _operands = Value[tensor, out_values, out_levels...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "sparse_tensor.unpack", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function unpack(tensor, out_values, out_levels; ret_values::IR.Type, ret_levels::Vector{IR.Type}, val_len::IR.Type, lvl_lens::Vector{IR.Type}, location=Location()) + results = IR.Type[ret_values, ret_levels..., val_len, lvl_lens..., ] + operands = Value[value(tensor), value(out_values), value.(out_levels)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "sparse_tensor.unpack", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1634,23 +1411,19 @@ Yields a value from within a `binary`, `unary`, `reduce`, } ``` """ -function yield(result=nothing::Union{Nothing,Value}; location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_operands, result) - - return IR.create_operation( - "sparse_tensor.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(result=nothing; location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(operands, value(result)) + + IR.create_operation( + "sparse_tensor.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Tensor.jl b/src/Dialects/17/Tensor.jl index a618c46c..9cb9020e 100644 --- a/src/Dialects/17/Tensor.jl +++ b/src/Dialects/17/Tensor.jl @@ -1,7 +1,6 @@ module tensor -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -18,22 +17,18 @@ should match. %2 = tensor.bitcast %1 : tensor<4xui32> to tensor<4xi32> ``` """ -function bitcast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -60,22 +55,18 @@ converting to a mismatching constant dimension. %5 = tensor.cast %4 : tensor to tensor<*xf32> ``` """ -function cast(source::Value; dest::IR.Type, location=Location()) - _results = IR.Type[dest,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(source; dest::IR.Type, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -104,22 +95,18 @@ Examples: : tensor into tensor ``` """ -function collapse_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function collapse_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "tensor.collapse_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -148,25 +135,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() -) - _results = IR.Type[] - _operands = Value[source, index] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "tensor.dim", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function dim(source, index; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(index), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "tensor.dim", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -186,22 +167,18 @@ with a `tensor.empty` destination. Note: This op can be lowered to a `bufferization.alloc_tensor`, at which point it turns into an explicit buffer allocation. """ -function empty(dynamicSizes::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[dynamicSizes...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.empty", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function empty(dynamicSizes; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(dynamicSizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.empty", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -230,22 +207,18 @@ Examples: : tensor into tensor ``` """ -function expand_shape(src::Value; result::IR.Type, reassociation, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expand_shape(src; result::IR.Type, reassociation, location=Location()) + results = IR.Type[result, ] + operands = Value[value(src), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("reassociation", reassociation), ] + + IR.create_operation( + "tensor.expand_shape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -264,28 +237,18 @@ the rank of the accessed value. All indices should all be of `index` type. %5 = tensor.extract %rt[%1, %2] : tensor ``` """ -function extract( - tensor::Value, - indices::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[tensor, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "tensor.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extract(tensor, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(tensor), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.extract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -349,40 +312,19 @@ dims, to map the rank-reduced type to the source type by dropping ones: 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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract_slice(source, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "tensor.extract_slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -404,22 +346,18 @@ will result in a tensor [[%a, %b, %c] [%d, %e, %f]] """ -function from_elements(elements::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[elements...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.from_elements", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function from_elements(elements; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(elements)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.from_elements", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -520,30 +458,19 @@ op: (memref<4x4xf32>, memref) -> memref> ``` """ -function gather( - source::Value, - indices::Value; - result::IR.Type, - gather_dims, - unique=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[source, indices] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("gather_dims", gather_dims),] - !isnothing(unique) && push!(_attributes, namedattribute("unique", unique)) - - return IR.create_operation( - "tensor.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gather(source, indices; result::IR.Type, gather_dims, unique=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(indices), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("gather_dims", gather_dims), ] + !isnothing(unique) && push!(attributes, namedattribute("unique", unique)) + + IR.create_operation( + "tensor.gather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -569,24 +496,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,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.generate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function generate(dynamicExtents; result::IR.Type, body::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value.(dynamicExtents)..., ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.generate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -609,29 +530,18 @@ indices should be of `index` type. %5 = tensor.insert %rt into %dest[%1, %2] : tensor ``` """ -function insert( - scalar::Value, - dest::Value, - indices::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[scalar, dest, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "tensor.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert(scalar, dest, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(scalar), value(dest), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.insert", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -689,42 +599,19 @@ Unlike ExtractSliceOp however, there is no need for a specific inference. tensor<1x?xf32> into tensor<8x16x4xf32> ``` """ -function insert_slice( - source::Value, - dest::Value, - offsets::Vector{Value}, - sizes::Vector{Value}, - strides::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - static_offsets, - static_sizes, - static_strides, - location=Location(), -) - _results = IR.Type[] - _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)]), - ) - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "tensor.insert_slice", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert_slice(source, dest, offsets, sizes, strides; result::IR.Type, static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(dest), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "tensor.insert_slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -767,43 +654,21 @@ Example NC_to_NCnc with padding: inner_tiles = [8, 2] into %arg1 : tensor<13x15xf32> -> tensor<2x8x8x2xf32> ``` """ -function pack( - source::Value, - dest::Value, - padding_value=nothing::Union{Nothing,Value}; - inner_tiles::Vector{Value}, - result=nothing::Union{Nothing,IR.Type}, - outer_dims_perm=nothing, - inner_dims_pos, - static_inner_tiles, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest, inner_tiles...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("inner_dims_pos", inner_dims_pos), - namedattribute("static_inner_tiles", static_inner_tiles), - ] - !isnothing(padding_value) && push!(_operands, padding_value) - push!( - _attributes, - operandsegmentsizes([1, 1, isnothing(padding_value) ? 0 : 1, length(inner_tiles)]), - ) - !isnothing(result) && push!(_results, result) - !isnothing(outer_dims_perm) && - push!(_attributes, namedattribute("outer_dims_perm", outer_dims_perm)) - - return IR.create_operation( - "tensor.pack", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function pack(source, dest, padding_value=nothing; inner_tiles, result::IR.Type, outer_dims_perm=nothing, inner_dims_pos, static_inner_tiles, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(dest), value.(inner_tiles)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("inner_dims_pos", inner_dims_pos), namedattribute("static_inner_tiles", static_inner_tiles), ] + !isnothing(padding_value) && push!(operands, value(padding_value)) + push!(attributes, operandsegmentsizes([1, 1, (padding_value==nothing) ? 0 : 1length(inner_tiles), ])) + !isnothing(outer_dims_perm) && push!(attributes, namedattribute("outer_dims_perm", outer_dims_perm)) + + IR.create_operation( + "tensor.pack", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -879,36 +744,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,] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pad(source, low, high; result::IR.Type, static_low, static_high, nofold=nothing, region::Region, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value.(low)..., value.(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), ])) + !isnothing(nofold) && push!(attributes, namedattribute("nofold", nofold)) + + IR.create_operation( + "tensor.pad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -972,40 +821,19 @@ rank-reducing behavior of tensor.insert_slice and tensor.extract_slice. The same verification discussion and mechanisms apply as for ExtractSliceOp. Unlike ExtractSliceOp however, there is no need for a specific inference. """ -function parallel_insert_slice( - source::Value, - dest::Value, - offsets::Vector{Value}, - sizes::Vector{Value}, - strides::Vector{Value}; - static_offsets, - static_sizes, - static_strides, - location=Location(), -) - _results = IR.Type[] - _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.parallel_insert_slice", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function parallel_insert_slice(source, dest, offsets, sizes, strides; static_offsets, static_sizes, static_strides, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), value.(offsets)..., value.(sizes)..., value.(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), ])) + + IR.create_operation( + "tensor.parallel_insert_slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1021,23 +849,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()) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function rank(tensor; result_0=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(tensor), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result_0) && push!(results, result_0) + + IR.create_operation( + "tensor.rank", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1075,22 +899,18 @@ Result type is unranked. : (tensor<*xf32>, tensor) -> tensor<*xf32> ``` """ -function reshape(source::Value, shape::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source, shape] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(source, shape; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(shape), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1194,31 +1014,19 @@ op: some_side_effecting_op_writing_into %v, ...: memref> ``` """ -function scatter( - source::Value, - dest::Value, - indices::Value; - result::IR.Type, - scatter_dims, - unique=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[source, dest, indices] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("scatter_dims", scatter_dims),] - !isnothing(unique) && push!(_attributes, namedattribute("unique", unique)) - - return IR.create_operation( - "tensor.scatter", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scatter(source, dest, indices; result::IR.Type, scatter_dims, unique=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(dest), value(indices), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("scatter_dims", scatter_dims), ] + !isnothing(unique) && push!(attributes, namedattribute("unique", unique)) + + IR.create_operation( + "tensor.scatter", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1247,22 +1055,18 @@ TODO: This operation is easy to extend to broadcast to dynamically shaped %t = tensor.splat %s [%m, %n] : tensor ``` """ -function splat(input::Value; aggregate::IR.Type, location=Location()) - _results = IR.Type[aggregate,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.splat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function splat(input; aggregate::IR.Type, location=Location()) + results = IR.Type[aggregate, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.splat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1290,37 +1094,19 @@ Example CK to KCck: inner_tiles = [8, 32] into %dest : tensor<8x16x8x32xf32> -> tensor<128x256xf32> ``` """ -function unpack( - source::Value, - dest::Value, - inner_tiles::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - outer_dims_perm=nothing, - inner_dims_pos, - static_inner_tiles, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest, inner_tiles...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("inner_dims_pos", inner_dims_pos), - namedattribute("static_inner_tiles", static_inner_tiles), - ] - !isnothing(result) && push!(_results, result) - !isnothing(outer_dims_perm) && - push!(_attributes, namedattribute("outer_dims_perm", outer_dims_perm)) - - return IR.create_operation( - "tensor.unpack", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function unpack(source, dest, inner_tiles; result::IR.Type, outer_dims_perm=nothing, inner_dims_pos, static_inner_tiles, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), value(dest), value.(inner_tiles)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("inner_dims_pos", inner_dims_pos), namedattribute("static_inner_tiles", static_inner_tiles), ] + !isnothing(outer_dims_perm) && push!(attributes, namedattribute("outer_dims_perm", outer_dims_perm)) + + IR.create_operation( + "tensor.unpack", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1331,22 +1117,18 @@ This operation is used to yield a single value from a within a region. It is used to create dynamically sized tensors (see `tensor.generate` and `tensor.pad` ops). """ -function yield(value::Value; location=Location()) - _results = IR.Type[] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tensor.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(value; location=Location()) + results = IR.Type[] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tensor.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Tosa.jl b/src/Dialects/17/Tosa.jl index 42430c5c..3f793638 100644 --- a/src/Dialects/17/Tosa.jl +++ b/src/Dialects/17/Tosa.jl @@ -1,7 +1,6 @@ module tosa -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -9,22 +8,18 @@ import ..Dialects: namedattribute, operandsegmentsizes Elementwise absolute value operation """ -function abs(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.abs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function abs(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.abs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -34,22 +29,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.add", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function add(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.add", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -63,29 +54,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("double_round", double_round),] - - return IR.create_operation( - "tosa.apply_scale", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_scale(value, multiplier, shift; output::IR.Type, double_round, location=Location()) + results = IR.Type[output, ] + operands = Value[value(value), value(multiplier), value(shift), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("double_round", double_round), ] + + IR.create_operation( + "tosa.apply_scale", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -95,22 +75,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.argmax", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function argmax(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.argmax", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -120,24 +96,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("round", round),] - - return IR.create_operation( - "tosa.arithmetic_right_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function arithmetic_right_shift(input1, input2; output::IR.Type, round, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("round", round), ] + + IR.create_operation( + "tosa.arithmetic_right_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -148,38 +118,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, - acc_type, - 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), - namedattribute("acc_type", acc_type), - ] - !isnothing(quantization_info) && - push!(_attributes, namedattribute("quantization_info", quantization_info)) - - return IR.create_operation( - "tosa.avg_pool2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avg_pool2d(input; output::IR.Type, kernel, stride, pad, acc_type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kernel", kernel), namedattribute("stride", stride), namedattribute("pad", pad), namedattribute("acc_type", acc_type), ] + !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 ) end @@ -189,22 +140,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_and(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_and", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -213,22 +160,18 @@ end Elementwise bitwise NOT of input tensor. """ -function bitwise_not(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_not(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_not", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -238,22 +181,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_or(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_or", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -263,22 +202,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.bitwise_xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitwise_xor(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.bitwise_xor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -308,22 +243,18 @@ Performs a set of permissible cast operations | float 32 to float 64 | float32 | float64 | | float 64 to float 32 | float64 | float32 | """ -function cast(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -332,22 +263,18 @@ end Elementwise ceiling operation """ -function ceil(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.ceil", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function ceil(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.ceil", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -360,29 +287,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clamp(input; output::IR.Type, min_int, max_int, min_fp, max_fp, location=Location()) + results = IR.Type[output, ] + operands = Value[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), ] + + IR.create_operation( + "tosa.clamp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -391,22 +307,18 @@ end Elementwise count leading zeros operation """ -function clz(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.clz", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function clz(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.clz", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -416,25 +328,19 @@ end Concatenate a variadic amount of tensors along a given axis. No data conversion happens during a concat operation. """ -function concat( - input1::Vector{Value}; output=nothing::Union{Nothing,IR.Type}, axis, location=Location() -) - _results = IR.Type[] - _operands = Value[input1...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "tosa.concat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function concat(input1; output=nothing::Union{Nothing, IR.Type}, axis, location=Location()) + results = IR.Type[] + operands = Value[value.(input1)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "tosa.concat", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -470,38 +376,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv2d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.conv2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -510,38 +397,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function conv3d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.conv3d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -567,33 +435,18 @@ set of attributes to the custom operator. `outputs is the list of tensors returned by the operator. The number of operators is backend specific. """ -function custom( - inputs::Vector{Value}; - outputs::Vector{IR.Type}, - identifier, - config, - implementation_attrs, - location=Location(), -) - _results = IR.Type[outputs...,] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("identifier", identifier), - namedattribute("config", config), - namedattribute("implementation_attrs", implementation_attrs), - ] - - return IR.create_operation( - "tosa.custom", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function custom(inputs; outputs::Vector{IR.Type}, identifier, config, implementation_attrs, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("identifier", identifier), namedattribute("config", config), namedattribute("implementation_attrs", implementation_attrs), ] + + IR.create_operation( + "tosa.custom", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -603,38 +456,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function depthwise_conv2d(input, weight, bias; output::IR.Type, pad, stride, dilation, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(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)) + + IR.create_operation( + "tosa.depthwise_conv2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -644,22 +478,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.div", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function div(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.div", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -668,28 +498,19 @@ end Elementwise comparison operation """ -function equal( - input1::Value, - input2::Value; - output=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[input1, input2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "tosa.equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function equal(input1, input2; output=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "tosa.equal", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -701,22 +522,18 @@ For quantized integer data types, the TABLE operator should be used instead with the following definition. The erf_table has 513 entries each of 16-bit/8-bit precision and covering the input range -4.0 to +4.0 in steps of 1/64. """ -function erf(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.erf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function erf(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.erf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -725,22 +542,18 @@ end Elementwise e to the x operation """ -function exp(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.exp", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function exp(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.exp", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -753,29 +566,18 @@ input_real and input_imag tensors. The resulting values in the output are split into the output_real and output_imag tensors. No normalization is applied on either the forward or inverse versions of the operation. """ -function fft2d( - input_real::Value, - input_imag::Value; - output_real::IR.Type, - output_imag::IR.Type, - inverse, - location=Location(), -) - _results = IR.Type[output_real, output_imag] - _operands = Value[input_real, input_imag] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("inverse", inverse),] - - return IR.create_operation( - "tosa.fft2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fft2d(input_real, input_imag; output_real::IR.Type, output_imag::IR.Type, inverse, location=Location()) + results = IR.Type[output_real, output_imag, ] + operands = Value[value(input_real), value(input_imag), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("inverse", inverse), ] + + IR.create_operation( + "tosa.fft2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -784,22 +586,18 @@ end Elementwise floor operation """ -function floor(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.floor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function floor(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.floor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -808,31 +606,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function fully_connected(input, weight, bias; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(weight), value(bias), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -842,22 +628,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gather(values, indices; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(values), value(indices), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.gather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -866,46 +648,38 @@ end Elementwise comparison operation """ -function greater_equal(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.greater_equal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end +function greater_equal(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.greater_equal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `greater` Elementwise greater than comparison operation """ -function greater(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.greater", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function greater(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.greater", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -915,22 +689,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.identity", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function identity(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.identity", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -940,29 +710,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] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.cond_if", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cond_if(cond, inputs; output::Vector{IR.Type}, then_branch::Region, else_branch::Region, location=Location()) + results = IR.Type[output..., ] + operands = Value[value(cond), value.(inputs)..., ] + owned_regions = Region[then_branch, else_branch, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.cond_if", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -971,22 +730,18 @@ end Elementwise natural logarithm operation """ -function log(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.log", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function log(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.log", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -996,22 +751,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_and", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_and(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_and", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1021,24 +772,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_left_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_left_shift(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_left_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1047,22 +792,18 @@ end Elementwise logical NOT of input. """ -function logical_not(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_not", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_not(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_not", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1072,22 +813,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_or", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_or(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_or", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1097,24 +834,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_right_shift", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_right_shift(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_right_shift", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1124,22 +855,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.logical_xor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function logical_xor(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.logical_xor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1150,26 +877,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matmul(a, b; c::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[c, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -1181,26 +901,18 @@ size given by is passed over the input tensor, with the 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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function max_pool2d(input; output::IR.Type, kernel, stride, pad, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -1210,22 +922,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.maximum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maximum(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.maximum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1235,22 +943,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.minimum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function minimum(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.minimum", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1261,22 +965,18 @@ Elementwise multiplication (Hadamard product) of input1 and input2. Axis of size 1 will be broadcast, as necessary. i8/i16 input type can be promoted to i32 result type. """ -function mul(input1::Value, input2::Value; output::IR.Type, shift, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mul(input1, input2; output::IR.Type, shift, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("shift", shift), ] + + IR.create_operation( + "tosa.mul", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1285,26 +985,19 @@ end Elementwise negation operation """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function negate(input1; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !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 ) end @@ -1329,32 +1022,20 @@ Example 2: \"tosa.pad\"(%arg0, %0) : (tensor<1x2xf32>, tensor<2x2xi32>) -> (tensor) ``` """ -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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pad(input1, padding, pad_const=nothing; output::IR.Type, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(padding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(pad_const) && push!(operands, value(pad_const)) + !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 ) end @@ -1364,22 +1045,18 @@ end 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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.pow", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function pow(input1, input2; z::IR.Type, location=Location()) + results = IR.Type[z, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.pow", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1393,24 +1070,18 @@ tensor arguments. RFFT2D takes advantage of Hermitian symmetry to only calculate the first half of the final output axis. Imaginary values with locations (0,0), (0,W/2), (H/2,0) and (H/2,W/2) are zero. """ -function rfft2d( - input::Value; output_real::IR.Type, output_imag::IR.Type, location=Location() -) - _results = IR.Type[output_real, output_imag] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.rfft2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rfft2d(input; output_real::IR.Type, output_imag::IR.Type, location=Location()) + results = IR.Type[output_real, output_imag, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.rfft2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1420,22 +1091,18 @@ end 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.reciprocal", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reciprocal(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.reciprocal", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1444,25 +1111,19 @@ end Reduce a tensor along the given axis with a logical AND operation """ -function reduce_all( - input::Value; output=nothing::Union{Nothing,IR.Type}, axis, location=Location() -) - _results = IR.Type[] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "tosa.reduce_all", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function reduce_all(input; output=nothing::Union{Nothing, IR.Type}, axis, location=Location()) + results = IR.Type[] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "tosa.reduce_all", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1471,25 +1132,19 @@ end Reduce a tensor along the given axis with a logical OR operation """ -function reduce_any( - input::Value; output=nothing::Union{Nothing,IR.Type}, axis, location=Location() -) - _results = IR.Type[] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "tosa.reduce_any", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function reduce_any(input; output=nothing::Union{Nothing, IR.Type}, axis, location=Location()) + results = IR.Type[] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "tosa.reduce_any", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1498,25 +1153,19 @@ end Reduce a tensor along the given axis with a maximum operation """ -function reduce_max( - input::Value; output=nothing::Union{Nothing,IR.Type}, axis, location=Location() -) - _results = IR.Type[] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "tosa.reduce_max", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function reduce_max(input; output=nothing::Union{Nothing, IR.Type}, axis, location=Location()) + results = IR.Type[] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "tosa.reduce_max", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1525,25 +1174,19 @@ end Reduce a tensor along the given axis with a minimum operation """ -function reduce_min( - input::Value; output=nothing::Union{Nothing,IR.Type}, axis, location=Location() -) - _results = IR.Type[] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "tosa.reduce_min", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function reduce_min(input; output=nothing::Union{Nothing, IR.Type}, axis, location=Location()) + results = IR.Type[] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "tosa.reduce_min", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1552,25 +1195,19 @@ end Reduce a tensor along the given axis by computing the product of the axis. """ -function reduce_prod( - input::Value; output=nothing::Union{Nothing,IR.Type}, axis, location=Location() -) - _results = IR.Type[] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "tosa.reduce_prod", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function reduce_prod(input; output=nothing::Union{Nothing, IR.Type}, axis, location=Location()) + results = IR.Type[] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "tosa.reduce_prod", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1579,25 +1216,19 @@ end Reduce a tensor along the given axis by computing the sum of the axis. """ -function reduce_sum( - input::Value; output=nothing::Union{Nothing,IR.Type}, axis, location=Location() -) - _results = IR.Type[] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "tosa.reduce_sum", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function reduce_sum(input; output=nothing::Union{Nothing, IR.Type}, axis, location=Location()) + results = IR.Type[] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "tosa.reduce_sum", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1621,41 +1252,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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rescale(input; output::IR.Type, input_zp, output_zp, multiplier, shift, scale32, double_round, per_channel, location=Location()) + results = IR.Type[output, ] + operands = Value[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 @@ -1666,25 +1274,19 @@ Returns a tensor with the same type/values as the input, with a new shape 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=nothing::Union{Nothing,IR.Type}, new_shape, location=Location() -) - _results = IR.Type[] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("new_shape", new_shape),] - !isnothing(output) && push!(_results, output) - - return IR.create_operation( - "tosa.reshape", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function reshape(input1; output=nothing::Union{Nothing, IR.Type}, new_shape, location=Location()) + results = IR.Type[] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("new_shape", new_shape), ] + !isnothing(output) && push!(results, output) + + IR.create_operation( + "tosa.reshape", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1698,29 +1300,18 @@ output dimensions can be derived from the input dimensions by inverting the scale. And the [order_y, border_x] values adjust the output size to allow fractional sampling beyond integer input position (IH-1,IW-1). """ -function resize( - input::Value; output::IR.Type, scale, offset, border, mode, location=Location() -) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("scale", scale), - namedattribute("offset", offset), - namedattribute("border", border), - namedattribute("mode", mode), - ] - - return IR.create_operation( - "tosa.resize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function resize(input; output::IR.Type, scale, offset, border, mode, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("scale", scale), namedattribute("offset", offset), namedattribute("border", border), namedattribute("mode", mode), ] + + IR.create_operation( + "tosa.resize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1731,22 +1322,18 @@ Returns a tensor with the same type/values as the input, with the data reversed along the given axis. No data conversion happens during a reverse operation. """ -function reverse(input::Value; output::IR.Type, axis, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("axis", axis),] - - return IR.create_operation( - "tosa.reverse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reverse(input; output::IR.Type, axis, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("axis", axis), ] + + IR.create_operation( + "tosa.reverse", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1756,22 +1343,18 @@ end Elementwise reciprocal square root operation. For integer operation, a TABLE should be used with the appropriate ranges. """ -function rsqrt(input1::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function rsqrt(input1; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.rsqrt", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1781,24 +1364,18 @@ end The values_out tensor is set to the values_in tensor with data modified as follows: data from the input tensor is inserted at the positions specified by the indices tensor. """ -function scatter( - values_in::Value, indices::Value, input::Value; values_out::IR.Type, location=Location() -) - _results = IR.Type[values_out,] - _operands = Value[values_in, indices, input] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.scatter", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scatter(values_in, indices, input; values_out::IR.Type, location=Location()) + results = IR.Type[values_out, ] + operands = Value[value(values_in), value(indices), value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.scatter", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1807,24 +1384,18 @@ end Elementwise select of the output based on a condition. """ -function select( - pred::Value, on_true::Value, on_false::Value; output::IR.Type, location=Location() -) - _results = IR.Type[output,] - _operands = Value[pred, on_true, on_false] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function select(pred, on_true, on_false; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(pred), value(on_true), value(on_false), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.select", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1837,22 +1408,18 @@ with the following definition. The sigmoid table has 513 entries each of 16-bit precision and covering the input range -16.0 to +16.0 in steps of 1/16. """ -function sigmoid(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.sigmoid", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sigmoid(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.sigmoid", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1863,24 +1430,18 @@ Extracts a slice of the input1 on the given axis, beginning at the start coordinates, and extending for size elements in each direction. No data conversion happens during a slice operation. """ -function slice(input::Value; output::IR.Type, start, size, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("start", start), namedattribute("size", size) - ] - - return IR.create_operation( - "tosa.slice", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function slice(input; output::IR.Type, start, size, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("start", start), namedattribute("size", size), ] + + IR.create_operation( + "tosa.slice", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1890,22 +1451,18 @@ end Elementwise subtraction of input1 and input2. Axis of size 1 will be broadcast as necessary. """ -function sub(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.sub", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sub(input1, input2; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(input2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.sub", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1927,22 +1484,18 @@ The TABLE operator is expected to be used as follows: * If an int8_t result is required then follow the TABLE operator with a RESCALE with a right shift of 15 """ -function table(input::Value, table::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input, table] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.table", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function table(input, table; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(table), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.table", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1954,22 +1507,18 @@ For quantized integer data types, the TABLE operator should be used instead with the following definition. The tanh_table has 513 entries each of 16-bit precision and covering the input range -8.0 to +8.0 in steps of 1/32. """ -function tanh(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.tanh", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tanh(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.tanh", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1978,22 +1527,18 @@ end Replicates input 0 multiplies times along each dimension. """ -function tile(input1::Value; output::IR.Type, multiples, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("multiples", multiples),] - - return IR.create_operation( - "tosa.tile", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tile(input1; output::IR.Type, multiples, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("multiples", multiples), ] + + IR.create_operation( + "tosa.tile", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2003,38 +1548,19 @@ end Performs a 2D transposed convolution over the given tensor input, using the weights tensor. """ -function transpose_conv2d( - input::Value, - filter::Value, - bias::Value; - output::IR.Type, - out_pad, - stride, - out_shape, - quantization_info=nothing, - location=Location(), -) - _results = IR.Type[output,] - _operands = Value[input, filter, bias] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("out_pad", out_pad), - namedattribute("stride", stride), - namedattribute("out_shape", out_shape), - ] - !isnothing(quantization_info) && - push!(_attributes, namedattribute("quantization_info", quantization_info)) - - return IR.create_operation( - "tosa.transpose_conv2d", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose_conv2d(input, filter, bias; output::IR.Type, out_pad, stride, out_shape, quantization_info=nothing, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), value(filter), value(bias), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("out_pad", out_pad), namedattribute("stride", stride), namedattribute("out_shape", out_shape), ] + !isnothing(quantization_info) && push!(attributes, namedattribute("quantization_info", quantization_info)) + + IR.create_operation( + "tosa.transpose_conv2d", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2043,22 +1569,18 @@ end Permutes the dimensions based on perm. """ -function transpose(input1::Value, perms::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input1, perms] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(input1, perms; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input1), value(perms), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2070,28 +1592,18 @@ exits to another control point. This action is performed repeatedly after updating and re-evaluating the Boolean condition every iteration. This implements the semantic foreach or while iterative loop structure. """ -function while_loop( - inputs::Vector{Value}; - output::Vector{IR.Type}, - cond::Region, - body::Region, - location=Location(), -) - _results = IR.Type[output...,] - _operands = Value[inputs...,] - _owned_regions = Region[cond, body] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.while_loop", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function while_loop(inputs; output::Vector{IR.Type}, cond::Region, body::Region, location=Location()) + results = IR.Type[output..., ] + operands = Value[value.(inputs)..., ] + owned_regions = Region[cond, body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.while_loop", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2102,22 +1614,18 @@ return operation within the conditional and body of structured control flow. Operation takes variadic operands but produces no results of its own. """ -function yield(inputs::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[inputs...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "tosa.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(inputs; location=Location()) + results = IR.Type[] + operands = Value[value.(inputs)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "tosa.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/Transform.jl b/src/Dialects/17/Transform.jl index fa70e144..4a8bbdeb 100644 --- a/src/Dialects/17/Transform.jl +++ b/src/Dialects/17/Transform.jl @@ -1,7 +1,6 @@ module transform -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -33,36 +32,22 @@ handles. TODO: Support affine.apply targets. TODO: Allow mixed PDL_Operation/int64_t for lower_bounds and upper_bounds. """ -function affine_simplify_bounded_affine_ops( - target::Value, - bounded_values::Vector{Value}; - lower_bounds, - upper_bounds, - location=Location(), -) - _results = IR.Type[] - _operands = Value[target, bounded_values...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("lower_bounds", lower_bounds), - namedattribute("upper_bounds", upper_bounds), - ] - - return IR.create_operation( - "transform.affine.simplify_bounded_affine_ops", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function affine_simplify_bounded_affine_ops(target, bounded_values; lower_bounds, upper_bounds, location=Location()) + results = IR.Type[] + operands = Value[value(target), value.(bounded_values)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("lower_bounds", lower_bounds), namedattribute("upper_bounds", upper_bounds), ] + + IR.create_operation( + "transform.affine.simplify_bounded_affine_ops", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -74,22 +59,18 @@ deallocation ops in the IR. This transform reads the `target` handle and modifies the payload. """ -function bufferization_buffer_loop_hoisting(target::Value; location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.bufferization.buffer_loop_hoisting", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bufferization_buffer_loop_hoisting(target; location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.bufferization.buffer_loop_hoisting", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -136,22 +117,18 @@ See `-eliminate-empty-tensors` for more details. This transform reads the target handle and modifies the payload. It does not produce any handle. """ -function bufferization_eliminate_empty_tensors(target::Value; location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.bufferization.eliminate_empty_tensors", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bufferization_eliminate_empty_tensors(target; location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.bufferization.eliminate_empty_tensors", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -166,24 +143,18 @@ This operation consumes the `target` handle and produces the `transformed` handle. `target` is expected to be a `tensor.empty` operation. The transform always succeeds. """ -function bufferization_empty_tensor_to_alloc_tensor( - target::Value; transformed::IR.Type, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.bufferization.empty_tensor_to_alloc_tensor", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bufferization_empty_tensor_to_alloc_tensor(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.bufferization.empty_tensor_to_alloc_tensor", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -211,60 +182,30 @@ otherwise, said ops would be considered non-bufferizable. This operation consumes the `target` handle and produces the `transformed` handle. """ -function bufferization_one_shot_bufferize( - target::Value; - transformed::IR.Type, - function_boundary_type_conversion=nothing, - allow_return_allocs=nothing, - allow_unknown_ops=nothing, - bufferize_function_boundaries=nothing, - create_deallocs=nothing, - test_analysis_only=nothing, - print_conflicts=nothing, - memcpy_op=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(function_boundary_type_conversion) && push!( - _attributes, - namedattribute( - "function_boundary_type_conversion", function_boundary_type_conversion - ), - ) - !isnothing(allow_return_allocs) && - push!(_attributes, namedattribute("allow_return_allocs", allow_return_allocs)) - !isnothing(allow_unknown_ops) && - push!(_attributes, namedattribute("allow_unknown_ops", allow_unknown_ops)) - !isnothing(bufferize_function_boundaries) && push!( - _attributes, - namedattribute("bufferize_function_boundaries", bufferize_function_boundaries), - ) - !isnothing(create_deallocs) && - push!(_attributes, namedattribute("create_deallocs", create_deallocs)) - !isnothing(test_analysis_only) && - push!(_attributes, namedattribute("test_analysis_only", test_analysis_only)) - !isnothing(print_conflicts) && - push!(_attributes, namedattribute("print_conflicts", print_conflicts)) - !isnothing(memcpy_op) && push!(_attributes, namedattribute("memcpy_op", memcpy_op)) - - return IR.create_operation( - "transform.bufferization.one_shot_bufferize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +function bufferization_one_shot_bufferize(target; transformed::IR.Type, function_boundary_type_conversion=nothing, allow_return_allocs=nothing, allow_unknown_ops=nothing, bufferize_function_boundaries=nothing, create_deallocs=nothing, test_analysis_only=nothing, print_conflicts=nothing, memcpy_op=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(function_boundary_type_conversion) && push!(attributes, namedattribute("function_boundary_type_conversion", function_boundary_type_conversion)) + !isnothing(allow_return_allocs) && push!(attributes, namedattribute("allow_return_allocs", allow_return_allocs)) + !isnothing(allow_unknown_ops) && push!(attributes, namedattribute("allow_unknown_ops", allow_unknown_ops)) + !isnothing(bufferize_function_boundaries) && push!(attributes, namedattribute("bufferize_function_boundaries", bufferize_function_boundaries)) + !isnothing(create_deallocs) && push!(attributes, namedattribute("create_deallocs", create_deallocs)) + !isnothing(test_analysis_only) && push!(attributes, namedattribute("test_analysis_only", test_analysis_only)) + !isnothing(print_conflicts) && push!(attributes, namedattribute("print_conflicts", print_conflicts)) + !isnothing(memcpy_op) && push!(attributes, namedattribute("memcpy_op", memcpy_op)) + + IR.create_operation( + "transform.bufferization.one_shot_bufferize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -351,31 +292,20 @@ The returned handle points to the same LaunchOp operand, consuming it and producing a new SSA value to satisfy chaining and linearity of the IR properties. """ -function gpu_map_forall_to_blocks( - target::Value; - result::IR.Type, - grid_dims=nothing, - generate_gpu_launch=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(grid_dims) && push!(_attributes, namedattribute("grid_dims", grid_dims)) - !isnothing(generate_gpu_launch) && - push!(_attributes, namedattribute("generate_gpu_launch", generate_gpu_launch)) - - return IR.create_operation( - "transform.gpu.map_forall_to_blocks", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gpu_map_forall_to_blocks(target; result::IR.Type, grid_dims=nothing, generate_gpu_launch=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(grid_dims) && push!(attributes, namedattribute("grid_dims", grid_dims)) + !isnothing(generate_gpu_launch) && push!(attributes, namedattribute("generate_gpu_launch", generate_gpu_launch)) + + IR.create_operation( + "transform.gpu.map_forall_to_blocks", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -470,38 +400,25 @@ gpu.launch blocks(%bx, %by, %bz) in (%x = %0, %y = %1, %z = %2) } ``` """ -function gpu_map_nested_forall_to_threads( - target::Value; - result::IR.Type, - block_dims=nothing, - warp_dims=nothing, - sync_after_distribute=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(block_dims) && push!(_attributes, namedattribute("block_dims", block_dims)) - !isnothing(warp_dims) && push!(_attributes, namedattribute("warp_dims", warp_dims)) - !isnothing(sync_after_distribute) && - push!(_attributes, namedattribute("sync_after_distribute", sync_after_distribute)) - - return IR.create_operation( - "transform.gpu.map_nested_forall_to_threads", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +function gpu_map_nested_forall_to_threads(target; result::IR.Type, block_dims=nothing, warp_dims=nothing, sync_after_distribute=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(block_dims) && push!(attributes, namedattribute("block_dims", block_dims)) + !isnothing(warp_dims) && push!(attributes, namedattribute("warp_dims", warp_dims)) + !isnothing(sync_after_distribute) && push!(attributes, namedattribute("sync_after_distribute", sync_after_distribute)) + + IR.create_operation( + "transform.gpu.map_nested_forall_to_threads", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -535,34 +452,21 @@ Succeeds if the operation body satisfies the specified criteria, produces a silenceable failure otherwise. Produces a definite failure if the operand is not associated with a single payload op. """ -function match_structured_body( - operand_handle::Value; - reduction_position=nothing, - passthrough=nothing, - contraction=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(reduction_position) && - push!(_attributes, namedattribute("reduction_position", reduction_position)) - !isnothing(passthrough) && - push!(_attributes, namedattribute("passthrough", passthrough)) - !isnothing(contraction) && - push!(_attributes, namedattribute("contraction", contraction)) - - return IR.create_operation( - "transform.match.structured.body", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured_body(operand_handle; reduction_position=nothing, passthrough=nothing, contraction=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand_handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(reduction_position) && push!(attributes, namedattribute("reduction_position", reduction_position)) + !isnothing(passthrough) && push!(attributes, namedattribute("passthrough", passthrough)) + !isnothing(contraction) && push!(attributes, namedattribute("contraction", contraction)) + + IR.create_operation( + "transform.match.structured.body", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -594,29 +498,18 @@ to have been already checked for being a single structured op. Succeeds if the operation has the contraction-like dimensions, produces a silenceable failure otherwise. """ -function match_structured_classify_contraction_dims( - operand_handle::Value; - batch::IR.Type, - m::IR.Type, - n::IR.Type, - k::IR.Type, - location=Location(), -) - _results = IR.Type[batch, m, n, k] - _operands = Value[operand_handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.match.structured.classify_contraction_dims", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured_classify_contraction_dims(operand_handle; batch::IR.Type, m::IR.Type, n::IR.Type, k::IR.Type, location=Location()) + results = IR.Type[batch, m, n, k, ] + operands = Value[value(operand_handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.match.structured.classify_contraction_dims", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -669,37 +562,23 @@ Succeeds if the specified dimensions satisfy the specified criteria, produces a silenceable failure otherwise. Produces a definite failure if the operand is not associated with a single payload op. """ -function match_structured_dim( - operand_handle::Value; - result=nothing::Union{Nothing,IR.Type}, - raw_dim_list, - is_inverted=nothing, - is_all=nothing, - parallel=nothing, - reduction=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("raw_dim_list", raw_dim_list),] - !isnothing(result) && push!(_results, result) - !isnothing(is_inverted) && - push!(_attributes, namedattribute("is_inverted", is_inverted)) - !isnothing(is_all) && push!(_attributes, namedattribute("is_all", is_all)) - !isnothing(parallel) && push!(_attributes, namedattribute("parallel", parallel)) - !isnothing(reduction) && push!(_attributes, namedattribute("reduction", reduction)) - - return IR.create_operation( - "transform.match.structured.dim", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured_dim(operand_handle; result=nothing::Union{Nothing, IR.Type}, raw_dim_list, is_inverted=nothing, is_all=nothing, parallel=nothing, reduction=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand_handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("raw_dim_list", raw_dim_list), ] + !isnothing(result) && push!(results, result) + !isnothing(is_inverted) && push!(attributes, namedattribute("is_inverted", is_inverted)) + !isnothing(is_all) && push!(attributes, namedattribute("is_all", is_all)) + !isnothing(parallel) && push!(attributes, namedattribute("parallel", parallel)) + !isnothing(reduction) && push!(attributes, namedattribute("reduction", reduction)) + + IR.create_operation( + "transform.match.structured.dim", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -718,24 +597,18 @@ to have been already checked for being a single structured op. Succeeds if the operand is associated with exactly one payload value of `ShapedType`. Produces a silenceable failure otherwise. """ -function match_structured_elemental_bitwidth( - operand_handle::Value; result::IR.Type, location=Location() -) - _results = IR.Type[result,] - _operands = Value[operand_handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.match.structured.elemental_bitwidth", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured_elemental_bitwidth(operand_handle; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand_handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.match.structured.elemental_bitwidth", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -800,39 +673,23 @@ failure otherwise. Additionally, when the result is an operation handle, produces a silenceable failure if the init(outs) specification defines more than one init(outs) or if the operand is not an operation result. """ -function match_structured_init( - operand_handle::Value; - result=nothing::Union{Nothing,IR.Type}, - raw_position_list, - is_inverted=nothing, - is_all=nothing, - permutation=nothing, - projected_permutation=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("raw_position_list", raw_position_list),] - !isnothing(result) && push!(_results, result) - !isnothing(is_inverted) && - push!(_attributes, namedattribute("is_inverted", is_inverted)) - !isnothing(is_all) && push!(_attributes, namedattribute("is_all", is_all)) - !isnothing(permutation) && - push!(_attributes, namedattribute("permutation", permutation)) - !isnothing(projected_permutation) && - push!(_attributes, namedattribute("projected_permutation", projected_permutation)) - - return IR.create_operation( - "transform.match.structured.init", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured_init(operand_handle; result=nothing::Union{Nothing, IR.Type}, raw_position_list, is_inverted=nothing, is_all=nothing, permutation=nothing, projected_permutation=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand_handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("raw_position_list", raw_position_list), ] + !isnothing(result) && push!(results, result) + !isnothing(is_inverted) && push!(attributes, namedattribute("is_inverted", is_inverted)) + !isnothing(is_all) && push!(attributes, namedattribute("is_all", is_all)) + !isnothing(permutation) && push!(attributes, namedattribute("permutation", permutation)) + !isnothing(projected_permutation) && push!(attributes, namedattribute("projected_permutation", projected_permutation)) + + IR.create_operation( + "transform.match.structured.init", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -898,39 +755,23 @@ otherwise. Additionally, when the result is an operation handle, produces a silenceable failure if the input specification defines more than one input or if the operand is not an operation result. """ -function match_structured_input( - operand_handle::Value; - result=nothing::Union{Nothing,IR.Type}, - raw_position_list, - is_inverted=nothing, - is_all=nothing, - permutation=nothing, - projected_permutation=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[operand_handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("raw_position_list", raw_position_list),] - !isnothing(result) && push!(_results, result) - !isnothing(is_inverted) && - push!(_attributes, namedattribute("is_inverted", is_inverted)) - !isnothing(is_all) && push!(_attributes, namedattribute("is_all", is_all)) - !isnothing(permutation) && - push!(_attributes, namedattribute("permutation", permutation)) - !isnothing(projected_permutation) && - push!(_attributes, namedattribute("projected_permutation", projected_permutation)) - - return IR.create_operation( - "transform.match.structured.input", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured_input(operand_handle; result=nothing::Union{Nothing, IR.Type}, raw_position_list, is_inverted=nothing, is_all=nothing, permutation=nothing, projected_permutation=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(operand_handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("raw_position_list", raw_position_list), ] + !isnothing(result) && push!(results, result) + !isnothing(is_inverted) && push!(attributes, namedattribute("is_inverted", is_inverted)) + !isnothing(is_all) && push!(attributes, namedattribute("is_all", is_all)) + !isnothing(permutation) && push!(attributes, namedattribute("permutation", permutation)) + !isnothing(projected_permutation) && push!(attributes, namedattribute("projected_permutation", projected_permutation)) + + IR.create_operation( + "transform.match.structured.input", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -952,24 +793,18 @@ to have been already checked for being a single structured op. Succeeds if the operand is associated with exactly one structured payload operation. Produces a silenceable failure otherwise. """ -function match_structured_num_inits( - operand_handle::Value; result::IR.Type, location=Location() -) - _results = IR.Type[result,] - _operands = Value[operand_handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.match.structured.num_inits", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured_num_inits(operand_handle; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand_handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.match.structured.num_inits", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -991,24 +826,18 @@ to have been already checked for being a single structured op. Succeeds if the operand is associated with exactly one structured payload operation. Produces a silenceable failure otherwise. """ -function match_structured_num_inputs( - operand_handle::Value; result::IR.Type, location=Location() -) - _results = IR.Type[result,] - _operands = Value[operand_handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.match.structured.num_inputs", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured_num_inputs(operand_handle; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand_handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.match.structured.num_inputs", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1049,32 +878,19 @@ in \"suppress\" mode as long as the operand handle is associated with exactly one payload operation. It produces a definite failure when the handle is not associated with exactly one payload operation. """ -function match_structured( - current::Value; - outputs::Vector{IR.Type}, - failure_propagation_mode=nothing, - body_region::Region, - location=Location(), -) - _results = IR.Type[outputs...,] - _operands = Value[current,] - _owned_regions = Region[body_region,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(failure_propagation_mode) && push!( - _attributes, - namedattribute("failure_propagation_mode", failure_propagation_mode), - ) - - return IR.create_operation( - "transform.match.structured", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured(current; outputs::Vector{IR.Type}, failure_propagation_mode=nothing, body_region::Region, location=Location()) + results = IR.Type[outputs..., ] + operands = Value[value(current), ] + owned_regions = Region[body_region, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(failure_propagation_mode) && push!(attributes, namedattribute("failure_propagation_mode", failure_propagation_mode)) + + IR.create_operation( + "transform.match.structured", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1096,22 +912,18 @@ to have been already checked for being a single structured op. Succeeds if the operand is associated with exactly one structured payload operation. Produces a silenceable failure otherwise. """ -function match_structured_rank(operand_handle::Value; rank::IR.Type, location=Location()) - _results = IR.Type[rank,] - _operands = Value[operand_handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.match.structured.rank", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured_rank(operand_handle; rank::IR.Type, location=Location()) + results = IR.Type[rank, ] + operands = Value[value(operand_handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.match.structured.rank", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1147,31 +959,20 @@ to have been already checked for being a single structured op. Succeeds if the position is in bounds and if the user operation could be found when requested. Produces a silenceable failure otherwise. """ -function match_structured_result( - operand_handle::Value; - result::IR.Type, - position, - any=nothing, - single=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[operand_handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("position", position),] - !isnothing(any) && push!(_attributes, namedattribute("any", any)) - !isnothing(single) && push!(_attributes, namedattribute("single", single)) - - return IR.create_operation( - "transform.match.structured.result", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured_result(operand_handle; result::IR.Type, position, any=nothing, single=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(operand_handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + !isnothing(any) && push!(attributes, namedattribute("any", any)) + !isnothing(single) && push!(attributes, namedattribute("single", single)) + + IR.create_operation( + "transform.match.structured.result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1181,27 +982,22 @@ end Forwards the payload association from the operands to the results of the parent op. Always succeeds. """ -function match_structured_yield(handles::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[handles...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.match.structured.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_structured_yield(handles; location=Location()) + results = IR.Type[] + operands = Value[value.(handles)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.match.structured.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -1364,39 +1160,22 @@ op are bufferized to a new memory allocation, but not the op itself. This operation consumes the `target` handle and produces the `allocated_buffer` and `new_ops` handles. It always succeeds. """ -function structured_bufferize_to_allocation( - target::Value; - allocated_buffer::IR.Type, - new_ops::IR.Type, - memory_space=nothing, - memcpy_op=nothing, - alloc_op=nothing, - bufferize_destination_only=nothing, - location=Location(), -) - _results = IR.Type[allocated_buffer, new_ops] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(memory_space) && - push!(_attributes, namedattribute("memory_space", memory_space)) - !isnothing(memcpy_op) && push!(_attributes, namedattribute("memcpy_op", memcpy_op)) - !isnothing(alloc_op) && push!(_attributes, namedattribute("alloc_op", alloc_op)) - !isnothing(bufferize_destination_only) && push!( - _attributes, - namedattribute("bufferize_destination_only", bufferize_destination_only), - ) - - return IR.create_operation( - "transform.structured.bufferize_to_allocation", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_bufferize_to_allocation(target; allocated_buffer::IR.Type, new_ops::IR.Type, memory_space=nothing, memcpy_op=nothing, alloc_op=nothing, bufferize_destination_only=nothing, location=Location()) + results = IR.Type[allocated_buffer, new_ops, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(memory_space) && push!(attributes, namedattribute("memory_space", memory_space)) + !isnothing(memcpy_op) && push!(attributes, namedattribute("memcpy_op", memcpy_op)) + !isnothing(alloc_op) && push!(attributes, namedattribute("alloc_op", alloc_op)) + !isnothing(bufferize_destination_only) && push!(attributes, namedattribute("bufferize_destination_only", bufferize_destination_only)) + + IR.create_operation( + "transform.structured.bufferize_to_allocation", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1448,24 +1227,18 @@ Returns two handles: Returns a definite failure if target is not isolated from above. Returns a silenceable failure if the pattern application failed. """ -function structured_convert_conv2d_to_img2col( - target::Value; img2col_tensor::IR.Type, transformed::IR.Type, location=Location() -) - _results = IR.Type[img2col_tensor, transformed] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.convert_conv2d_to_img2col", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_convert_conv2d_to_img2col(target; img2col_tensor::IR.Type, transformed::IR.Type, location=Location()) + results = IR.Type[img2col_tensor, transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.convert_conv2d_to_img2col", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1474,24 +1247,18 @@ end TODO """ -function structured_decompose_interface( - target::Value; transformed::IR.Type, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.decompose_interface", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_decompose_interface(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.decompose_interface", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1510,22 +1277,18 @@ properly, the transform succeeds. Otherwise the transform silently fails. The return handle points to only the subset of successfully produced computational operations, which can be empty. """ -function structured_decompose(target::Value; transformed::IR.Type, location=Location()) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.decompose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_decompose(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.decompose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1583,22 +1346,18 @@ bufferize without an allocation (in the absence of other conflicts). This transform reads the target handle and modifies the payload. It does not produce any handle. """ -function structured_eliminate_empty_tensors(target::Value; location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.eliminate_empty_tensors", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_eliminate_empty_tensors(target; location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.eliminate_empty_tensors", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1637,28 +1396,18 @@ op are rejected by this operation. This operation consumes the producer handle. This operation only reads the containing op handle. """ -function structured_fuse_into_containing_op( - producer_op::Value, - containing_op::Value; - fused_op::IR.Type, - new_containing_op::IR.Type, - location=Location(), -) - _results = IR.Type[fused_op, new_containing_op] - _operands = Value[producer_op, containing_op] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.fuse_into_containing_op", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_fuse_into_containing_op(producer_op, containing_op; fused_op::IR.Type, new_containing_op::IR.Type, location=Location()) + results = IR.Type[fused_op, new_containing_op, ] + operands = Value[value(producer_op), value(containing_op), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.fuse_into_containing_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1668,32 +1417,20 @@ end Tiles the operations pointed to by the target handle and fuses their producers greedily using the options provided as attributes. """ -function structured_fuse( - target::Value; - transformed::IR.Type, - loops::Vector{IR.Type}, - tile_sizes=nothing, - tile_interchange=nothing, - location=Location(), -) - _results = IR.Type[transformed, loops...] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(tile_sizes) && push!(_attributes, namedattribute("tile_sizes", tile_sizes)) - !isnothing(tile_interchange) && - push!(_attributes, namedattribute("tile_interchange", tile_interchange)) - - return IR.create_operation( - "transform.structured.fuse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_fuse(target; transformed::IR.Type, loops::Vector{IR.Type}, tile_sizes=nothing, tile_interchange=nothing, location=Location()) + results = IR.Type[transformed, loops..., ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + !isnothing(tile_interchange) && push!(attributes, namedattribute("tile_interchange", tile_interchange)) + + IR.create_operation( + "transform.structured.fuse", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1712,22 +1449,18 @@ The return handle points to only the subset of successfully produced equivalent generic operations, which can be empty or contain the original ops if they were already in generic form. """ -function structured_generalize(target::Value; transformed::IR.Type, location=Location()) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.generalize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_generalize(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.generalize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1749,29 +1482,19 @@ If any non-tensor.pad is passed, the transform emits a silenceable failure. The return handle points to only the subset of successfully created packing loop nests, which can be empty. """ -function structured_hoist_pad_build_packing_loop_nest( - target::Value, - loop::Value; - packing_loop::IR.Type, - transpose=nothing, - location=Location(), -) - _results = IR.Type[packing_loop,] - _operands = Value[target, loop] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(transpose) && push!(_attributes, namedattribute("transpose", transpose)) - - return IR.create_operation( - "transform.structured.hoist_pad.build_packing_loop_nest", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_hoist_pad_build_packing_loop_nest(target, loop; packing_loop::IR.Type, transpose=nothing, location=Location()) + results = IR.Type[packing_loop, ] + operands = Value[value(target), value(loop), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(transpose) && push!(attributes, namedattribute("transpose", transpose)) + + IR.create_operation( + "transform.structured.hoist_pad.build_packing_loop_nest", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1796,25 +1519,19 @@ transform succeeds. Otherwise the transform silently fails. The return handle points to only the subset of successfully hoisted tensor.pad operations, which can be empty. """ -function structured_hoist_pad( - target::Value; transformed::IR.Type, num_loops, transpose=nothing, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("num_loops", num_loops),] - !isnothing(transpose) && push!(_attributes, namedattribute("transpose", transpose)) - - return IR.create_operation( - "transform.structured.hoist_pad", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_hoist_pad(target; transformed::IR.Type, num_loops, transpose=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("num_loops", num_loops), ] + !isnothing(transpose) && push!(attributes, namedattribute("transpose", transpose)) + + IR.create_operation( + "transform.structured.hoist_pad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1841,22 +1558,18 @@ When applied to: The operation always succeeds and returns nothing. """ -function structured_hoist_redundant_tensor_subsets(target::Value; location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.hoist_redundant_tensor_subsets", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_hoist_redundant_tensor_subsets(target; location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.hoist_redundant_tensor_subsets", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1880,24 +1593,18 @@ TODO: obsolete and should be retired. The operation always succeeds and returns a handle to the transformed function op. """ -function structured_hoist_redundant_vector_transfers( - target::Value; transformed::IR.Type, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.hoist_redundant_vector_transfers", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_hoist_redundant_vector_transfers(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.hoist_redundant_vector_transfers", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1916,24 +1623,18 @@ op (i.e. do not create an additional linalg.copy op). The operation always succeeds and returns a handle to the relevant linalg.copy op. """ -function structured_insert_slice_to_copy( - target::Value; transformed::IR.Type, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.insert_slice_to_copy", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_insert_slice_to_copy(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.insert_slice_to_copy", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1953,26 +1654,19 @@ If any interchange fails, the transform definitely fails. The return handle points to only the subset of successfully produced interchanged operations, which can be empty. """ -function structured_interchange( - target::Value; transformed::IR.Type, iterator_interchange=nothing, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(iterator_interchange) && - push!(_attributes, namedattribute("iterator_interchange", iterator_interchange)) - - return IR.create_operation( - "transform.structured.interchange", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_interchange(target; transformed::IR.Type, iterator_interchange=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(iterator_interchange) && push!(attributes, namedattribute("iterator_interchange", iterator_interchange)) + + IR.create_operation( + "transform.structured.interchange", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1990,28 +1684,18 @@ If all the operations referred to by the `target` are rewritten, the transform succeeds. Return handles to the newly produced pad, expand_shape and transpose ops. """ -function structured_lower_pack( - target::Value; - pad_op::IR.Type, - expand_shape_op::IR.Type, - transpose_op::IR.Type, - location=Location(), -) - _results = IR.Type[pad_op, expand_shape_op, transpose_op] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.lower_pack", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_lower_pack(target; pad_op::IR.Type, expand_shape_op::IR.Type, transpose_op::IR.Type, location=Location()) + results = IR.Type[pad_op, expand_shape_op, transpose_op, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.lower_pack", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2030,29 +1714,18 @@ If all the operations referred to by the `target` are rewritten, the transform succeeds. Return handles to the newly produced empty, transpose, collapse_shape and extract_slice ops. """ -function structured_lower_unpack( - target::Value; - empty_op::IR.Type, - transpose_op::IR.Type, - collapse_shape_op::IR.Type, - extract_slice_op::IR.Type, - location=Location(), -) - _results = IR.Type[empty_op, transpose_op, collapse_shape_op, extract_slice_op] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.lower_unpack", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_lower_unpack(target; empty_op::IR.Type, transpose_op::IR.Type, collapse_shape_op::IR.Type, extract_slice_op::IR.Type, location=Location()) + results = IR.Type[empty_op, transpose_op, collapse_shape_op, extract_slice_op, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.lower_unpack", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2079,32 +1752,18 @@ linalg.copy / tensor.pad) among the targeted op. Otherwise, the operation always succeeds and returns a handle to the relevant tiled linalg.copy / tensor.pad op and the enclosing scf.forall op. """ -function structured_gpu_map_copy_to_threads( - target::Value; - forall_op::IR.Type, - tiled_op::IR.Type, - total_num_threads, - desired_bit_alignment, - location=Location(), -) - _results = IR.Type[forall_op, tiled_op] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("total_num_threads", total_num_threads), - namedattribute("desired_bit_alignment", desired_bit_alignment), - ] - - return IR.create_operation( - "transform.structured.gpu.map_copy_to_threads", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_gpu_map_copy_to_threads(target; forall_op::IR.Type, tiled_op::IR.Type, total_num_threads, desired_bit_alignment, location=Location()) + results = IR.Type[forall_op, tiled_op, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("total_num_threads", total_num_threads), namedattribute("desired_bit_alignment", desired_bit_alignment), ] + + IR.create_operation( + "transform.structured.gpu.map_copy_to_threads", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2131,35 +1790,21 @@ values) do not satisfy the constraints mentioned above. It produces a silenceable failure if at least one target op is not a Linalg op or fails to vectorize. """ -function structured_masked_vectorize( - target::Value, - vector_sizes::Vector{Value}; - vectorize_nd_extract=nothing, - scalable_sizes=nothing, - static_vector_sizes=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[target, vector_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(vectorize_nd_extract) && - push!(_attributes, namedattribute("vectorize_nd_extract", vectorize_nd_extract)) - !isnothing(scalable_sizes) && - push!(_attributes, namedattribute("scalable_sizes", scalable_sizes)) - !isnothing(static_vector_sizes) && - push!(_attributes, namedattribute("static_vector_sizes", static_vector_sizes)) - - return IR.create_operation( - "transform.structured.masked_vectorize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_masked_vectorize(target, vector_sizes; vectorize_nd_extract=nothing, scalable_sizes=nothing, static_vector_sizes=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(target), value.(vector_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(vectorize_nd_extract) && push!(attributes, namedattribute("vectorize_nd_extract", vectorize_nd_extract)) + !isnothing(scalable_sizes) && push!(attributes, namedattribute("scalable_sizes", scalable_sizes)) + !isnothing(static_vector_sizes) && push!(attributes, namedattribute("static_vector_sizes", static_vector_sizes)) + + IR.create_operation( + "transform.structured.masked_vectorize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2193,35 +1838,22 @@ Otherwise it succeeds. This operation does not consume the target handle and produces new handles: it is a navigation op. """ -function structured_match( - target::Value; - results::IR.Type, - ops=nothing, - interface=nothing, - op_attrs=nothing, - filter_result_type=nothing, - location=Location(), -) - _results = IR.Type[results,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(ops) && push!(_attributes, namedattribute("ops", ops)) - !isnothing(interface) && push!(_attributes, namedattribute("interface", interface)) - !isnothing(op_attrs) && push!(_attributes, namedattribute("op_attrs", op_attrs)) - !isnothing(filter_result_type) && - push!(_attributes, namedattribute("filter_result_type", filter_result_type)) - - return IR.create_operation( - "transform.structured.match", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_match(target; results_::IR.Type, ops=nothing, interface=nothing, op_attrs=nothing, filter_result_type=nothing, location=Location()) + results = IR.Type[results_, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(ops) && push!(attributes, namedattribute("ops", ops)) + !isnothing(interface) && push!(attributes, namedattribute("interface", interface)) + !isnothing(op_attrs) && push!(attributes, namedattribute("op_attrs", op_attrs)) + !isnothing(filter_result_type) && push!(attributes, namedattribute("filter_result_type", filter_result_type)) + + IR.create_operation( + "transform.structured.match", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2281,34 +1913,19 @@ structured.split %common after %splitr { dimension = 0 } // ... ``` """ -function structured_multitile_sizes( - target::Value; - low_size::IR.Type, - high_size::IR.Type, - split_point::IR.Type, - dimension, - target_size, - divisor=nothing, - location=Location(), -) - _results = IR.Type[low_size, high_size, split_point] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("dimension", dimension), namedattribute("target_size", target_size) - ] - !isnothing(divisor) && push!(_attributes, namedattribute("divisor", divisor)) - - return IR.create_operation( - "transform.structured.multitile_sizes", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_multitile_sizes(target; low_size::IR.Type, high_size::IR.Type, split_point::IR.Type, dimension, target_size, divisor=nothing, location=Location()) + results = IR.Type[low_size, high_size, split_point, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), namedattribute("target_size", target_size), ] + !isnothing(divisor) && push!(attributes, namedattribute("divisor", divisor)) + + IR.create_operation( + "transform.structured.multitile_sizes", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2369,43 +1986,21 @@ This operation ignores non-Linalg ops and drops them in the return. It returns the list of packed Linalg ops or the original op when all available packing strategies failed to apply. """ -function structured_pack_greedily( - target::Value, - matmul_packed_sizes::Vector{Value}; - packed_op::IR.Type, - static_matmul_packed_sizes=nothing, - matmul_padded_sizes_next_multiple_of=nothing, - matmul_inner_dims_order=nothing, - location=Location(), -) - _results = IR.Type[packed_op,] - _operands = Value[target, matmul_packed_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(static_matmul_packed_sizes) && push!( - _attributes, - namedattribute("static_matmul_packed_sizes", static_matmul_packed_sizes), - ) - !isnothing(matmul_padded_sizes_next_multiple_of) && push!( - _attributes, - namedattribute( - "matmul_padded_sizes_next_multiple_of", matmul_padded_sizes_next_multiple_of - ), - ) - !isnothing(matmul_inner_dims_order) && push!( - _attributes, namedattribute("matmul_inner_dims_order", matmul_inner_dims_order) - ) - - return IR.create_operation( - "transform.structured.pack_greedily", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_pack_greedily(target, matmul_packed_sizes; packed_op::IR.Type, static_matmul_packed_sizes=nothing, matmul_padded_sizes_next_multiple_of=nothing, matmul_inner_dims_order=nothing, location=Location()) + results = IR.Type[packed_op, ] + operands = Value[value(target), value.(matmul_packed_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_matmul_packed_sizes) && push!(attributes, namedattribute("static_matmul_packed_sizes", static_matmul_packed_sizes)) + !isnothing(matmul_padded_sizes_next_multiple_of) && push!(attributes, namedattribute("matmul_padded_sizes_next_multiple_of", matmul_padded_sizes_next_multiple_of)) + !isnothing(matmul_inner_dims_order) && push!(attributes, namedattribute("matmul_inner_dims_order", matmul_inner_dims_order)) + + IR.create_operation( + "transform.structured.pack_greedily", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2470,30 +2065,19 @@ reason. The returned handle point to the packed LinalgOp. """ -function structured_pack( - target::Value, - packed_sizes::Vector{Value}; - packed_op::IR.Type, - static_packed_sizes=nothing, - location=Location(), -) - _results = IR.Type[packed_op,] - _operands = Value[target, packed_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(static_packed_sizes) && - push!(_attributes, namedattribute("static_packed_sizes", static_packed_sizes)) - - return IR.create_operation( - "transform.structured.pack", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_pack(target, packed_sizes; packed_op::IR.Type, static_packed_sizes=nothing, location=Location()) + results = IR.Type[packed_op, ] + operands = Value[value(target), value.(packed_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_packed_sizes) && push!(attributes, namedattribute("static_packed_sizes", static_packed_sizes)) + + IR.create_operation( + "transform.structured.pack", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2535,33 +2119,20 @@ the transformed `tensor.pack` and one to the transformed `tensor.unpack`. The last handle for `tensor.unpack` is empty if `target_pack_or_unpack_op` was not itself a `tensor.unpack`. """ -function structured_pack_transpose( - target_pack_or_un_pack_op::Value, - target_linalg_op::Value; - packed_op::IR.Type, - pack_op::IR.Type, - un_pack_op::IR.Type, - outer_perm=nothing, - inner_perm=nothing, - location=Location(), -) - _results = IR.Type[packed_op, pack_op, un_pack_op] - _operands = Value[target_pack_or_un_pack_op, target_linalg_op] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(outer_perm) && push!(_attributes, namedattribute("outer_perm", outer_perm)) - !isnothing(inner_perm) && push!(_attributes, namedattribute("inner_perm", inner_perm)) - - return IR.create_operation( - "transform.structured.pack_transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_pack_transpose(target_pack_or_un_pack_op, target_linalg_op; packed_op::IR.Type, pack_op::IR.Type, un_pack_op::IR.Type, outer_perm=nothing, inner_perm=nothing, location=Location()) + results = IR.Type[packed_op, pack_op, un_pack_op, ] + operands = Value[value(target_pack_or_un_pack_op), value(target_linalg_op), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(outer_perm) && push!(attributes, namedattribute("outer_perm", outer_perm)) + !isnothing(inner_perm) && push!(attributes, namedattribute("inner_perm", inner_perm)) + + IR.create_operation( + "transform.structured.pack_transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2583,44 +2154,24 @@ properly, the transform succeeds. Otherwise the transform silently fails. The return handle points to only the subset of successfully produced padded operations, which can be empty. """ -function structured_pad( - target::Value; - padded::IR.Type, - pad::IR.Type, - padding_values=nothing, - padding_dimensions=nothing, - pad_to_multiple_of=nothing, - pack_paddings=nothing, - transpose_paddings=nothing, - copy_back=nothing, - location=Location(), -) - _results = IR.Type[padded, pad] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(padding_values) && - push!(_attributes, namedattribute("padding_values", padding_values)) - !isnothing(padding_dimensions) && - push!(_attributes, namedattribute("padding_dimensions", padding_dimensions)) - !isnothing(pad_to_multiple_of) && - push!(_attributes, namedattribute("pad_to_multiple_of", pad_to_multiple_of)) - !isnothing(pack_paddings) && - push!(_attributes, namedattribute("pack_paddings", pack_paddings)) - !isnothing(transpose_paddings) && - push!(_attributes, namedattribute("transpose_paddings", transpose_paddings)) - !isnothing(copy_back) && push!(_attributes, namedattribute("copy_back", copy_back)) - - return IR.create_operation( - "transform.structured.pad", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_pad(target; padded::IR.Type, pad::IR.Type, padding_values=nothing, padding_dimensions=nothing, pad_to_multiple_of=nothing, pack_paddings=nothing, transpose_paddings=nothing, copy_back=nothing, location=Location()) + results = IR.Type[padded, pad, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(padding_values) && push!(attributes, namedattribute("padding_values", padding_values)) + !isnothing(padding_dimensions) && push!(attributes, namedattribute("padding_dimensions", padding_dimensions)) + !isnothing(pad_to_multiple_of) && push!(attributes, namedattribute("pad_to_multiple_of", pad_to_multiple_of)) + !isnothing(pack_paddings) && push!(attributes, namedattribute("pack_paddings", pack_paddings)) + !isnothing(transpose_paddings) && push!(attributes, namedattribute("transpose_paddings", transpose_paddings)) + !isnothing(copy_back) && push!(attributes, namedattribute("copy_back", copy_back)) + + IR.create_operation( + "transform.structured.pad", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2643,43 +2194,24 @@ properly, the transform succeeds. When successful, the return handle points to the \$target operation that was modified inplace. """ -function structured_promote( - target::Value; - transformed::IR.Type, - operands_to_promote=nothing, - use_full_tile_buffers=nothing, - use_full_tiles_by_default=nothing, - use_alloca=nothing, - mapping=nothing, - alignment=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(operands_to_promote) && - push!(_attributes, namedattribute("operands_to_promote", operands_to_promote)) - !isnothing(use_full_tile_buffers) && - push!(_attributes, namedattribute("use_full_tile_buffers", use_full_tile_buffers)) - !isnothing(use_full_tiles_by_default) && push!( - _attributes, - namedattribute("use_full_tiles_by_default", use_full_tiles_by_default), - ) - !isnothing(use_alloca) && push!(_attributes, namedattribute("use_alloca", use_alloca)) - !isnothing(mapping) && push!(_attributes, namedattribute("mapping", mapping)) - !isnothing(alignment) && push!(_attributes, namedattribute("alignment", alignment)) - - return IR.create_operation( - "transform.structured.promote", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_promote(target; transformed::IR.Type, operands_to_promote=nothing, use_full_tile_buffers=nothing, use_full_tiles_by_default=nothing, use_alloca=nothing, mapping=nothing, alignment=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(operands_to_promote) && push!(attributes, namedattribute("operands_to_promote", operands_to_promote)) + !isnothing(use_full_tile_buffers) && push!(attributes, namedattribute("use_full_tile_buffers", use_full_tile_buffers)) + !isnothing(use_full_tiles_by_default) && push!(attributes, namedattribute("use_full_tiles_by_default", use_full_tiles_by_default)) + !isnothing(use_alloca) && push!(attributes, namedattribute("use_alloca", use_alloca)) + !isnothing(mapping) && push!(attributes, namedattribute("mapping", mapping)) + !isnothing(alignment) && push!(attributes, namedattribute("alignment", alignment)) + + IR.create_operation( + "transform.structured.promote", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2696,24 +2228,18 @@ This op is for debugging/experiments only. This operation consumes the `target` handle. """ -function structured_replace( - target::Value; replacement::IR.Type, bodyRegion::Region, location=Location() -) - _results = IR.Type[replacement,] - _operands = Value[target,] - _owned_regions = Region[bodyRegion,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.replace", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_replace(target; replacement::IR.Type, bodyRegion::Region, location=Location()) + results = IR.Type[replacement, ] + operands = Value[value(target), ] + owned_regions = Region[bodyRegion, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.replace", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2740,24 +2266,18 @@ The return handle points to a subset of successfully produced operations: - `tensor.from_elements` case, the returned handle points to the last `tensor.insert`. """ -function structured_rewrite_in_destination_passing_style( - target::Value; transformed::IR.Type, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.rewrite_in_destination_passing_style", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_rewrite_in_destination_passing_style(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.rewrite_in_destination_passing_style", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2785,22 +2305,18 @@ dimensions after multiple transformations have been applied). Loops can always be recovered by navigating from the tiled operations if needed. """ -function structured_scalarize(target::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.structured.scalarize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_scalarize(target; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.structured.scalarize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2825,34 +2341,19 @@ of the structured op after splitting, in the same order as the target operand, with the first handle corresponding to the part with lower iteration space indices. """ -function structured_split( - target::Value, - dynamic_split_point=nothing::Union{Nothing,Value}; - first::IR.Type, - second::IR.Type, - dimension, - static_split_point, - location=Location(), -) - _results = IR.Type[first, second] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("dimension", dimension), - namedattribute("static_split_point", static_split_point), - ] - !isnothing(dynamic_split_point) && push!(_operands, dynamic_split_point) - - return IR.create_operation( - "transform.structured.split", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_split(target, dynamic_split_point=nothing; first::IR.Type, second::IR.Type, dimension, static_split_point, location=Location()) + results = IR.Type[first, second, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("dimension", dimension), namedattribute("static_split_point", static_split_point), ] + !isnothing(dynamic_split_point) && push!(operands, value(dynamic_split_point)) + + IR.create_operation( + "transform.structured.split", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2992,43 +2493,23 @@ Is transformed to: return %4 : tensor<16x32xf32> ``` """ -function structured_split_reduction( - target::Value; - init_or_alloc_op::IR.Type, - fill_op::IR.Type, - split_linalg_op::IR.Type, - combining_linalg_op::IR.Type, - split_factor=nothing, - insert_split_dimension=nothing, - inner_parallel=nothing, - use_scaling_algorithm=nothing, - use_alloc=nothing, - location=Location(), -) - _results = IR.Type[init_or_alloc_op, fill_op, split_linalg_op, combining_linalg_op] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(split_factor) && - push!(_attributes, namedattribute("split_factor", split_factor)) - !isnothing(insert_split_dimension) && - push!(_attributes, namedattribute("insert_split_dimension", insert_split_dimension)) - !isnothing(inner_parallel) && - push!(_attributes, namedattribute("inner_parallel", inner_parallel)) - !isnothing(use_scaling_algorithm) && - push!(_attributes, namedattribute("use_scaling_algorithm", use_scaling_algorithm)) - !isnothing(use_alloc) && push!(_attributes, namedattribute("use_alloc", use_alloc)) - - return IR.create_operation( - "transform.structured.split_reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_split_reduction(target; init_or_alloc_op::IR.Type, fill_op::IR.Type, split_linalg_op::IR.Type, combining_linalg_op::IR.Type, split_factor=nothing, insert_split_dimension=nothing, inner_parallel=nothing, use_scaling_algorithm=nothing, use_alloc=nothing, location=Location()) + results = IR.Type[init_or_alloc_op, fill_op, split_linalg_op, combining_linalg_op, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(split_factor) && push!(attributes, namedattribute("split_factor", split_factor)) + !isnothing(insert_split_dimension) && push!(attributes, namedattribute("insert_split_dimension", insert_split_dimension)) + !isnothing(inner_parallel) && push!(attributes, namedattribute("inner_parallel", inner_parallel)) + !isnothing(use_scaling_algorithm) && push!(attributes, namedattribute("use_scaling_algorithm", use_scaling_algorithm)) + !isnothing(use_alloc) && push!(attributes, namedattribute("use_alloc", use_alloc)) + + IR.create_operation( + "transform.structured.split_reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3071,37 +2552,21 @@ that of the list associated with the `target` handle. If the internal implementation of tiling for any of the operations fails, produces a definite failure. """ -function structured_tile( - target::Value, - dynamic_sizes::Vector{Value}; - tiled_linalg_op::IR.Type, - loops::Vector{IR.Type}, - static_sizes=nothing, - interchange=nothing, - scalable_sizes=nothing, - location=Location(), -) - _results = IR.Type[tiled_linalg_op, loops...] - _operands = Value[target, dynamic_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(static_sizes) && - push!(_attributes, namedattribute("static_sizes", static_sizes)) - !isnothing(interchange) && - push!(_attributes, namedattribute("interchange", interchange)) - !isnothing(scalable_sizes) && - push!(_attributes, namedattribute("scalable_sizes", scalable_sizes)) - - return IR.create_operation( - "transform.structured.tile", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile(target, dynamic_sizes; tiled_linalg_op::IR.Type, loops::Vector{IR.Type}, static_sizes=nothing, interchange=nothing, scalable_sizes=nothing, location=Location()) + results = IR.Type[tiled_linalg_op, loops..., ] + operands = Value[value(target), value.(dynamic_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_sizes) && push!(attributes, namedattribute("static_sizes", static_sizes)) + !isnothing(interchange) && push!(attributes, namedattribute("interchange", interchange)) + !isnothing(scalable_sizes) && push!(attributes, namedattribute("scalable_sizes", scalable_sizes)) + + IR.create_operation( + "transform.structured.tile", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3172,36 +2637,21 @@ is transformed into: } -> tensor ``` """ -function structured_tile_reduction_using_forall( - target::Value; - forall_op::IR.Type, - fill_op::IR.Type, - split_linalg_op::IR.Type, - combining_linalg_op::IR.Type, - num_threads=nothing, - tile_sizes=nothing, - mapping=nothing, - location=Location(), -) - _results = IR.Type[forall_op, fill_op, split_linalg_op, combining_linalg_op] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(num_threads) && - push!(_attributes, namedattribute("num_threads", num_threads)) - !isnothing(tile_sizes) && push!(_attributes, namedattribute("tile_sizes", tile_sizes)) - !isnothing(mapping) && push!(_attributes, namedattribute("mapping", mapping)) - - return IR.create_operation( - "transform.structured.tile_reduction_using_forall", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile_reduction_using_forall(target; forall_op::IR.Type, fill_op::IR.Type, split_linalg_op::IR.Type, combining_linalg_op::IR.Type, num_threads=nothing, tile_sizes=nothing, mapping=nothing, location=Location()) + results = IR.Type[forall_op, fill_op, split_linalg_op, combining_linalg_op, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(num_threads) && push!(attributes, namedattribute("num_threads", num_threads)) + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + !isnothing(mapping) && push!(attributes, namedattribute("mapping", mapping)) + + IR.create_operation( + "transform.structured.tile_reduction_using_forall", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3275,31 +2725,19 @@ is transformed into: } -> tensor ``` """ -function structured_tile_reduction_using_scf( - target::Value; - for_op::IR.Type, - fill_op::IR.Type, - split_linalg_op::IR.Type, - combining_linalg_op::IR.Type, - tile_sizes=nothing, - location=Location(), -) - _results = IR.Type[for_op, fill_op, split_linalg_op, combining_linalg_op] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(tile_sizes) && push!(_attributes, namedattribute("tile_sizes", tile_sizes)) - - return IR.create_operation( - "transform.structured.tile_reduction_using_scf", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile_reduction_using_scf(target; for_op::IR.Type, fill_op::IR.Type, split_linalg_op::IR.Type, combining_linalg_op::IR.Type, tile_sizes=nothing, location=Location()) + results = IR.Type[for_op, fill_op, split_linalg_op, combining_linalg_op, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(tile_sizes) && push!(attributes, namedattribute("tile_sizes", tile_sizes)) + + IR.create_operation( + "transform.structured.tile_reduction_using_scf", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3360,51 +2798,24 @@ These two returned handles point to: %3:2 = transform.structured.tile_to_forall_op %0 tile_sizes [0, %sz, 20] ``` """ -function structured_tile_to_forall_op( - target::Value, - num_threads::Vector{Value}, - tile_sizes::Vector{Value}, - packed_num_threads=nothing::Union{Nothing,Value}; - packed_tile_sizes=nothing::Union{Nothing,Value}, - forall_op::IR.Type, - tiled_op::IR.Type, - static_num_threads=nothing, - static_tile_sizes=nothing, - mapping=nothing, - location=Location(), -) - _results = IR.Type[forall_op, tiled_op] - _operands = Value[target, num_threads..., tile_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(packed_num_threads) && push!(_operands, packed_num_threads) - !isnothing(packed_tile_sizes) && push!(_operands, packed_tile_sizes) - push!( - _attributes, - operandsegmentsizes([ - 1, - length(num_threads), - length(tile_sizes), - isnothing(packed_num_threads) ? 0 : 1, - isnothing(packed_tile_sizes) ? 0 : 1, - ]), - ) - !isnothing(static_num_threads) && - push!(_attributes, namedattribute("static_num_threads", static_num_threads)) - !isnothing(static_tile_sizes) && - push!(_attributes, namedattribute("static_tile_sizes", static_tile_sizes)) - !isnothing(mapping) && push!(_attributes, namedattribute("mapping", mapping)) - - return IR.create_operation( - "transform.structured.tile_to_forall_op", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile_to_forall_op(target, num_threads, tile_sizes, packed_num_threads=nothing; packed_tile_sizes=nothing, forall_op::IR.Type, tiled_op::IR.Type, static_num_threads=nothing, static_tile_sizes=nothing, mapping=nothing, location=Location()) + results = IR.Type[forall_op, tiled_op, ] + operands = Value[value(target), value.(num_threads)..., value.(tile_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(packed_num_threads) && push!(operands, value(packed_num_threads)) + !isnothing(packed_tile_sizes) && push!(operands, value(packed_tile_sizes)) + push!(attributes, operandsegmentsizes([1, length(num_threads), length(tile_sizes), (packed_num_threads==nothing) ? 0 : 1(packed_tile_sizes==nothing) ? 0 : 1])) + !isnothing(static_num_threads) && push!(attributes, namedattribute("static_num_threads", static_num_threads)) + !isnothing(static_tile_sizes) && push!(attributes, namedattribute("static_tile_sizes", static_tile_sizes)) + !isnothing(mapping) && push!(attributes, namedattribute("mapping", mapping)) + + IR.create_operation( + "transform.structured.tile_to_forall_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3447,34 +2858,20 @@ that of the list associated with the `target` handle. If the internal implementation of tiling for any of the operations fails, produces a definite failure. """ -function structured_tile_to_scf_for( - target::Value, - dynamic_sizes::Vector{Value}; - tiled_linalg_op::IR.Type, - loops::Vector{IR.Type}, - static_sizes=nothing, - interchange=nothing, - location=Location(), -) - _results = IR.Type[tiled_linalg_op, loops...] - _operands = Value[target, dynamic_sizes...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(static_sizes) && - push!(_attributes, namedattribute("static_sizes", static_sizes)) - !isnothing(interchange) && - push!(_attributes, namedattribute("interchange", interchange)) - - return IR.create_operation( - "transform.structured.tile_to_scf_for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function structured_tile_to_scf_for(target, dynamic_sizes; tiled_linalg_op::IR.Type, loops::Vector{IR.Type}, static_sizes=nothing, interchange=nothing, location=Location()) + results = IR.Type[tiled_linalg_op, loops..., ] + operands = Value[value(target), value.(dynamic_sizes)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(static_sizes) && push!(attributes, namedattribute("static_sizes", static_sizes)) + !isnothing(interchange) && push!(attributes, namedattribute("interchange", interchange)) + + IR.create_operation( + "transform.structured.tile_to_scf_for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3515,53 +2912,26 @@ reason. The operation always returns the handle to the target op that is expected to be isolated from above. """ -function structured_vectorize( - target::Value; - transformed::IR.Type, - vectorize_padding=nothing, - vectorize_nd_extract=nothing, - disable_multi_reduction_to_contract_patterns=nothing, - disable_transfer_permutation_map_lowering_patterns=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(vectorize_padding) && - push!(_attributes, namedattribute("vectorize_padding", vectorize_padding)) - !isnothing(vectorize_nd_extract) && - push!(_attributes, namedattribute("vectorize_nd_extract", vectorize_nd_extract)) - !isnothing(disable_multi_reduction_to_contract_patterns) && push!( - _attributes, - namedattribute( - "disable_multi_reduction_to_contract_patterns", - disable_multi_reduction_to_contract_patterns, - ), - ) - !isnothing(disable_transfer_permutation_map_lowering_patterns) && push!( - _attributes, - namedattribute( - "disable_transfer_permutation_map_lowering_patterns", - disable_transfer_permutation_map_lowering_patterns, - ), - ) - - return IR.create_operation( - "transform.structured.vectorize", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end - -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +function structured_vectorize(target; transformed::IR.Type, vectorize_padding=nothing, vectorize_nd_extract=nothing, disable_multi_reduction_to_contract_patterns=nothing, disable_transfer_permutation_map_lowering_patterns=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(vectorize_padding) && push!(attributes, namedattribute("vectorize_padding", vectorize_padding)) + !isnothing(vectorize_nd_extract) && push!(attributes, namedattribute("vectorize_nd_extract", vectorize_nd_extract)) + !isnothing(disable_multi_reduction_to_contract_patterns) && push!(attributes, namedattribute("disable_multi_reduction_to_contract_patterns", disable_multi_reduction_to_contract_patterns)) + !isnothing(disable_transfer_permutation_map_lowering_patterns) && push!(attributes, namedattribute("disable_transfer_permutation_map_lowering_patterns", disable_transfer_permutation_map_lowering_patterns)) + + IR.create_operation( + "transform.structured.vectorize", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end + +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -3734,26 +3104,20 @@ Otherwise, the returned handle points to a subset of the produced ops: This transform op consumes the target handle and produces a result handle. """ -function memref_make_loop_independent( - target::Value; transformed::IR.Type, num_loops, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("num_loops", num_loops),] - - return IR.create_operation( - "transform.memref.make_loop_independent", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end +function memref_make_loop_independent(target; transformed::IR.Type, num_loops, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("num_loops", num_loops), ] + + IR.create_operation( + "transform.memref.make_loop_independent", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `memref_multibuffer` @@ -3772,31 +3136,23 @@ iterations. This operation returns the new allocation if multi-buffering succeeds, and failure otherwise. """ -function memref_multibuffer( - target::Value; transformed::IR.Type, factor, skip_analysis=nothing, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("factor", factor),] - !isnothing(skip_analysis) && - push!(_attributes, namedattribute("skip_analysis", skip_analysis)) - - return IR.create_operation( - "transform.memref.multibuffer", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function memref_multibuffer(target; transformed::IR.Type, factor, skip_analysis=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("factor", factor), ] + !isnothing(skip_analysis) && push!(attributes, namedattribute("skip_analysis", skip_analysis)) + + IR.create_operation( + "transform.memref.multibuffer", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -3818,25 +3174,19 @@ This op consumes the `target` handle and produces the `result` handle, which is mapped to the same payload operations as the `target` handle. The op modifies the payload. """ -function nvgpu_create_async_groups( - target::Value; result::IR.Type, bypass_l1=nothing, location=Location() -) - _results = IR.Type[result,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(bypass_l1) && push!(_attributes, namedattribute("bypass_l1", bypass_l1)) - - return IR.create_operation( - "transform.nvgpu.create_async_groups", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function nvgpu_create_async_groups(target; result::IR.Type, bypass_l1=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(bypass_l1) && push!(attributes, namedattribute("bypass_l1", bypass_l1)) + + IR.create_operation( + "transform.nvgpu.create_async_groups", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3874,35 +3224,20 @@ TODO: the shared memory part and behavior specific to NVGPU should be made orthogonal to pipelining so that `transform.loop.pipeline` becomes usable here. """ -function nvgpu_pipeline_shared_memory_copies( - for_op::Value; - result::IR.Type, - depth, - peel_epilogue=nothing, - failure_propagation_mode=nothing, - location=Location(), -) - _results = IR.Type[result,] - _operands = Value[for_op,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("depth", depth),] - !isnothing(peel_epilogue) && - push!(_attributes, namedattribute("peel_epilogue", peel_epilogue)) - !isnothing(failure_propagation_mode) && push!( - _attributes, - namedattribute("failure_propagation_mode", failure_propagation_mode), - ) - - return IR.create_operation( - "transform.nvgpu.pipeline_shared_memory_copies", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function nvgpu_pipeline_shared_memory_copies(for_op; result::IR.Type, depth, peel_epilogue=nothing, failure_propagation_mode=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(for_op), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("depth", depth), ] + !isnothing(peel_epilogue) && push!(attributes, namedattribute("peel_epilogue", peel_epilogue)) + !isnothing(failure_propagation_mode) && push!(attributes, namedattribute("failure_propagation_mode", failure_propagation_mode)) + + IR.create_operation( + "transform.nvgpu.pipeline_shared_memory_copies", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -3915,27 +3250,22 @@ Memory copies with the required access patterns are automatically inserted. Operations that do not have a 1-1 mapping to mma.sync operations are left unchanged. """ -function nvgpu_rewrite_matmul_as_mma_sync(target::Value; location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.nvgpu.rewrite_matmul_as_mma_sync", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function nvgpu_rewrite_matmul_as_mma_sync(target; location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.nvgpu.rewrite_matmul_as_mma_sync", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -3974,26 +3304,20 @@ of operations associated with the handle contains parent operations in the same order as the list associated with the operand, except for operations that are parents to more than one input which are only present once. """ -function loop_get_parent_for( - target::Value; parent::IR.Type, num_loops=nothing, affine=nothing, location=Location() -) - _results = IR.Type[parent,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(num_loops) && push!(_attributes, namedattribute("num_loops", num_loops)) - !isnothing(affine) && push!(_attributes, namedattribute("affine", affine)) - - return IR.create_operation( - "transform.loop.get_parent_for", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_get_parent_for(target; parent::IR.Type, num_loops=nothing, affine=nothing, location=Location()) + results = IR.Type[parent, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(num_loops) && push!(attributes, namedattribute("num_loops", num_loops)) + !isnothing(affine) && push!(attributes, namedattribute("affine", affine)) + + IR.create_operation( + "transform.loop.get_parent_for", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4008,22 +3332,18 @@ perform loop coalescing in a bottom-up one-by-one manner. The return handle points to the coalesced loop if coalescing happens, or the given input loop if coalescing does not happen. """ -function loop_coalesce(target::Value; transformed::IR.Type, location=Location()) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.loop.coalesce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_coalesce(target; transformed::IR.Type, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.loop.coalesce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4047,24 +3367,18 @@ handle. Produces a definite failure if outlining failed for any of the targets. """ -function loop_outline( - target::Value; function_::IR.Type, call::IR.Type, func_name, location=Location() -) - _results = IR.Type[function_, call] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("func_name", func_name),] - - return IR.create_operation( - "transform.loop.outline", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_outline(target; function_::IR.Type, call::IR.Type, func_name, location=Location()) + results = IR.Type[function_, call, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("func_name", func_name), ] + + IR.create_operation( + "transform.loop.outline", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4092,31 +3406,19 @@ one. TODO: Return both the peeled loop and the remainder loop. """ -function loop_peel( - target::Value; - transformed::IR.Type, - fail_if_already_divisible=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(fail_if_already_divisible) && push!( - _attributes, - namedattribute("fail_if_already_divisible", fail_if_already_divisible), - ) - - return IR.create_operation( - "transform.loop.peel", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_peel(target; transformed::IR.Type, fail_if_already_divisible=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(fail_if_already_divisible) && push!(attributes, namedattribute("fail_if_already_divisible", fail_if_already_divisible)) + + IR.create_operation( + "transform.loop.peel", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4143,32 +3445,20 @@ properly, the transform succeeds. Otherwise the transform silently fails. The return handle points to only the subset of successfully produced pipelined loops, which can be empty. """ -function loop_pipeline( - target::Value; - transformed::IR.Type, - iteration_interval=nothing, - read_latency=nothing, - location=Location(), -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(iteration_interval) && - push!(_attributes, namedattribute("iteration_interval", iteration_interval)) - !isnothing(read_latency) && - push!(_attributes, namedattribute("read_latency", read_latency)) - - return IR.create_operation( - "transform.loop.pipeline", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_pipeline(target; transformed::IR.Type, iteration_interval=nothing, read_latency=nothing, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(iteration_interval) && push!(attributes, namedattribute("iteration_interval", iteration_interval)) + !isnothing(read_latency) && push!(attributes, namedattribute("read_latency", read_latency)) + + IR.create_operation( + "transform.loop.pipeline", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4185,22 +3475,18 @@ considered loops if they implement the `LoopLikeOpInterface`. Otherwise, this transform always succeeds. The transform consumes the target handle and modifies the payload. """ -function loop_promote_if_one_iteration(target::Value; location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.loop.promote_if_one_iteration", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_promote_if_one_iteration(target; location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.loop.promote_if_one_iteration", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4221,22 +3507,18 @@ fails. Does not return handles as the operation may result in the loop being removed after a full unrolling. """ -function loop_unroll(target::Value; factor, location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("factor", factor),] - - return IR.create_operation( - "transform.loop.unroll", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function loop_unroll(target; factor, location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("factor", factor), ] + + IR.create_operation( + "transform.loop.unroll", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4261,31 +3543,23 @@ The transform only consumes its operand and does not produce any result. The transform definitely fails if `take_else_branch` is specified and the `else` region is empty. """ -function scf_take_assumed_branch( - target::Value; take_else_branch=nothing, location=Location() -) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(take_else_branch) && - push!(_attributes, namedattribute("take_else_branch", take_else_branch)) - - return IR.create_operation( - "transform.scf.take_assumed_branch", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scf_take_assumed_branch(target; take_else_branch=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(take_else_branch) && push!(attributes, namedattribute("take_else_branch", take_else_branch)) + + IR.create_operation( + "transform.scf.take_assumed_branch", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -4531,29 +3805,22 @@ Otherwise, the returned handle points to a subset of the produced ops: This transform op consumes the target handle and produces a result handle. """ -function tensor_make_loop_independent( - target::Value; transformed::IR.Type, num_loops, location=Location() -) - _results = IR.Type[transformed,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("num_loops", num_loops),] - - return IR.create_operation( - "transform.tensor.make_loop_independent", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function tensor_make_loop_independent(target; transformed::IR.Type, num_loops, location=Location()) + results = IR.Type[transformed, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("num_loops", num_loops), ] + + IR.create_operation( + "transform.tensor.make_loop_independent", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -4617,28 +3884,19 @@ Remark: this op allows one to implement a simple \"try\" construct as follows: } ``` """ -function alternatives( - scope=nothing::Union{Nothing,Value}; - results::Vector{IR.Type}, - alternatives::Vector{Region}, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[] - _owned_regions = Region[alternatives...,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(scope) && push!(_operands, scope) - - return IR.create_operation( - "transform.alternatives", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function alternatives(scope=nothing; results_::Vector{IR.Type}, alternatives::Vector{Region}, location=Location()) + results = IR.Type[results_..., ] + operands = Value[] + owned_regions = Region[alternatives..., ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(scope) && push!(operands, value(scope)) + + IR.create_operation( + "transform.alternatives", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4654,25 +3912,19 @@ the order within the handles. Fails silently if the length of the parameter payload does not match the length of the target payload. Does not consume the provided handles. """ -function annotate( - target::Value, param=nothing::Union{Nothing,Value}; name, location=Location() -) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("name", name),] - !isnothing(param) && push!(_operands, param) - - return IR.create_operation( - "transform.annotate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function annotate(target, param=nothing; name, location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("name", name), ] + !isnothing(param) && push!(operands, value(param)) + + IR.create_operation( + "transform.annotate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4713,22 +3965,18 @@ necessary. Note that this can lead to situations where a handle, that was previously mapped to multiple distinct (but equivalent) operations, is now mapped to the same operation multiple times. """ -function apply_cse(target::Value; location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.apply_cse", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_cse(target; location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.apply_cse", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4745,22 +3993,18 @@ op folding and region simplification. This transform reads the target handle and modifies the payload. Note that this transform may silently remove payload ops from handles. """ -function apply_dce(target::Value; location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.apply_dce", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_dce(target; location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.apply_dce", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4776,22 +4020,18 @@ to each loop of the loop nest, starting with the inner-most loop. This transform reads the target handle and modifies the payload. """ -function apply_licm(target::Value; location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.apply_licm", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_licm(target; location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.apply_licm", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4825,27 +4065,21 @@ This transform also fails silently if the pattern application did not converge within the default number of iterations/rewrites of the greedy pattern rewrite driver. """ -function apply_patterns( - target::Value; apply_cse=nothing, patterns::Region, location=Location() -) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[patterns,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(apply_cse) && push!(_attributes, namedattribute("apply_cse", apply_cse)) - - return IR.create_operation( - "transform.apply_patterns", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, - ) -end +function apply_patterns(target; apply_cse=nothing, patterns::Region, location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[patterns, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(apply_cse) && push!(attributes, namedattribute("apply_cse", apply_cse)) + + IR.create_operation( + "transform.apply_patterns", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false + ) +end """ `apply_registered_pass` @@ -4862,25 +4096,19 @@ that they operate on, so the target op is guaranteed to still exist. The target handle is invalidated because a pass may arbitrarily modify the body of targeted ops. """ -function apply_registered_pass( - target::Value; result::IR.Type, pass_name, options=nothing, location=Location() -) - _results = IR.Type[result,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pass_name", pass_name),] - !isnothing(options) && push!(_attributes, namedattribute("options", options)) - - return IR.create_operation( - "transform.apply_registered_pass", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function apply_registered_pass(target; result::IR.Type, pass_name, options=nothing, location=Location()) + results = IR.Type[result, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("pass_name", pass_name), ] + !isnothing(options) && push!(attributes, namedattribute("options", options)) + + IR.create_operation( + "transform.apply_registered_pass", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4888,22 +4116,18 @@ end `cast` """ -function cast(input::Value; output::IR.Type, location=Location()) - _results = IR.Type[output,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function cast(input; output::IR.Type, location=Location()) + results = IR.Type[output, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -4959,26 +4183,18 @@ the resulting handle is associated with an empty payload. The operation produces a definite failure if any of the applied matchers or actions produced a definite failure. """ -function foreach_match( - root::Value; updated::IR.Type, matchers, actions, location=Location() -) - _results = IR.Type[updated,] - _operands = Value[root,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("matchers", matchers), namedattribute("actions", actions) - ] - - return IR.create_operation( - "transform.foreach_match", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach_match(root; updated::IR.Type, matchers, actions, location=Location()) + results = IR.Type[updated, ] + operands = Value[value(root), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("matchers", matchers), namedattribute("actions", actions), ] + + IR.create_operation( + "transform.foreach_match", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5004,22 +4220,18 @@ This op generates as many handles as the terminating YieldOp has operands. For each result, the payload ops of the corresponding YieldOp operand are merged and mapped to the same resulting handle. """ -function foreach(target::Value; results::Vector{IR.Type}, body::Region, location=Location()) - _results = IR.Type[results...,] - _operands = Value[target,] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.foreach", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function foreach(target; results_::Vector{IR.Type}, body::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(target), ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.foreach", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5034,24 +4246,18 @@ definitely fails. The return handle points to the consuming operations operations, which can be empty. """ -function get_consumers_of_result( - target::Value; consumers::IR.Type, result_number, location=Location() -) - _results = IR.Type[consumers,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("result_number", result_number),] - - return IR.create_operation( - "transform.get_consumers_of_result", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_consumers_of_result(target; consumers::IR.Type, result_number, location=Location()) + results = IR.Type[consumers, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("result_number", result_number), ] + + IR.create_operation( + "transform.get_consumers_of_result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5063,22 +4269,18 @@ the targeted value. This transform fails silently if the targeted value is a block argument. """ -function get_defining_op(target::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.get_defining_op", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_defining_op(target; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.get_defining_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5104,34 +4306,21 @@ on the further transformation applied to the handle produced here. If any of the given Payload IR ops has no such suitable parent, the transformation fails silently. """ -function get_parent_op( - target::Value; - parent::IR.Type, - isolated_from_above=nothing, - op_name=nothing, - deduplicate=nothing, - location=Location(), -) - _results = IR.Type[parent,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(isolated_from_above) && - push!(_attributes, namedattribute("isolated_from_above", isolated_from_above)) - !isnothing(op_name) && push!(_attributes, namedattribute("op_name", op_name)) - !isnothing(deduplicate) && - push!(_attributes, namedattribute("deduplicate", deduplicate)) - - return IR.create_operation( - "transform.get_parent_op", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_parent_op(target; parent::IR.Type, isolated_from_above=nothing, op_name=nothing, deduplicate=nothing, location=Location()) + results = IR.Type[parent, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(isolated_from_above) && push!(attributes, namedattribute("isolated_from_above", isolated_from_above)) + !isnothing(op_name) && push!(attributes, namedattribute("op_name", op_name)) + !isnothing(deduplicate) && push!(attributes, namedattribute("deduplicate", deduplicate)) + + IR.create_operation( + "transform.get_parent_op", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5145,24 +4334,18 @@ a block argument), the transform silently fails. The return handle points to only the subset of successfully produced computational operations, which can be empty. """ -function get_producer_of_operand( - target::Value; producer::IR.Type, operand_number, location=Location() -) - _results = IR.Type[producer,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("operand_number", operand_number),] - - return IR.create_operation( - "transform.get_producer_of_operand", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_producer_of_operand(target; producer::IR.Type, operand_number, location=Location()) + results = IR.Type[producer, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("operand_number", operand_number), ] + + IR.create_operation( + "transform.get_producer_of_operand", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5175,22 +4358,18 @@ The handle defined by this Transform op corresponds to the OpResult with This transform fails silently if the targeted operation does not have enough results. It reads the target handle and produces the result handle. """ -function get_result(target::Value; result::IR.Type, result_number, location=Location()) - _results = IR.Type[result,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("result_number", result_number),] - - return IR.create_operation( - "transform.get_result", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_result(target; result::IR.Type, result_number, location=Location()) + results = IR.Type[result, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("result_number", result_number), ] + + IR.create_operation( + "transform.get_result", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5202,23 +4381,19 @@ type(s) of the value(s) associated with the operand handle. This transform never fails. """ -function get_type(value::Value; type_param::IR.Type, elemental=nothing, location=Location()) - _results = IR.Type[type_param,] - _operands = Value[value,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(elemental) && push!(_attributes, namedattribute("elemental", elemental)) - - return IR.create_operation( - "transform.get_type", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function get_type(value; type_param::IR.Type, elemental=nothing, location=Location()) + results = IR.Type[type_param, ] + operands = Value[value(value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(elemental) && push!(attributes, namedattribute("elemental", elemental)) + + IR.create_operation( + "transform.get_type", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5242,31 +4417,18 @@ immediately regardless of the mode. The objects associated with the results of this operation are the same as those associated with the operands of the `transform.yield` in the referenced named sequence. """ -function include_( - operands::Vector{Value}; - results::Vector{IR.Type}, - target, - failure_propagation_mode, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("target", target), - namedattribute("failure_propagation_mode", failure_propagation_mode), - ] - - return IR.create_operation( - "transform.include", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function include_(operands_; results_::Vector{IR.Type}, target, failure_propagation_mode, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("target", target), namedattribute("failure_propagation_mode", failure_propagation_mode), ] + + IR.create_operation( + "transform.include", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5279,22 +4441,18 @@ given operation names. Produces a silenceable failure otherwise. If more than one payload operation is associated with the operand handle, produces a definite failure. """ -function match_operation_name(operand_handle::Value; op_names, location=Location()) - _results = IR.Type[] - _operands = Value[operand_handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("op_names", op_names),] - - return IR.create_operation( - "transform.match.operation_name", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_operation_name(operand_handle; op_names, location=Location()) + results = IR.Type[] + operands = Value[value(operand_handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("op_names", op_names), ] + + IR.create_operation( + "transform.match.operation_name", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5306,22 +4464,18 @@ parameters relate as specified by the predicate (greater than, less than, equal to, or their combinations). Comparison treats all values as signed. Produces a silenceable failure otherwise. """ -function match_param_cmpi(param::Value, reference::Value; predicate, location=Location()) - _results = IR.Type[] - _operands = Value[param, reference] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("predicate", predicate),] - - return IR.create_operation( - "transform.match.param.cmpi", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function match_param_cmpi(param, reference; predicate, location=Location()) + results = IR.Type[] + operands = Value[value(param), value(reference), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("predicate", predicate), ] + + IR.create_operation( + "transform.match.param.cmpi", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5337,30 +4491,20 @@ first, then all Payload IR associated with the second handle and so on. If parameter more than once to the final list regardless of it coming from the same or different handles. Consumes the operands and produces a new handle. """ -function merge_handles( - handles::Vector{Value}; - result=nothing::Union{Nothing,IR.Type}, - deduplicate=nothing, - location=Location(), -) - _results = IR.Type[] - _operands = Value[handles...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - !isnothing(deduplicate) && - push!(_attributes, namedattribute("deduplicate", deduplicate)) - - return IR.create_operation( - "transform.merge_handles", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function merge_handles(handles; result=nothing::Union{Nothing, IR.Type}, deduplicate=nothing, location=Location()) + results = IR.Type[] + operands = Value[value.(handles)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + !isnothing(deduplicate) && push!(attributes, namedattribute("deduplicate", deduplicate)) + + IR.create_operation( + "transform.merge_handles", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -5460,24 +4604,20 @@ specified, the top-level op is dumped. This op is useful for printf-style debugging. """ -function print(target=nothing::Union{Nothing,Value}; name=nothing, location=Location()) - _results = IR.Type[] - _operands = Value[] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(target) && push!(_operands, target) - !isnothing(name) && push!(_attributes, namedattribute("name", name)) - - return IR.create_operation( - "transform.print", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function print(target=nothing; name=nothing, location=Location()) + results = IR.Type[] + operands = Value[] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(target) && push!(operands, value(target)) + !isnothing(name) && push!(attributes, namedattribute("name", name)) + + IR.create_operation( + "transform.print", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5506,24 +4646,18 @@ MergeHandlesOp may be used to deduplicate the associated list of payload IR ops when necessary. Furthermore, a combination of ReplicateOp and MergeHandlesOp can be used to construct arbitrary lists with repetitions. """ -function replicate( - pattern::Value, handles::Vector{Value}; replicated::Vector{IR.Type}, location=Location() -) - _results = IR.Type[replicated...,] - _operands = Value[pattern, handles...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.replicate", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function replicate(pattern, handles; replicated::Vector{IR.Type}, location=Location()) + results = IR.Type[replicated..., ] + operands = Value[value(pattern), value.(handles)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.replicate", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5540,22 +4674,18 @@ The result payload ops are in the same relative order as the targeted ops. This transform op reads the `target` handle and produces the `result` handle. It reads the payload, but does not modify it. """ -function select(target::Value; result::IR.Type, op_name, location=Location()) - _results = IR.Type[result,] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("op_name", op_name),] - - return IR.create_operation( - "transform.select", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function select(target; result::IR.Type, op_name, location=Location()) + results = IR.Type[result, ] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("op_name", op_name), ] + + IR.create_operation( + "transform.select", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5610,35 +4740,20 @@ The body of the sequence terminates with an implicit or explicit `transform.yield` op. The operands of the terminator are returned as the results of the sequence op. """ -function sequence( - root=nothing::Union{Nothing,Value}; - extra_bindings::Vector{Value}, - results::Vector{IR.Type}, - failure_propagation_mode, - body::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[extra_bindings...,] - _owned_regions = Region[body,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute( - "failure_propagation_mode", failure_propagation_mode - ),] - !isnothing(root) && push!(_operands, root) - push!( - _attributes, operandsegmentsizes([isnothing(root) ? 0 : 1, length(extra_bindings)]) - ) - - return IR.create_operation( - "transform.sequence", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function sequence(root=nothing; extra_bindings, results_::Vector{IR.Type}, failure_propagation_mode, body::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value.(extra_bindings)..., ] + owned_regions = Region[body, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("failure_propagation_mode", failure_propagation_mode), ] + !isnothing(root) && push!(operands, value(root)) + push!(attributes, operandsegmentsizes([(root==nothing) ? 0 : 1length(extra_bindings), ])) + + IR.create_operation( + "transform.sequence", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5666,39 +4781,21 @@ the remaining result handles are not mapped to any op. It also succeeds if `handle` is empty and `pass_through_empty_handle` is set to \"true\", regardless of `fail_on_payload_too_small`. """ -function split_handle( - handle::Value; - results::Vector{IR.Type}, - pass_through_empty_handle=nothing, - fail_on_payload_too_small=nothing, - overflow_result=nothing, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[handle,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(pass_through_empty_handle) && push!( - _attributes, - namedattribute("pass_through_empty_handle", pass_through_empty_handle), - ) - !isnothing(fail_on_payload_too_small) && push!( - _attributes, - namedattribute("fail_on_payload_too_small", fail_on_payload_too_small), - ) - !isnothing(overflow_result) && - push!(_attributes, namedattribute("overflow_result", overflow_result)) - - return IR.create_operation( - "transform.split_handle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function split_handle(handle; results_::Vector{IR.Type}, pass_through_empty_handle=nothing, fail_on_payload_too_small=nothing, overflow_result=nothing, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(handle), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(pass_through_empty_handle) && push!(attributes, namedattribute("pass_through_empty_handle", pass_through_empty_handle)) + !isnothing(fail_on_payload_too_small) && push!(attributes, namedattribute("fail_on_payload_too_small", fail_on_payload_too_small)) + !isnothing(overflow_result) && push!(attributes, namedattribute("overflow_result", overflow_result)) + + IR.create_operation( + "transform.split_handle", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5715,22 +4812,18 @@ op. This transform reads the target handle. """ -function verify(target::Value; location=Location()) - _results = IR.Type[] - _operands = Value[target,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.verify", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function verify(target; location=Location()) + results = IR.Type[] + operands = Value[value(target), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.verify", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -5741,27 +4834,22 @@ This terminator operation yields operation handles from regions of the transform IR ops back to the containing op. It is not itself associated with any transformation on the payload IR and is used for flow purposes only. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "transform.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "transform.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ diff --git a/src/Dialects/17/UB.jl b/src/Dialects/17/UB.jl index e7e81163..81c5e3b1 100644 --- a/src/Dialects/17/UB.jl +++ b/src/Dialects/17/UB.jl @@ -1,7 +1,6 @@ module ub -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ diff --git a/src/Dialects/17/Vector.jl b/src/Dialects/17/Vector.jl index 1f20a5c9..f330eb8d 100644 --- a/src/Dialects/17/Vector.jl +++ b/src/Dialects/17/Vector.jl @@ -1,7 +1,6 @@ module vector -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ @@ -62,22 +61,18 @@ equal. %7 = vector.bitcast %6 : vector to vector ``` """ -function bitcast(source::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.bitcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function bitcast(source; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.bitcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -112,22 +107,18 @@ shaped vector with the same element type is always legal. %2 = vector.broadcast %1 : vector<16xf32> to vector<4x16xf32> ``` """ -function broadcast(source::Value; vector::IR.Type, location=Location()) - _results = IR.Type[vector,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.broadcast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function broadcast(source; vector::IR.Type, location=Location()) + results = IR.Type[vector, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.broadcast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -167,28 +158,18 @@ vector.compressstore %base[%i, %j], %mask, %value : memref, vector<16xi1>, vector<16xf32> ``` """ -function compressstore( - base::Value, - indices::Vector{Value}, - mask::Value, - valueToStore::Value; - location=Location(), -) - _results = IR.Type[] - _operands = Value[base, indices..., mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.compressstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function compressstore(base, indices, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.compressstore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -353,35 +334,19 @@ int only. The default is \"add\". : vector<10xf32>, vector<10xf32> into f32 ``` """ -function contract( - lhs::Value, - rhs::Value, - acc::Value; - result_0::IR.Type, - indexing_maps, - iterator_types, - kind=nothing, - location=Location(), -) - _results = IR.Type[result_0,] - _operands = Value[lhs, rhs, acc] - _owned_regions = Region[] - _successors = Block[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function contract(lhs, rhs, acc; result_0::IR.Type, indexing_maps, iterator_types, kind=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("indexing_maps", indexing_maps), namedattribute("iterator_types", iterator_types), ] + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) + + IR.create_operation( + "vector.contract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -415,22 +380,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...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.create_mask", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function create_mask(operands_; result_0::IR.Type, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.create_mask", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -470,29 +431,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.expandload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function expandload(base, indices, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.expandload", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -518,29 +468,19 @@ https://llvm.org/docs/LangRef.html#extractelement-instruction %2 = vector.extractelement %z[]: vector ``` """ -function extractelement( - vector::Value, - position=nothing::Union{Nothing,Value}; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[vector,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(position) && push!(_operands, position) - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "vector.extractelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extractelement(vector, position=nothing; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(position) && push!(operands, value(position)) + + IR.create_operation( + "vector.extractelement", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -558,25 +498,19 @@ the proper position. Degenerates to an element type if n-k is zero. %3 = vector.extract %1[]: vector ``` """ -function extract( - vector::Value; result_0=nothing::Union{Nothing,IR.Type}, position, location=Location() -) - _results = IR.Type[] - _operands = Value[vector,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("position", position),] - !isnothing(result_0) && push!(_results, result_0) - - return IR.create_operation( - "vector.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function extract(vector; result_0=nothing::Union{Nothing, IR.Type}, position, location=Location()) + results = IR.Type[] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + !isnothing(result_0) && push!(results, result_0) + + IR.create_operation( + "vector.extract", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -606,28 +540,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,] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function extract_strided_slice(vector; result_0::IR.Type, offsets, sizes, strides, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -648,29 +572,19 @@ to the `llvm.fma.*` intrinsic. %3 = vector.fma %0, %1, %2: vector<8x16xf32> ``` """ -function fma( - lhs::Value, - rhs::Value, - acc::Value; - result=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[lhs, rhs, acc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "vector.fma", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function fma(lhs, rhs, acc; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(lhs), value(rhs), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(result) && push!(results, result) + + IR.create_operation( + "vector.fma", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -699,24 +613,18 @@ http://llvm.org/docs/LangRef.html#llvm-matrix-transpose-intrinsic : vector<16xf32> -> vector<16xf32> ``` """ -function flat_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( - "vector.flat_transpose", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function flat_transpose(matrix; res::IR.Type, rows, columns, location=Location()) + results = IR.Type[res, ] + operands = Value[value(matrix), ] + owned_regions = Region[] + successors = Block[] + 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 ) end @@ -755,30 +663,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.gather", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function gather(base, indices, index_vec, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(index_vec), value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.gather", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -803,30 +699,20 @@ 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=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(position) && push!(_operands, position) - !isnothing(result) && push!(_results, result) - - return IR.create_operation( - "vector.insertelement", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insertelement(source, dest, position=nothing; result=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(position) && push!(operands, value(position)) + !isnothing(result) && push!(results, result) + + IR.create_operation( + "vector.insertelement", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -846,29 +732,19 @@ position. Degenerates to a scalar or a 0-d vector source type when n = 0. %11 = vector.insert %9, %10[3, 3, 3] : vector into vector<4x8x16xf32> ``` """ -function insert( - source::Value, - dest::Value; - res=nothing::Union{Nothing,IR.Type}, - position, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("position", position),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "vector.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert(source, dest; res=nothing::Union{Nothing, IR.Type}, position, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("position", position), ] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "vector.insert", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -894,32 +770,19 @@ the proper location as specified by the offsets. vector<2x4xf32> into vector<16x4x8xf32> ``` """ -function insert_strided_slice( - source::Value, - dest::Value; - res=nothing::Union{Nothing,IR.Type}, - offsets, - strides, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("offsets", offsets), namedattribute("strides", strides) - ] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "vector.insert_strided_slice", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function insert_strided_slice(source, dest; res=nothing::Union{Nothing, IR.Type}, offsets, strides, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("offsets", offsets), namedattribute("strides", strides), ] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "vector.insert_strided_slice", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -979,22 +842,18 @@ Example 6: Explicit out-of-bound vector load. %result = vector.load %memref[%c0] : memref<7xf32>, vector<8xf32> ``` """ -function load(base::Value, indices::Vector{Value}; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.load", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function load(base, indices; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.load", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1046,29 +905,19 @@ Examples: vector.mask %mask { vector.transfer_write %val, %t0[%idx] : vector<16xf32>, tensor } : vector<16xi1> -> tensor ``` """ -function mask( - mask::Value, - passthru=nothing::Union{Nothing,Value}; - results::Vector{IR.Type}, - maskRegion::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[mask,] - _owned_regions = Region[maskRegion,] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(passthru) && push!(_operands, passthru) - - return IR.create_operation( - "vector.mask", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function mask(mask, passthru=nothing; results_::Vector{IR.Type}, maskRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(mask), ] + owned_regions = Region[maskRegion, ] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(passthru) && push!(operands, value(passthru)) + + IR.create_operation( + "vector.mask", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1106,29 +955,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.maskedload", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maskedload(base, indices, mask, pass_thru; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(base), value.(indices)..., value(mask), value(pass_thru), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.maskedload", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1166,28 +1004,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(), -) - _results = IR.Type[] - _operands = Value[base, indices..., mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.maskedstore", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function maskedstore(base, indices, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.maskedstore", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1218,34 +1046,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] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function matrix_multiply(lhs, rhs; res::IR.Type, lhs_rows, lhs_columns, rhs_columns, location=Location()) + results = IR.Type[res, ] + operands = Value[value(lhs), value(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( + "vector.matrix_multiply", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1266,32 +1078,19 @@ Takes an initial accumulator operand. vector<4x16xf32> into f32 ``` """ -function multi_reduction( - source::Value, - acc::Value; - dest=nothing::Union{Nothing,IR.Type}, - kind, - reduction_dims, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, acc] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("kind", kind), namedattribute("reduction_dims", reduction_dims) - ] - !isnothing(dest) && push!(_results, dest) - - return IR.create_operation( - "vector.multi_reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function multi_reduction(source, acc; dest=nothing::Union{Nothing, IR.Type}, kind, reduction_dims, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(acc), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dims", reduction_dims), ] + !isnothing(dest) && push!(results, dest) + + IR.create_operation( + "vector.multi_reduction", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1345,30 +1144,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...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(kind) && push!(_attributes, namedattribute("kind", kind)) - - return IR.create_operation( - "vector.outerproduct", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function outerproduct(lhs, rhs, acc; result_0::IR.Type, kind=nothing, location=Location()) + results = IR.Type[result_0, ] + operands = Value[value(lhs), value(rhs), value.(acc)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(kind) && push!(attributes, namedattribute("kind", kind)) + + IR.create_operation( + "vector.outerproduct", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1396,22 +1184,18 @@ value for all data types, opening/closing bracket, comma, newline). ``` """ -function print(source::Value; location=Location()) - _results = IR.Type[] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.print", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function print(source; location=Location()) + results = IR.Type[] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.print", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1437,29 +1221,19 @@ http://llvm.org/docs/LangRef.html#vector-reduction-intrinsics %4 = vector.reduction , %0, %1 : vector<16xf32> into f32 ``` """ -function reduction( - vector::Value, - acc=nothing::Union{Nothing,Value}; - dest::IR.Type, - kind, - location=Location(), -) - _results = IR.Type[dest,] - _operands = Value[vector,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("kind", kind),] - !isnothing(acc) && push!(_operands, acc) - - return IR.create_operation( - "vector.reduction", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reduction(vector, acc=nothing; dest::IR.Type, kind, location=Location()) + results = IR.Type[dest, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), ] + !isnothing(acc) && push!(operands, value(acc)) + + IR.create_operation( + "vector.reduction", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1547,30 +1321,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...] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function reshape(vector, input_shape, output_shape; result::IR.Type, fixed_vector_sizes, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), value.(input_shape)..., value.(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), ])) + + IR.create_operation( + "vector.reshape", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1598,22 +1361,18 @@ Invalid example: %1 = vector.scalable.extract %0[5] : vector<4xf32> from vector<[16]xf32> ``` """ -function scalable_extract(source::Value; res::IR.Type, pos, location=Location()) - _results = IR.Type[res,] - _operands = Value[source,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pos", pos),] - - return IR.create_operation( - "vector.scalable.extract", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scalable_extract(source; res::IR.Type, pos, location=Location()) + results = IR.Type[res, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("pos", pos), ] + + IR.create_operation( + "vector.scalable.extract", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1645,29 +1404,19 @@ Invalid example: %2 = vector.scalable.insert %0, %1[5] : vector<4xf32> into vector<[16]xf32> ``` """ -function scalable_insert( - source::Value, - dest::Value; - res=nothing::Union{Nothing,IR.Type}, - pos, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, dest] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("pos", pos),] - !isnothing(res) && push!(_results, res) - - return IR.create_operation( - "vector.scalable.insert", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function scalable_insert(source, dest; res=nothing::Union{Nothing, IR.Type}, pos, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(dest), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("pos", pos), ] + !isnothing(res) && push!(results, res) + + IR.create_operation( + "vector.scalable.insert", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1688,37 +1437,20 @@ reduction in the scan. vector<4x8x16x32xf32>, vector<4x16x32xf32> ``` """ -function scan( - source::Value, - initial_value::Value; - dest=nothing::Union{Nothing,IR.Type}, - accumulated_value=nothing::Union{Nothing,IR.Type}, - kind, - reduction_dim, - inclusive, - location=Location(), -) - _results = IR.Type[] - _operands = Value[source, initial_value] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[ - namedattribute("kind", kind), - namedattribute("reduction_dim", reduction_dim), - namedattribute("inclusive", inclusive), - ] - !isnothing(dest) && push!(_results, dest) - !isnothing(accumulated_value) && push!(_results, accumulated_value) - - return IR.create_operation( - "vector.scan", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function scan(source, initial_value; dest=nothing::Union{Nothing, IR.Type}, accumulated_value=nothing::Union{Nothing, IR.Type}, kind, reduction_dim, inclusive, location=Location()) + results = IR.Type[] + operands = Value[value(source), value(initial_value), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("kind", kind), namedattribute("reduction_dim", reduction_dim), namedattribute("inclusive", inclusive), ] + !isnothing(dest) && push!(results, dest) + !isnothing(accumulated_value) && push!(results, accumulated_value) + + IR.create_operation( + "vector.scan", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1761,29 +1493,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(), -) - _results = IR.Type[] - _operands = Value[base, indices..., index_vec, mask, valueToStore] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.scatter", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function scatter(base, indices, index_vec, mask, valueToStore; location=Location()) + results = IR.Type[] + operands = Value[value(base), value.(indices)..., value(index_vec), value(mask), value(valueToStore), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.scatter", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1822,22 +1543,18 @@ 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,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.shape_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function shape_cast(source; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(source), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.shape_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1876,25 +1593,19 @@ The legality rules are: : vector, vector ; yields vector<2xf32> ``` """ -function shuffle( - v1::Value, v2::Value; vector=nothing::Union{Nothing,IR.Type}, mask, location=Location() -) - _results = IR.Type[] - _operands = Value[v1, v2] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("mask", mask),] - !isnothing(vector) && push!(_results, vector) - - return IR.create_operation( - "vector.shuffle", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function shuffle(v1, v2; vector=nothing::Union{Nothing, IR.Type}, mask, location=Location()) + results = IR.Type[] + operands = Value[value(v1), value(v2), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("mask", mask), ] + !isnothing(vector) && push!(results, vector) + + IR.create_operation( + "vector.shuffle", location; + operands, owned_regions, successors, attributes, + results=(length(results) == 0 ? nothing : results), + result_inference=(length(results) == 0 ? true : false) ) end @@ -1911,22 +1622,18 @@ required to be of integer/index/float type. %t = vector.splat %s : vector<8x16xi32> ``` """ -function splat(input::Value; aggregate::IR.Type, location=Location()) - _results = IR.Type[aggregate,] - _operands = Value[input,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.splat", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function splat(input; aggregate::IR.Type, location=Location()) + results = IR.Type[aggregate, ] + operands = Value[value(input), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.splat", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -1984,24 +1691,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() -) - _results = IR.Type[] - _operands = Value[valueToStore, base, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.store", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function store(valueToStore, base, indices; location=Location()) + results = IR.Type[] + operands = Value[value(valueToStore), value(base), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.store", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2186,36 +1887,21 @@ affine.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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("permutation_map", permutation_map),] - !isnothing(mask) && push!(_operands, mask) - push!( - _attributes, operandsegmentsizes([1, length(indices), 1, isnothing(mask) ? 0 : 1]) - ) - !isnothing(in_bounds) && push!(_attributes, namedattribute("in_bounds", in_bounds)) - - return IR.create_operation( - "vector.transfer_read", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transfer_read(source, indices, padding, mask=nothing; vector::IR.Type, permutation_map, in_bounds=nothing, location=Location()) + results = IR.Type[vector, ] + operands = Value[value(source), value.(indices)..., value(padding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] + !isnothing(mask) && push!(operands, value(mask)) + push!(attributes, operandsegmentsizes([1, length(indices), 1, (mask==nothing) ? 0 : 1])) + !isnothing(in_bounds) && push!(attributes, namedattribute("in_bounds", in_bounds)) + + IR.create_operation( + "vector.transfer_read", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2318,37 +2004,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(), -) - _results = IR.Type[] - _operands = Value[vector, source, indices...] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("permutation_map", permutation_map),] - !isnothing(mask) && push!(_operands, mask) - push!( - _attributes, operandsegmentsizes([1, 1, length(indices), isnothing(mask) ? 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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transfer_write(vector, source, indices, mask=nothing; result=nothing::Union{Nothing, IR.Type}, permutation_map, in_bounds=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(vector), value(source), value.(indices)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("permutation_map", permutation_map), ] + !isnothing(mask) && push!(operands, value(mask)) + 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)) + + IR.create_operation( + "vector.transfer_write", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2378,22 +2049,18 @@ the transp array [i_1, .., i_n] must be a permutation of [0, .., n-1]. [c, f] ] ``` """ -function transpose(vector::Value; result::IR.Type, transp, location=Location()) - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function transpose(vector; result::IR.Type, transp, location=Location()) + results = IR.Type[result, ] + operands = Value[value(vector), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[namedattribute("transp", transp), ] + + IR.create_operation( + "vector.transpose", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2419,22 +2086,18 @@ operation ::= `vector.type_cast` ssa-use : memref-type to memref-type %VA = vector.type_cast %A : memref<5x4x3xf32> to memref> ``` """ -function type_cast(memref::Value; result::IR.Type, location=Location()) - _results = IR.Type[result,] - _operands = Value[memref,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.type_cast", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function type_cast(memref; result::IR.Type, location=Location()) + results = IR.Type[result, ] + operands = Value[value(memref), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.type_cast", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2540,29 +2203,18 @@ some_synchronization_primitive // Execute in parallel on all threads/lanes. ``` """ -function warp_execute_on_lane_0( - laneid::Value, - args::Vector{Value}; - results::Vector{IR.Type}, - warp_size, - warpRegion::Region, - location=Location(), -) - _results = IR.Type[results...,] - _operands = Value[laneid, args...] - _owned_regions = Region[warpRegion,] - _successors = Block[] - _attributes = NamedAttribute[namedattribute("warp_size", warp_size),] - - return IR.create_operation( - "vector.warp_execute_on_lane_0", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function warp_execute_on_lane_0(laneid, args; results_::Vector{IR.Type}, warp_size, warpRegion::Region, location=Location()) + results = IR.Type[results_..., ] + operands = Value[value(laneid), value.(args)..., ] + owned_regions = Region[warpRegion, ] + successors = Block[] + attributes = NamedAttribute[namedattribute("warp_size", warp_size), ] + + IR.create_operation( + "vector.warp_execute_on_lane_0", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -2577,22 +2229,18 @@ parent operation\'s results. If the parent operation defines no value the vector.yield may be omitted when printing the region. """ -function yield(operands::Vector{Value}; location=Location()) - _results = IR.Type[] - _operands = Value[operands...,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "vector.yield", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function yield(operands_; location=Location()) + results = IR.Type[] + operands = Value[value.(operands_)..., ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "vector.yield", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Dialects/17/X86Vector.jl b/src/Dialects/17/X86Vector.jl index c45d602c..2c2d5665 100644 --- a/src/Dialects/17/X86Vector.jl +++ b/src/Dialects/17/X86Vector.jl @@ -1,32 +1,25 @@ module x86vector -import ...IR: - IR, NamedAttribute, Value, Location, Block, Region, Attribute, context, IndexType +import ...IR: IR, NamedAttribute, Value, value, Location, Block, Region, Attribute, context, IndexType import ..Dialects: namedattribute, operandsegmentsizes """ `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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_dp_ps_256(a, b, c; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), value(c), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -48,25 +41,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_dot(a, b; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -74,25 +61,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() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_compress(a, src, k; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), value(src), value(k), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -111,33 +92,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_compress(k, a, src=nothing; dst=nothing::Union{Nothing, IR.Type}, constant_src=nothing, location=Location()) + results = IR.Type[] + operands = Value[value(k), value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(src) && push!(operands, value(src)) + !isnothing(dst) && push!(results, dst) + !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) ) end @@ -155,31 +124,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_rndscale(src, k, a, imm, rounding; dst=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dst) && push!(results, dst) + + 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) ) end @@ -187,31 +144,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_rndscale_pd_512(src, k, a, imm, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -219,31 +164,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_rndscale_ps_512(src, k, a, imm, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(k), value(a), value(imm), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -261,31 +194,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_mask_scalef(src, a, b, k, rounding; dst=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(dst) && push!(results, dst) + + 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) ) end @@ -293,31 +214,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_scalef_pd_512(src, a, b, k, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -325,31 +234,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(), -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_intr_mask_scalef_ps_512(src, a, b, k, rounding; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(src), value(a), value(b), value(k), value(rounding), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -357,25 +254,19 @@ end `avx_intr_rsqrt_ps_256` """ -function avx_intr_rsqrt_ps_256( - a::Value; res=nothing::Union{Nothing,IR.Type}, location=Location() -) - _results = IR.Type[] - _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=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_intr_rsqrt_ps_256(a; res=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(res) && push!(results, res) + + 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) ) end @@ -383,23 +274,19 @@ end `avx_rsqrt` """ -function avx_rsqrt(a::Value; b=nothing::Union{Nothing,IR.Type}, location=Location()) - _results = IR.Type[] - _operands = Value[a,] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(b) && push!(_results, b) - - return IR.create_operation( - "x86vector.avx.rsqrt", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx_rsqrt(a; b=nothing::Union{Nothing, IR.Type}, location=Location()) + results = IR.Type[] + operands = Value[value(a), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + !isnothing(b) && push!(results, b) + + 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) ) end @@ -407,24 +294,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.intr.vp2intersect.d.512", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avx512_intr_vp2intersect_d_512(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.intr.vp2intersect.d.512", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -444,30 +325,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=nothing::Union{Nothing,IR.Type}, - k2=nothing::Union{Nothing,IR.Type}, - location=Location(), -) - _results = IR.Type[] - _operands = Value[a, b] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - !isnothing(k1) && push!(_results, k1) - !isnothing(k2) && push!(_results, k2) - - return IR.create_operation( - "x86vector.avx512.vp2intersect", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=(length(_results) == 0 ? nothing : _results), - result_inference=(length(_results) == 0 ? true : false), +function avx512_vp2intersect(a, b; k1::IR.Type, k2::IR.Type, location=Location()) + results = IR.Type[k1, k2, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.vp2intersect", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end @@ -475,24 +344,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] - _owned_regions = Region[] - _successors = Block[] - _attributes = NamedAttribute[] - - return IR.create_operation( - "x86vector.avx512.intr.vp2intersect.q.512", - location; - operands=_operands, - owned_regions=_owned_regions, - successors=_successors, - attributes=_attributes, - results=_results, - result_inference=false, +function avx512_intr_vp2intersect_q_512(a, b; res::IR.Type, location=Location()) + results = IR.Type[res, ] + operands = Value[value(a), value(b), ] + owned_regions = Region[] + successors = Block[] + attributes = NamedAttribute[] + + IR.create_operation( + "x86vector.avx512.intr.vp2intersect.q.512", location; + operands, owned_regions, successors, attributes, + results=results, + result_inference=false ) end diff --git a/src/Generate/CodeInfoTools.jl b/src/Generate/CodeInfoTools.jl new file mode 100644 index 00000000..b86d9b1a --- /dev/null +++ b/src/Generate/CodeInfoTools.jl @@ -0,0 +1,675 @@ +# Copied from CodeInfoTools package, with slight modifications for Julia 1.11 +# (https://github.com/jumerckx/CodeInfoTools.jl/tree/jm/ssaflags) + +module CodeInfoTools + +using Core: CodeInfo + +import Base: iterate, + push!, + pushfirst!, + insert!, + delete!, + getindex, + lastindex, + setindex!, + display, + +, + length, + identity, + isempty, + show + +import Core.Compiler: AbstractInterpreter, + OptimizationState, + OptimizationParams + +##### +##### Exports +##### + +export code_info, + code_inferred, + walk, + var, + Variable, + slot, + get_slot, + Statement, + stmt, + Canvas, + Builder, + slot!, + return!, + renumber, + verify, + finish, + unwrap, + lambda, + λ + +##### +##### Utilities +##### + +const Variable = Core.SSAValue +var(id::Int) = Variable(id) + +@doc( +""" + const Variable = Core.SSAValue + var(id::Int) = Variable(id) + +Alias for `Core.SSAValue` -- represents a primitive register in lowered code. See the section of Julia's documentation on [lowered forms](https://docs.julialang.org/en/v1/devdocs/ast/#Lowered-form) for more information. +""", Variable) + +Base.:(+)(v::Variable, id::Int) = Variable(v.id + id) +Base.:(+)(id::Int, v::Variable) = Variable(v.id + id) + +function code_info(f, tt::Type{T}; generated=true, debuginfo=:default) where T <: Tuple + ir = code_lowered(f, tt; generated = generated, debuginfo = :default) + isempty(ir) && return nothing + return ir[1] +end + +function code_info(f, t::Type...; generated = true, debuginfo = :default) + return code_info(f, Tuple{t...}; generated = generated, debuginfo = debuginfo) +end + +@doc( +""" + code_info(f::Function, tt::Type{T}; generated = true, debuginfo = :default) where T <: Tuple + code_info(f::Function, t::Type...; generated = true, debuginfo = :default) + +Return lowered code for function `f` with tuple type `tt`. Equivalent to `InteractiveUtils.@code_lowered` -- but a function call and requires a tuple type `tt` as input. +""", code_info) + +slot(ind::Int) = Core.SlotNumber(ind) + +function get_slot(ci::CodeInfo, s::Symbol) + ind = findfirst(el -> el == s, ci.slotnames) + ind === nothing && return + return slot(ind) +end + +@doc( +""" + get_slot(ci::CodeInfo, s::Symbol) + +Get the `Core.Compiler.SlotNumber` associated with the `s::Symbol` in `ci::CodeInfo`. If there is no associated `Core.Compiler.SlotNumber`, returns `nothing`. +""", get_slot) + +walk(fn, x, guard) = fn(x) +walk(fn, x::Variable, guard) = fn(x) +walk(fn, x::Core.SlotNumber, guard) = fn(x) +walk(fn, x::Core.NewvarNode, guard) = Core.NewvarNode(walk(fn, x.slot, guard)) +walk(fn, x::Core.ReturnNode, guard) = Core.ReturnNode(walk(fn, x.val, guard)) +walk(fn, x::Core.GotoNode, guard) = Core.GotoNode(walk(fn, x.label, guard)) +walk(fn, x::Core.GotoIfNot, guard) = Core.GotoIfNot(walk(fn, x.cond, guard), walk(fn, x.dest, guard)) +walk(fn, x::Expr, guard) = Expr(x.head, map(a -> walk(fn, a, guard), x.args)...) +function walk(fn, x::Vector, guard) + map(x) do el + walk(fn, el, guard) + end +end +walk(fn, x) = walk(fn, x, Val(:no_catch)) + +@doc( +""" + walk(fn::Function, x) + +A generic dispatch-based tree-walker which applies `fn::Function` to `x`, specialized to `Code` node types (like `Core.ReturnNode`, `Core.GotoNode`, `Core.GotoIfNot`, etc). Applies `fn::Function` to sub-fields of nodes, and then zips the result back up into the node. +""", walk) + +resolve(x) = x +resolve(gr::GlobalRef) = getproperty(gr.mod, gr.name) + +##### +##### Canvas +##### + +struct Statement{T} + node::T + type::Any +end +Statement(node::T) where T = Statement(node, Union{}) +unwrap(stmt::Statement) = stmt.node +walk(fn, stmt::Statement{T}, guard) where T = Statement(walk(fn, stmt.node, guard), stmt.type) + +const stmt = Statement + +@doc( +""" + struct Statement{T} + node::T + type::Any + end + +A wrapper around `Core` nodes with an optional `type` field to allow for user-based local propagation and other forms of analysis. Usage of [`Builder`](@ref) or [`Canvas`](@ref) will automatically wrap or unwrap nodes when inserting or calling [`finish`](@ref) -- so the user should never see `Statement` instances directly unless they are working on type propagation. + +For more information on `Core` nodes, please see Julia's documentation on [lowered forms](https://docs.julialang.org/en/v1/devdocs/ast/#Lowered-form). +""", Statement) + +struct Canvas + defs::Vector{Tuple{Int, Int}} + code::Vector{Any} + codelocs::Vector{Int32} + ssaflags::Vector{UInt32} +end +Canvas() = Canvas(Tuple{Int, Int}[], [], Int32[], UInt32[]) + +Base.isempty(canv::Canvas) = Base.isempty(canv.defs) + +@doc( +""" +```julia +struct Canvas + defs::Vector{Tuple{Int, Int}} + code::Vector{Any} + codelocs::Vector{Int32} +end +Canvas() = Canvas(Tuple{Int, Int}[], [], Int32[]) +``` + +A `Vector`-like abstraction for `Core` code nodes. + +Properties to keep in mind: + +1. Insertion anywhere is slow. +2. Pushing to beginning is slow. +2. Pushing to end is fast. +3. Deletion is fast. +4. Accessing elements is fast. +5. Setting elements is fast. + +Thus, if you build up a `Canvas` instance incrementally, everything should be fast. +""", Canvas) + +length(c::Canvas) = length(filter(x -> x[2] > 0, c.defs)) + +function getindex(c::Canvas, idx::Int) + r, ind = c.defs[idx] + @assert ind > 0 + getindex(c.code, r) +end +getindex(c::Canvas, v::Variable) = getindex(c, v.id) + +function push!(c::Canvas, stmt::Statement) + push!(c.code, stmt) + push!(c.codelocs, Int32(1)) + push!(c.ssaflags, UInt32(0)) + l = length(c.defs) + 1 + push!(c.defs, (l, l)) + return Variable(length(c.defs)) +end + +function push!(c::Canvas, node) + push!(c.code, Statement(node)) + push!(c.codelocs, Int32(1)) + push!(c.ssaflags, UInt32(0)) + l = length(c.defs) + 1 + push!(c.defs, (l, l)) + return Variable(length(c.defs)) +end + +function insert!(c::Canvas, idx::Int, x::Statement) + r, ind = c.defs[idx] + @assert(ind > 0) + push!(c.code, x) + push!(c.codelocs, Int32(1)) + push!(c.ssaflags, UInt32(0)) + for i in 1 : length(c.defs) + r, k = c.defs[i] + if k > 0 && k >= ind + c.defs[i] = (r, k + 1) + end + end + push!(c.defs, (length(c.defs) + 1, ind)) + return Variable(length(c.defs)) +end + +function insert!(c::Canvas, idx::Int, x) + r, ind = c.defs[idx] + @assert(ind > 0) + push!(c.code, Statement(x)) + push!(c.codelocs, Int32(1)) + for i in 1 : length(c.defs) + r, k = c.defs[i] + if k > 0 && k >= ind + c.defs[i] = (r, k + 1) + end + end + push!(c.defs, (length(c.defs) + 1, ind)) + return Variable(length(c.defs)) +end +insert!(c::Canvas, v::Variable, x) = insert!(c, v.id, x) + +pushfirst!(c::Canvas, x) = isempty(c.defs) ? push!(c, x) : insert!(c, 1, x) + +setindex!(c::Canvas, x::Statement, v::Int) = setindex!(c.code, x, v) +setindex!(c::Canvas, x, v::Int) = setindex!(c, Statement(x), v) +setindex!(c::Canvas, x, v::Variable) = setindex!(c, x, v.id) + +function delete!(c::Canvas, idx::Int) + c.code[idx] = nothing + c.defs[idx] = (idx, -1) + return nothing +end +delete!(c::Canvas, v::Variable) = delete!(c, v.id) + +_get(d::Dict, c, k) = c +_get(d::Dict, c::Variable, k) = haskey(d, c.id) ? Variable(getindex(d, c.id)) : nothing +function _get(d::Dict, c::Core.GotoIfNot, k) + v = c.dest + if haskey(d, v) + nv = getindex(d, v) + else + nv = findfirst(l -> l > v, d) + if nv === nothing + nv = maximum(d)[1] + end + nv = getindex(d, nv) + end + c = _get(d, c.cond, c.cond) + return Core.GotoIfNot(c, nv) +end +function _get(d::Dict, c::Core.GotoNode, k) + v = c.label + if haskey(d, v) + nv = getindex(d, v) + else + nv = findfirst(l -> l > v, d) + if nv === nothing + nv = maximum(d)[1] + end + nv = getindex(d, nv) + end + return Core.GotoNode(nv) +end + +# Override for renumber. +walk(fn, c::Core.GotoIfNot, ::Val{:catch_jumps}) = fn(c) +walk(fn, c::Core.GotoNode, ::Val{:catch_jumps}) = fn(c) + +function renumber(c::Canvas) + s = sort(filter(v -> v[2] > 0, c.defs); by = x -> x[2]) + d = Dict((s[i][1], i) for i in 1 : length(s)) + ind = first.(s) + swap = walk(k -> _get(d, k, k), c.code, Val(:catch_jumps)) + return Canvas(Tuple{Int, Int}[(i, i) for i in 1 : length(s)], + getindex(swap, ind), getindex(c.codelocs, ind), getindex(c.ssaflags, ind)) +end + +##### +##### Pretty printing +##### + +print_stmt(io::IO, ex) = print(io, ex) +print_stmt(io::IO, ex::Expr) = print_stmt(io::IO, Val(ex.head), ex) + +const tab = " " + +function show(io::IO, c::Canvas) + indent = get(io, :indent, 0) + bs = get(io, :bindings, Dict()) + for (r, ind) in sort(c.defs; by = x -> x[2]) + ind > 0 || continue + println(io) + print(io, tab^indent, " ") + print(io, string("%", r), " = ") + ex = get(c.code, r, nothing) + ex == nothing ? print(io, "nothing") : print_stmt(io, unwrap(ex)) + if unwrap(ex) isa Expr + ex.type !== Union{} && print(io, "::$(ex.type)") + end + end +end + +print_stmt(io::IO, ::Val, ex) = print(io, ex) + +function print_stmt(io::IO, ::Val{:enter}, ex) + print(io, "try (outer %$(ex.args[1]))") +end + +function print_stmt(io::IO, ::Val{:leave}, ex) + print(io, "end try (start %$(ex.args[1]))") +end + +function print_stmt(io::IO, ::Val{:pop_exception}, ex) + print(io, "pop exception $(ex.args[1])") +end + +##### +##### Builder +##### + +struct NewVariable + id::Int +end + +mutable struct Builder + from::CodeInfo + to::Canvas + map::Dict{Any, Any} + slots::Vector{Symbol} + var::Int +end + +function Builder(ci::CodeInfo) + canv = Canvas() + p = Builder(ci, canv, Dict(), Symbol[], 0) + return p +end + +function Builder(fn::Function, t::Type...) + src = code_info(fn, t...) + return Builder(src) +end + +function Builder() + dummy = () -> return + return Builder(dummy) +end + +@doc( +""" + Builder(ci::Core.CodeInfo) + Builder(fn::Function, t::Type...) + Builder() + +A wrapper around a [`Canvas`](@ref) instance. Call [`finish`](@ref) when done to produce a new `CodeInfo` instance. +""", Builder) + +function get_slot(b::Builder, s::Symbol) + s = get_slot(b.from, s) + s === nothing || return s + ind = findfirst(k -> k == s, b.slots) + return ind === nothing ? s : slot(ind) +end + +# This is used to handle NewVariable instances. +substitute!(b::Builder, x, y) = (b.map[x] = y; x) +substitute(b::Builder, x) = get(b.map, x, x) +substitute(b::Builder, x::Expr) = Expr(x.head, substitute.((b, ), x.args)...) +substitute(b::Builder, x::Core.GotoNode) = Core.GotoNode(substitute(b, x.label)) +substitute(b::Builder, x::Core.GotoIfNot) = Core.GotoIfNot(substitute(b, x.cond), substitute(b, x.dest)) +substitute(b::Builder, x::Core.ReturnNode) = Core.ReturnNode(substitute(b, x.val)) + +length(b::Builder) = length(b.to) + +getindex(b::Builder, v) = getindex(b.to, v) +function getindex(b::Builder, v::Union{Variable, NewVariable}) + tg = substitute(b, v) + return getindex(b.to, tg) +end + +lastindex(b::Builder) = length(b.to) + +function pipestate(ci::CodeInfo) + ks = sort([Variable(i) => v for (i, v) in enumerate(ci.code)], by = x -> x[1].id) + return first.(ks) +end + +function iterate(b::Builder, (ks, i) = (pipestate(b.from), 1)) + i > length(ks) && return + v = ks[i] + st = walk(resolve, b.from.code[v.id]) + substitute!(b, v, push!(b.to, substitute(b, st))) + return ((v, st), (ks, i + 1)) +end + +@doc( +""" + iterate(b::Builder, (ks, i) = (pipestate(p.from), 1)) + +Iterate over the original `CodeInfo` and add statements to a target [`Canvas`](@ref) held by `b::Builder`. `iterate` builds the [`Canvas`](@ref) in place -- it also resolves local `GlobalRef` instances to their global values in-place at the function argument (the 1st argument) of `Expr(:call, ...)` instances. `iterate` is the key to expressing idioms like: + +```julia +for (v, st) in b + b[v] = swap(st) +end +``` + +At each step of the iteration, a new node is copied from the original `CodeInfo` to the target [`Canvas`](@ref) -- and the user is allowed to `setindex!`, `push!`, or otherwise change the target [`Canvas`](@ref) before the next iteration. The naming of `Core.SSAValues` is taken care of to allow this. +""", iterate) + +var!(b::Builder) = NewVariable(b.var += 1) + +function Base.push!(b::Builder, x) + tmp = var!(b) + v = push!(b.to, substitute(b, x)) + substitute!(b, tmp, v) + return tmp +end + +function Base.pushfirst!(b::Builder, x) + tmp = var!(b) + v = pushfirst!(b.to, substitute(b, x)) + substitute!(b, tmp, v) + return tmp +end + +function setindex!(b::Builder, x, v::Union{Variable, NewVariable}) + k = substitute(b, v) + setindex!(b.to, substitute(b, x), k) +end + +function insert!(b::Builder, v::Union{Variable, NewVariable}, x; after = false) + v′ = substitute(b, v).id + x = substitute(b, x) + tmp = var!(b) + substitute!(b, tmp, insert!(b.to, v′ + after, x)) + return tmp +end + +function Base.delete!(b::Builder, v::Union{Variable, NewVariable}) + v′ = substitute(b, v) + substitute!(b, v′, delete!(b.to, v′)) +end + +function slot!(b::Builder, name::Symbol; arg = false) + @assert(get_slot(b, name) === nothing) + push!(b.slots, name) + ind = length(b.from.slotnames) + length(b.slots) + s = slot(ind) + arg || pushfirst!(b, Core.NewvarNode(s)) + return s +end + +@doc( +""" + slot!(b::Builder, name::Symbol; arg = false)::Core.SlotNumber + +Add a new `Core.SlotNumber` with associated `name::Symbol` to the in-progress `Core.CodeInfo` on the `c::Canvas` inside `b::Builder`. If `arg == false`, also performs a `pushfirst!` with a `Core.NewvarNode` for consistency in the in-progress `Core.CodeInfo`. (`arg` controls whether or not we interpreter the new slot as an argument) + +`name::Symbol` must not already be associated with a `Core.SlotNumber`. +""", slot!) + +return!(b::Builder, v) = push!(b, Core.ReturnNode(v)) +return!(b::Builder, v::Variable) = push!(b, Core.ReturnNode(v)) +return!(b::Builder, v::NewVariable) = push!(b, Core.ReturnNode(v)) + +@doc( +""" + return!(b::Builder, v::Variable) + return!(b::Builder, v::NewVariable) + +Push a `Core.ReturnNode` to the current end of `b.to::Canvas`. Requires that the user pass in a `v::Variable` or `v::NewVariable` instance -- so perform the correct unpack/tupling before creating a `Core.ReturnNode`. +""", return!) + +function verify(src::Core.CodeInfo) + Core.Compiler.validate_code(src) + @assert(!isempty(src.linetable)) +end + +@doc( +""" + verify(src::Core.CodeInfo) + +Validate `Core.CodeInfo` instances using `Core.Compiler.verify`. Also explicitly checks that the linetable in `src::Core.CodeInfo` is not empty. +""", verify) + +function check_empty_canvas(b::Builder) + isempty(b.to) && error("Builder has empty `c::Canvas` instance. This means you haven't added anything, or you've accidentally wiped the :defs subfield of `c::Canvas`.") +end + +function finish(b::Builder; validate = true) + check_empty_canvas(b) + new_ci = copy(b.from) + c = renumber(b.to) + new_ci.code = map(unwrap, c.code) + new_ci.codelocs = c.codelocs + new_ci.ssaflags = c.ssaflags + new_ci.slotnames = copy(b.from.slotnames) + append!(new_ci.slotnames, b.slots) + new_ci.slotflags = copy(b.from.slotflags) + append!(new_ci.slotflags, [0x18 for _ in b.slots]) + new_ci.inferred = false + new_ci.inlineable = b.from.inlineable + new_ci.ssavaluetypes = length(b.to) + validate && verify(new_ci) + return new_ci +end + +@doc( +""" + finish(b::Builder) + +Create a new `CodeInfo` instance from a [`Builder`](@ref). Renumbers the wrapped [`Canvas`](@ref) in-place -- then copies information from the original `CodeInfo` instance and inserts modifications from the wrapped [`Canvas`](@ref) +""", finish) + +function Base.show(io::IO, b::Builder) + print("1: $((b.from.slotnames..., b.slots...))") + Base.show(io, b.to) +end + +function Base.identity(b::Builder) + for (v, st) in b + end + return b +end + +##### +##### Inference +##### + +# Experimental interfaces which exposes several **stateful** parts of Core.Compiler. +# If you're using this stuff, you should really know what you're doing. + +function code_inferred(mi::Core.Compiler.MethodInstance; + world=Base.get_world_counter(), + interp=Core.Compiler.NativeInterpreter(world)) + ccall(:jl_typeinf_begin, Cvoid, ()) + result = Core.Compiler.InferenceResult(mi) + src = Core.Compiler.retrieve_code_info(mi) + src === nothing && return nothing + src.inferred && return src + Core.Compiler.validate_code_in_debug_mode(result.linfo, + src, "lowered") + frame = @static if VERSION < v"1.8.0-DEV.472" + Core.Compiler.InferenceState(result, src, false, interp) + else + Core.Compiler.InferenceState(result, src, :no, interp) + end + frame === nothing && return nothing + if Core.Compiler.typeinf(interp, frame) + opt_params = Core.Compiler.OptimizationParams(interp) + opt = Core.Compiler.OptimizationState(frame, opt_params, interp) + Core.Compiler.optimize(interp, opt, opt_params, result) + end + ccall(:jl_typeinf_end, Cvoid, ()) + frame.inferred || return nothing + return src +end + +function code_inferred(@nospecialize(f), types::Type{T}; + world=Base.get_world_counter(), + interp=Core.Compiler.NativeInterpreter(world)) where T <: Tuple + return pop!([code_inferred(mi; world=world, interp=interp) + for mi in Base.method_instances(f, types, world)]) +end + +function code_inferred(@nospecialize(f), t::Type...; + world = Base.get_world_counter(), + interp = Core.Compiler.NativeInterpreter(world)) + return code_inferred(f, Tuple{t...}; + world = world, interp = interp) +end + +@doc( +""" + code_inferred(@nospecialize(f), t::Type...; + world = Base.get_world_counter(), + interp = Core.Compiler.NativeInterpreter(world)) + +Derives a `Core.MethodInstance` specialization for signature `Tuple{typeof(f), t::Type...}` and infers it with `interp`. Can be used to derive inferred lowered code with custom interpreters, either as parts of custom compilation pipelines or for debugging purposes. + +`code_inferred` includes explicit checks which prevent the user from inadvertedly running inference multiple times on the same cached `Core.CodeInfo` associated with the specialization. + +!!! warning + Inference and optimization are stateful -- if you try to do "dumb" things like grab the inferred `Core.CodeInfo`, wipe it, and shove it through [`lambda`](@ref) ... it is highly unlikely to work and very likely to explode in your face. + + Inference also caches the inferred `Core.CodeInfo` associated with the `Core.MethodInstance` specialization _irrespective of the interpreter_. That means (at least as far as I know at this time) you can't quickly infer with multiple interpreters without forcing a cache invalidation in between inference runs. +""", code_inferred) + +##### +##### Evaluation +##### + +function lambda(m::Module, src::Core.CodeInfo) + ci = copy(src) + verify(ci) + inds = findall(==(0x00), src.slotflags) + @assert(inds !== nothing) + args = getindex(src.slotnames, inds)[2 : end] + @eval m @generated function $(gensym())($(args...)) + return $ci + end +end + +function lambda(m::Module, src::Core.CodeInfo, nargs::Int) + ci = copy(src) + verify(ci) + @debug "Warning: using explicit `nargs` to construct the generated function. If this number does not match the correct number of arguments in the :slotflags field of `src::Core.CodeInfo`, this can lead to segfaults and other bad behavior." + args = src.slotnames[2 : 1 + nargs] + @eval m @generated function $(gensym())($(args...)) + return $ci + end +end + +lambda(src::Core.CodeInfo) = lambda(Main, src) +lambda(src::Core.CodeInfo, nargs::Int) = lambda(Main, src, nargs) + +const λ = lambda + +@doc( +""" +!!! warning + It is relatively difficult to prevent the user from shooting themselves in the foot with this sort of functionality. Please be aware of this. Segfaults should be cautiously expected. + +```julia +lambda(m::Module, src::Core.CodeInfo) +lambda(m::Module, src::Core.CodeInfo, nargs::Int) +const λ = lambda +``` + +Create an anonymous `@generated` function from a piece of `src::Core.CodeInfo`. The `src::Core.CodeInfo` is checked for consistency by [`verify`](@ref). + +`lambda` has a 2 different forms. The first form, given by signature: + +```julia +lambda(m::Module, src::Core.CodeInfo) +``` + +tries to detect the correct number of arguments automatically. This may fail (for any number of internal reasons). Expecting this, the second form, given by signature: + +```julia +lambda(m::Module, src::Core.CodeInfo, nargs::Int) +``` + +allows the user to specify the number of arguments via `nargs`. + +`lambda` also has the shorthand `λ` for those lovers of Unicode. +""", lambda) + +end # module \ No newline at end of file diff --git a/src/Generate/CodegenContext.jl b/src/Generate/CodegenContext.jl new file mode 100644 index 00000000..31392406 --- /dev/null +++ b/src/Generate/CodegenContext.jl @@ -0,0 +1,73 @@ +abstract type AbstractCodegenContext end + +for method in ( + :generate_return, + :generate_goto, + :generate_gotoifnot, + :generate_function, + :name, + :generate_invoke, + :aggregate_funcs +) + @eval begin + $method(cg::T, args...; kwargs...) where {T<:AbstractCodegenContext} = error("$method not implemented for type \$T") + end +end + +mutable struct CodegenContext{T} <: AbstractCodegenContext + CodegenContext{T}() where T = new{T}() + + function (cg::CodegenContext)(f, types) + mod = IR.Module() + toplevel, methods = collect_methods(f, types) + funcs = [] + + captures = collect_captures(f) + mlir_func = generate!(cg, toplevel.ir, toplevel.ret; mi=toplevel.mi, captures) + push!(funcs, mlir_func) + + for (mi, (ir, ret)) in methods + mlir_func = generate!(cg, ir, ret; mi) + push!(funcs, mlir_func) + end + return aggregate_funcs(cg, funcs) + end +end + +abstract type Default end +CodegenContext() = CodegenContext{Default}() + +generate_return(cg::CodegenContext, values; location) = Dialects.func.return_(values; location) +generate_goto(cg::CodegenContext, args, dest; location) = Dialects.cf.br(args; dest, location) +generate_gotoifnot(cg::CodegenContext, cond; + true_args, false_args, true_dest, false_dest, location + ) = Dialects.cf.cond_br( + cond, true_args, false_args; + trueDest=true_dest, falseDest=false_dest, location + ) +generate_function(cg::CodegenContext{T}, types::Pair, reg::IR.Region; kwargs...) where {T} = generate_function(cg, types.first, types.second, reg; kwargs...) +function generate_function(cg::CodegenContext, argtypes, rettypes, reg; name="f") + function_type = IR.FunctionType(argtypes, rettypes) + op = Dialects.func.func_(; + sym_name=string(name), + sym_visibility="private", + function_type, + body=reg, + ) + return op +end +function name(cg::CodegenContext, mi::MethodInstance) + return "$(mi.specTypes)_$(mi.def.module)_$(mi.def.primary_world)" +end +function generate_invoke(cg::CodegenContext, fname::String, ret, args) + op = Dialects.func.call(args; result_0=IR.Type[IR.Type(ret)], callee=IR.FlatSymbolRefAttribute(fname)) + return ret(IR.result(op)) +end +function aggregate_funcs(cg::CodegenContext, funcs) + mod = IR.Module() + bod = IR.body(mod) + for func in funcs + push!(bod, func) + end + return mod +end \ No newline at end of file diff --git a/src/Generate/Generate.jl b/src/Generate/Generate.jl new file mode 100644 index 00000000..f456b733 --- /dev/null +++ b/src/Generate/Generate.jl @@ -0,0 +1,13 @@ +include("CodeInfoTools.jl") + +module Generate + +using ..IR +import ..Dialects + +include("intrinsic.jl") +include("absint.jl") +include("transform.jl") +include("CodegenContext.jl") + +end \ No newline at end of file diff --git a/src/Generate/absint.jl b/src/Generate/absint.jl new file mode 100644 index 00000000..a8a6fd80 --- /dev/null +++ b/src/Generate/absint.jl @@ -0,0 +1,224 @@ +using Core: MethodInstance, CodeInstance, OpaqueClosure +const CC = Core.Compiler +using ..CodeInfoTools + +## custom interpreter + +struct MLIRInterpreter <: CC.AbstractInterpreter + cache_token::Symbol + world::UInt + inf_params::CC.InferenceParams + opt_params::CC.OptimizationParams + inf_cache::Vector{CC.InferenceResult} + + active::Bool # when set to false, inlining_policy is not changed. + + function _MLIRInterpreter() + return new( + cache_token, + Base.get_world_counter(), + CC.InferenceParams(; aggressive_constant_propagation=true), + CC.OptimizationParams(), + CC.InferenceResult[], + true + ) + end + + function MLIRInterpreter(interp::MLIRInterpreter=_MLIRInterpreter(); + cache_token::Symbol = interp.cache_token, + world::UInt = interp.world, + inf_params::CC.InferenceParams = interp.inf_params, + opt_params::CC.OptimizationParams = interp.opt_params, + inf_cache::Vector{CC.InferenceResult} = interp.inf_cache, + active::Bool = interp.active) + @assert world <= Base.get_world_counter() + + return new(cache_token, world, + inf_params, opt_params, + inf_cache, active) + end +end + + + + +cache_token = gensym(:MLIRInterpreterCache) +function reset_cache!() + @debug "Resetting cache" + + global cache_token + cache_token = gensym(:MLIRInterpreterCache) +end + +CC.InferenceParams(interp::MLIRInterpreter) = interp.inf_params +CC.OptimizationParams(interp::MLIRInterpreter) = interp.opt_params +CC.get_inference_cache(interp::MLIRInterpreter) = interp.inf_cache +CC.get_inference_world(interp::MLIRInterpreter) = interp.world +CC.cache_owner(interp::MLIRInterpreter) = interp.cache_token + +# # No need to do any locking since we're not putting our results into the runtime cache +CC.lock_mi_inference(interp::MLIRInterpreter, mi::MethodInstance) = nothing +CC.unlock_mi_inference(interp::MLIRInterpreter, mi::MethodInstance) = nothing + +function CC.add_remark!(interp::MLIRInterpreter, sv::CC.InferenceState, msg) + @debug "Inference remark during compilation of MethodInstance of $(sv.linfo): $msg" +end + +CC.may_optimize(interp::MLIRInterpreter) = true +CC.may_compress(interp::MLIRInterpreter) = true +CC.may_discard_trees(interp::MLIRInterpreter) = true +CC.verbose_stmt_info(interp::MLIRInterpreter) = false + +struct MLIRIntrinsicCallInfo <: CC.CallInfo + info::CC.CallInfo + MLIRIntrinsicCallInfo(@nospecialize(info::CC.CallInfo)) = new(info) +end +CC.nsplit_impl(info::MLIRIntrinsicCallInfo) = CC.nsplit(info.info) +CC.getsplit_impl(info::MLIRIntrinsicCallInfo, idx::Int) = CC.getsplit(info.info, idx) +CC.getresult_impl(info::MLIRIntrinsicCallInfo, idx::Int) = CC.getresult(info.info, idx) + + +function CC.abstract_call_gf_by_type(interp::MLIRInterpreter, @nospecialize(f), arginfo::CC.ArgInfo, si::CC.StmtInfo, @nospecialize(atype), + sv::CC.AbsIntState, max_methods::Int) + + if interp.active && is_intrinsic(atype) + interp′ = MLIRInterpreter(interp; active=false) + else + interp′ = interp + end + + cm = @invoke CC.abstract_call_gf_by_type(interp′::CC.AbstractInterpreter, f::Any, + arginfo::CC.ArgInfo, si::CC.StmtInfo, atype::Any, sv::CC.AbsIntState, max_methods::Int) + + if interp.active && is_intrinsic(atype) + return CC.CallMeta(cm.rt, cm.exct, cm.effects, MLIRIntrinsicCallInfo(cm.info)) + else + return cm + end +end + + +""" + _typeof(x) + +Central definition of typeof, which is specific to the use-required in this package. +""" +_typeof(x) = Base._stable_typeof(x) +_typeof(x::Tuple) = Tuple{map(_typeof, x)...} +_typeof(x::NamedTuple{names}) where {names} = NamedTuple{names, _typeof(Tuple(x))} + +_type(x) = x +_type(x::CC.Const) = _typeof(x.val) +_type(x::CC.PartialStruct) = _type(x.typ) +_type(x::CC.Conditional) = Union{_type(x.thentype), _type(x.elsetype)} + +function CC.inlining_policy(interp::MLIRInterpreter, + @nospecialize(src), @nospecialize(info::CC.CallInfo), stmt_flag::UInt32) + if (!interp.active) || !isa(info, MLIRIntrinsicCallInfo) + return @invoke CC.inlining_policy( + interp::CC.AbstractInterpreter, + src::Any, + info::CC.CallInfo, + stmt_flag::UInt32, + ) + else + return nothing + end +end + + +## utils + +# create a MethodError from a function type +# TODO: fix upstream +function unsafe_function_from_type(ft::Type) + if isdefined(ft, :instance) + ft.instance + else + # HACK: dealing with a closure or something... let's do somthing really invalid, + # which works because MethodError doesn't actually use the function + Ref{ft}()[] + end +end +function MethodError(ft::Type{<:Function}, tt::Type, world::Integer=typemax(UInt)) + Base.MethodError(unsafe_function_from_type(ft), tt, world) +end +MethodError(ft, tt, world=typemax(UInt)) = Base.MethodError(ft, tt, world) + +import Core.Compiler: retrieve_code_info, maybe_validate_code, InferenceState, InferenceResult +# Replace usage sites of `retrieve_code_info`, OptimizationState is one such, but in all interesting use-cases +# it is derived from an InferenceState. There is a third one in `typeinf_ext` in case the module forbids inference. +function InferenceState(result::InferenceResult, cache_mode::UInt8, interp::MLIRInterpreter) + src = retrieve_code_info(result.linfo, interp.world) + src === nothing && return nothing + maybe_validate_code(result.linfo, src, "lowered") + if (interp.active) + src = transform(interp, result.linfo, src) + maybe_validate_code(result.linfo, src, "transformed") + end + return InferenceState(result, src, cache_mode, interp) +end + +""" +Datastructure to keep track of how value numbers need to be updated after insertions. +""" +struct DestinationOffsets + indices::Vector{Int} + DestinationOffsets() = new([]) +end +function Base.insert!(d::DestinationOffsets, insertion::Int) + candidateindex = d[insertion]+1 + if (length(d.indices) == 0) + push!(d.indices, insertion) + elseif candidateindex == length(d.indices)+1 + push!(d.indices, insertion) + elseif (candidateindex == 1) || (d.indices[candidateindex-1] != insertion) + insert!(d.indices, candidateindex, insertion) + end + return d +end +Base.getindex(d::DestinationOffsets, i::Int) = searchsortedlast(d.indices, i, lt= <=) + +function insert_bool_conversions_pass(mi, src) + offsets = DestinationOffsets() + + b = CodeInfoTools.Builder(src) + for (v, st) in b + if st isa Core.GotoIfNot + arg = st.cond isa Core.SSAValue ? var(st.cond.id + offsets[st.cond.id]) : st.cond + b[v] = Statement(Expr(:call, GlobalRef(@__MODULE__, :mlir_bool_conversion), arg)) + push!(b, Core.GotoIfNot(v, st.dest)) + insert!(offsets, v.id) + elseif st isa Core.GotoNode + b[v] = st + end + end + + # fix destinations and conditions + for i in 1:length(b.to) + st = b.to[i].node + if st isa Core.GotoNode + b.to[i] = Core.GotoNode(st.label + offsets[st.label]) + elseif st isa Core.GotoIfNot + b.to[i] = Statement(Core.GotoIfNot(st.cond, st.dest + offsets[st.dest])) + end + end + finish(b) +end + +function transform(interp, mi, src) + src = insert_bool_conversions_pass(mi, src) + return src +end + +abstract type BoolTrait end +struct NonBoollike <: BoolTrait end +struct Boollike <: BoolTrait end +BoolTrait(T) = NonBoollike() + +@inline mlir_bool_conversion(x::Bool) = x +@inline mlir_bool_conversion(x::T) where T = mlir_bool_conversion(BoolTrait(T), x) + +@inline mlir_bool_conversion(::Boollike, x)::Bool = bool_conversion_intrinsic(x) +@intrinsic bool_conversion_intrinsic(x)::Bool = Base.inferencebarrier(nothing)::Bool +@intrinsic mlir_bool_conversion(::NonBoollike, x::T) where T = error("Type $T is not marked as Boollike.") diff --git a/src/Generate/intrinsic.jl b/src/Generate/intrinsic.jl new file mode 100644 index 00000000..b6401259 --- /dev/null +++ b/src/Generate/intrinsic.jl @@ -0,0 +1,35 @@ +import MacroTools: splitdef + +is_intrinsic(::Any) = false + +macro is_intrinsic(sig) + return esc(:($(@__MODULE__).is_intrinsic(::Type{<:$sig}) = true)) +end + +function intrinsic_(expr) + dict = splitdef(expr) + # TODO: this can probably be fixed: + length(dict[:kwargs]) == 0 || error("Intrinsic functions can't have keyword arguments\nDefine a regular function with kwargs that calls the intrinsic instead.") + argtypes = map(dict[:args]) do arg + if arg isa Symbol + return :Any + elseif arg.head == :(::) + return arg.args[end] + else + error("Don't know how to handle argument type $arg") + end + end + + return quote + $(reset_cache!)() + $(esc(expr)) + $(@__MODULE__).is_intrinsic(::Type{<:Tuple{$(_typeof)($(esc(dict[:name]))), $(esc.(argtypes)...)}}) where {$(esc.(dict[:whereparams])...)} = true + end +end + +macro intrinsic(f) + f = macroexpand(__module__, f) + Base.is_function_def(f) || error("@intrinsic requires a function definition") + intrinsic_(f) +end + diff --git a/src/Generate/transform.jl b/src/Generate/transform.jl new file mode 100644 index 00000000..0aab2bac --- /dev/null +++ b/src/Generate/transform.jl @@ -0,0 +1,443 @@ +# partially based on: https://gist.github.com/oxinabox/cdcffc1392f91a2f6d80b2524726d802 + +const CC = Core.Compiler + +function handle_goto(cg, dest, args) + generate_goto(cg, args, dest; location=IR.Location()) +end +function handle_gotoifnot(cg, cond, true_dest, false_dest, true_args, false_args) + generate_gotoifnot(cg, cond; true_args, false_args, true_dest, false_dest, location=IR.Location()) +end +function handle_gotoifnot(cg, cond::Bool, true_dest, false_dest, true_args, false_args) + if cond + handle_goto(cg, true_dest, true_args) + else + handle_goto(cg, false_dest, false_args) + end +end +function handle_phi(cg, T, i) + T(IR.argument(IR.currentblock[], i)) # TODO: flimsy conversion from IR.Value to T. only works if T's constructor can handle this. +end +function handle_return(cg, val::T) where T + if isnothing(val) + returnvalues = [] + else + returnvalues = Base._reinterpret(Tuple{IR.unpack(T)...}, val) + end + generate_return(cg, returnvalues; location=IR.Location()) +end +function handle_invoke(cg, fname, ret, args...) + if ret == Union{} + # Code contains an error, we execute the function for the error to occur. + args[1](args[2:end]...) + error("This error should never be reached.") + end + + if first(args) isa Core.Const + args[begin] = args[begin].val + end + unpacked = [] + for arg in args + push!(unpacked, Base._reinterpret(Tuple{IR.unpack(typeof(arg))...}, arg)...) + end + generate_invoke(cg, fname, ret, unpacked) +end + + +#Helpers: +"Given some IR generates a MethodInstance suitable for passing to infer_ir!, if you don't already have one with the right argument types" +function get_toplevel_mi_from_ir(ir, _module::Module) + mi = ccall(:jl_new_method_instance_uninit, Ref{Core.MethodInstance}, ()); + argtypes = [] + for argtype in ir.argtypes + if argtype isa Core.Const + push!(argtypes, argtype.val) + else + push!(argtypes, argtype) + end + end + mi.specTypes = Tuple{argtypes...} + mi.def = _module + return mi +end + +"run type inference and constant propagation on the ir" +function infer_ir!(ir, interp::CC.AbstractInterpreter, mi::CC.MethodInstance) + method_info = CC.MethodInfo(#=propagate_inbounds=#true, nothing) + min_world = world = CC.get_world_counter() + max_world = Base.get_world_counter() + irsv = CC.IRInterpretationState(interp, method_info, ir, mi, ir.argtypes, world, min_world, max_world) + ret = CC._ir_abstract_constant_propagation(interp, irsv) + return ir +end + + +# add overloads from Core.Compiler into Base +# Diffractor has a bunch of these, we need to make a library for them +# https://github.com/JuliaDiff/Diffractor.jl/blob/b23337a4b12d21104ff237cf0c72bcd2fe13a4f6/src/stage1/hacks.jl +# https://github.com/JuliaDiff/Diffractor.jl/blob/b23337a4b12d21104ff237cf0c72bcd2fe13a4f6/src/stage1/recurse.jl#L238-L247 +# https://github.com/JuliaDiff/Diffractor.jl/blob/b23337a4b12d21104ff237cf0c72bcd2fe13a4f6/src/stage1/compiler_utils.jl + +Base.iterate(compact::CC.IncrementalCompact, state) = CC.iterate(compact, state) +Base.iterate(compact::CC.IncrementalCompact) = CC.iterate(compact) +Base.getindex(c::CC.IncrementalCompact, args...) = CC.getindex(c, args...) +Base.setindex!(c::CC.IncrementalCompact, args...) = CC.setindex!(c, args...) +Base.setindex!(i::CC.Instruction, args...) = CC.setindex!(i, args...) + +function collect_phi_nodes(ir) + phi_nodes = [Core.PhiNode[] for _ in ir.cfg.blocks] + for (i, stmt) in enumerate(ir.stmts) + inst = stmt[:inst] + if inst isa Core.PhiNode + push!( + phi_nodes[CC.block_for_inst(ir.cfg.blocks, i)], + inst) + end + end + return phi_nodes +end + +function get_block_args(phi_nodes, from, to, ssa_rename) + values = [] + for phi in phi_nodes[to] + i = findfirst(isequal(from), phi.edges) + val = isnothing(i) ? nothing : phi.values[i] + if val isa Core.SSAValue + val = ssa_rename[val.id] + end + push!(values, val) + end + return values +end + +""" +Transform the IR that was generated by MLIRInterpeter +and wrap the result in an opaque closure that will generate +the MLIR code and return a `IR.Region` when called. + +# Example + +```julia +cg = ... +blocks = ... +args = ... +ir = first(only(Base.code_ircode(f, types, interp=MLIR.Generate.MLIRInterpreter()))) +builder = create_builder!(ir, blocks, cg) +region = builder(args) +``` + +For a more easy-to-use interface, use methods from `CodegenContext`. +""" +function generate!(cg, ir::CC.IRCode, ret; mi=get_toplevel_mi_from_ir(ir, @__MODULE__), captures=nothing) + original_currentblock = IR.currentblock[] + + reg = IR.Region() + + blocks = [ + prepare_block(ir, bb) + for bb in ir.cfg.blocks + ] + entryblock = first(blocks) + + if isnothing(captures) + # The first argument is the function object itself. In the case where this is a closure, + # we want the captured variables to be included as function arguments in the generated function. + func_arg = first(ir.argtypes) isa Core.Const ? first(ir.argtypes).val : first(ir.argtypes) + captures = if func_arg isa Type + map(IR.unpack(func_arg)) do t + val = IR.push_argument!(entryblock, IR.Type(t)) + end |> Tuple + else + () + end + end + + args = map(enumerate(ir.argtypes[begin+1:end])) do (i, argtype) + temp = map(IR.unpack(argtype)) do t + arg = IR.push_argument!(entryblock, IR.Type(t)) + t(arg) + end + return Base._reinterpret(argtype, Tuple(temp)) + end + + currentblockindex = 0 + function next_block() + currentblockindex += 1 + b = blocks[currentblockindex] + IR.setcurrentblock!(b) + push!(reg, b) + end + + transformed_ir = transform(cg, ir, blocks, next_block) + builder! = Core.OpaqueClosure(transformed_ir, captures...; do_compile=true) + + builder!(args...) + + argtypes = IR.Type[IR.type(IR.argument(entryblock, i)) for i in 1:IR.nargs(entryblock)] + rettypes = IR.Type[IR.Type.(IR.unpack(ret))...] + IR.resetcurrentblock!() + f_mlir = generate_function(cg, argtypes=>rettypes, reg; name=name(cg, mi)) + + IR.setcurrentblock!(original_currentblock) # restore original currentblock (needed for recursion) + + return f_mlir +end +generate(cg, ir::CC.IRCode, ret; mi=get_toplevel_mi_from_ir(ir, @__MODULE__), captures=nothing) = generate!(cg, Core.Compiler.copy(ir), ret; mi, captures) +generate(cg, f, types; captures=getfield.(f, fieldnames(typeof(f)))) = generate!(cg, only(Core.Compiler.code_ircode(f, types, interp=MLIRInterpreter()))...; captures) + + +function get_mi(f, types) + tt = Base.signature_type(f, types) + # Find all methods that are applicable to these types + mthds = Base._methods_by_ftype(tt, -1, Base.get_world_counter()) + if mthds === false || length(mthds) != 1 + error("Unable to find single applicable method for $tt") + end + + mtypes, msp, m = mthds[1] + + # Grab the appropriate method instance for these types + mi = Core.Compiler.specialize_method(m, mtypes, msp) + return mi +end + +function find_invokes(ir) + callees = Core.MethodInstance[] + for stmt in ir.stmts + inst = stmt[:inst] + if Meta.isexpr(inst, :invoke) + callee = inst.args[1] + push!(callees, callee) + end + end + return callees +end + +collect_captures(f) = getfield.(f, fieldnames(typeof(f))) +collect_captures(f::Core.Const) = collect_captures(f.val) + +function collect_methods(f, types) + mi = get_mi(f, types) + ir, ret = only(Core.Compiler.code_ircode_by_type(mi.specTypes, interp=MLIRInterpreter())) + + worklist = Core.Compiler.IRCode[ir] + methods = Dict{Core.MethodInstance, Tuple{Core.Compiler.IRCode, Type}}( + mi => (ir, ret) + ) + while !isempty(worklist) + code = pop!(worklist) + callees = find_invokes(code) + for callee in callees + if !haskey(methods, callee) + if is_intrinsic(callee.specTypes) + # TODO: if an intrinsic does nested code generation, + # invocations that are called within should be captured as well. + nothing + else + ir, ret = only(Core.Compiler.code_ircode_by_type(callee.specTypes, interp=MLIRInterpreter())) + methods[callee] = (ir, ret) + push!(worklist, ir) + end + end + end + end + ir, ret = methods[mi] + toplevel = (; mi, ir, ret) + delete!(methods, mi) # remove the toplevel method from the list of methods to generate + return toplevel, methods +end + + +function transform(cg, ir, blocks, next_block) + # insert calls to next_block at the beginning of each block and add explicit gotos if they are missing. + # first block is handled separately: + CC.insert_node!( + ir, + CC.SSAValue(1), + CC.NewInstruction( + Expr(:call, next_block), + Any, + CC.NoCallInfo(), + Int32(1), + CC.IR_FLAG_REFINED + ) + ) + # remainder of the blocks: + for i in ir.cfg.index + CC.insert_node!( + ir, + i, + CC.NewInstruction( + Expr(:call, next_block), + Any, + CC.NoCallInfo(), + Int32(1), + CC.IR_FLAG_REFINED + ) + ) + if !(ir.stmts[i-1][:inst] isa Union{Core.GotoIfNot, Core.GotoNode, Core.ReturnNode}) + CC.insert_node!( + ir, + CC.SSAValue(i-1), + CC.NewInstruction( + Core.GotoNode(CC.block_for_inst(ir.cfg.blocks, i)), + Any, + CC.NoCallInfo(), + Int32(1), + CC.IR_FLAG_REFINED + ), + true + ) + end + end + + phi_nodes = collect_phi_nodes(ir) + compact = CC.IncrementalCompact(ir, #=allow_cfg_transforms=# true) + + prev_bb = compact.active_bb + current_phi = 1 + + # Core of the transformation: + # replace GotoIfNot, GotoNode, PhiNode, ReturnNode with calls to MLIR generation functions. + for ((original_idx, idx), inst) in compact + ssa = Core.SSAValue(idx) + + if inst isa Union{Core.GotoIfNot, Core.GotoNode, Core.PhiNode, Core.ReturnNode} + if inst isa Core.GotoIfNot + false_dest = inst.dest + true_dest = compact.active_bb + compact[ssa][:inst] = Expr(:call, Core.tuple, get_block_args(phi_nodes, compact.active_bb-1, false_dest, compact.ssa_rename)...) + + false_args = ssa + # when cond is true, branch to next block + true_args = Core.Compiler.insert_node_here!( + compact, + Core.Compiler.NewInstruction( + Expr(:call, Core.tuple, get_block_args(phi_nodes, compact.active_bb-1, true_dest, compact.ssa_rename)...), + Any, + Core.Compiler.NoCallInfo(), + Int32(1), + Core.Compiler.IR_FLAG_REFINED + ), + true + ) + Core.Compiler.insert_node_here!( + compact, + Core.Compiler.NewInstruction( + Expr(:call, handle_gotoifnot, cg, inst.cond, blocks[true_dest], blocks[false_dest], true_args, false_args), + Any, + Core.Compiler.NoCallInfo(), + Int32(1), + Core.Compiler.IR_FLAG_REFINED + ), + true # insert within the current basic block, not at the start of the next one + ) + elseif inst isa Core.GotoNode + compact[ssa][:inst] = Expr(:call, Core.tuple, get_block_args(phi_nodes, compact.active_bb-1, inst.label, compact.ssa_rename)...) + Core.Compiler.insert_node_here!( + compact, + Core.Compiler.NewInstruction( + Expr(:call, handle_goto, cg, blocks[inst.label], ssa), + Any, + Core.Compiler.NoCallInfo(), + Int32(1), + Core.Compiler.IR_FLAG_REFINED + ), + true + ) + elseif inst isa Core.PhiNode + # determine how many phi nodes came before within this block. + if prev_bb == compact.active_bb + current_phi += 1 + else + current_phi = 1 + prev_bb = compact.active_bb + end + + compact[ssa][:inst] = Expr(:call, handle_phi, cg, compact[ssa][:type], current_phi) + elseif inst isa Core.ReturnNode + if isdefined(inst, :val) + compact[ssa][:inst] = Expr(:call, handle_return, cg, inst.val) + else + compact[ssa][:inst] = :nothing + end + end + + # Set general type Any and set flag to allow re-inferring type. + compact[ssa][:type] = Any + compact[ssa][:flag] = CC.IR_FLAG_REFINED + elseif Meta.isexpr(inst, :invoke) + mi, called_func, args... = inst.args + if called_func == bool_conversion_intrinsic + compact[ssa][:inst] = only(args) + + # Set general type Any and set flag to allow re-inferring type. + compact[ssa][:type] = Any + compact[ssa][:flag] = CC.IR_FLAG_REFINED + elseif !is_intrinsic(mi.specTypes) + fname = name(cg, mi) + compact[ssa][:inst] = Expr(:call, handle_invoke, cg, fname, compact[ssa][:type], called_func, args...) + end + end + end + + # Since ReturnNodes have disappeared, add an explicit `return nothing` at the end. + CC.insert_node_here!( + compact, + CC.NewInstruction( + Core.ReturnNode(nothing), + Nothing, + Int32(1) + )) + + ir = CC.finish(compact) + + # manually set CFG to be a straight line. + # TODO: there might be a better way to do this + for (i, b) in enumerate(ir.cfg.blocks) + deleteat!(b.preds, 1:length(b.preds)) + deleteat!(b.succs, 1:length(b.succs)) + insert!(b.preds, 1, i-1) + insert!(b.succs, 1, i+1) + end + deleteat!(ir.cfg.blocks[1].preds, 1:length(ir.cfg.blocks[1].preds)) + deleteat!(ir.cfg.blocks[end].succs, 1:length(ir.cfg.blocks[end].succs)) + + ir = CC.compact!(ir) + + # type inference + interp = CC.NativeInterpreter() + mi = get_toplevel_mi_from_ir(ir, @__MODULE__); + ir = infer_ir!(ir, interp, mi) + + # inlining + inline_state = CC.InliningState(interp) + ir = CC.ssa_inlining_pass!(ir, inline_state, #=propagate_inbounds=#true) + ir = CC.compact!(ir) + + # SROA + DCE + ir = CC.sroa_pass!(ir, inline_state) + ir = first(CC.adce_pass!(ir, inline_state)) + ir = CC.compact!(ir) + + # errors if invalid + CC.verify_ir(ir) + + return ir +end + +"Generates a block argument for each phi node present in the block." +function prepare_block(ir, bb) + b = IR.Block() + + for sidx in bb.stmts + stmt = ir.stmts[sidx] + inst = stmt[:inst] + inst isa Core.PhiNode || continue + + type = stmt[:type] + IR.push_argument!(b, IR.Type(type)) + end + + return b +end \ No newline at end of file diff --git a/src/IR/AffineExpr.jl b/src/IR/AffineExpr.jl index 7a0f4931..13a5607c 100644 --- a/src/IR/AffineExpr.jl +++ b/src/IR/AffineExpr.jl @@ -124,11 +124,11 @@ ConstantExpr(constant; context::Context=context()) = AffineExpr(API.mlirAffineConstantExprGet(context, constant)) """ - value(affineExpr) + constvalue(affineExpr) Returns the value of the given affine constant expression. """ -function value(expr::AffineExpr) +function constvalue(expr::AffineExpr) @assert isconstantexpr(expr) "The given affine expression is not a constant expression" return API.mlirAffineConstantExprGetValue(expr) end diff --git a/src/IR/Block.jl b/src/IR/Block.jl index 2fcdadef..43734e65 100644 --- a/src/IR/Block.jl +++ b/src/IR/Block.jl @@ -1,3 +1,5 @@ +using TaskLocalValues + mutable struct Block block::API.MlirBlock @atomic owned::Bool @@ -14,6 +16,14 @@ end Block() = Block(Type[], Location[]) +""" +Used during MLIR code generation to keep track of the current block. +""" +const currentblock = TaskLocalValue{Union{Nothing, Block}}(()->nothing) + +setcurrentblock!(block::Union{Nothing, Block}) = currentblock[] = block +resetcurrentblock!() = currentblock[] = nothing + """ Block(args, locs) diff --git a/src/IR/Operation.jl b/src/IR/Operation.jl index aad10a09..0978babc 100644 --- a/src/IR/Operation.jl +++ b/src/IR/Operation.jl @@ -286,7 +286,7 @@ function create_operation( attributes=nothing, result_inference=isnothing(results), ) - GC.@preserve name loc begin + op = GC.@preserve name loc begin state = Ref(API.mlirOperationStateGet(name, loc)) if !isnothing(results) if result_inference @@ -324,4 +324,8 @@ function create_operation( end Operation(op, true) end + if (!isnothing(currentblock[])) + push!(currentblock[], op) + end + return op end diff --git a/src/IR/Value.jl b/src/IR/Value.jl index 6538447c..f355fc56 100644 --- a/src/IR/Value.jl +++ b/src/IR/Value.jl @@ -11,6 +11,36 @@ Base.convert(::Core.Type{API.MlirValue}, value::Value) = value.value Base.size(value::Value) = Base.size(type(value)) Base.ndims(value::Value) = Base.ndims(type(value)) +abstract type ValueTrait end +struct Convertible <: ValueTrait end +struct NonConvertible <: ValueTrait end + +ValueTrait(T) = NonConvertible() +value(x::Value) = x +value(x::T) where T = value(ValueTrait(T), x) +value(::Convertible, x) = x.value +value(::NonConvertible, x::T) where T = error("Type $T does not have the Convertible ValueTrait") + +unpack(T) = unpack(IR.ValueTrait(T), T) +unpack(::IR.Convertible, T) = (T, ) +function unpack(::IR.NonConvertible, T) + isbitstype(T) || error("Cannot unpack type $T that is not `isbitstype`") + fc = fieldcount(T) + if (fc == 0) + if (sizeof(T) == 0) + return [] + else + error("Unable to unpack NonConvertible type $T any further") + end + end + unpacked = [] + for i in 1:fc + ft = fieldtype(T, i) + append!(unpacked, unpack(ft)) + end + return unpacked +end + """ ==(value1, value2) diff --git a/src/MLIR.jl b/src/MLIR.jl index f718b587..458aab42 100644 --- a/src/MLIR.jl +++ b/src/MLIR.jl @@ -18,5 +18,6 @@ Base.showerror(io::IO, err::MLIRException) = print(io, err.msg) include("API/API.jl") include("IR/IR.jl") include("Dialects/Dialects.jl") +include("Generate/Generate.jl") end # module MLIR diff --git a/test/runtests.jl b/test/runtests.jl index 778edcd5..af336f95 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,9 +1,14 @@ using MLIR using Test -include("examples.jl") -include("executionengine.jl") -include("ir.jl") +@testset "$file" for file in ( + "examples.jl", + "executionengine.jl", + "ir.jl" +) + @info "testing" file + include(file) +end @testset "MlirStringRef conversion" begin s = "mlir 😄 α γ 🍕"