-
Notifications
You must be signed in to change notification settings - Fork 614
feat(aztec-nr): initial work for aztec public vm macro #4400
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,9 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec<u8> { | |
| // TODO(4268): set in_tag to `field` | ||
| avm_instrs.push(AvmInstruction { | ||
| opcode: avm_opcode, | ||
| indirect: Some(0), | ||
| // TEMPORARY - instruction set currently expects this | ||
| dst_tag: Some(AvmTypeTag::UINT32), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Start this comment with |
||
| operands: vec![ | ||
| AvmOperand::U32 { | ||
| value: lhs.to_usize() as u32, | ||
|
|
@@ -80,6 +83,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec<u8> { | |
| // TODO(4268): support u8..u128 and use in_tag | ||
| avm_instrs.push(AvmInstruction { | ||
| opcode: avm_opcode, | ||
| indirect: Some(0), | ||
| operands: vec![ | ||
| AvmOperand::U32 { | ||
| value: lhs.to_usize() as u32, | ||
|
|
@@ -97,6 +101,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec<u8> { | |
| BrilligOpcode::CalldataCopy { destination_address, size, offset } => { | ||
| avm_instrs.push(AvmInstruction { | ||
| opcode: AvmOpcode::CALLDATACOPY, | ||
| indirect: Some(0), | ||
| operands: vec![ | ||
| AvmOperand::U32 { | ||
| value: *offset as u32, // cdOffset (calldata offset) | ||
|
|
@@ -125,6 +130,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec<u8> { | |
| let avm_loc = brillig_pcs_to_avm_pcs[*location]; | ||
| avm_instrs.push(AvmInstruction { | ||
| opcode: AvmOpcode::JUMPI, | ||
| indirect: Some(0), | ||
| operands: vec![ | ||
| AvmOperand::U32 { | ||
| value: avm_loc as u32, | ||
|
|
@@ -139,12 +145,15 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec<u8> { | |
| BrilligOpcode::Const { destination, value } => { | ||
| avm_instrs.push(AvmInstruction { | ||
| opcode: AvmOpcode::SET, | ||
| indirect: Some(0), | ||
| dst_tag: Some(AvmTypeTag::UINT32), | ||
| operands: vec![ | ||
| // TODO(4267): support u8..u128 and use dst_tag | ||
| AvmOperand::U32 { | ||
| value: value.to_usize() as u32, | ||
| // value - temporarily as u128 | ||
| AvmOperand::U128 { | ||
| value: value.to_usize() as u128, | ||
| }, | ||
| // dest offset | ||
| AvmOperand::U32 { | ||
| value: destination.to_usize() as u32, | ||
| }, | ||
|
|
@@ -158,6 +167,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec<u8> { | |
| } => { | ||
| avm_instrs.push(AvmInstruction { | ||
| opcode: AvmOpcode::MOV, | ||
| indirect: Some(0), | ||
| operands: vec![ | ||
| AvmOperand::U32 { | ||
| value: source.to_usize() as u32, | ||
|
|
@@ -223,6 +233,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec<u8> { | |
| BrilligOpcode::Stop { return_data_offset, return_data_size } => { | ||
| avm_instrs.push(AvmInstruction { | ||
| opcode: AvmOpcode::RETURN, | ||
| indirect: Some(0), | ||
| operands: vec![ | ||
| AvmOperand::U32 { value: *return_data_offset as u32}, | ||
| AvmOperand::U32 { value: *return_data_size as u32}, | ||
|
|
@@ -234,6 +245,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec<u8> { | |
| // TODO(https://github.com/noir-lang/noir/issues/3113): Trap should support return data | ||
| avm_instrs.push(AvmInstruction { | ||
| opcode: AvmOpcode::REVERT, | ||
| indirect: Some(0), | ||
| operands: vec![ | ||
| //AvmOperand::U32 { value: *return_data_offset as u32}, | ||
| //AvmOperand::U32 { value: *return_data_size as u32}, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,7 +56,6 @@ const INSTRUCTION_SET: InstructionSet = new Map<Opcode, DeserializableInstructio | |
| [ | ||
| [Add.opcode, Add], | ||
| [Sub.opcode, Sub], | ||
| [Sub.opcode, Sub], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👀 |
||
| [Mul.opcode, Mul], | ||
| [Div.opcode, Div], | ||
| [Eq.opcode, Eq], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,8 @@ contract AvmTest { | |
| fn constructor() {} | ||
|
|
||
| // Function name prefix "avm_" flags it for transpilation | ||
| unconstrained fn avm_addArgsReturn(argA: Field, argB: Field) -> pub Field { | ||
| #[aztec(public-vm)] | ||
| fn addArgsReturn(argA: Field, argB: Field) -> pub Field { | ||
| argA + argB | ||
| } | ||
|
Comment on lines
12
to
16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.