Skip to content

bloqade.rewrite.passes.callgraph.CallGraphPass

← Module overview

classCallGraphPasssource

bloqade.rewrite.passes.callgraph.CallGraphPass

Bases: passes.Pass

Copy all functions in the call graph and apply a rule to each of them.

Signature
class CallGraphPass(rule: RewriteRule | None = None, rule_factory: Callable[[ir.Method, CallGraph], RewriteRule] | None = None)

Note: This pass modifies the input method in place, but copies all methods invoked within it before applying the rule to them.

Usage

rule = Walk(SomeRewriteRule()) pass_ = CallGraphPass(rule=rule, dialects=…) pass_(some_method)

or, when the rule needs per-method context:

Section titled “or, when the rule needs per-method context:”

pass_ = CallGraphPass( rule_factory=lambda callee, call_graph: Walk(MyRule(callee, call_graph)), dialects=…, )

Parameters

NameTypeDefaultDescription
ruleRewriteRule | NoneNone
rule_factoryCallable[[ir.Method, CallGraph], RewriteRule] | NoneNone

Attributes

NameTypeDefaultDescription
ruleRewriteRule | NoneNoneThe rule to apply to each function in the call graph.
rule_factoryCallable[[ir.Method, CallGraph], RewriteRule] | NoneNoneBuild a per-method rule from the callee and call graph. Mutually exclusive with ``rule``.
fold_passpasses.Foldfield(init=False)

methodunsafe_runsource

bloqade.rewrite.passes.callgraph.CallGraphPass.unsafe_run

def unsafe_run(mt: ir.Method) -> RewriteResult

Parameters

NameTypeDescription
mtir.Method

Returns

RewriteResult

source