diff --git a/crates/noirc_evaluator/src/lib.rs b/crates/noirc_evaluator/src/lib.rs index 8dcc25a9866..b044c70570a 100644 --- a/crates/noirc_evaluator/src/lib.rs +++ b/crates/noirc_evaluator/src/lib.rs @@ -73,12 +73,7 @@ pub fn create_circuit( let mut evaluator = Evaluator::default(); // First evaluate the main function - evaluator.evaluate_main_alt( - program.clone(), - is_opcode_supported, - enable_logging, - show_output, - )?; + evaluator.evaluate_main_alt(program.clone(), enable_logging, show_output)?; let Evaluator { current_witness_index, @@ -152,7 +147,6 @@ impl Evaluator { pub fn evaluate_main_alt( &mut self, program: Program, - is_opcode_supported: IsOpcodeSupported, enable_logging: bool, show_output: bool, ) -> Result<(), RuntimeError> { @@ -165,7 +159,7 @@ impl Evaluator { ir_gen.ssa_gen_main()?; //Generates ACIR representation: - ir_gen.context.ir_to_acir(self, is_opcode_supported, enable_logging, show_output)?; + ir_gen.context.ir_to_acir(self, enable_logging, show_output)?; Ok(()) } diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index 277eb54d356..22b5390e2fa 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -13,7 +13,6 @@ use acvm::acir::native_types::{Expression, Witness}; mod operations; mod internal_var; -use acvm::compiler::transformers::IsOpcodeSupported; pub(crate) use internal_var::InternalVar; mod constraints; mod internal_var_cache; @@ -36,7 +35,6 @@ impl Acir { evaluator: &mut Evaluator, ctx: &SsaContext, root: &BasicBlock, - is_opcode_supported: IsOpcodeSupported, show_output: bool, ) -> Result<(), RuntimeError> { let mut current_block = Some(root); @@ -48,7 +46,7 @@ impl Acir { //TODO we should rather follow the jumps current_block = block.left.map(|block_id| &ctx[block_id]); } - self.memory.acir_gen(evaluator, is_opcode_supported, ctx); + self.memory.acir_gen(evaluator, ctx); Ok(()) } diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/acir_mem.rs b/crates/noirc_evaluator/src/ssa/acir_gen/acir_mem.rs index 14f084bc947..397e19c82f6 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/acir_mem.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/acir_mem.rs @@ -389,15 +389,19 @@ impl AcirMem { let item = MemOp { operation: op, value, index }; self.array_heap_mut(*array_id).push(item); } - pub(crate) fn acir_gen( - &self, - evaluator: &mut Evaluator, - is_opcode_supported: IsOpcodeSupported, - ctx: &SsaContext, - ) { + pub(crate) fn acir_gen(&self, evaluator: &mut Evaluator, ctx: &SsaContext) { + //Temporary hack - We hardcode Barretenberg support here. + //TODO: to remove once opcodesupported usage is clarified + let is_opcode_supported: OpcodeSupported = |o| match o { + AcirOpcode::Block(_) => false, + AcirOpcode::ROM(_) | AcirOpcode::RAM(_) => true, + _ => unreachable!(), + }; for mem in &self.virtual_memory { let array = &ctx.mem[*mem.0]; mem.1.acir_gen(evaluator, array.id, array.len, is_opcode_supported); } } } + +type OpcodeSupported = fn(&AcirOpcode) -> bool; diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 327ffc2b222..2efdd8ff304 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -12,7 +12,6 @@ use crate::ssa::{ {block, builtin, flatten, function, inline, integer, node, optimizations}, }; use crate::Evaluator; -use acvm::compiler::transformers::IsOpcodeSupported; use acvm::FieldElement; use iter_extended::vecmap; use noirc_errors::Location; @@ -702,7 +701,6 @@ impl SsaContext { pub(crate) fn ir_to_acir( &mut self, evaluator: &mut Evaluator, - is_opcode_supported: IsOpcodeSupported, enable_logging: bool, show_output: bool, ) -> Result<(), RuntimeError> { @@ -749,7 +747,7 @@ impl SsaContext { self.log(enable_logging, "\noverflow:", ""); //ACIR let mut acir = Acir::default(); - acir.acir_gen(evaluator, self, &self[self.first_block], is_opcode_supported, show_output)?; + acir.acir_gen(evaluator, self, &self[self.first_block], show_output)?; if enable_logging { print_acir_circuit(&evaluator.opcodes); println!("DONE");