Skip to content

Commit

Permalink
Merge ca32afe into 5f730e8
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh authored Nov 19, 2024
2 parents 5f730e8 + ca32afe commit 0a3f9ff
Show file tree
Hide file tree
Showing 9 changed files with 1,059 additions and 339 deletions.
19 changes: 19 additions & 0 deletions compiler/noirc_evaluator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,22 @@ pub(crate) fn trim_leading_whitespace_from_lines(src: &str) -> String {
}
result
}

/// Trim comments from the lines, ie. content starting with `//`.
#[cfg(test)]
pub(crate) fn trim_comments_from_lines(src: &str) -> String {
let mut result = String::new();
let mut first = true;
for line in src.lines() {
if !first {
result.push('\n');
}
if let Some(comment) = line.find("//") {
result.push_str(line[..comment].trim_end());
} else {
result.push_str(line);
}
first = false;
}
result
}
8 changes: 8 additions & 0 deletions compiler/noirc_evaluator/src/ssa/ir/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ impl RuntimeType {
| RuntimeType::Brillig(InlineType::NoPredicates)
)
}

pub(crate) fn is_brillig(&self) -> bool {
matches!(self, RuntimeType::Brillig(_))
}

pub(crate) fn is_acir(&self) -> bool {
matches!(self, RuntimeType::Acir(_))
}
}

/// A function holds a list of instructions.
Expand Down
1 change: 1 addition & 0 deletions compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl<'f> FunctionInserter<'f> {
}
}

/// Get an instruction and make sure all the values in it are freshly resolved.
pub(crate) fn map_instruction(&mut self, id: InstructionId) -> (Instruction, CallStack) {
(
self.function.dfg[id].clone().map_values(|id| self.resolve(id)),
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/ssa/ir/post_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl PostOrder {
}

impl PostOrder {
/// Allocate and compute a function's block post-order. Pos
/// Allocate and compute a function's block post-order.
pub(crate) fn with_function(func: &Function) -> Self {
PostOrder(Self::compute_post_order(func))
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/noirc_evaluator/src/ssa/opt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ pub(crate) fn assert_normalized_ssa_equals(mut ssa: super::Ssa, expected: &str)
panic!("`expected` argument of `assert_ssa_equals` is not valid SSA:\n{:?}", err);
}

use crate::{ssa::Ssa, trim_leading_whitespace_from_lines};
use crate::{ssa::Ssa, trim_comments_from_lines, trim_leading_whitespace_from_lines};

ssa.normalize_ids();

let ssa = ssa.to_string();
let ssa = trim_leading_whitespace_from_lines(&ssa);
let expected = trim_leading_whitespace_from_lines(expected);
let expected = trim_comments_from_lines(&expected);

if ssa != expected {
println!("Expected:\n~~~\n{expected}\n~~~\nGot:\n~~~\n{ssa}\n~~~");
Expand Down
Loading

0 comments on commit 0a3f9ff

Please sign in to comment.