Skip to content

Aggressive unroll

AggressiveUnroll dataclass

AggressiveUnroll(
    additional_inline_heuristic: Callable[
        [Statement], bool
    ] = lambda node: True,
)

Bases: Pass

A pass to unroll structured control flow

inline_heuristic

inline_heuristic(node: Statement) -> bool

The heuristic to decide whether to inline a function call or not. inside loops and if-else, only inline simple functions, i.e. functions with a single block

Source code in .venv/lib/python3.12/site-packages/bloqade/rewrite/passes/aggressive_unroll.py
84
85
86
87
88
89
90
91
92
93
def inline_heuristic(self, node: ir.Statement) -> bool:
    """The heuristic to decide whether to inline a function call or not.
    inside loops and if-else, only inline simple functions, i.e.
    functions with a single block
    """
    return not isinstance(
        node.parent_stmt, (scf.For, scf.IfElse)
    ) and self.additional_inline_heuristic(
        node
    )  # always inline calls outside of loops and if-else