Skip to content

Transform

transform

TransformFunctions

Bases: InterpreterFunctions

Source code in xdsl/interpreters/transform.py
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
@register_impls
class TransformFunctions(InterpreterFunctions):
    ctx: Context
    passes: dict[str, Callable[[], type[ModulePass]]]

    def __init__(
        self, ctx: Context, available_passes: dict[str, Callable[[], type[ModulePass]]]
    ):
        self.ctx = ctx
        self.passes = available_passes

    @impl_callable(transform.NamedSequenceOp)
    def run_named_sequence_op(
        self,
        interpreter: Interpreter,
        op: transform.NamedSequenceOp,
        args: PythonValues,
    ) -> PythonValues:
        return interpreter.run_ssacfg_region(op.body, args, op.sym_name.data)

    @impl(transform.ApplyRegisteredPassOp)
    def run_apply_registered_pass_op(
        self,
        interpreter: Interpreter,
        op: transform.ApplyRegisteredPassOp,
        args: PythonValues,
    ) -> PythonValues:
        pass_name = op.pass_name.data
        pipeline = PassPipeline.parse_spec(self.passes, pass_name)
        pipeline.apply(self.ctx, args[0])
        return (args[0],)

    @impl_terminator(transform.YieldOp)
    def run_yield_op(
        self, interpreter: Interpreter, op: transform.YieldOp, args: PythonValues
    ) -> tuple[TerminatorValue, PythonValues]:
        return ReturnedValues(args), ()

ctx: Context = ctx instance-attribute

passes: dict[str, Callable[[], type[ModulePass]]] = available_passes instance-attribute

__init__(ctx: Context, available_passes: dict[str, Callable[[], type[ModulePass]]])

Source code in xdsl/interpreters/transform.py
24
25
26
27
28
def __init__(
    self, ctx: Context, available_passes: dict[str, Callable[[], type[ModulePass]]]
):
    self.ctx = ctx
    self.passes = available_passes

run_named_sequence_op(interpreter: Interpreter, op: transform.NamedSequenceOp, args: PythonValues) -> PythonValues

Source code in xdsl/interpreters/transform.py
30
31
32
33
34
35
36
37
@impl_callable(transform.NamedSequenceOp)
def run_named_sequence_op(
    self,
    interpreter: Interpreter,
    op: transform.NamedSequenceOp,
    args: PythonValues,
) -> PythonValues:
    return interpreter.run_ssacfg_region(op.body, args, op.sym_name.data)

run_apply_registered_pass_op(interpreter: Interpreter, op: transform.ApplyRegisteredPassOp, args: PythonValues) -> PythonValues

Source code in xdsl/interpreters/transform.py
39
40
41
42
43
44
45
46
47
48
49
@impl(transform.ApplyRegisteredPassOp)
def run_apply_registered_pass_op(
    self,
    interpreter: Interpreter,
    op: transform.ApplyRegisteredPassOp,
    args: PythonValues,
) -> PythonValues:
    pass_name = op.pass_name.data
    pipeline = PassPipeline.parse_spec(self.passes, pass_name)
    pipeline.apply(self.ctx, args[0])
    return (args[0],)

run_yield_op(interpreter: Interpreter, op: transform.YieldOp, args: PythonValues) -> tuple[TerminatorValue, PythonValues]

Source code in xdsl/interpreters/transform.py
51
52
53
54
55
@impl_terminator(transform.YieldOp)
def run_yield_op(
    self, interpreter: Interpreter, op: transform.YieldOp, args: PythonValues
) -> tuple[TerminatorValue, PythonValues]:
    return ReturnedValues(args), ()