Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
shak58 committed Aug 18, 2024
1 parent 7e8e053 commit 0586062
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 20 deletions.
8 changes: 4 additions & 4 deletions acvm-repo/acir/tests/test_program_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::collections::BTreeSet;
use acir::{
circuit::{
brillig::{BrilligBytecode, BrilligFunctionId, BrilligInputs, BrilligOutputs},
opcodes::{BlackBoxFuncCall, BlockId, FunctionInput, MemOp},
opcodes::{AcirFunctionId, BlackBoxFuncCall, BlockId, FunctionInput, MemOp},
Circuit, Opcode, Program, PublicInputs,
},
native_types::{Expression, Witness},
Expand Down Expand Up @@ -381,13 +381,13 @@ fn nested_acir_call_circuit() {
// x
// }
let nested_call = Opcode::Call {
id: 1,
id: AcirFunctionId(1),
inputs: vec![Witness(0), Witness(1)],
outputs: vec![Witness(2)],
predicate: None,
};
let nested_call_two = Opcode::Call {
id: 1,
id: AcirFunctionId(1),
inputs: vec![Witness(0), Witness(1)],
outputs: vec![Witness(3)],
predicate: None,
Expand Down Expand Up @@ -419,7 +419,7 @@ fn nested_acir_call_circuit() {
q_c: FieldElement::one() + FieldElement::one(),
});
let call = Opcode::Call {
id: 2,
id: AcirFunctionId(2),
inputs: vec![Witness(2), Witness(1)],
outputs: vec![Witness(3)],
predicate: None,
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm/src/pwg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use acir::{
brillig::ForeignCallResult,
circuit::{
brillig::{BrilligBytecode, BrilligFunctionId},
opcodes::{function_id::AcirFunctionId, BlockId, ConstantOrWitnessEnum, FunctionInput},
opcodes::{AcirFunctionId, BlockId, ConstantOrWitnessEnum, FunctionInput},
AssertionPayload, ErrorSelector, ExpressionOrMemory, Opcode, OpcodeLocation,
RawAssertionPayload, ResolvedAssertionPayload, STRING_ERROR_SELECTOR,
},
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acvm_js/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl<'a, B: BlackBoxFunctionSolver<FieldElement>> ProgramExecutor<'a, B> {
acvm.resolve_pending_foreign_call(result);
}
ACVMStatus::RequiresAcirCall(call_info) => {
let acir_to_call = &self.functions[call_info.id as usize];
let acir_to_call = &self.functions[call_info.id.as_usize()];
let initial_witness = call_info.initial_witness;
let call_solved_witness = self
.execute_circuit(acir_to_call, initial_witness, witness_stack)
Expand All @@ -267,7 +267,7 @@ impl<'a, B: BlackBoxFunctionSolver<FieldElement>> ProgramExecutor<'a, B> {
}
}
acvm.resolve_pending_acir_call(call_resolved_outputs);
witness_stack.push(call_info.id, call_solved_witness.clone());
witness_stack.push(call_info.id.0, call_solved_witness.clone());
}
}
}
Expand Down
55 changes: 44 additions & 11 deletions compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ use crate::brillig::brillig_ir::BrilligContext;
use crate::brillig::{brillig_gen::brillig_fn::FunctionContext as BrilligFunctionContext, Brillig};
use crate::errors::{InternalError, InternalWarning, RuntimeError, SsaReport};
pub(crate) use acir_ir::generated_acir::GeneratedAcir;
use acvm::acir::circuit::opcodes::BlockType;
use acvm::acir::circuit::opcodes::{AcirFunctionId, BlockType};
use noirc_frontend::monomorphization::ast::InlineType;

use acvm::acir::circuit::brillig::{BrilligBytecode, BrilligFunctionId};
use acvm::acir::circuit::opcodes::function_id::AcirFunctionId;
use acvm::acir::circuit::{AssertionPayload, ErrorSelector, ExpressionWidth, OpcodeLocation};
use acvm::acir::native_types::Witness;
use acvm::acir::BlackBoxFunc;
Expand Down Expand Up @@ -2868,9 +2867,13 @@ fn can_omit_element_sizes_array(array_typ: &Type) -> bool {

#[cfg(test)]
mod test {

use acvm::{
acir::{
circuit::{brillig::BrilligFunctionId, ExpressionWidth, Opcode, OpcodeLocation},
circuit::{
brillig::BrilligFunctionId, opcodes::AcirFunctionId, ExpressionWidth, Opcode,
OpcodeLocation,
},
native_types::Witness,
},
FieldElement,
Expand Down Expand Up @@ -3021,8 +3024,18 @@ mod test {
let main_opcodes = main_acir.opcodes();
assert_eq!(main_opcodes.len(), 3, "Should have two calls to `foo`");

check_call_opcode(&main_opcodes[0], 1, vec![Witness(0), Witness(1)], vec![Witness(2)]);
check_call_opcode(&main_opcodes[1], 1, vec![Witness(0), Witness(1)], vec![Witness(3)]);
check_call_opcode(
&main_opcodes[0],
AcirFunctionId(1),
vec![Witness(0), Witness(1)],
vec![Witness(2)],
);
check_call_opcode(
&main_opcodes[1],
AcirFunctionId(1),
vec![Witness(0), Witness(1)],
vec![Witness(3)],
);

if let Opcode::AssertZero(expr) = &main_opcodes[2] {
assert_eq!(expr.linear_combinations[0].0, FieldElement::from(1u128));
Expand Down Expand Up @@ -3077,9 +3090,19 @@ mod test {
let main_opcodes = main_acir.opcodes();
assert_eq!(main_opcodes.len(), 3, "Should have two calls to `foo` and an assert");

check_call_opcode(&main_opcodes[0], 1, vec![Witness(0), Witness(1)], vec![Witness(2)]);
check_call_opcode(
&main_opcodes[0],
AcirFunctionId(1),
vec![Witness(0), Witness(1)],
vec![Witness(2)],
);
// The output of the first call should be the input of the second call
check_call_opcode(&main_opcodes[1], 1, vec![Witness(2), Witness(1)], vec![Witness(3)]);
check_call_opcode(
&main_opcodes[1],
AcirFunctionId(1),
vec![Witness(2), Witness(1)],
vec![Witness(3)],
);
}

fn basic_nested_call(inline_type: InlineType) {
Expand Down Expand Up @@ -3168,9 +3191,19 @@ mod test {
assert_eq!(main_opcodes.len(), 3, "Should have two calls to `foo` and an assert");

// Both of these should call func_with_nested_foo_call f1
check_call_opcode(&main_opcodes[0], 1, vec![Witness(0), Witness(1)], vec![Witness(2)]);
check_call_opcode(
&main_opcodes[0],
AcirFunctionId(1),
vec![Witness(0), Witness(1)],
vec![Witness(2)],
);
// The output of the first call should be the input of the second call
check_call_opcode(&main_opcodes[1], 1, vec![Witness(0), Witness(1)], vec![Witness(3)]);
check_call_opcode(
&main_opcodes[1],
AcirFunctionId(1),
vec![Witness(0), Witness(1)],
vec![Witness(3)],
);

let func_with_nested_call_acir = &acir_functions[1];
let func_with_nested_call_opcodes = func_with_nested_call_acir.opcodes();
Expand All @@ -3183,15 +3216,15 @@ mod test {
// Should call foo f2
check_call_opcode(
&func_with_nested_call_opcodes[1],
2,
AcirFunctionId(2),
vec![Witness(3), Witness(1)],
vec![Witness(4)],
);
}

fn check_call_opcode(
opcode: &Opcode<FieldElement>,
expected_id: u32,
expected_id: AcirFunctionId,
expected_inputs: Vec<Witness>,
expected_outputs: Vec<Witness>,
) {
Expand Down
9 changes: 7 additions & 2 deletions tooling/debugger/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ mod tests {
brillig::IntegerBitSize,
circuit::{
brillig::{BrilligFunctionId, BrilligInputs, BrilligOutputs},
opcodes::{BlockId, BlockType},
opcodes::{AcirFunctionId, BlockId, BlockType},
},
native_types::Expression,
AcirField,
Expand Down Expand Up @@ -1210,7 +1210,12 @@ mod tests {
outputs: vec![],
predicate: None,
},
Opcode::Call { id: 1, inputs: vec![], outputs: vec![], predicate: None },
Opcode::Call {
id: AcirFunctionId(1),
inputs: vec![],
outputs: vec![],
predicate: None,
},
Opcode::AssertZero(Expression::default()),
],
..Circuit::default()
Expand Down

0 comments on commit 0586062

Please sign in to comment.