Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(avm-transpiler): implement tags for SET and others (#4545)
Generates tags for * `BinaryFieldOp` * `BinaryIntOp` * `Const` (SET on the AVM) * CAST on the AVM Gotcha (1): Brillig seems to only support fields of <= 126 bits. We now support CONST of a field (Brillig) and transpile it to a `SET<u128>` + `CAST<field>`. It's very difficult to test this e2e in the `avm_test` contract since Noir does a lot of optimizations. Moreover, Noir currently generates code that compares different bit sizes and uses unsupported bit sizes. As an example ``` #[aztec(public-vm)] fn setOpcodeUint64() -> pub u64 { 1 << 60 as u64 } ``` produces (using `nargo compile --package avm_test_contract --show-ssa --print-acir`) ``` Compiled ACIR for AvmTest::avm_setOpcodeUint64 (unoptimized): current witness index : 0 public parameters indices : [] return value indices : [0] BRILLIG: inputs: [] outputs: [Simple(Witness(0))] [Const { destination: MemoryAddress(0), bit_size: 32, value: Value { inner: 1025 } }, CalldataCopy { destination_address: MemoryAddress(1024), size: 0, offset: 0 }, Call { location: 5 }, Mov { destination: MemoryAddress(1024), source: MemoryAddress(2) }, Stop { return_data_offset: 1024, return_data_size: 1 }, Const { destination: MemoryAddress(2), bit_size: 64, value: Value { inner: 2⁶⁰ } }, Mov { destination: MemoryAddress(3), source: MemoryAddress(2) }, Mov { destination: MemoryAddress(2), source: MemoryAddress(3) }, Return] Initial SSA: brillig fn avm_setOpcodeUint64 f0 { b0(): call f1() return u64 2⁶⁰ } ... After Dead Instruction Elimination: brillig fn avm_setOpcodeUint64 f0 { b0(): return u64 2⁶⁰ } ``` Closes #4268.
- Loading branch information