Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
alu_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 aluImpl<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/alu");
18
19 const auto constants_MEM_TAG_FF = FF(0);
20 const auto constants_MEM_TAG_U1 = FF(1);
21 const auto constants_MEM_TAG_U128 = FF(6);
22 const auto constants_AVM_EXEC_OP_ID_ALU_ADD = FF(1);
23 const auto constants_AVM_EXEC_OP_ID_ALU_SUB = FF(2);
24 const auto constants_AVM_EXEC_OP_ID_ALU_MUL = FF(4);
25 const auto constants_AVM_EXEC_OP_ID_ALU_DIV = FF(8);
26 const auto constants_AVM_EXEC_OP_ID_ALU_FDIV = FF(16);
27 const auto constants_AVM_EXEC_OP_ID_ALU_EQ = FF(32);
28 const auto constants_AVM_EXEC_OP_ID_ALU_LT = FF(64);
29 const auto constants_AVM_EXEC_OP_ID_ALU_LTE = FF(128);
30 const auto constants_AVM_EXEC_OP_ID_ALU_NOT = FF(256);
31 const auto constants_AVM_EXEC_OP_ID_ALU_SHL = FF(512);
32 const auto constants_AVM_EXEC_OP_ID_ALU_SHR = FF(1024);
33 const auto constants_AVM_EXEC_OP_ID_ALU_TRUNCATE = FF(2048);
34 const auto alu_IS_NOT_FF = (FF(1) - in.get(C::alu_sel_is_ff));
35 const auto alu_IS_NOT_U128 = (FF(1) - in.get(C::alu_sel_is_u128));
36 const auto alu_CHECK_TAG_FF = in.get(C::alu_sel_op_div) + in.get(C::alu_sel_op_fdiv) + in.get(C::alu_sel_op_lt) +
37 in.get(C::alu_sel_op_lte) + in.get(C::alu_sel_op_not) + in.get(C::alu_sel_shift_ops);
38 const auto alu_TAG_FF_DIFF = (in.get(C::alu_ia_tag) - constants_MEM_TAG_FF);
39 const auto alu_CHECK_TAG_U128 = in.get(C::alu_sel_op_mul) + in.get(C::alu_sel_op_div);
40 const auto alu_TAG_U128_DIFF = (in.get(C::alu_ia_tag) - constants_MEM_TAG_U128);
41 const auto alu_EXPECTED_C_TAG =
42 (in.get(C::alu_sel_op_add) + in.get(C::alu_sel_op_sub) + in.get(C::alu_sel_op_mul) + in.get(C::alu_sel_op_div) +
43 in.get(C::alu_sel_op_truncate) + in.get(C::alu_sel_shift_ops)) *
44 in.get(C::alu_ia_tag) +
45 (in.get(C::alu_sel_op_eq) + in.get(C::alu_sel_op_lt) + in.get(C::alu_sel_op_lte)) * constants_MEM_TAG_U1 +
46 in.get(C::alu_sel_op_fdiv) * constants_MEM_TAG_FF;
47 const auto alu_FF_TAG_ERR = (in.get(C::alu_sel_op_div) + in.get(C::alu_sel_op_not) + in.get(C::alu_sel_shift_ops)) *
48 in.get(C::alu_sel_is_ff) +
49 in.get(C::alu_sel_op_fdiv) * alu_IS_NOT_FF;
50 const auto alu_CHECK_AB_TAGS =
51 ((FF(1) - in.get(C::alu_sel_op_not) * in.get(C::alu_sel_is_ff)) - in.get(C::alu_sel_op_truncate));
52 const auto alu_AB_TAGS_EQ = (FF(1) - in.get(C::alu_sel_ab_tag_mismatch));
53 const auto alu_TWO_POW_64 = FF(uint256_t{ 0UL, 1UL, 0UL, 0UL });
54 const auto alu_DECOMPOSED_A =
55 (in.get(C::alu_sel_mul_u128) + in.get(C::alu_sel_shift_ops_no_overflow)) * in.get(C::alu_ia) +
56 (in.get(C::alu_sel_shift_ops) - in.get(C::alu_sel_shift_ops_no_overflow)) *
57 (in.get(C::alu_ib) - in.get(C::alu_max_bits)) +
58 in.get(C::alu_sel_is_u128) * in.get(C::alu_sel_op_div) * (FF(1) - in.get(C::alu_sel_tag_err)) *
59 in.get(C::alu_ic);
60 const auto alu_DECOMPOSED_B = in.get(C::alu_ib);
61 const auto alu_LIMB_SIZE = in.get(C::alu_sel_mul_div_u128) * alu_TWO_POW_64 +
62 in.get(C::alu_sel_shift_ops) * in.get(C::alu_two_pow_shift_lo_bits);
63 const auto alu_DIV_OPS = in.get(C::alu_sel_op_div) + in.get(C::alu_sel_op_fdiv);
64 const auto alu_DIV_OPS_NON_U128 =
65 (FF(1) - in.get(C::alu_sel_err)) * (in.get(C::alu_sel_op_fdiv) + in.get(C::alu_sel_op_div) * alu_IS_NOT_U128);
66 const auto alu_DIFF = (in.get(C::alu_ia) - in.get(C::alu_ib));
67 const auto alu_SHIFT_OVERFLOW = in.get(C::alu_sel_shift_ops) * (FF(1) - in.get(C::alu_sel_shift_ops_no_overflow));
68 const auto alu_SHIFT_HI_BITS =
69 (in.get(C::alu_max_bits) - in.get(C::alu_sel_shift_ops_no_overflow) * in.get(C::alu_shift_lo_bits));
70
71 {
72 using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>;
73 auto tmp = in.get(C::alu_sel) * (FF(1) - in.get(C::alu_sel));
74 tmp *= scaling_factor;
75 std::get<0>(evals) += typename Accumulator::View(tmp);
76 }
77 {
78 using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>;
79 auto tmp = in.get(C::alu_cf) * (FF(1) - in.get(C::alu_cf));
80 tmp *= scaling_factor;
81 std::get<1>(evals) += typename Accumulator::View(tmp);
82 }
83 {
84 using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>;
85 auto tmp = in.get(C::alu_sel_is_ff) * (FF(1) - in.get(C::alu_sel_is_ff));
86 tmp *= scaling_factor;
87 std::get<2>(evals) += typename Accumulator::View(tmp);
88 }
89 {
90 using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>;
91 auto tmp = in.get(C::alu_sel_is_u128) * (FF(1) - in.get(C::alu_sel_is_u128));
92 tmp *= scaling_factor;
93 std::get<3>(evals) += typename Accumulator::View(tmp);
94 }
95 { // ERR_CHECK
96 using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>;
97 auto tmp = (in.get(C::alu_sel_err) - ((in.get(C::alu_sel_tag_err) + in.get(C::alu_sel_div_0_err)) -
98 in.get(C::alu_sel_tag_err) * in.get(C::alu_sel_div_0_err)));
99 tmp *= scaling_factor;
100 std::get<4>(evals) += typename Accumulator::View(tmp);
101 }
102 { // OP_ID_CHECK
103 using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>;
104 auto tmp = (in.get(C::alu_op_id) - (in.get(C::alu_sel_op_add) * constants_AVM_EXEC_OP_ID_ALU_ADD +
105 in.get(C::alu_sel_op_sub) * constants_AVM_EXEC_OP_ID_ALU_SUB +
106 in.get(C::alu_sel_op_mul) * constants_AVM_EXEC_OP_ID_ALU_MUL +
107 in.get(C::alu_sel_op_div) * constants_AVM_EXEC_OP_ID_ALU_DIV +
108 in.get(C::alu_sel_op_fdiv) * constants_AVM_EXEC_OP_ID_ALU_FDIV +
109 in.get(C::alu_sel_op_eq) * constants_AVM_EXEC_OP_ID_ALU_EQ +
110 in.get(C::alu_sel_op_lt) * constants_AVM_EXEC_OP_ID_ALU_LT +
111 in.get(C::alu_sel_op_lte) * constants_AVM_EXEC_OP_ID_ALU_LTE +
112 in.get(C::alu_sel_op_not) * constants_AVM_EXEC_OP_ID_ALU_NOT +
113 in.get(C::alu_sel_op_shl) * constants_AVM_EXEC_OP_ID_ALU_SHL +
114 in.get(C::alu_sel_op_shr) * constants_AVM_EXEC_OP_ID_ALU_SHR +
115 in.get(C::alu_sel_op_truncate) * constants_AVM_EXEC_OP_ID_ALU_TRUNCATE));
116 tmp *= scaling_factor;
117 std::get<5>(evals) += typename Accumulator::View(tmp);
118 }
119 { // TAG_IS_FF
120 using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>;
121 auto tmp = alu_CHECK_TAG_FF *
122 ((alu_TAG_FF_DIFF * (in.get(C::alu_sel_is_ff) * (FF(1) - in.get(C::alu_tag_ff_diff_inv)) +
123 in.get(C::alu_tag_ff_diff_inv)) +
124 in.get(C::alu_sel_is_ff)) -
125 FF(1));
126 tmp *= scaling_factor;
127 std::get<6>(evals) += typename Accumulator::View(tmp);
128 }
129 { // TAG_IS_U128
130 using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>;
131 auto tmp = alu_CHECK_TAG_U128 *
132 ((alu_TAG_U128_DIFF * (in.get(C::alu_sel_is_u128) * (FF(1) - in.get(C::alu_tag_u128_diff_inv)) +
133 in.get(C::alu_tag_u128_diff_inv)) +
134 in.get(C::alu_sel_is_u128)) -
135 FF(1));
136 tmp *= scaling_factor;
137 std::get<7>(evals) += typename Accumulator::View(tmp);
138 }
139 { // C_TAG_CHECK
140 using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>;
141 auto tmp = (FF(1) - in.get(C::alu_sel_err)) * (alu_EXPECTED_C_TAG - in.get(C::alu_ic_tag));
142 tmp *= scaling_factor;
143 std::get<8>(evals) += typename Accumulator::View(tmp);
144 }
145 {
146 using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>;
147 auto tmp = in.get(C::alu_sel_tag_err) * (FF(1) - in.get(C::alu_sel_tag_err));
148 tmp *= scaling_factor;
149 std::get<9>(evals) += typename Accumulator::View(tmp);
150 }
151 {
152 using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>;
153 auto tmp = in.get(C::alu_sel_ab_tag_mismatch) * (FF(1) - in.get(C::alu_sel_ab_tag_mismatch));
154 tmp *= scaling_factor;
155 std::get<10>(evals) += typename Accumulator::View(tmp);
156 }
157 { // TAG_ERR_CHECK
158 using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>;
159 auto tmp = (in.get(C::alu_sel_tag_err) - ((in.get(C::alu_sel_ab_tag_mismatch) + alu_FF_TAG_ERR) -
160 in.get(C::alu_sel_ab_tag_mismatch) * alu_FF_TAG_ERR));
161 tmp *= scaling_factor;
162 std::get<11>(evals) += typename Accumulator::View(tmp);
163 }
164 { // AB_TAGS_CHECK
165 using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>;
166 auto tmp =
167 alu_CHECK_AB_TAGS *
168 (((in.get(C::alu_ia_tag) - in.get(C::alu_ib_tag)) *
169 (alu_AB_TAGS_EQ * (FF(1) - in.get(C::alu_ab_tags_diff_inv)) + in.get(C::alu_ab_tags_diff_inv)) -
170 FF(1)) +
171 alu_AB_TAGS_EQ);
172 tmp *= scaling_factor;
173 std::get<12>(evals) += typename Accumulator::View(tmp);
174 }
175 {
176 using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>;
177 auto tmp = (in.get(C::alu_sel_decompose_a) -
178 (in.get(C::alu_sel_mul_div_u128) + in.get(C::alu_sel_shift_ops) * alu_IS_NOT_FF));
179 tmp *= scaling_factor;
180 std::get<13>(evals) += typename Accumulator::View(tmp);
181 }
182 { // A_DECOMPOSITION
183 using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>;
184 auto tmp = in.get(C::alu_sel_decompose_a) *
185 (alu_DECOMPOSED_A - (in.get(C::alu_a_lo) + alu_LIMB_SIZE * in.get(C::alu_a_hi)));
186 tmp *= scaling_factor;
187 std::get<14>(evals) += typename Accumulator::View(tmp);
188 }
189 { // B_DECOMPOSITION
190 using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>;
191 auto tmp = in.get(C::alu_sel_mul_div_u128) *
192 (alu_DECOMPOSED_B - (in.get(C::alu_b_lo) + alu_LIMB_SIZE * in.get(C::alu_b_hi)));
193 tmp *= scaling_factor;
194 std::get<15>(evals) += typename Accumulator::View(tmp);
195 }
196 {
197 using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>;
198 auto tmp = in.get(C::alu_sel_mul_div_u128) * (FF(64) - in.get(C::alu_constant_64));
199 tmp *= scaling_factor;
200 std::get<16>(evals) += typename Accumulator::View(tmp);
201 }
202 { // A_LO_BITS
203 using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>;
204 auto tmp = ((in.get(C::alu_a_lo_bits) - in.get(C::alu_sel_mul_div_u128) * in.get(C::alu_constant_64)) -
205 in.get(C::alu_sel_shift_ops) * in.get(C::alu_shift_lo_bits));
206 tmp *= scaling_factor;
207 std::get<17>(evals) += typename Accumulator::View(tmp);
208 }
209 { // A_HI_BITS
210 using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>;
211 auto tmp = ((in.get(C::alu_a_hi_bits) - in.get(C::alu_sel_mul_div_u128) * in.get(C::alu_constant_64)) -
212 in.get(C::alu_sel_shift_ops) * alu_SHIFT_HI_BITS);
213 tmp *= scaling_factor;
214 std::get<18>(evals) += typename Accumulator::View(tmp);
215 }
216 {
217 using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>;
218 auto tmp = in.get(C::alu_sel_op_add) * (FF(1) - in.get(C::alu_sel_op_add));
219 tmp *= scaling_factor;
220 std::get<19>(evals) += typename Accumulator::View(tmp);
221 }
222 {
223 using Accumulator = typename std::tuple_element_t<20, ContainerOverSubrelations>;
224 auto tmp = in.get(C::alu_sel_op_sub) * (FF(1) - in.get(C::alu_sel_op_sub));
225 tmp *= scaling_factor;
226 std::get<20>(evals) += typename Accumulator::View(tmp);
227 }
228 { // ALU_ADD_SUB
229 using Accumulator = typename std::tuple_element_t<21, ContainerOverSubrelations>;
230 auto tmp = (in.get(C::alu_sel_op_add) + in.get(C::alu_sel_op_sub)) * (FF(1) - in.get(C::alu_sel_tag_err)) *
231 ((in.get(C::alu_ia) - in.get(C::alu_ic)) +
232 (in.get(C::alu_sel_op_add) - in.get(C::alu_sel_op_sub)) *
233 (in.get(C::alu_ib) - in.get(C::alu_cf) * (in.get(C::alu_max_value) + FF(1))));
234 tmp *= scaling_factor;
235 std::get<21>(evals) += typename Accumulator::View(tmp);
236 }
237 {
238 using Accumulator = typename std::tuple_element_t<22, ContainerOverSubrelations>;
239 auto tmp = in.get(C::alu_sel_op_mul) * (FF(1) - in.get(C::alu_sel_op_mul));
240 tmp *= scaling_factor;
241 std::get<22>(evals) += typename Accumulator::View(tmp);
242 }
243 { // ALU_MUL_NON_U128
244 using Accumulator = typename std::tuple_element_t<23, ContainerOverSubrelations>;
245 auto tmp = in.get(C::alu_sel_op_mul) * alu_IS_NOT_U128 * (FF(1) - in.get(C::alu_sel_tag_err)) *
246 ((in.get(C::alu_ia) * in.get(C::alu_ib) - in.get(C::alu_ic)) -
247 (in.get(C::alu_max_value) + FF(1)) * in.get(C::alu_c_hi));
248 tmp *= scaling_factor;
249 std::get<23>(evals) += typename Accumulator::View(tmp);
250 }
251 {
252 using Accumulator = typename std::tuple_element_t<24, ContainerOverSubrelations>;
253 auto tmp = (in.get(C::alu_sel_mul_u128) - in.get(C::alu_sel_is_u128) * in.get(C::alu_sel_op_mul));
254 tmp *= scaling_factor;
255 std::get<24>(evals) += typename Accumulator::View(tmp);
256 }
257 { // ALU_MUL_U128
258 using Accumulator = typename std::tuple_element_t<25, ContainerOverSubrelations>;
259 auto tmp =
260 in.get(C::alu_sel_mul_u128) * (FF(1) - in.get(C::alu_sel_tag_err)) *
261 (((in.get(C::alu_ia) * in.get(C::alu_b_lo) + in.get(C::alu_a_lo) * in.get(C::alu_b_hi) * alu_TWO_POW_64) -
262 in.get(C::alu_ic)) -
263 (in.get(C::alu_max_value) + FF(1)) * (in.get(C::alu_cf) * alu_TWO_POW_64 + in.get(C::alu_c_hi)));
264 tmp *= scaling_factor;
265 std::get<25>(evals) += typename Accumulator::View(tmp);
266 }
267 {
268 using Accumulator = typename std::tuple_element_t<26, ContainerOverSubrelations>;
269 auto tmp = in.get(C::alu_sel_op_div) * (FF(1) - in.get(C::alu_sel_op_div));
270 tmp *= scaling_factor;
271 std::get<26>(evals) += typename Accumulator::View(tmp);
272 }
273 {
274 using Accumulator = typename std::tuple_element_t<27, ContainerOverSubrelations>;
275 auto tmp =
276 (in.get(C::alu_sel_div_no_0_err) - in.get(C::alu_sel_op_div) * (FF(1) - in.get(C::alu_sel_div_0_err)));
277 tmp *= scaling_factor;
278 std::get<27>(evals) += typename Accumulator::View(tmp);
279 }
280 {
281 using Accumulator = typename std::tuple_element_t<28, ContainerOverSubrelations>;
282 auto tmp = (in.get(C::alu_sel_mul_div_u128) -
283 (in.get(C::alu_sel_mul_u128) + in.get(C::alu_sel_is_u128) * in.get(C::alu_sel_op_div)));
284 tmp *= scaling_factor;
285 std::get<28>(evals) += typename Accumulator::View(tmp);
286 }
287 { // ALU_DIV_U128_CHECK
288 using Accumulator = typename std::tuple_element_t<29, ContainerOverSubrelations>;
289 auto tmp = in.get(C::alu_sel_is_u128) * in.get(C::alu_sel_op_div) * (FF(1) - in.get(C::alu_sel_err)) *
290 in.get(C::alu_a_hi) * in.get(C::alu_b_hi);
291 tmp *= scaling_factor;
292 std::get<29>(evals) += typename Accumulator::View(tmp);
293 }
294 { // ALU_DIV_U128
295 using Accumulator = typename std::tuple_element_t<30, ContainerOverSubrelations>;
296 auto tmp =
297 in.get(C::alu_sel_is_u128) * in.get(C::alu_sel_op_div) * (FF(1) - in.get(C::alu_sel_err)) *
298 ((in.get(C::alu_ic) * in.get(C::alu_b_lo) + in.get(C::alu_a_lo) * in.get(C::alu_b_hi) * alu_TWO_POW_64) -
299 (in.get(C::alu_ia) - in.get(C::alu_helper1)));
300 tmp *= scaling_factor;
301 std::get<30>(evals) += typename Accumulator::View(tmp);
302 }
303 {
304 using Accumulator = typename std::tuple_element_t<31, ContainerOverSubrelations>;
305 auto tmp = in.get(C::alu_sel_op_fdiv) * (FF(1) - in.get(C::alu_sel_op_fdiv));
306 tmp *= scaling_factor;
307 std::get<31>(evals) += typename Accumulator::View(tmp);
308 }
309 {
310 using Accumulator = typename std::tuple_element_t<32, ContainerOverSubrelations>;
311 auto tmp = in.get(C::alu_sel_div_0_err) * (FF(1) - in.get(C::alu_sel_div_0_err));
312 tmp *= scaling_factor;
313 std::get<32>(evals) += typename Accumulator::View(tmp);
314 }
315 { // DIV_0_ERR
316 using Accumulator = typename std::tuple_element_t<33, ContainerOverSubrelations>;
317 auto tmp = (alu_DIV_OPS * ((in.get(C::alu_ib) * (in.get(C::alu_sel_div_0_err) * (FF(1) - in.get(C::alu_b_inv)) +
318 in.get(C::alu_b_inv)) +
319 in.get(C::alu_sel_div_0_err)) -
320 FF(1)) +
321 in.get(C::alu_sel_div_0_err) * (in.get(C::alu_sel_div_0_err) - alu_DIV_OPS));
322 tmp *= scaling_factor;
323 std::get<33>(evals) += typename Accumulator::View(tmp);
324 }
325 { // ALU_FDIV_DIV_NON_U128
326 using Accumulator = typename std::tuple_element_t<34, ContainerOverSubrelations>;
327 auto tmp = alu_DIV_OPS_NON_U128 * (in.get(C::alu_ib) * in.get(C::alu_ic) -
328 (in.get(C::alu_ia) - in.get(C::alu_sel_op_div) * in.get(C::alu_helper1)));
329 tmp *= scaling_factor;
330 std::get<34>(evals) += typename Accumulator::View(tmp);
331 }
332 {
333 using Accumulator = typename std::tuple_element_t<35, ContainerOverSubrelations>;
334 auto tmp = in.get(C::alu_sel_op_eq) * (FF(1) - in.get(C::alu_sel_op_eq));
335 tmp *= scaling_factor;
336 std::get<35>(evals) += typename Accumulator::View(tmp);
337 }
338 { // EQ_OP_MAIN
339 using Accumulator = typename std::tuple_element_t<36, ContainerOverSubrelations>;
340 auto tmp =
341 in.get(C::alu_sel_op_eq) * (FF(1) - in.get(C::alu_sel_tag_err)) *
342 ((alu_DIFF * (in.get(C::alu_ic) * (FF(1) - in.get(C::alu_helper1)) + in.get(C::alu_helper1)) - FF(1)) +
343 in.get(C::alu_ic));
344 tmp *= scaling_factor;
345 std::get<36>(evals) += typename Accumulator::View(tmp);
346 }
347 {
348 using Accumulator = typename std::tuple_element_t<37, ContainerOverSubrelations>;
349 auto tmp = in.get(C::alu_sel_op_lt) * (FF(1) - in.get(C::alu_sel_op_lt));
350 tmp *= scaling_factor;
351 std::get<37>(evals) += typename Accumulator::View(tmp);
352 }
353 {
354 using Accumulator = typename std::tuple_element_t<38, ContainerOverSubrelations>;
355 auto tmp = in.get(C::alu_sel_op_lte) * (FF(1) - in.get(C::alu_sel_op_lte));
356 tmp *= scaling_factor;
357 std::get<38>(evals) += typename Accumulator::View(tmp);
358 }
359 {
360 using Accumulator = typename std::tuple_element_t<39, ContainerOverSubrelations>;
361 auto tmp = (in.get(C::alu_sel_lt_ops) -
362 (FF(1) - in.get(C::alu_sel_tag_err)) * (in.get(C::alu_sel_op_lt) + in.get(C::alu_sel_op_lte)));
363 tmp *= scaling_factor;
364 std::get<39>(evals) += typename Accumulator::View(tmp);
365 }
366 {
367 using Accumulator = typename std::tuple_element_t<40, ContainerOverSubrelations>;
368 auto tmp = (in.get(C::alu_sel_ff_lt_ops) - in.get(C::alu_sel_is_ff) * in.get(C::alu_sel_lt_ops));
369 tmp *= scaling_factor;
370 std::get<40>(evals) += typename Accumulator::View(tmp);
371 }
372 {
373 using Accumulator = typename std::tuple_element_t<41, ContainerOverSubrelations>;
374 auto tmp = (in.get(C::alu_sel_int_lt_ops) - alu_IS_NOT_FF * in.get(C::alu_sel_lt_ops));
375 tmp *= scaling_factor;
376 std::get<41>(evals) += typename Accumulator::View(tmp);
377 }
378 { // LT_SWAP_INPUTS_A
379 using Accumulator = typename std::tuple_element_t<42, ContainerOverSubrelations>;
380 auto tmp = (in.get(C::alu_sel_op_lt) * (in.get(C::alu_lt_ops_input_a) - in.get(C::alu_ib)) +
381 in.get(C::alu_sel_op_lte) * (in.get(C::alu_lt_ops_input_a) - in.get(C::alu_ia)));
382 tmp *= scaling_factor;
383 std::get<42>(evals) += typename Accumulator::View(tmp);
384 }
385 { // LT_SWAP_INPUTS_B
386 using Accumulator = typename std::tuple_element_t<43, ContainerOverSubrelations>;
387 auto tmp = (in.get(C::alu_sel_op_lt) * (in.get(C::alu_lt_ops_input_b) - in.get(C::alu_ia)) +
388 in.get(C::alu_sel_op_lte) * (in.get(C::alu_lt_ops_input_b) - in.get(C::alu_ib)));
389 tmp *= scaling_factor;
390 std::get<43>(evals) += typename Accumulator::View(tmp);
391 }
392 { // LTE_NEGATE_RESULT_C
393 using Accumulator = typename std::tuple_element_t<44, ContainerOverSubrelations>;
394 auto tmp = (in.get(C::alu_sel_op_lt) * (in.get(C::alu_lt_ops_result_c) - in.get(C::alu_ic)) +
395 in.get(C::alu_sel_op_lte) * (FF(1) - in.get(C::alu_sel_tag_err)) *
396 ((FF(1) - in.get(C::alu_lt_ops_result_c)) - in.get(C::alu_ic)));
397 tmp *= scaling_factor;
398 std::get<44>(evals) += typename Accumulator::View(tmp);
399 }
400 {
401 using Accumulator = typename std::tuple_element_t<45, ContainerOverSubrelations>;
402 auto tmp = in.get(C::alu_sel_op_not) * (FF(1) - in.get(C::alu_sel_op_not));
403 tmp *= scaling_factor;
404 std::get<45>(evals) += typename Accumulator::View(tmp);
405 }
406 { // NOT_OP_MAIN
407 using Accumulator = typename std::tuple_element_t<46, ContainerOverSubrelations>;
408 auto tmp = in.get(C::alu_sel_op_not) * (FF(1) - in.get(C::alu_sel_tag_err)) *
409 ((in.get(C::alu_ia) + in.get(C::alu_ib)) - in.get(C::alu_max_value));
410 tmp *= scaling_factor;
411 std::get<46>(evals) += typename Accumulator::View(tmp);
412 }
413 { // SHL_TWO_POW_SHIFT
414 using Accumulator = typename std::tuple_element_t<47, ContainerOverSubrelations>;
415 auto tmp = in.get(C::alu_sel_op_shl) * in.get(C::alu_sel_shift_ops_no_overflow) *
416 (FF(1) - in.get(C::alu_sel_tag_err)) *
417 ((in.get(C::alu_max_value) + FF(1)) - in.get(C::alu_two_pow_shift_lo_bits) * in.get(C::alu_helper1));
418 tmp *= scaling_factor;
419 std::get<47>(evals) += typename Accumulator::View(tmp);
420 }
421 { // ALU_SHL
422 using Accumulator = typename std::tuple_element_t<48, ContainerOverSubrelations>;
423 auto tmp = in.get(C::alu_sel_op_shl) * (FF(1) - in.get(C::alu_sel_tag_err)) *
424 (in.get(C::alu_ic) -
425 in.get(C::alu_sel_shift_ops_no_overflow) * in.get(C::alu_a_lo) * in.get(C::alu_helper1));
426 tmp *= scaling_factor;
427 std::get<48>(evals) += typename Accumulator::View(tmp);
428 }
429 { // ALU_SHR
430 using Accumulator = typename std::tuple_element_t<49, ContainerOverSubrelations>;
431 auto tmp = in.get(C::alu_sel_op_shr) * (FF(1) - in.get(C::alu_sel_tag_err)) *
432 (in.get(C::alu_ic) - in.get(C::alu_sel_shift_ops_no_overflow) * in.get(C::alu_a_hi));
433 tmp *= scaling_factor;
434 std::get<49>(evals) += typename Accumulator::View(tmp);
435 }
436 {
437 using Accumulator = typename std::tuple_element_t<50, ContainerOverSubrelations>;
438 auto tmp = (in.get(C::alu_sel_shift_ops) - (in.get(C::alu_sel_op_shl) + in.get(C::alu_sel_op_shr)));
439 tmp *= scaling_factor;
440 std::get<50>(evals) += typename Accumulator::View(tmp);
441 }
442 {
443 using Accumulator = typename std::tuple_element_t<51, ContainerOverSubrelations>;
444 auto tmp = in.get(C::alu_sel_shift_ops_no_overflow) * (FF(1) - in.get(C::alu_sel_shift_ops));
445 tmp *= scaling_factor;
446 std::get<51>(evals) += typename Accumulator::View(tmp);
447 }
448 { // SHIFTS_LO_BITS
449 using Accumulator = typename std::tuple_element_t<52, ContainerOverSubrelations>;
450 auto tmp = ((in.get(C::alu_shift_lo_bits) -
451 in.get(C::alu_sel_shift_ops_no_overflow) *
452 (in.get(C::alu_sel_op_shl) * (in.get(C::alu_max_bits) - in.get(C::alu_ib)) +
453 in.get(C::alu_sel_op_shr) * in.get(C::alu_ib))) -
454 alu_SHIFT_OVERFLOW * in.get(C::alu_max_bits));
455 tmp *= scaling_factor;
456 std::get<52>(evals) += typename Accumulator::View(tmp);
457 }
458 {
459 using Accumulator = typename std::tuple_element_t<53, ContainerOverSubrelations>;
460 auto tmp = in.get(C::alu_sel_op_truncate) * (FF(1) - in.get(C::alu_sel_op_truncate));
461 tmp *= scaling_factor;
462 std::get<53>(evals) += typename Accumulator::View(tmp);
463 }
464 {
465 using Accumulator = typename std::tuple_element_t<54, ContainerOverSubrelations>;
466 auto tmp = in.get(C::alu_sel_trunc_trivial) * (FF(1) - in.get(C::alu_sel_trunc_trivial));
467 tmp *= scaling_factor;
468 std::get<54>(evals) += typename Accumulator::View(tmp);
469 }
470 {
471 using Accumulator = typename std::tuple_element_t<55, ContainerOverSubrelations>;
472 auto tmp = in.get(C::alu_sel_trunc_gte_128) * (FF(1) - in.get(C::alu_sel_trunc_gte_128));
473 tmp *= scaling_factor;
474 std::get<55>(evals) += typename Accumulator::View(tmp);
475 }
476 {
477 using Accumulator = typename std::tuple_element_t<56, ContainerOverSubrelations>;
478 auto tmp = in.get(C::alu_sel_trunc_lt_128) * (FF(1) - in.get(C::alu_sel_trunc_lt_128));
479 tmp *= scaling_factor;
480 std::get<56>(evals) += typename Accumulator::View(tmp);
481 }
482 { // SEL_TRUNC_NON_TRIVIAL
483 using Accumulator = typename std::tuple_element_t<57, ContainerOverSubrelations>;
484 auto tmp = (in.get(C::alu_sel_trunc_non_trivial) -
485 (in.get(C::alu_sel_trunc_gte_128) + in.get(C::alu_sel_trunc_lt_128)));
486 tmp *= scaling_factor;
487 std::get<57>(evals) += typename Accumulator::View(tmp);
488 }
489 { // SEL_TRUNCATE
490 using Accumulator = typename std::tuple_element_t<58, ContainerOverSubrelations>;
491 auto tmp = (in.get(C::alu_sel_op_truncate) -
492 (in.get(C::alu_sel_trunc_non_trivial) + in.get(C::alu_sel_trunc_trivial)));
493 tmp *= scaling_factor;
494 std::get<58>(evals) += typename Accumulator::View(tmp);
495 }
496 { // TRUNC_TRIVIAL_CASE
497 using Accumulator = typename std::tuple_element_t<59, ContainerOverSubrelations>;
498 auto tmp = in.get(C::alu_sel_trunc_trivial) * (in.get(C::alu_ia) - in.get(C::alu_ic));
499 tmp *= scaling_factor;
500 std::get<59>(evals) += typename Accumulator::View(tmp);
501 }
502 { // SMALL_TRUNC_VAL_IS_LO
503 using Accumulator = typename std::tuple_element_t<60, ContainerOverSubrelations>;
504 auto tmp = in.get(C::alu_sel_trunc_lt_128) * (in.get(C::alu_a_lo) - in.get(C::alu_ia));
505 tmp *= scaling_factor;
506 std::get<60>(evals) += typename Accumulator::View(tmp);
507 }
508 { // TRUNC_LO_128_DECOMPOSITION
509 using Accumulator = typename std::tuple_element_t<61, ContainerOverSubrelations>;
510 auto tmp =
511 in.get(C::alu_sel_trunc_non_trivial) *
512 ((in.get(C::alu_ic) + in.get(C::alu_mid) * (in.get(C::alu_max_value) + FF(1))) - in.get(C::alu_a_lo));
513 tmp *= scaling_factor;
514 std::get<61>(evals) += typename Accumulator::View(tmp);
515 }
516 { // TRUNC_MID_BITS
517 using Accumulator = typename std::tuple_element_t<62, ContainerOverSubrelations>;
518 auto tmp =
519 (in.get(C::alu_mid_bits) - in.get(C::alu_sel_trunc_non_trivial) * (FF(128) - in.get(C::alu_max_bits)));
520 tmp *= scaling_factor;
521 std::get<62>(evals) += typename Accumulator::View(tmp);
522 }
523}
524
525} // namespace bb::avm2
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
Definition alu_impl.hpp:10
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.