Emitc
emitc
¶
Dialect to generate C/C++ from MLIR.
The EmitC dialect allows to convert operations from other MLIR dialects to EmitC ops. Those can be translated to C/C++ via the Cpp emitter.
See external documentation.
EmitCIntegerType = IntegerType[Literal[1, 8, 16, 32, 64]]
module-attribute
¶
Type for integer types supported by EmitC. See external documentation.
EmitCIntegerTypeConstr = irdl_to_attr_constraint(EmitCIntegerType)
module-attribute
¶
Constraint for integer types supported by EmitC. See external documentation.
EmitCFloatType = Float16Type | BFloat16Type | Float32Type | Float64Type
module-attribute
¶
EmitCFloatTypeConstr = irdl_to_attr_constraint(EmitCFloatType)
module-attribute
¶
Supported floating-point type in EmitC. See external documentation
EmitCPointerWideType = EmitC_PtrDiffT | EmitC_SignedSizeT | EmitC_SizeT
module-attribute
¶
EmitCPointerWideTypeConstr = irdl_to_attr_constraint(EmitCPointerWideType)
module-attribute
¶
Constraint for pointer-wide types supported by EmitC. These types have the same width as platform-specific pointer types.
EmitCIntegerIndexOpaqueType = EmitCIntegerType | IndexType | EmitC_OpaqueType
module-attribute
¶
EmitCIntegerIndexOpaqueTypeConstr = irdl_to_attr_constraint(EmitCIntegerIndexOpaqueType)
module-attribute
¶
Constraint for integer, index, or opaque types supported by EmitC.
EmitCArrayElementType = EmitCIntegerIndexOpaqueType | EmitCFloatType | EmitCPointerWideType
module-attribute
¶
EmitCArrayElementTypeConstr = irdl_to_attr_constraint(EmitCArrayElementType)
module-attribute
¶
Constraint for valid element types in EmitC arrays.
EmitCArrayElementTypeCovT = TypeVar('EmitCArrayElementTypeCovT', bound=EmitCArrayElementType, covariant=True, default=EmitCArrayElementType)
module-attribute
¶
EmitCTypeConstr = EmitCTypeConstraint()
module-attribute
¶
EmitC = Dialect('emitc', [EmitC_AddOp, EmitC_ApplyOp, EmitC_CallOpaqueOp], [EmitC_ArrayType, EmitC_LValueType, EmitC_OpaqueAttr, EmitC_OpaqueType, EmitC_PointerType, EmitC_PtrDiffT, EmitC_SignedSizeT, EmitC_SizeT])
module-attribute
¶
EmitC_OpaqueType
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute
EmitC opaque type
Source code in xdsl/dialects/emitc.py
EmitC_PtrDiffT
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute
EmitC signed pointer diff type.
Signed data type as wide as platform-specific pointer types. In particular, it is as wide as emitc.size_t.
It corresponds to ptrdiff_t found in
Source code in xdsl/dialects/emitc.py
name = 'emitc.ptrdiff_t'
class-attribute
instance-attribute
¶
EmitC_SignedSizeT
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute
EmitC signed size type.
Data type representing all values of emitc.size_t, plus -1. It corresponds to ssize_t found in
Source code in xdsl/dialects/emitc.py
name = 'emitc.ssize_t'
class-attribute
instance-attribute
¶
EmitC_SizeT
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute
EmitC unsigned size type.
Unsigned data type as wide as platform-specific pointer types. It corresponds to size_t found in
Source code in xdsl/dialects/emitc.py
name = 'emitc.size_t'
class-attribute
instance-attribute
¶
EmitC_OpaqueAttr
dataclass
¶
Bases: ParametrizedAttribute
An opaque attribute of which the value gets emitted as is.
Source code in xdsl/dialects/emitc.py
EmitC_ArrayType
¶
Bases: ParametrizedAttribute, TypeAttribute, ShapedType, ContainerType[EmitCArrayElementTypeCovT], Generic[EmitCArrayElementTypeCovT]
EmitC array type
Source code in xdsl/dialects/emitc.py
name = 'emitc.array'
class-attribute
instance-attribute
¶
shape: ArrayAttr[IntAttr] = param_def(StaticShapeArrayConstr)
class-attribute
instance-attribute
¶
element_type: EmitCArrayElementTypeCovT
instance-attribute
¶
__init__(shape: Iterable[int | IntAttr], element_type: EmitCArrayElementType)
¶
verify() -> None
¶
Source code in xdsl/dialects/emitc.py
get_num_dims() -> int
¶
get_shape() -> tuple[int, ...]
¶
get_element_type() -> EmitCArrayElementTypeCovT
¶
parse_parameters(parser: AttrParser)
classmethod
¶
print_parameters(printer: Printer) -> None
¶
Source code in xdsl/dialects/emitc.py
EmitCTypeConstraint
dataclass
¶
Bases: AttrConstraint
Check if a type is supported by EmitC. See MLIR implementation.
Source code in xdsl/dialects/emitc.py
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
Source code in xdsl/dialects/emitc.py
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> AttrConstraint
¶
EmitC_LValueType
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute
EmitC lvalue type. Values of this type can be assigned to and their address can be taken. See tablegen definition
Source code in xdsl/dialects/emitc.py
name = 'emitc.lvalue'
class-attribute
instance-attribute
¶
value_type: Attribute = param_def(EmitCTypeConstr)
class-attribute
instance-attribute
¶
verify() -> None
¶
Verify the LValueType. See MLIR implementation
Source code in xdsl/dialects/emitc.py
EmitC_PointerType
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute
EmitC pointer type
Source code in xdsl/dialects/emitc.py
EmitC_BinaryOperation
¶
Bases: IRDLOperation, ABC
Base class for EmitC binary operations.
Source code in xdsl/dialects/emitc.py
lhs = operand_def(EmitCTypeConstr)
class-attribute
instance-attribute
¶
rhs = operand_def(EmitCTypeConstr)
class-attribute
instance-attribute
¶
result = result_def(EmitCTypeConstr)
class-attribute
instance-attribute
¶
assembly_format = 'operands attr-dict `:` functional-type(operands, results)'
class-attribute
instance-attribute
¶
EmitC_AddOp
dataclass
¶
Bases: EmitC_BinaryOperation
Addition operation.
With the emitc.add operation the arithmetic operator + (addition) can
be applied. Supports pointer arithmetic where one operand is a pointer
and the other is an integer or opaque type.
Example:
// Custom form of the addition operation.
%0 = emitc.add %arg0, %arg1 : (i32, i32) -> i32
%1 = emitc.add %arg2, %arg3 : (!emitc.ptr<f32>, i32) -> !emitc.ptr<f32>
Source code in xdsl/dialects/emitc.py
name = 'emitc.add'
class-attribute
instance-attribute
¶
verify_() -> None
¶
Source code in xdsl/dialects/emitc.py
EmitC_ApplyOp
dataclass
¶
Bases: IRDLOperation
Apply operation
Source code in xdsl/dialects/emitc.py
name = 'emitc.apply'
class-attribute
instance-attribute
¶
assembly_format = '\n $applicableOperator `(` $operand `)` attr-dict `:` functional-type($operand, results)\n '
class-attribute
instance-attribute
¶
applicableOperator = prop_def(StringAttr)
class-attribute
instance-attribute
¶
operand = operand_def(AnyAttr())
class-attribute
instance-attribute
¶
result = result_def(EmitCTypeConstr)
class-attribute
instance-attribute
¶
verify_() -> None
¶
Source code in xdsl/dialects/emitc.py
EmitC_CallOpaqueOp
¶
Bases: IRDLOperation
The emitc.call_opaque operation represents a C++ function call. The callee can be an arbitrary non-empty string.
The call allows specifying order of operands and attributes in the call as follows:
- integer value of index type refers to an operand;
- attribute which will get lowered to constant value in call;