Type conversion
type_conversion
¶
FunctionRegistry
¶
A mapping between Python callables and IR operation types.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
__init__()
¶
insert(callable: Callable[..., Any], ir_constructor: Callable[..., Operation]) -> None
¶
Insert a relation between a Python callable and an IR operation constructor.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
get_operation_constructor(callable: Callable[..., Any]) -> Callable[..., Operation] | None
¶
Get the IR operation constructor from a Python callable.
resolve_operation(module_name: str, method_name: str, args: tuple[SSAValue[Attribute], ...] = tuple(), kwargs: dict[str, SSAValue[Attribute]] = dict()) -> Operation | None
¶
Get a concrete IR operation from a method name and its arguments.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
TypeRegistry
¶
A mapping between Python type annotations and IR type attributes.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
__init__()
¶
insert(annotation: type, attribute: TypeAttribute) -> None
¶
Insert a relation between a Python type annotation and an IR type attribute.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
get_annotation(attribute: TypeAttribute) -> type | None
¶
Get the Python type annotation from an IR type attribute.
This supports many-to-one mappings by resolving greedily on the first mapping inserted.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
resolve_attribute(annotation_name: str, globals: dict[str, Any]) -> TypeAttribute | None
¶
Get an IR type attribute from a string annotation.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
LiteralRegistry
¶
A mapping between Python literals and IR operation constructors.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
__init__()
¶
insert(value_type: type[object], ir_constructor: Callable[[Any], Operation]) -> None
¶
Insert a relation between a Python literal type and IR operation constructor.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
resolve_operation(value: Any) -> Operation | None
¶
Get a concrete IR operation for a literal value.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
TypeConverter
dataclass
¶
Responsible for conversion of Python type hints to xDSL types.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
globals: dict[str, Any] = field(default_factory=dict[str, Any])
class-attribute
instance-attribute
¶
Stores all globals in the current Python program, including imports. This is useful because we can lookup a class which corresponds to the type annotation without explicitly constructing it.
type_registry: TypeRegistry = field(default_factory=TypeRegistry)
class-attribute
instance-attribute
¶
Mappings between source code and ir type, indexed by name.
function_registry: FunctionRegistry = field(default_factory=FunctionRegistry)
class-attribute
instance-attribute
¶
Mappings between methods on objects and their operations.
literal_registry: LiteralRegistry = field(default_factory=LiteralRegistry)
class-attribute
instance-attribute
¶
Mappings between literal types and their operation constructors.