Beaver.MLIR.Dialect.IRDL (beaver v0.4.7)
Summary
Functions
irdl.all_of - Constraints to the intersection of the provided constraints
irdl.any
irdl.any_of - Constraints to the union of the provided constraints
irdl.attribute
irdl.attributes - Define the attributes of an operation
irdl.base
irdl.c_pred
irdl.dialect
irdl.is
irdl.operands - Define the operands of an operation
irdl.operation
irdl.parameters - Define the constraints on parameters of a type/attribute definition
irdl.parametric - Constraints an attribute/type base and its parameters
irdl.region - Define a region of an operation
irdl.regions - Define the regions of an operation
irdl.results - Define the results of an operation
irdl.type
Functions
irdl.all_of - Constraints to the intersection of the provided constraints
Operands
args- Variadic,IRDL_AttributeType, variadic of IRDL handle to anmlir::Attribute
Results
output- Single,IRDL_AttributeType, IRDL handle to anmlir::Attribute
Description
irdl.all_of defines a constraint that accepts any type or attribute that
satisfies all of its provided constraints.
Example:
irdl.dialect @cmath {
irdl.type @complex_f32 {
%0 = irdl.is i32
%1 = irdl.is f32
%2 = irdl.any_of(%0, %1) // is 32-bit
%3 = irdl.is f32
%4 = irdl.is f64
%5 = irdl.any_of(%3, %4) // is a float
%6 = irdl.all_of(%2, %5) // is a 32-bit float
irdl.parameters(%6)
}
}The above program defines a type complex inside the dialect cmath that
has one parameter that must be 32-bit long and a float (in other
words, that must be f32).
irdl.any
irdl.any_of - Constraints to the union of the provided constraints
Operands
args- Variadic,IRDL_AttributeType, variadic of IRDL handle to anmlir::Attribute
Results
output- Single,IRDL_AttributeType, IRDL handle to anmlir::Attribute
Description
irdl.any_of defines a constraint that accepts any type or attribute that
satisfies at least one of its provided type constraints.
Example:
irdl.dialect @cmath {
irdl.type @complex {
%0 = irdl.is i32
%1 = irdl.is i64
%2 = irdl.is f32
%3 = irdl.is f64
%4 = irdl.any_of(%0, %1, %2, %3)
irdl.parameters(%4)
}
}The above program defines a type complex inside the dialect cmath that
has a single type parameter that can be either i32, i64, f32 or
f64.
irdl.attribute
irdl.attributes - Define the attributes of an operation
Attributes
attributeValueNames- Single,StrArrayAttr, string array attribute
Operands
attributeValues- Variadic,IRDL_AttributeType, variadic of IRDL handle to anmlir::Attribute
Description
irdl.attributes defines the attributes of the irdl.operation parent
operation definition.
In the following example, irdl.attributes defines the attributes of the
attr_op operation:
irdl.dialect @example {
irdl.operation @attr_op {
%0 = irdl.any
%1 = irdl.is i64
irdl.attibutes {
"attr1" = %0,
"attr2" = %1
}
}
}The operation will expect an arbitrary attribute "attr1" and an
attribute "attr2" with value i64.
irdl.base
irdl.c_pred
irdl.dialect
irdl.is
irdl.operands - Define the operands of an operation
Attributes
names- Single,StrArrayAttr, string array attributevariadicity- Single,VariadicityArrayAttr,
Operands
args- Variadic,IRDL_AttributeType, variadic of IRDL handle to anmlir::Attribute
Description
irdl.operands define the operands of the irdl.operation parent operation
definition. Each operand is named after an identifier.
In the following example, irdl.operands defines the operands of the
mul operation:
irdl.dialect @cmath {
irdl.type @complex { /* ... */ }
irdl.operation @mul {
%0 = irdl.any
%1 = irdl.parametric @cmath::@complex<%0>
irdl.results(res: %1)
irdl.operands(lhs: %1, rhs: %1)
}
}The mul operation will expect two operands of type cmath.complex, that
have the same type, and return a result of the same type.
The operands can also be marked as variadic or optional:
irdl.operands(foo: %0, bar: single %1, baz: optional %2, qux: variadic %3)Here, foo and bar are required single operands, baz is an optional operand, and qux is a variadic operand.
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.
irdl.operation
irdl.parameters - Define the constraints on parameters of a type/attribute definition
Attributes
names- Single,StrArrayAttr, string array attribute
Operands
args- Variadic,IRDL_AttributeType, variadic of IRDL handle to anmlir::Attribute
Description
irdl.parameters defines the constraints on parameters of a type or
attribute definition. Each parameter is named after an identifier.
Example:
irdl.dialect @cmath {
irdl.type @complex {
%0 = irdl.is i32
%1 = irdl.is i64
%2 = irdl.any_of(%0, %1)
irdl.parameters(elem: %2)
}
}The above program defines a type complex inside the dialect cmath. The
type has a single parameter elem that should be either i32 or i64.
irdl.parametric - Constraints an attribute/type base and its parameters
This op has support for result type inference.
Attributes
base_type- Single,SymbolRefAttr, symbol reference attribute
Operands
args- Variadic,IRDL_AttributeType, variadic of IRDL handle to anmlir::Attribute
Results
output- Single,IRDL_AttributeType, IRDL handle to anmlir::Attribute
Description
irdl.parametric defines a constraint that accepts only a single type
or attribute base. The attribute base is defined by a symbolic reference
to the corresponding definition. It will additionally constraint the
parameters of the type/attribute.
Example:
irdl.dialect @cmath {
irdl.type @complex { /* ... */ }
irdl.operation @norm {
%0 = irdl.any
%1 = irdl.parametric @cmath::@complex<%0>
irdl.operands(%1)
irdl.results(%0)
}
}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.
irdl.region - Define a region of an operation
This op has support for result type inference.
Attributes
numberOfBlocks- Optional,I32Attr, 32-bit signless integer attributeconstrainedArguments- Optional,UnitAttr, unit attribute
Operands
entryBlockArgs- Variadic,IRDL_AttributeType, variadic of IRDL handle to anmlir::Attribute
Results
output- Single,IRDL_RegionType, IRDL handle to a region definition
Description
The irdl.region construct defines a set of characteristics that a region of an operation should satify. Each region is named after an identifier.
These characteristics include constraints for the entry block arguments of the region and the total number of blocks it contains. The number of blocks must be a non-zero and non-negative integer, and it is optional by default. The set of constraints for the entry block arguments may be optional or empty. If no parentheses are provided, the set is assumed to be optional, and the arguments are not constrained in any way. If parentheses are provided with no arguments, it means that the region must have no entry block arguments
Example:
irdl.dialect @example {
irdl.operation @op_with_regions {
%r0 = irdl.region
%r1 = irdl.region()
%v0 = irdl.is i32
%v1 = irdl.is i64
%r2 = irdl.region(%v0, %v1)
%r3 = irdl.region with size 3
irdl.regions(foo: %r0, bar: %r1, baz: %r2, qux: %r3)
}
}The above snippet demonstrates an operation named @op_with_regions,
which is constrained to have four regions.
- Region
foodoesn't have any constraints on the arguments or the number of blocks. - Region
barshould have an empty set of arguments. - Region
bazshould have two arguments of typesi32andi64. - Region
quxshould contain exactly three blocks.
irdl.regions - Define the regions of an operation
Attributes
names- Single,StrArrayAttr, string array attribute
Operands
args- Variadic,IRDL_RegionType, variadic of IRDL handle to a region definition
Description
irdl.regions defines the regions of an operation by accepting
values produced by irdl.region operation as arguments. Each
region has an identifier as name.
Example:
irdl.dialect @example {
irdl.operation @op_with_regions {
%r1 = irdl.region with size 3
%0 = irdl.any
%r2 = irdl.region(%0)
irdl.regions(foo: %r1, bar: %r2)
}
}In the snippet above the operation is constrained to have two regions.
The first region (foo) should contain three blocks.
The second region (bar) should have one region with one argument.
irdl.results - Define the results of an operation
Attributes
names- Single,StrArrayAttr, string array attributevariadicity- Single,VariadicityArrayAttr,
Operands
args- Variadic,IRDL_AttributeType, variadic of IRDL handle to anmlir::Attribute
Description
irdl.results define the results of the irdl.operation parent operation
definition. Each result is named after an identifier.
In the following example, irdl.results defines the results of the
get_values operation:
irdl.dialect @cmath {
irdl.type @complex { /* ... */ }
/// Returns the real and imaginary parts of a complex number.
irdl.operation @get_values {
%0 = irdl.any
%1 = irdl.parametric @cmath::@complex<%0>
irdl.results(re: %0, im: %0)
irdl.operands(complex: %1)
}
}The operation will expect one operand of the cmath.complex type, and two
results that have the underlying type of the cmath.complex.
The results can also be marked as variadic or optional:
irdl.results(foo: %0, bar: single %1, baz: optional %2, qux: variadic %3)Here, foo and bar are required single results, baz is an optional result, and qux is a variadic result.
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.
irdl.type