diff --git a/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs b/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs index b5688763dae..61ad747421a 100644 --- a/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs +++ b/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs @@ -65,20 +65,6 @@ impl AcirType { pub(crate) fn unsigned(bit_size: u32) -> Self { AcirType::NumericType(NumericType::Unsigned { bit_size }) } - - /// Returns a boolean type - fn boolean() -> Self { - AcirType::NumericType(NumericType::Unsigned { bit_size: 1 }) - } - - /// True if type is signed - pub(crate) fn is_signed(&self) -> bool { - let numeric_type = match self { - AcirType::NumericType(numeric_type) => numeric_type, - AcirType::Array(_, _) => return false, - }; - matches!(numeric_type, NumericType::Signed { .. }) - } } impl From for AcirType { @@ -317,17 +303,6 @@ impl AcirContext { Ok(inverted_var) } - // Constrains `var` to be equal to the constant value `1` - pub(crate) fn assert_eq_one( - &mut self, - var: AcirVar, - assert_message: Option, - ) -> Result<(), RuntimeError> { - let one = self.add_constant(FieldElement::one()); - self.assert_eq_var(var, one, assert_message)?; - Ok(()) - } - // Constrains `var` to be equal to predicate if the predicate is true // or to be equal to 0 if the predicate is false. // @@ -557,31 +532,6 @@ impl AcirContext { self.sub_var(max, x) } - /// Returns an `AcirVar` that is constrained to be `lhs << rhs`. - /// - /// We convert left shifts to multiplications, so this is equivalent to - /// `lhs * 2^rhs`. - /// - /// We currently require `rhs` to be a constant - /// however this can be extended, see #1478. - pub(crate) fn shift_left_var( - &mut self, - lhs: AcirVar, - rhs: AcirVar, - _typ: AcirType, - ) -> Result { - let rhs_data = &self.vars[&rhs]; - - // Compute 2^{rhs} - let two_pow_rhs = match rhs_data.as_constant() { - Some(exponent) => FieldElement::from(2_i128).pow(&exponent), - None => unimplemented!("rhs must be a constant when doing a right shift"), - }; - let two_pow_rhs_var = self.add_constant(two_pow_rhs); - - self.mul_var(lhs, two_pow_rhs_var) - } - /// Returns the quotient and remainder such that lhs = rhs * quotient + remainder fn euclidean_division_var( &mut self, @@ -635,35 +585,6 @@ impl AcirContext { Ok(remainder) } - /// Returns an `AcirVar` that is constrained to be `lhs >> rhs`. - /// - /// We convert right shifts to divisions, so this is equivalent to - /// `lhs / 2^rhs`. - /// - /// We currently require `rhs` to be a constant - /// however this can be extended, see #1478. - /// - /// This code is doing a field division instead of an integer division, - /// see #1479 about how this is expected to change. - pub(crate) fn shift_right_var( - &mut self, - lhs: AcirVar, - rhs: AcirVar, - typ: AcirType, - predicate: AcirVar, - ) -> Result { - let rhs_data = &self.vars[&rhs]; - - // Compute 2^{rhs} - let two_pow_rhs = match rhs_data.as_constant() { - Some(exponent) => FieldElement::from(2_i128).pow(&exponent), - None => unimplemented!("rhs must be a constant when doing a right shift"), - }; - let two_pow_rhs_var = self.add_constant(two_pow_rhs); - - self.div_var(lhs, two_pow_rhs_var, typ, predicate) - } - /// Converts the `AcirVar` to a `Witness` if it hasn't been already, and appends it to the /// `GeneratedAcir`'s return witnesses. pub(crate) fn return_var(&mut self, acir_var: AcirVar) -> Result<(), InternalError> { @@ -897,17 +818,6 @@ impl AcirContext { self.radix_decompose(endian, input_var, two_var, limb_count_var, result_element_type) } - /// Flatten the given Vector of AcirValues into a single vector of only variables. - /// Each AcirValue::Array in the vector is recursively flattened, so each element - /// will flattened into the resulting Vec. E.g. flatten_values([1, [2, 3]) == [1, 2, 3]. - fn flatten_values(values: Vec) -> Vec { - let mut acir_vars = Vec::with_capacity(values.len()); - for value in values { - Self::flatten_value(&mut acir_vars, value); - } - acir_vars - } - /// Recursive helper for flatten_values to flatten a single AcirValue into the result vector. pub(crate) fn flatten_value(acir_vars: &mut Vec, value: AcirValue) { match value { diff --git a/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs b/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs index 0adb14246b7..6e019d01c44 100644 --- a/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs +++ b/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs @@ -581,10 +581,6 @@ impl GeneratedAcir { num_bits::() as u32 - a.leading_zeros() } - fn bit_size_u32(a: u32) -> u32 where { - num_bits::() as u32 - a.leading_zeros() - } - assert!( bits < FieldElement::max_num_bits(), "range check with bit size of the prime field is not implemented yet" @@ -624,21 +620,6 @@ impl GeneratedAcir { Ok(()) } - /// Computes the expression x(x-1) - /// - /// If the above is constrained to zero, then it can only be - /// true, iff x equals zero or one. - fn boolean_expr(&mut self, expr: &Expression) -> Expression { - let expr_as_witness = self.create_witness_for_expression(expr); - let mut expr_squared = Expression::default(); - expr_squared.push_multiplication_term( - FieldElement::one(), - expr_as_witness, - expr_as_witness, - ); - &expr_squared - expr - } - /// Adds an inversion brillig opcode. /// /// This code will invert `expr` without applying constraints diff --git a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs index 6316b25c09d..0f238bd2858 100644 --- a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -1657,15 +1657,6 @@ impl Context { acir_vars } - fn bit_count(&self, lhs: ValueId, dfg: &DataFlowGraph) -> u32 { - match dfg.type_of_value(lhs) { - Type::Numeric(NumericType::Signed { bit_size }) => bit_size, - Type::Numeric(NumericType::Unsigned { bit_size }) => bit_size, - Type::Numeric(NumericType::NativeField) => FieldElement::max_num_bits(), - _ => 0, - } - } - /// Convert a Vec into a Vec using the given result ids. /// If the type of a result id is an array, several acir vars are collected into /// a single AcirValue::Array of the same length. @@ -1706,13 +1697,6 @@ impl Context { } } } - - /// Creates a default, meaningless value meant only to be a valid value of the given type. - fn create_default_value(&mut self, param_type: &Type) -> Result { - self.create_value_from_type(param_type, &mut |this, _| { - Ok(this.acir_context.add_constant(FieldElement::zero())) - }) - } } #[cfg(test)] diff --git a/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs b/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs index 961ff8cc33e..3489cd271ed 100644 --- a/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs @@ -342,11 +342,6 @@ impl FunctionBuilder { pub(crate) fn import_intrinsic_id(&mut self, intrinsic: Intrinsic) -> ValueId { self.current_function.dfg.import_intrinsic(intrinsic) } - - /// Removes the given instruction from the current block or panics otherwise. - pub(crate) fn remove_instruction_from_current_block(&mut self, instruction: InstructionId) { - self.current_function.dfg[self.current_block].remove_instruction(instruction); - } } impl std::ops::Index for FunctionBuilder { diff --git a/compiler/noirc_evaluator/src/ssa/ir/basic_block.rs b/compiler/noirc_evaluator/src/ssa/ir/basic_block.rs index 998591f7210..9ca73bea762 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/basic_block.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/basic_block.rs @@ -145,13 +145,4 @@ impl BasicBlock { None => vec![].into_iter(), } } - - /// Removes the given instruction from this block if present or panics otherwise. - pub(crate) fn remove_instruction(&mut self, instruction: InstructionId) { - let index = - self.instructions.iter().position(|id| *id == instruction).unwrap_or_else(|| { - panic!("remove_instruction: No such instruction {instruction:?} in block") - }); - self.instructions.remove(index); - } } diff --git a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs index 242278bd581..3cb6736007d 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs @@ -4,7 +4,7 @@ use crate::ssa::ir::instruction::SimplifyResult; use super::{ basic_block::{BasicBlock, BasicBlockId}, - function::{FunctionId, Signature}, + function::FunctionId, instruction::{ Instruction, InstructionId, InstructionResultType, Intrinsic, TerminatorInstruction, }, @@ -61,9 +61,6 @@ pub(crate) struct DataFlowGraph { /// represented by only 1 ValueId within this function. foreign_functions: HashMap, - /// Function signatures of external methods - signatures: DenseMap, - /// All blocks in a function blocks: DenseMap,