-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
public-vm(transpiler): generate proper type tags #4268
Labels
C-avm
Component: AVM related tickets (aka public VM)
Milestone
Comments
dbanks12
changed the title
public-vm(transpiler): generate type tags
public-vm(transpiler): generate proper type tags
Feb 2, 2024
Can accomplish this without Noir limiting types/sizes by triggering a transpiler error if a BinaryIntOp/Const Blocked by #4385 |
fcarreiro
added a commit
that referenced
this issue
Feb 12, 2024
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.
michaelelliot
pushed a commit
to Swoir/noir_rs
that referenced
this issue
Feb 28, 2024
…l#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 AztecProtocol#4268.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following AVM instructions have type tags:
inTag
inTag
inTag
CAST
hasdstTag
For 1, 2, and 3, the Brillig instruction is flagged with a
bit_size
which will likely change to specify one of a few pre-known types (u8, ... u128).Brillig's
BinaryFieldOps
can be transpiled to havefield
tag.Brillig does not yet have
CAST
, but should eventually.The text was updated successfully, but these errors were encountered: