Skip to content

Commit

Permalink
chore(ssa refactor): cfg - merge related fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joss-aztec committed Apr 25, 2023
1 parent 69189bc commit 169c491
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
12 changes: 0 additions & 12 deletions crates/noirc_evaluator/src/ssa_refactor/ir/basic_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ pub(crate) struct BasicBlock {
terminator: Option<TerminatorInstruction>,
}

impl BasicBlock {
/// Gets a reference to basic block's terminator instruction.
///
/// This accessor should not be used during basic block construction, at which time the
/// terminator may be as of yet unassigned.
pub(crate) fn terminator(&self) -> &TerminatorInstruction {
self.terminator
.as_ref()
.expect("ICE: Tried to get terminator before basic block construction had finished.")
}
}

/// An identifier for a Basic Block.
pub(crate) type BasicBlockId = Id<BasicBlock>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use super::{
/// arguments are the branch instruction that is used to reach the successor,
/// and the id of the successor block itself.
pub(crate) fn visit_block_succs<F: FnMut(BasicBlockId)>(basic_block: &BasicBlock, mut visit: F) {
match basic_block.terminator() {
match basic_block
.terminator()
.expect("ICE: No terminator indicates block is still under construction.")
{
TerminatorInstruction::Jmp { destination, .. } => visit(*destination),
TerminatorInstruction::JmpIf { then_destination, else_destination, .. } => {
visit(*then_destination);
Expand Down
12 changes: 1 addition & 11 deletions crates/noirc_evaluator/src/ssa_refactor/ir/dfg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::ops::{Index, IndexMut};

use super::{
basic_block::{BasicBlock, BasicBlockId},
constant::{NumericConstant, NumericConstantId},
Expand Down Expand Up @@ -249,15 +247,7 @@ impl std::ops::Index<BasicBlockId> for DataFlowGraph {
}
}

impl Index<BasicBlockId> for DataFlowGraph {
type Output = BasicBlock;
/// Get a reference to a function's basic block for the given id.
fn index(&self, id: BasicBlockId) -> &BasicBlock {
&self.blocks[id]
}
}

impl IndexMut<BasicBlockId> for DataFlowGraph {
impl std::ops::IndexMut<BasicBlockId> for DataFlowGraph {
/// Get a mutable reference to a function's basic block for the given id.
fn index_mut(&mut self, id: BasicBlockId) -> &mut BasicBlock {
&mut self.blocks[id]
Expand Down

0 comments on commit 169c491

Please sign in to comment.