Skip to content

Passes

passes

AvailablePass

Bases: NamedTuple

Type alias for the attributes that describe a pass, namely the display name of the pass, the module pass and pass spec.

Source code in xdsl/interactive/passes.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class AvailablePass(NamedTuple):
    """
    Type alias for the attributes that describe a pass, namely the display name of the
    pass, the module pass and pass spec.
    """

    module_pass: type[ModulePass] | ModulePass

    def __str__(self) -> str:
        module_pass = self.module_pass
        if isinstance(module_pass, ModulePass):
            return str(module_pass.pipeline_pass_spec())
        else:
            return module_pass.name

module_pass: type[ModulePass] | ModulePass instance-attribute

__str__() -> str

Source code in xdsl/interactive/passes.py
19
20
21
22
23
24
def __str__(self) -> str:
    module_pass = self.module_pass
    if isinstance(module_pass, ModulePass):
        return str(module_pass.pipeline_pass_spec())
    else:
        return module_pass.name

get_new_registered_context(all_dialects: tuple[tuple[str, Callable[[], Dialect]], ...]) -> Context

Generates a new Context, registers it and returns it.

Source code in xdsl/interactive/passes.py
27
28
29
30
31
32
33
34
35
36
def get_new_registered_context(
    all_dialects: tuple[tuple[str, Callable[[], Dialect]], ...],
) -> Context:
    """
    Generates a new Context, registers it and returns it.
    """
    ctx = Context(True)
    for dialect_name, dialect_factory in all_dialects:
        ctx.register_dialect(dialect_name, dialect_factory)
    return ctx

iter_condensed_passes(ctx: Context, input: builtin.ModuleOp, all_passes: tuple[tuple[str, type[ModulePass]], ...])

Source code in xdsl/interactive/passes.py
39
40
41
42
43
44
45
46
47
48
49
50
def iter_condensed_passes(
    ctx: Context,
    input: builtin.ModuleOp,
    all_passes: tuple[tuple[str, type[ModulePass]], ...],
):
    for _, pass_type in all_passes:
        if pass_type is MLIROptPass:
            # Always keep MLIROptPass as an option in condensed list
            yield AvailablePass(pass_type)
            continue
        for p in pass_type.schedule_space(ctx, input):
            yield AvailablePass(p)

get_condensed_pass_list(ctx: Context, input: builtin.ModuleOp, all_passes: tuple[tuple[str, type[ModulePass]], ...]) -> tuple[AvailablePass, ...]

Function that returns the condensed pass list for a given ModuleOp, i.e. the passes that change the ModuleOp.

Source code in xdsl/interactive/passes.py
53
54
55
56
57
58
59
60
61
62
def get_condensed_pass_list(
    ctx: Context,
    input: builtin.ModuleOp,
    all_passes: tuple[tuple[str, type[ModulePass]], ...],
) -> tuple[AvailablePass, ...]:
    """
    Function that returns the condensed pass list for a given ModuleOp, i.e. the passes that
    change the ModuleOp.
    """
    return tuple(iter_condensed_passes(ctx, input, all_passes))