Context
context
¶
FuncInfo
¶
Bases: NamedTuple
Information about a decorated function being generated into IR.
Source code in xdsl/frontend/pyast/context.py
PyASTContext
dataclass
¶
Encapsulate the mapping between Python and IR types and operations.
Source code in xdsl/frontend/pyast/context.py
52 53 54 55 56 57 58 59 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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
type_registry: TypeRegistry = field(default_factory=TypeRegistry)
class-attribute
instance-attribute
¶
Mappings between source code and IR type.
function_registry: FunctionRegistry = field(default_factory=FunctionRegistry)
class-attribute
instance-attribute
¶
Mappings between functions and their operation types.
literal_registry: LiteralRegistry = field(default_factory=LiteralRegistry)
class-attribute
instance-attribute
¶
Mappings between literal types and their operation constructors.
post_transforms: list[ModulePass] = field(default_factory=lambda: [FrontendDesymrefyPass()])
class-attribute
instance-attribute
¶
An ordered list of passes to apply to the built module.
post_callback: PassPipelineCallbackType | None = default_pipeline_callback
class-attribute
instance-attribute
¶
Callback to run between post transforms.
ir_context: Context = field(default_factory=lambda: Context(allow_unregistered=True))
class-attribute
instance-attribute
¶
The xDSL context to use when applying transformations to the built module.
function_definition_constructor: FunctionDefinitionConstructor = build_func
class-attribute
instance-attribute
¶
Construct the operation for each function.
return_constructor: ReturnConstructor = build_return
class-attribute
instance-attribute
¶
Construct return operations, optionally omitting the terminator.
pass_pipeline: PassPipeline
property
¶
Get a pass pipeline from the context state.
__init__(type_registry: TypeRegistry = TypeRegistry(), function_registry: FunctionRegistry = FunctionRegistry(), literal_registry: LiteralRegistry = LiteralRegistry(), post_transforms: list[ModulePass] = (lambda: [FrontendDesymrefyPass()])(), post_callback: PassPipelineCallbackType | None = default_pipeline_callback, ir_context: Context = (lambda: Context(allow_unregistered=True))(), function_definition_constructor: FunctionDefinitionConstructor = build_func, return_constructor: ReturnConstructor = build_return) -> None
¶
register_type(source_type: TypeForm[Any], ir_type: TypeAttribute) -> None
¶
Associate a type in the source code with its type in the IR.
register_function(function: Callable[..., Any], ir_constructor: Callable[..., Operation]) -> None
¶
Associate a method on an object in the source code with its IR implementation.
Source code in xdsl/frontend/pyast/context.py
register_literal(value_type: type[object], ir_constructor: Callable[[Any], Operation]) -> None
¶
Associate a Python literal type with an IR constructor.
register_function_definition(ir_constructor: FunctionDefinitionConstructor) -> None
¶
Set the definition constructor, receiving name, type, body, and location.
register_return(ir_constructor: ReturnConstructor) -> None
¶
Set the return constructor, receiving expression results and location.
register_post_transform(transform: ModulePass) -> None
¶
register_dialect(dialect: Dialect) -> None
¶
parse_program(func: Callable[P, R]) -> PyASTProgram[P, R]
¶
Get a program wrapper by decorating a function.
Source code in xdsl/frontend/pyast/context.py
default_pipeline_callback(previous_pass: ModulePass | None, module: ModuleOp, next_pass: ModulePass | None) -> None
¶
Default callback to verify the module after each transformation pass.