Dialect codegen
dialect_codegen
¶
Functions to print a Python file with the definition of a dialect, given specifications of its operations and attributes.
generate_dynamic_attr_class(class_name: str, attr: ParamAttrDef, is_type: bool = True) -> type[Attribute]
¶
Dynamically define a type based on ParamAttrDef. This is needed to reference dynamically created attributes in operations.
Source code in xdsl/utils/dialect_codegen.py
get_str_from_operand_or_result(name: str, operand_or_result: OperandDef | ResultDef) -> str
¶
Get a constraint from the RangeConstraint wrapper. Build the correct definition function based on the wrapper's type.
Source code in xdsl/utils/dialect_codegen.py
typedef_to_class_string(class_name: str, typedef: ParamAttrDef) -> str
¶
Generate class definition for a type.
Source code in xdsl/utils/dialect_codegen.py
attrdef_to_class_string(class_name: str, attr: ParamAttrDef) -> str
¶
Generate class definition for an attribute.
Source code in xdsl/utils/dialect_codegen.py
opdef_to_class_string(class_name: str, op: OpDef) -> str
¶
Generate class definition for an operation.
Source code in xdsl/utils/dialect_codegen.py
dump_dialect_pyfile(dialect_name: str, ops: Iterable[tuple[str, OpDef]] = (), *, attributes: Iterable[tuple[str, ParamAttrDef]] = (), types: Iterable[tuple[str, ParamAttrDef]] = (), out: TextIO | None = None, dialect_obj_name: str = '')
¶
Generate a python file with a dialect comprised of given ops, attributes and types.