Skip to content

Commit

Permalink
feat(ssa refactor): Implement dominator tree (#1278)
Browse files Browse the repository at this point in the history
* feat(ssa refactor): dominator tree

* reorder functions

* chore(ssa refactor): use true post order

* chore(ssa refactor): externalise PostOrder

* chore(ssa refactor):  use FunctionBuilder in tests

* chore(ssa refactor): add header comments

* chore(ssa refactor): clippy

* chore(ssa refactor): elaborate header comments

* chore(ssa refactor): domtree/post-order cleanup:
- Comment tweaks
- rm unneeded collect iter into vec
- clippy changes
- DominatorTree::with_function helper
- rename DomNode DominatorTreeNode

* chore(ssa refactor): use domtree helper in tests

* fix: update usage of cfg.pred_iter to cfg.predecessors

* chore(saa refactor): tidy up test and naming
  • Loading branch information
joss-aztec authored May 3, 2023
1 parent f144391 commit 144ebf5
Show file tree
Hide file tree
Showing 5 changed files with 602 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crates/noirc_evaluator/src/ssa_refactor/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ pub(crate) mod basic_block;
pub(crate) mod cfg;
pub(crate) mod constant;
pub(crate) mod dfg;
pub(crate) mod dom;
pub(crate) mod function;
pub(crate) mod instruction;
pub(crate) mod map;
pub(crate) mod post_order;
pub(crate) mod printer;
pub(crate) mod types;
pub(crate) mod value;
4 changes: 3 additions & 1 deletion crates/noirc_evaluator/src/ssa_refactor/ir/basic_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ impl BasicBlock {
/// Iterate over all the successors of the currently block, as determined by
/// the blocks jumped to in the terminator instruction. If there is no terminator
/// instruction yet, this will iterate 0 times.
pub(crate) fn successors(&self) -> impl ExactSizeIterator<Item = BasicBlockId> {
pub(crate) fn successors(
&self,
) -> impl ExactSizeIterator<Item = BasicBlockId> + DoubleEndedIterator {
match &self.terminator {
Some(TerminatorInstruction::Jmp { destination, .. }) => vec![*destination].into_iter(),
Some(TerminatorInstruction::JmpIf { then_destination, else_destination, .. }) => {
Expand Down
Loading

0 comments on commit 144ebf5

Please sign in to comment.