Skip to content

handle multiple optional operands #81

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 23, 2024
15 changes: 7 additions & 8 deletions deps/tblgen/jl-generators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ end

if (op.getTrait("::mlir::OpTrait::AttrSizedOperandSegments"))
{
std::vector<std::string> opseglist;
std::string operandsegmentsizes = "";
for (int i = 0; i < op.getNumOperands(); i++)
{
const auto &named_operand = op.getOperand(i);
Expand All @@ -314,15 +314,14 @@ end
operandname = "operand_" + std::to_string(i);
}
if (named_operand.isOptional())
opseglist.push_back("isnothing(" + operandname + ") ? 0 : 1");
{
operandsegmentsizes += "isnothing(" + operandname + ") ? 0 : 1, ";
}
else
opseglist.push_back(named_operand.isVariadic() ? "length(" + operandname + "), " : "1, ");
{
operandsegmentsizes += named_operand.isVariadic() ? "length(" + operandname + "), " : "1, ";
}
}
std::string operandsegmentsizes = std::accumulate(std::begin(opseglist), std::end(opseglist), std::string(),
[](std::string &ss, std::string &s)
{
return ss.empty() ? s : ss + "," + s;
});
optionals += llvm::formatv(R"(push!(attributes, operandsegmentsizes([{0}]))
)",
operandsegmentsizes);
Expand Down
25 changes: 3 additions & 22 deletions src/API/14/libMLIR_h.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ using CEnum

const intptr_t = Clong

"""
mlirStringRefCreate(str, length)

Constructs a string reference from the pointer and length. The pointer need not reference to a null-terminated string.
"""
function mlirStringRefCreate(str, length)
@ccall (MLIR_C_PATH[]).mlirStringRefCreate(str::Cstring, length::Csize_t)::MlirStringRef
@ccall (MLIR_C_PATH[]).mlirStringRefCreate(str::Cstring, length::Cint)::MlirStringRef
end

"""
Expand Down Expand Up @@ -1475,13 +1470,8 @@ function mlirTypeIDEqual(typeID1, typeID2)
@ccall (MLIR_C_PATH[]).mlirTypeIDEqual(typeID1::MlirTypeID, typeID2::MlirTypeID)::Bool
end

"""
mlirTypeIDHashValue(typeID)

Returns the hash value of the type id.
"""
function mlirTypeIDHashValue(typeID)
@ccall (MLIR_C_PATH[]).mlirTypeIDHashValue(typeID::MlirTypeID)::Csize_t
@ccall (MLIR_C_PATH[]).mlirTypeIDHashValue(typeID::MlirTypeID)::Cint
end

"""
Expand Down Expand Up @@ -2749,18 +2739,9 @@ function mlirDenseElementsAttrGet(shapedType, numElements, elements)
)::MlirAttribute
end

"""
mlirDenseElementsAttrRawBufferGet(shapedType, rawBufferSize, rawBuffer)

Creates a dense elements attribute with the given Shaped type and elements populated from a packed, row-major opaque buffer of contents.

The format of the raw buffer is a densely packed array of values that can be bitcast to the storage format of the element type specified. Types that are not byte aligned will be: - For bitwidth > 1: Rounded up to the next byte. - For bitwidth = 1: Packed into 8bit bytes with bits corresponding to the linear order of the shape type from MSB to LSB, padded to on the right.

A raw buffer of a single element (or for 1-bit, a byte of value 0 or 255) will be interpreted as a splat. User code should be prepared for additional, conformant patterns to be identified as splats in the future.
"""
function mlirDenseElementsAttrRawBufferGet(shapedType, rawBufferSize, rawBuffer)
@ccall (MLIR_C_PATH[]).mlirDenseElementsAttrRawBufferGet(
shapedType::MlirType, rawBufferSize::Csize_t, rawBuffer::Ptr{Cvoid}
shapedType::MlirType, rawBufferSize::Cint, rawBuffer::Ptr{Cvoid}
)::MlirAttribute
end

Expand Down
25 changes: 3 additions & 22 deletions src/API/15/libMLIR_h.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ using CEnum

const intptr_t = Clong

"""
mlirStringRefCreate(str, length)

Constructs a string reference from the pointer and length. The pointer need not reference to a null-terminated string.
"""
function mlirStringRefCreate(str, length)
@ccall (MLIR_C_PATH[]).mlirStringRefCreate(str::Cstring, length::Csize_t)::MlirStringRef
@ccall (MLIR_C_PATH[]).mlirStringRefCreate(str::Cstring, length::Cint)::MlirStringRef
end

"""
Expand Down Expand Up @@ -102,13 +97,8 @@ function mlirTypeIDEqual(typeID1, typeID2)
@ccall (MLIR_C_PATH[]).mlirTypeIDEqual(typeID1::MlirTypeID, typeID2::MlirTypeID)::Bool
end

"""
mlirTypeIDHashValue(typeID)

Returns the hash value of the type id.
"""
function mlirTypeIDHashValue(typeID)
@ccall (MLIR_C_PATH[]).mlirTypeIDHashValue(typeID::MlirTypeID)::Csize_t
@ccall (MLIR_C_PATH[]).mlirTypeIDHashValue(typeID::MlirTypeID)::Cint
end

"""
Expand Down Expand Up @@ -2867,18 +2857,9 @@ function mlirDenseElementsAttrGet(shapedType, numElements, elements)
)::MlirAttribute
end

"""
mlirDenseElementsAttrRawBufferGet(shapedType, rawBufferSize, rawBuffer)

Creates a dense elements attribute with the given Shaped type and elements populated from a packed, row-major opaque buffer of contents.

The format of the raw buffer is a densely packed array of values that can be bitcast to the storage format of the element type specified. Types that are not byte aligned will be: - For bitwidth > 1: Rounded up to the next byte. - For bitwidth = 1: Packed into 8bit bytes with bits corresponding to the linear order of the shape type from MSB to LSB, padded to on the right.

A raw buffer of a single element (or for 1-bit, a byte of value 0 or 255) will be interpreted as a splat. User code should be prepared for additional, conformant patterns to be identified as splats in the future.
"""
function mlirDenseElementsAttrRawBufferGet(shapedType, rawBufferSize, rawBuffer)
@ccall (MLIR_C_PATH[]).mlirDenseElementsAttrRawBufferGet(
shapedType::MlirType, rawBufferSize::Csize_t, rawBuffer::Ptr{Cvoid}
shapedType::MlirType, rawBufferSize::Cint, rawBuffer::Ptr{Cvoid}
)::MlirAttribute
end

Expand Down
25 changes: 3 additions & 22 deletions src/API/16/libMLIR_h.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ using CEnum

const intptr_t = Clong

"""
mlirStringRefCreate(str, length)

Constructs a string reference from the pointer and length. The pointer need not reference to a null-terminated string.
"""
function mlirStringRefCreate(str, length)
@ccall (MLIR_C_PATH[]).mlirStringRefCreate(str::Cstring, length::Csize_t)::MlirStringRef
@ccall (MLIR_C_PATH[]).mlirStringRefCreate(str::Cstring, length::Cint)::MlirStringRef
end

"""
Expand Down Expand Up @@ -102,13 +97,8 @@ function mlirTypeIDEqual(typeID1, typeID2)
@ccall (MLIR_C_PATH[]).mlirTypeIDEqual(typeID1::MlirTypeID, typeID2::MlirTypeID)::Bool
end

"""
mlirTypeIDHashValue(typeID)

Returns the hash value of the type id.
"""
function mlirTypeIDHashValue(typeID)
@ccall (MLIR_C_PATH[]).mlirTypeIDHashValue(typeID::MlirTypeID)::Csize_t
@ccall (MLIR_C_PATH[]).mlirTypeIDHashValue(typeID::MlirTypeID)::Cint
end

"""
Expand Down Expand Up @@ -3059,18 +3049,9 @@ function mlirDenseElementsAttrGet(shapedType, numElements, elements)
)::MlirAttribute
end

"""
mlirDenseElementsAttrRawBufferGet(shapedType, rawBufferSize, rawBuffer)

Creates a dense elements attribute with the given Shaped type and elements populated from a packed, row-major opaque buffer of contents.

The format of the raw buffer is a densely packed array of values that can be bitcast to the storage format of the element type specified. Types that are not byte aligned will be: - For bitwidth > 1: Rounded up to the next byte. - For bitwidth = 1: Packed into 8bit bytes with bits corresponding to the linear order of the shape type from MSB to LSB, padded to on the right.

A raw buffer of a single element (or for 1-bit, a byte of value 0 or 255) will be interpreted as a splat. User code should be prepared for additional, conformant patterns to be identified as splats in the future.
"""
function mlirDenseElementsAttrRawBufferGet(shapedType, rawBufferSize, rawBuffer)
@ccall (MLIR_C_PATH[]).mlirDenseElementsAttrRawBufferGet(
shapedType::MlirType, rawBufferSize::Csize_t, rawBuffer::Ptr{Cvoid}
shapedType::MlirType, rawBufferSize::Cint, rawBuffer::Ptr{Cvoid}
)::MlirAttribute
end

Expand Down
25 changes: 3 additions & 22 deletions src/API/17/libMLIR_h.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ using CEnum

const intptr_t = Clong

"""
mlirStringRefCreate(str, length)

Constructs a string reference from the pointer and length. The pointer need not reference to a null-terminated string.
"""
function mlirStringRefCreate(str, length)
@ccall (MLIR_C_PATH[]).mlirStringRefCreate(str::Cstring, length::Csize_t)::MlirStringRef
@ccall (MLIR_C_PATH[]).mlirStringRefCreate(str::Cstring, length::Cint)::MlirStringRef
end

"""
Expand Down Expand Up @@ -120,13 +115,8 @@ function mlirTypeIDEqual(typeID1, typeID2)
@ccall (MLIR_C_PATH[]).mlirTypeIDEqual(typeID1::MlirTypeID, typeID2::MlirTypeID)::Bool
end

"""
mlirTypeIDHashValue(typeID)

Returns the hash value of the type id.
"""
function mlirTypeIDHashValue(typeID)
@ccall (MLIR_C_PATH[]).mlirTypeIDHashValue(typeID::MlirTypeID)::Csize_t
@ccall (MLIR_C_PATH[]).mlirTypeIDHashValue(typeID::MlirTypeID)::Cint
end

"""
Expand Down Expand Up @@ -3387,18 +3377,9 @@ function mlirDenseElementsAttrGet(shapedType, numElements, elements)
)::MlirAttribute
end

"""
mlirDenseElementsAttrRawBufferGet(shapedType, rawBufferSize, rawBuffer)

Creates a dense elements attribute with the given Shaped type and elements populated from a packed, row-major opaque buffer of contents.

The format of the raw buffer is a densely packed array of values that can be bitcast to the storage format of the element type specified. Types that are not byte aligned will be: - For bitwidth > 1: Rounded up to the next byte. - For bitwidth = 1: Packed into 8bit bytes with bits corresponding to the linear order of the shape type from MSB to LSB, padded to on the right.

A raw buffer of a single element (or for 1-bit, a byte of value 0 or 255) will be interpreted as a splat. User code should be prepared for additional, conformant patterns to be identified as splats in the future.
"""
function mlirDenseElementsAttrRawBufferGet(shapedType, rawBufferSize, rawBuffer)
@ccall (MLIR_C_PATH[]).mlirDenseElementsAttrRawBufferGet(
shapedType::MlirType, rawBufferSize::Csize_t, rawBuffer::Ptr{Cvoid}
shapedType::MlirType, rawBufferSize::Cint, rawBuffer::Ptr{Cvoid}
)::MlirAttribute
end

Expand Down
40 changes: 11 additions & 29 deletions src/API/18/libMLIR_h.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ using CEnum

const intptr_t = Clong

"""
mlirStringRefCreate(str, length)

Constructs a string reference from the pointer and length. The pointer need not reference to a null-terminated string.
"""
function mlirStringRefCreate(str, length)
@ccall (MLIR_C_PATH[]).mlirStringRefCreate(str::Cstring, length::Csize_t)::MlirStringRef
@ccall (MLIR_C_PATH[]).mlirStringRefCreate(str::Cstring, length::Cint)::MlirStringRef
end

"""
Expand Down Expand Up @@ -120,13 +115,8 @@ function mlirTypeIDEqual(typeID1, typeID2)
@ccall (MLIR_C_PATH[]).mlirTypeIDEqual(typeID1::MlirTypeID, typeID2::MlirTypeID)::Bool
end

"""
mlirTypeIDHashValue(typeID)

Returns the hash value of the type id.
"""
function mlirTypeIDHashValue(typeID)
@ccall (MLIR_C_PATH[]).mlirTypeIDHashValue(typeID::MlirTypeID)::Csize_t
@ccall (MLIR_C_PATH[]).mlirTypeIDHashValue(typeID::MlirTypeID)::Cint
end

"""
Expand Down Expand Up @@ -3579,18 +3569,9 @@ function mlirDenseElementsAttrGet(shapedType, numElements, elements)
)::MlirAttribute
end

"""
mlirDenseElementsAttrRawBufferGet(shapedType, rawBufferSize, rawBuffer)

Creates a dense elements attribute with the given Shaped type and elements populated from a packed, row-major opaque buffer of contents.

The format of the raw buffer is a densely packed array of values that can be bitcast to the storage format of the element type specified. Types that are not byte aligned will be: - For bitwidth > 1: Rounded up to the next byte. - For bitwidth = 1: Packed into 8bit bytes with bits corresponding to the linear order of the shape type from MSB to LSB, padded to on the right.

A raw buffer of a single element (or for 1-bit, a byte of value 0 or 255) will be interpreted as a splat. User code should be prepared for additional, conformant patterns to be identified as splats in the future.
"""
function mlirDenseElementsAttrRawBufferGet(shapedType, rawBufferSize, rawBuffer)
@ccall (MLIR_C_PATH[]).mlirDenseElementsAttrRawBufferGet(
shapedType::MlirType, rawBufferSize::Csize_t, rawBuffer::Ptr{Cvoid}
shapedType::MlirType, rawBufferSize::Cint, rawBuffer::Ptr{Cvoid}
)::MlirAttribute
end

Expand Down Expand Up @@ -3930,20 +3911,15 @@ function mlirAttributeIsADenseResourceElements(attr)
@ccall (MLIR_C_PATH[]).mlirAttributeIsADenseResourceElements(attr::MlirAttribute)::Bool
end

"""
mlirUnmanagedDenseResourceElementsAttrGet(shapedType, name, data, dataLength, dataAlignment, dataIsMutable, deleter, userData)

Unlike the typed accessors below, constructs the attribute with a raw data buffer and no type/alignment checking. Use a more strongly typed accessor if possible. If dataIsMutable is false, then an immutable AsmResourceBlob will be created and that passed data contents will be treated as const. If the deleter is non NULL, then it will be called when the data buffer can no longer be accessed (passing userData to it).
"""
function mlirUnmanagedDenseResourceElementsAttrGet(
shapedType, name, data, dataLength, dataAlignment, dataIsMutable, deleter, userData
)
@ccall (MLIR_C_PATH[]).mlirUnmanagedDenseResourceElementsAttrGet(
shapedType::MlirType,
name::MlirStringRef,
data::Ptr{Cvoid},
dataLength::Csize_t,
dataAlignment::Csize_t,
dataLength::Cint,
dataAlignment::Cint,
dataIsMutable::Bool,
deleter::Ptr{Cvoid},
userData::Ptr{Cvoid},
Expand Down Expand Up @@ -8115,3 +8091,9 @@ end
function mlirRegisterTransformsViewOpGraph()
@ccall (MLIR_C_PATH[]).mlirRegisterTransformsViewOpGraph()::Cvoid
end

const INT64_MAX = Clonglong(9223372036854775807)

const INT64_MIN = -INT64_MAX - 1

const UINT64_MAX = Culonglong(0xffffffffffffffff)
24 changes: 12 additions & 12 deletions src/Dialects/14/Affine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ 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()
operand_0::Vector{Value}; results_::Vector{IR.Type}, region::Region, location=Location()
)
results = IR.Type[results...,]
results = IR.Type[results_...,]
operands = Value[operand_0...,]
owned_regions = Region[region,]
successors = Block[]
Expand Down Expand Up @@ -245,12 +245,12 @@ func @pad_edges(%I : memref<10x10xf32>) -> (memref<12x12xf32) {
"""
function if_(
operand_0::Vector{Value};
results::Vector{IR.Type},
results_::Vector{IR.Type},
thenRegion::Region,
elseRegion::Region,
location=Location(),
)
results = IR.Type[results...,]
results = IR.Type[results_...,]
operands = Value[operand_0...,]
owned_regions = Region[thenRegion, elseRegion]
successors = Block[]
Expand Down Expand Up @@ -321,9 +321,9 @@ affine map.
%0 = affine.max (d0) -> (1000, d0 + 512) (%i0) : index
```
"""
function max(operands::Vector{Value}; result_0::IR.Type, map, location=Location())
function max(operands_::Vector{Value}; result_0::IR.Type, map, location=Location())
results = IR.Type[result_0,]
operands = Value[operands...,]
operands = Value[operands_...,]
owned_regions = Region[]
successors = Block[]
attributes = NamedAttribute[namedattribute("map", map),]
Expand Down Expand Up @@ -362,9 +362,9 @@ 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())
function min(operands_::Vector{Value}; result_0::IR.Type, map, location=Location())
results = IR.Type[result_0,]
operands = Value[operands...,]
operands = Value[operands_...,]
owned_regions = Region[]
successors = Block[]
attributes = NamedAttribute[namedattribute("map", map),]
Expand Down Expand Up @@ -448,7 +448,7 @@ affine.parallel (%ii, %jj) = (0, 0) to (%N, %M) step (32, 32) {
"""
function parallel(
mapOperands::Vector{Value};
results::Vector{IR.Type},
results_::Vector{IR.Type},
reductions,
lowerBoundsMap,
lowerBoundsGroups,
Expand All @@ -458,7 +458,7 @@ function parallel(
region::Region,
location=Location(),
)
results = IR.Type[results...,]
results = IR.Type[results_...,]
operands = Value[mapOperands...,]
owned_regions = Region[region,]
successors = Block[]
Expand Down Expand Up @@ -708,9 +708,9 @@ Otherwise, it has to be present in the syntax to indicate which values are
yielded.
```
"""
function yield(operands::Vector{Value}; location=Location())
function yield(operands_::Vector{Value}; location=Location())
results = IR.Type[]
operands = Value[operands...,]
operands = Value[operands_...,]
owned_regions = Region[]
successors = Block[]
attributes = NamedAttribute[]
Expand Down
Loading
Loading