NormalizeGuppy

class tket.passes.NormalizeGuppy(simplify_cfgs=True, remove_tuple_untuple=True, constant_folding=True, remove_dead_funcs=True, inline_dfgs=True, remove_redundant_order_edges=True, squash_borrows=True)[source]

Bases: ComposablePass

__call__(hugr, *, inplace=True)

Call the pass to transform a HUGR, returning a Hugr.

Return type:

Hugr

__init__(simplify_cfgs=True, remove_tuple_untuple=True, constant_folding=True, remove_dead_funcs=True, inline_dfgs=True, remove_redundant_order_edges=True, squash_borrows=True)
constant_folding: bool = True
inline_dfgs: bool = True
property name: str

Returns the name of the pass.

remove_dead_funcs: bool = True
remove_redundant_order_edges: bool = True
remove_tuple_untuple: bool = True
run(hugr, *, inplace=True)[source]

Run the pass to transform a HUGR, returning a PassResult.

See implement_pass_run() for a helper function to implement this method.

Return type:

PassResult

simplify_cfgs: bool = True
squash_borrows: bool = True

Flatten the structure of a Guppy-generated program to enable additional optimisations.

This should normally be called first before other optimisations.

Parameters: - simplify_cfgs: Whether to simplify CFG control flow. - remove_tuple_untuple: Whether to remove tuple/untuple operations. - constant_folding: Whether to constant fold the program. - remove_dead_funcs: Whether to remove dead functions. - inline_dfgs: Whether to inline DFG operations. - remove_redundant_order_edges: Whether to remove redundant order edges. - squash_borrows: Whether to squash return-borrow pairs on BorrowArrays.

then(other)

Perform another composable pass after this pass.

Return type:

ComposablePass

with_scope(_scope)[source]

Set the scope of this pass and return self.

Return type:

ComposablePass