mlir.dialects.irdl

Attributes

Classes

DialectOp

The irdl.dialect operation defines a dialect. All operations, attributes,

OperationOp

irdl.operation defines a new operation belonging to the irdl.dialect

TypeOp

irdl.type defines a new type belonging to the irdl.dialect parent.

AttributeOp

irdl.attribute defines a new attribute belonging to the irdl.dialect

Functions

dialect(→ DialectOp)

operation_(→ OperationOp)

type_(→ TypeOp)

attribute(→ AttributeOp)

_variadicity_array_attr(→ _ods_ir)

Module Contents

mlir.dialects.irdl._ods_ir
class mlir.dialects.irdl.DialectOp(sym_name: str | _ods_ir, *, loc=None, ip=None)

Bases: DialectOp

The irdl.dialect operation defines a dialect. All operations, attributes, and types defined inside its region will be part of the dialect.

Example:

irdl.dialect @cmath {
  ...
}

The above program defines a cmath dialect.

__doc__
property body: _ods_ir
mlir.dialects.irdl.dialect(sym_name: str | _ods_ir, *, loc=None, ip=None) DialectOp
class mlir.dialects.irdl.OperationOp(sym_name: str | _ods_ir, *, loc=None, ip=None)

Bases: OperationOp

irdl.operation defines a new operation belonging to the irdl.dialect parent.

Operations can define constraints on their operands and results with the irdl.results and irdl.operands operations. If these operations are not present in the region, the results or operands are expected to be empty.

Example:

irdl.dialect @cmath {

  irdl.type @complex { /* ... */ }

  irdl.operation @norm {
    %0 = irdl.any
    %1 = irdl.parametric @cmath::@complex<%0>
    irdl.results(%0)
    irdl.operands(%1)
  }
}

The above program defines an operation norm inside the dialect cmath. The operation expects a single operand of base type cmath.complex, and returns a single result of the element type of the operand.

__doc__
property body: _ods_ir
mlir.dialects.irdl.operation_(sym_name: str | _ods_ir, *, loc=None, ip=None) OperationOp
class mlir.dialects.irdl.TypeOp(sym_name: str | _ods_ir, *, loc=None, ip=None)

Bases: TypeOp

irdl.type defines a new type belonging to the irdl.dialect parent.

The type parameters can be defined with an irdl.parameters operation in the optional region.

Example:

irdl.dialect @cmath {
  irdl.type @complex {
    %0 = irdl.is i32
    %1 = irdl.is i64
    %2 = irdl.any_of(%0, %1)
    irdl.parameters(%2)
  }
}

The above program defines a type complex inside the dialect cmath. The type has a single parameter that should be either i32 or i64.

__doc__
property body: _ods_ir
mlir.dialects.irdl.type_(sym_name: str | _ods_ir, *, loc=None, ip=None) TypeOp
class mlir.dialects.irdl.AttributeOp(sym_name: str | _ods_ir, *, loc=None, ip=None)

Bases: AttributeOp

irdl.attribute defines a new attribute belonging to the irdl.dialect parent.

The attribute parameters can be defined with an irdl.parameters operation in the optional region.

Example:

irdl.dialect @testd {
  irdl.attribute @enum_attr {
    %0 = irdl.is "foo"
    %1 = irdl.is "bar"
    %2 = irdl.any_of(%0, %1)
    irdl.parameters(%2)
  }
}

The above program defines an enum_attr attribute inside the testd dialect. The attribute has one StringAttr parameter that should be either a "foo" or a "bar".

__doc__
property body: _ods_ir
mlir.dialects.irdl.attribute(sym_name: str | _ods_ir, *, loc=None, ip=None) AttributeOp
mlir.dialects.irdl._variadicity_array_attr(x: Sequence[mlir.dialects._irdl_enum_gen.Variadicity], context) _ods_ir