diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/mod.rs b/crates/noirc_evaluator/src/ssa/acir_gen/mod.rs index 96ff3acc426..d108a5042e7 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -993,8 +993,6 @@ impl Context { self.acir_context.bit_decompose(endian, field, bit_size, result_type) } - // TODO(#2115): Remove the println intrinsic as the oracle println is now used instead - Intrinsic::Println => Ok(Vec::new()), Intrinsic::Sort => { let inputs = vecmap(arguments, |arg| self.convert_value(*arg, dfg)); // We flatten the inputs and retrieve the bit_size of the elements diff --git a/crates/noirc_evaluator/src/ssa/ir/instruction.rs b/crates/noirc_evaluator/src/ssa/ir/instruction.rs index 8f3cd0cfe3c..6b68b0f85a4 100644 --- a/crates/noirc_evaluator/src/ssa/ir/instruction.rs +++ b/crates/noirc_evaluator/src/ssa/ir/instruction.rs @@ -41,7 +41,6 @@ pub(crate) enum Intrinsic { SliceInsert, SliceRemove, StrAsBytes, - Println, ToBits(Endian), ToRadix(Endian), BlackBox(BlackBoxFunc), @@ -50,7 +49,6 @@ pub(crate) enum Intrinsic { impl std::fmt::Display for Intrinsic { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Intrinsic::Println => write!(f, "println"), Intrinsic::Sort => write!(f, "arraysort"), Intrinsic::ArrayLen => write!(f, "array_len"), Intrinsic::AssertConstant => write!(f, "assert_constant"), @@ -76,7 +74,7 @@ impl Intrinsic { /// If there are no side effects then the `Intrinsic` can be removed if the result is unused. pub(crate) fn has_side_effects(&self) -> bool { match self { - Intrinsic::Println | Intrinsic::AssertConstant => true, + Intrinsic::AssertConstant => true, Intrinsic::Sort | Intrinsic::ArrayLen @@ -99,7 +97,6 @@ impl Intrinsic { /// If there is no such intrinsic by that name, None is returned. pub(crate) fn lookup(name: &str) -> Option { match name { - "println" => Some(Intrinsic::Println), "arraysort" => Some(Intrinsic::Sort), "array_len" => Some(Intrinsic::ArrayLen), "assert_constant" => Some(Intrinsic::AssertConstant), diff --git a/crates/noirc_evaluator/src/ssa/ir/instruction/call.rs b/crates/noirc_evaluator/src/ssa/ir/instruction/call.rs index e73ff02ba08..7eab8fc2eef 100644 --- a/crates/noirc_evaluator/src/ssa/ir/instruction/call.rs +++ b/crates/noirc_evaluator/src/ssa/ir/instruction/call.rs @@ -178,7 +178,6 @@ pub(super) fn simplify_call( } Intrinsic::BlackBox(bb_func) => simplify_black_box_func(bb_func, arguments, dfg), Intrinsic::Sort => simplify_sort(dfg, arguments), - Intrinsic::Println => SimplifyResult::None, } } diff --git a/crates/noirc_evaluator/src/ssa/opt/die.rs b/crates/noirc_evaluator/src/ssa/opt/die.rs index ee78fa82256..47b94741266 100644 --- a/crates/noirc_evaluator/src/ssa/opt/die.rs +++ b/crates/noirc_evaluator/src/ssa/opt/die.rs @@ -155,7 +155,7 @@ mod test { // v9 = add v7, Field 2 // v10 = add v7, Field 3 // v11 = add v10, v10 - // call println(v8) + // call assert_constant(v8) // return v9 // } let main_id = Id::test_new(0); @@ -187,8 +187,8 @@ mod test { let v10 = builder.insert_binary(v7, BinaryOp::Add, three); let _v11 = builder.insert_binary(v10, BinaryOp::Add, v10); - let println_id = builder.import_intrinsic_id(Intrinsic::Println); - builder.insert_call(println_id, vec![v8], vec![]); + let assert_constant_id = builder.import_intrinsic_id(Intrinsic::AssertConstant); + builder.insert_call(assert_constant_id, vec![v8], vec![]); builder.terminate_with_return(vec![v9]); let ssa = builder.finish(); @@ -210,7 +210,7 @@ mod test { // v7 = load v6 // v8 = add v7, Field 1 // v9 = add v7, Field 2 - // call println(v8) + // call assert_constant(v8) // return v9 // } let ssa = ssa.dead_instruction_elimination(); diff --git a/crates/noirc_evaluator/src/ssa/opt/flatten_cfg.rs b/crates/noirc_evaluator/src/ssa/opt/flatten_cfg.rs index 3df27868737..e99a46186e6 100644 --- a/crates/noirc_evaluator/src/ssa/opt/flatten_cfg.rs +++ b/crates/noirc_evaluator/src/ssa/opt/flatten_cfg.rs @@ -1000,8 +1000,8 @@ mod test { // will store values. Other blocks do not store values so that we can test // how these existing values are merged at each join point. // - // For debugging purposes, each block also has a call to println with two - // arguments. The first is the block the println was originally in, and the + // For debugging purposes, each block also has a call to test_function with two + // arguments. The first is the block the test_function was originally in, and the // second is the current value stored in the reference. // // b0 (0 stored) @@ -1040,54 +1040,56 @@ mod test { builder.insert_store(r1, value); }; - let println = builder.import_intrinsic_id(Intrinsic::Println); + let test_function = Id::test_new(1); - let call_println = |builder: &mut FunctionBuilder, block: u128| { + let call_test_function = |builder: &mut FunctionBuilder, block: u128| { let block = builder.field_constant(block); let load = builder.insert_load(r1, Type::field()); - builder.insert_call(println, vec![block, load], Vec::new()); + builder.insert_call(test_function, vec![block, load], Vec::new()); }; - let switch_store_and_print = |builder: &mut FunctionBuilder, block, block_number: u128| { - builder.switch_to_block(block); - store_value(builder, block_number); - call_println(builder, block_number); - }; + let switch_store_and_test_function = + |builder: &mut FunctionBuilder, block, block_number: u128| { + builder.switch_to_block(block); + store_value(builder, block_number); + call_test_function(builder, block_number); + }; - let switch_and_print = |builder: &mut FunctionBuilder, block, block_number: u128| { - builder.switch_to_block(block); - call_println(builder, block_number); - }; + let switch_and_test_function = + |builder: &mut FunctionBuilder, block, block_number: u128| { + builder.switch_to_block(block); + call_test_function(builder, block_number); + }; store_value(&mut builder, 0); - call_println(&mut builder, 0); + call_test_function(&mut builder, 0); builder.terminate_with_jmp(b1, vec![]); - switch_store_and_print(&mut builder, b1, 1); + switch_store_and_test_function(&mut builder, b1, 1); builder.terminate_with_jmpif(c1, b2, b3); - switch_store_and_print(&mut builder, b2, 2); + switch_store_and_test_function(&mut builder, b2, 2); builder.terminate_with_jmp(b4, vec![]); - switch_store_and_print(&mut builder, b3, 3); + switch_store_and_test_function(&mut builder, b3, 3); builder.terminate_with_jmp(b8, vec![]); - switch_and_print(&mut builder, b4, 4); + switch_and_test_function(&mut builder, b4, 4); builder.terminate_with_jmpif(c4, b5, b6); - switch_store_and_print(&mut builder, b5, 5); + switch_store_and_test_function(&mut builder, b5, 5); builder.terminate_with_jmp(b7, vec![]); - switch_store_and_print(&mut builder, b6, 6); + switch_store_and_test_function(&mut builder, b6, 6); builder.terminate_with_jmp(b7, vec![]); - switch_and_print(&mut builder, b7, 7); + switch_and_test_function(&mut builder, b7, 7); builder.terminate_with_jmp(b9, vec![]); - switch_and_print(&mut builder, b8, 8); + switch_and_test_function(&mut builder, b8, 8); builder.terminate_with_jmp(b9, vec![]); - switch_and_print(&mut builder, b9, 9); + switch_and_test_function(&mut builder, b9, 9); let load = builder.insert_load(r1, Type::field()); builder.terminate_with_return(vec![load]); @@ -1097,18 +1099,18 @@ mod test { // // fn main f0 { // b0(v0: u1, v1: u1): - // call println(Field 0, Field 0) - // call println(Field 1, Field 1) + // call test_function(Field 0, Field 0) + // call test_function(Field 1, Field 1) // enable_side_effects v0 - // call println(Field 2, Field 2) - // call println(Field 4, Field 2) + // call test_function(Field 2, Field 2) + // call test_function(Field 4, Field 2) // v29 = and v0, v1 // enable_side_effects v29 - // call println(Field 5, Field 5) + // call test_function(Field 5, Field 5) // v32 = not v1 // v33 = and v0, v32 // enable_side_effects v33 - // call println(Field 6, Field 6) + // call test_function(Field 6, Field 6) // enable_side_effects v0 // v36 = mul v1, Field 5 // v37 = mul v32, Field 2 @@ -1116,12 +1118,12 @@ mod test { // v39 = mul v1, Field 5 // v40 = mul v32, Field 6 // v41 = add v39, v40 - // call println(Field 7, v42) + // call test_function(Field 7, v42) // v43 = not v0 // enable_side_effects v43 // store Field 3 at v2 - // call println(Field 3, Field 3) - // call println(Field 8, Field 3) + // call test_function(Field 3, Field 3) + // call test_function(Field 8, Field 3) // enable_side_effects Field 1 // v47 = mul v0, v41 // v48 = mul v43, Field 1 @@ -1129,7 +1131,7 @@ mod test { // v50 = mul v0, v44 // v51 = mul v43, Field 3 // v52 = add v50, v51 - // call println(Field 9, v53) + // call test_function(Field 9, v53) // return v54 // } diff --git a/crates/noirc_evaluator/src/ssa/opt/inlining.rs b/crates/noirc_evaluator/src/ssa/opt/inlining.rs index cf7b5860ea6..55424f8f32f 100644 --- a/crates/noirc_evaluator/src/ssa/opt/inlining.rs +++ b/crates/noirc_evaluator/src/ssa/opt/inlining.rs @@ -721,7 +721,7 @@ mod test { // fn main f0 { // b0(v0: u1): // v2 = call f1(v0) - // call println(v2) + // call assert_constant(v2) // return // } // fn inner1 f1 { @@ -746,8 +746,8 @@ mod test { let inner1_id = Id::test_new(1); let inner1 = builder.import_function(inner1_id); let main_v2 = builder.insert_call(inner1, vec![main_cond], vec![Type::field()])[0]; - let println = builder.import_intrinsic_id(Intrinsic::Println); - builder.insert_call(println, vec![main_v2], vec![]); + let assert_constant = builder.import_intrinsic_id(Intrinsic::AssertConstant); + builder.insert_call(assert_constant, vec![main_v2], vec![]); builder.terminate_with_return(vec![]); builder.new_function("inner1".into(), inner1_id); @@ -781,7 +781,7 @@ mod test { // b1(): // jmp b3(Field 1) // b3(v3: Field): - // call println(v3) + // call assert_constant(v3) // return // b2(): // jmp b3(Field 2) diff --git a/crates/noirc_evaluator/src/ssa/opt/mem2reg.rs b/crates/noirc_evaluator/src/ssa/opt/mem2reg.rs index be0ded802b3..d83cda4a8b1 100644 --- a/crates/noirc_evaluator/src/ssa/opt/mem2reg.rs +++ b/crates/noirc_evaluator/src/ssa/opt/mem2reg.rs @@ -455,7 +455,7 @@ mod tests { let one = builder.field_constant(FieldElement::one()); builder.insert_store(v0, one); let v1 = builder.insert_load(v0, Type::field()); - let f0 = builder.import_intrinsic_id(Intrinsic::Println); + let f0 = builder.import_intrinsic_id(Intrinsic::AssertConstant); builder.insert_call(f0, vec![v0], vec![]); builder.terminate_with_return(vec![v1]);