Type conversion
type_conversion
FunctionRegistry
A mapping between Python callables and IR operation types.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
__init__()
Instantiate the function registry.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
18 19 20 | |
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
22 23 24 25 26 27 28 29 30 | |
get_operation_constructor(callable: Callable[..., Any]) -> Callable[..., Operation] | None
Get the IR operation constructor from a Python callable.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
32 33 34 35 36 | |
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
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
TypeRegistry
A mapping between Python type annotations and IR type attributes.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
__init__()
Instantiate the function registry.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
63 64 65 | |
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
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
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
83 84 85 86 87 88 89 90 91 92 | |
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
94 95 96 97 98 99 100 101 102 | |
TypeConverter
dataclass
Responsible for conversion of Python type hints to xDSL types.
Source code in xdsl/frontend/pyast/utils/type_conversion.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
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.