Skip to content

Migrate passes to use the new PassScope #2771

@aborgna-q

Description

@aborgna-q

See #2772

/// Set the scope configuration used to run the pass.
///
/// See [`PassScope`] for more details.
///
/// In `hugr 0.25.*`, this configuration is only a guidance, and may be
/// ignored by the pass.
///
/// From `hugr >=0.26.0`, passes must respect the scope configuration.
fn ComposablePass::with_scope_internal(self, scope: &PassScope) -> Self;

(#2921 will change the location of this method)

  • feat: update passes to use PassScope where non-breaking #2836 - generally keeping old configurators with proviso that these and with_scope_internal override previous calls to the other.

    • ConstantFoldPass - store Option<PassScope> so that None retains the old behaviour (entrypoint-subtree even if entrypoint is module-root, as PassScope::Entrypoint would do nothing in latter case).
      • Also retain with_inputs; deprecate constant_fold_pass (which preserved all functions).
    • DeadCodeElimPass - similar Option<PassScope>
      • retain with_entry_points.
    • NormalizeCFGPass - store Either<Vec<N>, PassScope>
      • deprecate fn cfgs -> &mut Vec.
    • RemoveDeadFuncsPass - store Either<Vec<Node>, PassScope>
      • deprecate ...with_module_entry_points and remove_dead_funcs.
    • ReplaceTypes - switch Option<Vec<Node>> to Either<PassScope, Vec<Node>> as the old None roughly corresponds to a default PassScope::Global.
      • deprecate set_regions.
      • Note that as a lowering pass, this generally ignores preserve.
    • UntuplePass: store Either<PassScope, (UntupleRecursive, Option<Node>)>
      • deprecate new, set_parent, recursive and UntupleRecursive.
    • Also deprecate fn monomorphize
  • breaking change required: feat!: Update remainder of passes to use PassScope, drop default with_scope #2871

    • InlineDFGsPass: struct stores a PassScope. This changes InlineDFGsPass to InlineDFGsPass::default() which has the same behaviour (preserves the entrypoint; also any functions but they aren't DFGs)
    • MonomorphizePass similarly
    • LocalizeEdges similarly, plus some refactoring/moving of toplevel methods
    • RedundantOrderEdgesPass: scorched earth move from recursive:bool beneath entrypoint to PassScope as cannot make nonbreaking due to derivation of Copy
  • tket passes: feat!: Follow pass scopes in composable passes tket2#1429

    • ModifierResolverPass
    • BorrowSquashPass
    • NormalizeGuppy
    • LowerDropsPass
    • ReplaceBoolPass
    • LowerTketToQSystemPass
    • ReplaceStaticArrayBoolPass

Metadata

Metadata

Labels

C-tracking-issueAn issue/PR that collects information about a broad development initiative

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions