Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
instr_fetching_impl.hpp
Go to the documentation of this file.
1// AUTOGENERATED FILE
2#pragma once
3
5
6namespace bb::avm2 {
7
8template <typename FF_>
9template <typename ContainerOverSubrelations, typename AllEntities>
10void instr_fetchingImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
11 const AllEntities& in,
12 [[maybe_unused]] const RelationParameters<FF_>&,
13 [[maybe_unused]] const FF_& scaling_factor)
14{
15 using C = ColumnAndShifts;
16
17 PROFILE_THIS_NAME("accumulate/instr_fetching");
18
19 const auto constants_AVM_PC_SIZE_IN_BITS = FF(32);
20 const auto instr_fetching_PARSING_ERROR_EXCEPT_TAG_ERROR = in.get(C::instr_fetching_pc_out_of_range) +
21 in.get(C::instr_fetching_opcode_out_of_range) +
22 in.get(C::instr_fetching_instr_out_of_range);
23 const auto instr_fetching_SEL_OP_DC_17 =
24 in.get(C::instr_fetching_sel_op_dc_2) + in.get(C::instr_fetching_sel_op_dc_6);
25
26 {
27 using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>;
28 auto tmp = in.get(C::instr_fetching_sel) * (FF(1) - in.get(C::instr_fetching_sel));
29 tmp *= scaling_factor;
30 std::get<0>(evals) += typename Accumulator::View(tmp);
31 }
32 {
33 using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>;
34 auto tmp = in.get(C::instr_fetching_pc_out_of_range) * (FF(1) - in.get(C::instr_fetching_pc_out_of_range));
35 tmp *= scaling_factor;
36 std::get<1>(evals) += typename Accumulator::View(tmp);
37 }
38 {
39 using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>;
40 auto tmp =
41 in.get(C::instr_fetching_instr_out_of_range) * (FF(1) - in.get(C::instr_fetching_instr_out_of_range));
42 tmp *= scaling_factor;
43 std::get<2>(evals) += typename Accumulator::View(tmp);
44 }
45 {
46 using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>;
47 auto tmp = in.get(C::instr_fetching_sel_parsing_err) * (FF(1) - in.get(C::instr_fetching_sel_parsing_err));
48 tmp *= scaling_factor;
49 std::get<3>(evals) += typename Accumulator::View(tmp);
50 }
51 { // PC_OUT_OF_RANGE_TOGGLE
52 using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>;
53 auto tmp = (in.get(C::instr_fetching_pc_abs_diff) -
54 in.get(C::instr_fetching_sel) *
55 (((FF(2) * in.get(C::instr_fetching_pc_out_of_range) - FF(1)) *
56 (in.get(C::instr_fetching_pc) - in.get(C::instr_fetching_bytecode_size)) -
57 FF(1)) +
58 in.get(C::instr_fetching_pc_out_of_range)));
59 tmp *= scaling_factor;
60 std::get<4>(evals) += typename Accumulator::View(tmp);
61 }
62 {
63 using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>;
64 auto tmp =
65 in.get(C::instr_fetching_sel) * (in.get(C::instr_fetching_pc_size_in_bits) - constants_AVM_PC_SIZE_IN_BITS);
66 tmp *= scaling_factor;
67 std::get<5>(evals) += typename Accumulator::View(tmp);
68 }
69 { // INSTR_OUT_OF_RANGE_TOGGLE
70 using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>;
71 auto tmp = (in.get(C::instr_fetching_instr_abs_diff) -
72 ((FF(2) * in.get(C::instr_fetching_instr_out_of_range) - FF(1)) *
73 (in.get(C::instr_fetching_instr_size) - in.get(C::instr_fetching_bytes_to_read)) -
74 in.get(C::instr_fetching_instr_out_of_range)));
75 tmp *= scaling_factor;
76 std::get<6>(evals) += typename Accumulator::View(tmp);
77 }
78 { // TAG_VALUE
79 using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>;
80 auto tmp = (in.get(C::instr_fetching_tag_value) -
81 ((in.get(C::instr_fetching_sel_has_tag) - in.get(C::instr_fetching_sel_tag_is_op2)) *
82 in.get(C::instr_fetching_op3) +
83 in.get(C::instr_fetching_sel_tag_is_op2) * in.get(C::instr_fetching_op2)));
84 tmp *= scaling_factor;
85 std::get<7>(evals) += typename Accumulator::View(tmp);
86 }
87 {
88 using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>;
89 auto tmp = (in.get(C::instr_fetching_sel_pc_in_range) -
90 in.get(C::instr_fetching_sel) * (FF(1) - in.get(C::instr_fetching_pc_out_of_range)));
91 tmp *= scaling_factor;
92 std::get<8>(evals) += typename Accumulator::View(tmp);
93 }
94 { // INDIRECT_BYTES_DECOMPOSITION
95 using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>;
96 auto tmp = (in.get(C::instr_fetching_indirect) -
97 (FF(1) - instr_fetching_PARSING_ERROR_EXCEPT_TAG_ERROR) *
98 (in.get(C::instr_fetching_sel_op_dc_0) *
99 (in.get(C::instr_fetching_bd1) * FF(256) + in.get(C::instr_fetching_bd2) * FF(1)) +
100 instr_fetching_SEL_OP_DC_17 * in.get(C::instr_fetching_bd1) * FF(1)));
101 tmp *= scaling_factor;
102 std::get<9>(evals) += typename Accumulator::View(tmp);
103 }
104 { // OP1_BYTES_DECOMPOSITION
105 using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>;
106 auto tmp = (in.get(C::instr_fetching_op1) -
107 (FF(1) - instr_fetching_PARSING_ERROR_EXCEPT_TAG_ERROR) *
108 (in.get(C::instr_fetching_sel_op_dc_0) *
109 (in.get(C::instr_fetching_bd3) * FF(256) + in.get(C::instr_fetching_bd4) * FF(1)) +
110 in.get(C::instr_fetching_sel_op_dc_2) *
111 (in.get(C::instr_fetching_bd2) * FF(256) + in.get(C::instr_fetching_bd3) * FF(1)) +
112 in.get(C::instr_fetching_sel_op_dc_6) * in.get(C::instr_fetching_bd2) * FF(1) +
113 in.get(C::instr_fetching_sel_op_dc_15) *
114 (in.get(C::instr_fetching_bd1) * FF(16777216) + in.get(C::instr_fetching_bd2) * FF(65536) +
115 in.get(C::instr_fetching_bd3) * FF(256) + in.get(C::instr_fetching_bd4) * FF(1))));
116 tmp *= scaling_factor;
117 std::get<10>(evals) += typename Accumulator::View(tmp);
118 }
119 { // OP2_BYTES_DECOMPOSITION
120 using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>;
121 auto tmp = (in.get(C::instr_fetching_op2) -
122 (FF(1) - instr_fetching_PARSING_ERROR_EXCEPT_TAG_ERROR) *
123 (in.get(C::instr_fetching_sel_op_dc_0) *
124 (in.get(C::instr_fetching_bd5) * FF(256) + in.get(C::instr_fetching_bd6) * FF(1)) +
125 in.get(C::instr_fetching_sel_op_dc_3) *
126 (in.get(C::instr_fetching_bd4) * FF(256) + in.get(C::instr_fetching_bd5) * FF(1)) +
127 in.get(C::instr_fetching_sel_op_dc_6) * in.get(C::instr_fetching_bd3) * FF(1) +
128 in.get(C::instr_fetching_sel_op_dc_8) * in.get(C::instr_fetching_bd4) * FF(1) +
129 in.get(C::instr_fetching_sel_op_dc_16) *
130 (in.get(C::instr_fetching_bd4) * FF(16777216) + in.get(C::instr_fetching_bd5) * FF(65536) +
131 in.get(C::instr_fetching_bd6) * FF(256) + in.get(C::instr_fetching_bd7) * FF(1))));
132 tmp *= scaling_factor;
133 std::get<11>(evals) += typename Accumulator::View(tmp);
134 }
135 { // OP3_BYTES_DECOMPOSITION
136 using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>;
137 auto tmp =
138 (in.get(C::instr_fetching_op3) -
139 (FF(1) - instr_fetching_PARSING_ERROR_EXCEPT_TAG_ERROR) *
140 (in.get(C::instr_fetching_sel_op_dc_0) *
141 (in.get(C::instr_fetching_bd7) * FF(256) + in.get(C::instr_fetching_bd8) * FF(1)) +
142 in.get(C::instr_fetching_sel_op_dc_4) *
143 (in.get(C::instr_fetching_bd6) * FF(256) + in.get(C::instr_fetching_bd7) * FF(1)) +
144 in.get(C::instr_fetching_sel_op_dc_7) * in.get(C::instr_fetching_bd6) * FF(1) +
145 in.get(C::instr_fetching_sel_op_dc_9) *
146 (in.get(C::instr_fetching_bd5) * FF(uint256_t{ 0UL, 0UL, 0UL, 72057594037927936UL }) +
147 in.get(C::instr_fetching_bd6) * FF(uint256_t{ 0UL, 0UL, 0UL, 281474976710656UL }) +
148 in.get(C::instr_fetching_bd7) * FF(uint256_t{ 0UL, 0UL, 0UL, 1099511627776UL }) +
149 in.get(C::instr_fetching_bd8) * FF(uint256_t{ 0UL, 0UL, 0UL, 4294967296UL }) +
150 in.get(C::instr_fetching_bd9) * FF(uint256_t{ 0UL, 0UL, 0UL, 16777216UL }) +
151 in.get(C::instr_fetching_bd10) * FF(uint256_t{ 0UL, 0UL, 0UL, 65536UL }) +
152 in.get(C::instr_fetching_bd11) * FF(uint256_t{ 0UL, 0UL, 0UL, 256UL }) +
153 in.get(C::instr_fetching_bd12) * FF(uint256_t{ 0UL, 0UL, 0UL, 1UL }) +
154 in.get(C::instr_fetching_bd13) * FF(uint256_t{ 0UL, 0UL, 72057594037927936UL, 0UL }) +
155 in.get(C::instr_fetching_bd14) * FF(uint256_t{ 0UL, 0UL, 281474976710656UL, 0UL }) +
156 in.get(C::instr_fetching_bd15) * FF(uint256_t{ 0UL, 0UL, 1099511627776UL, 0UL }) +
157 in.get(C::instr_fetching_bd16) * FF(uint256_t{ 0UL, 0UL, 4294967296UL, 0UL }) +
158 in.get(C::instr_fetching_bd17) * FF(uint256_t{ 0UL, 0UL, 16777216UL, 0UL }) +
159 in.get(C::instr_fetching_bd18) * FF(uint256_t{ 0UL, 0UL, 65536UL, 0UL }) +
160 in.get(C::instr_fetching_bd19) * FF(uint256_t{ 0UL, 0UL, 256UL, 0UL }) +
161 in.get(C::instr_fetching_bd20) * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }) +
162 in.get(C::instr_fetching_bd21) * FF(uint256_t{ 0UL, 72057594037927936UL, 0UL, 0UL }) +
163 in.get(C::instr_fetching_bd22) * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }) +
164 in.get(C::instr_fetching_bd23) * FF(uint256_t{ 0UL, 1099511627776UL, 0UL, 0UL }) +
165 in.get(C::instr_fetching_bd24) * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }) +
166 in.get(C::instr_fetching_bd25) * FF(uint256_t{ 0UL, 16777216UL, 0UL, 0UL }) +
167 in.get(C::instr_fetching_bd26) * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }) +
168 in.get(C::instr_fetching_bd27) * FF(uint256_t{ 0UL, 256UL, 0UL, 0UL }) +
169 in.get(C::instr_fetching_bd28) * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }) +
170 in.get(C::instr_fetching_bd29) * FF(72057594037927936UL) +
171 in.get(C::instr_fetching_bd30) * FF(281474976710656UL) +
172 in.get(C::instr_fetching_bd31) * FF(1099511627776UL) +
173 in.get(C::instr_fetching_bd32) * FF(4294967296UL) +
174 in.get(C::instr_fetching_bd33) * FF(16777216) + in.get(C::instr_fetching_bd34) * FF(65536) +
175 in.get(C::instr_fetching_bd35) * FF(256) + in.get(C::instr_fetching_bd36) * FF(1)) +
176 in.get(C::instr_fetching_sel_op_dc_10) *
177 (in.get(C::instr_fetching_bd5) * FF(uint256_t{ 0UL, 72057594037927936UL, 0UL, 0UL }) +
178 in.get(C::instr_fetching_bd6) * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }) +
179 in.get(C::instr_fetching_bd7) * FF(uint256_t{ 0UL, 1099511627776UL, 0UL, 0UL }) +
180 in.get(C::instr_fetching_bd8) * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }) +
181 in.get(C::instr_fetching_bd9) * FF(uint256_t{ 0UL, 16777216UL, 0UL, 0UL }) +
182 in.get(C::instr_fetching_bd10) * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }) +
183 in.get(C::instr_fetching_bd11) * FF(uint256_t{ 0UL, 256UL, 0UL, 0UL }) +
184 in.get(C::instr_fetching_bd12) * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }) +
185 in.get(C::instr_fetching_bd13) * FF(72057594037927936UL) +
186 in.get(C::instr_fetching_bd14) * FF(281474976710656UL) +
187 in.get(C::instr_fetching_bd15) * FF(1099511627776UL) +
188 in.get(C::instr_fetching_bd16) * FF(4294967296UL) +
189 in.get(C::instr_fetching_bd17) * FF(16777216) + in.get(C::instr_fetching_bd18) * FF(65536) +
190 in.get(C::instr_fetching_bd19) * FF(256) + in.get(C::instr_fetching_bd20) * FF(1)) +
191 in.get(C::instr_fetching_sel_op_dc_11) *
192 (in.get(C::instr_fetching_bd5) * FF(72057594037927936UL) +
193 in.get(C::instr_fetching_bd6) * FF(281474976710656UL) +
194 in.get(C::instr_fetching_bd7) * FF(1099511627776UL) +
195 in.get(C::instr_fetching_bd8) * FF(4294967296UL) + in.get(C::instr_fetching_bd9) * FF(16777216) +
196 in.get(C::instr_fetching_bd10) * FF(65536) + in.get(C::instr_fetching_bd11) * FF(256) +
197 in.get(C::instr_fetching_bd12) * FF(1)) +
198 in.get(C::instr_fetching_sel_op_dc_12) *
199 (in.get(C::instr_fetching_bd5) * FF(16777216) + in.get(C::instr_fetching_bd6) * FF(65536) +
200 in.get(C::instr_fetching_bd7) * FF(256) + in.get(C::instr_fetching_bd8) * FF(1)) +
201 in.get(C::instr_fetching_sel_op_dc_13) *
202 (in.get(C::instr_fetching_bd5) * FF(256) + in.get(C::instr_fetching_bd6) * FF(1)) +
203 in.get(C::instr_fetching_sel_op_dc_14) * in.get(C::instr_fetching_bd4) * FF(1)));
204 tmp *= scaling_factor;
205 std::get<12>(evals) += typename Accumulator::View(tmp);
206 }
207 { // OP4_BYTES_DECOMPOSITION
208 using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>;
209 auto tmp = (in.get(C::instr_fetching_op4) -
210 (FF(1) - instr_fetching_PARSING_ERROR_EXCEPT_TAG_ERROR) *
211 (in.get(C::instr_fetching_sel_op_dc_0) *
212 (in.get(C::instr_fetching_bd9) * FF(256) + in.get(C::instr_fetching_bd10) * FF(1)) +
213 in.get(C::instr_fetching_sel_op_dc_5) *
214 (in.get(C::instr_fetching_bd8) * FF(256) + in.get(C::instr_fetching_bd9) * FF(1))));
215 tmp *= scaling_factor;
216 std::get<13>(evals) += typename Accumulator::View(tmp);
217 }
218 { // OP5_BYTES_DECOMPOSITION
219 using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>;
220 auto tmp = (in.get(C::instr_fetching_op5) -
221 (FF(1) - instr_fetching_PARSING_ERROR_EXCEPT_TAG_ERROR) * in.get(C::instr_fetching_sel_op_dc_0) *
222 (in.get(C::instr_fetching_bd11) * FF(256) + in.get(C::instr_fetching_bd12) * FF(1)));
223 tmp *= scaling_factor;
224 std::get<14>(evals) += typename Accumulator::View(tmp);
225 }
226 { // OP6_BYTES_DECOMPOSITION
227 using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>;
228 auto tmp = (in.get(C::instr_fetching_op6) -
229 (FF(1) - instr_fetching_PARSING_ERROR_EXCEPT_TAG_ERROR) * in.get(C::instr_fetching_sel_op_dc_1) *
230 (in.get(C::instr_fetching_bd13) * FF(256) + in.get(C::instr_fetching_bd14) * FF(1)));
231 tmp *= scaling_factor;
232 std::get<15>(evals) += typename Accumulator::View(tmp);
233 }
234 { // OP7_BYTES_DECOMPOSITION
235 using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>;
236 auto tmp = (in.get(C::instr_fetching_op7) -
237 (FF(1) - instr_fetching_PARSING_ERROR_EXCEPT_TAG_ERROR) * in.get(C::instr_fetching_sel_op_dc_1) *
238 (in.get(C::instr_fetching_bd15) * FF(256) + in.get(C::instr_fetching_bd16) * FF(1)));
239 tmp *= scaling_factor;
240 std::get<16>(evals) += typename Accumulator::View(tmp);
241 }
242}
243
244} // namespace bb::avm2
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
ColumnAndShifts
Definition columns.hpp:35
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define PROFILE_THIS_NAME(name)
Definition op_count.hpp:16
Container for parameters used by the grand product (permutation, lookup) Honk relations.