11use std:: collections:: BTreeMap ;
22
3- use p3_koala_bear:: KoalaBear ;
4-
53type Label = String ;
6- type F = KoalaBear ;
74
85#[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
9- pub struct Bytecode {
10- pub instructions : Vec < Instruction > ,
11- pub hints : BTreeMap < usize , Vec < Hint > > , // pc -> hints
6+ pub struct Bytecode < F > {
7+ pub instructions : Vec < Instruction < F > > ,
8+ pub hints : BTreeMap < usize , Vec < Hint < F > > > , // pc -> hints
129 pub public_input_start : usize ,
1310 pub ending_pc : usize ,
1411}
1512
1613#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
17- pub enum MemOrConstant {
14+ pub enum MemOrConstant < F > {
1815 Constant ( F ) ,
1916 MemoryAfterFp { shift : usize } , // m[fp + shift]
2017}
18+
2119#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
22- pub enum MemOrFpOrConstant {
20+ pub enum MemOrFpOrConstant < F > {
2321 MemoryAfterFp { shift : usize } , // m[fp + shift]
2422 Fp ,
2523 Constant ( F ) ,
@@ -38,21 +36,21 @@ pub enum Operation {
3836}
3937
4038#[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
41- pub enum Instruction {
39+ pub enum Instruction < F > {
4240 Computation {
4341 operation : Operation ,
44- arg_a : MemOrConstant ,
42+ arg_a : MemOrConstant < F > ,
4543 arg_b : MemOrFp ,
46- res : MemOrConstant ,
44+ res : MemOrConstant < F > ,
4745 } ,
4846 Deref {
4947 shift_0 : usize ,
5048 shift_1 : usize ,
51- res : MemOrFpOrConstant ,
49+ res : MemOrFpOrConstant < F > ,
5250 } , // res = m[m[fp + shift_0] + shift_1]
5351 JumpIfNotZero {
54- condition : MemOrConstant ,
55- dest : MemOrConstant ,
52+ condition : MemOrConstant < F > ,
53+ dest : MemOrConstant < F > ,
5654 updated_fp : MemOrFp ,
5755 } ,
5856 Poseidon2_16 {
@@ -72,21 +70,21 @@ pub enum Instruction {
7270
7371/// Hints does not appear in the verified bytecode, but are useful during execution
7472#[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
75- pub enum Hint {
73+ pub enum Hint < F > {
7674 RequestMemory {
7775 offset : usize , // the pointer to the allocated memory range will be stored at m[fp + offset]
78- size : MemOrConstant ,
76+ size : MemOrConstant < F > ,
7977 /// if vectorized == true, the start of the allocated memory will be aligned to 8 field elements
8078 /// m[8X...] and we set m[fp + offset] = X
8179 vectorized : bool ,
8280 } ,
8381 DecomposeBits {
8482 res_offset : usize , // m[fp + res_offset..fp + res_offset + 31] will contain the decomposed bits
85- to_decompose : MemOrConstant ,
83+ to_decompose : MemOrConstant < F > ,
8684 } ,
8785 // Debug purpose
8886 Print {
8987 line_info : String ,
90- content : Vec < MemOrConstant > ,
88+ content : Vec < MemOrConstant < F > > ,
9189 } ,
9290}
0 commit comments