Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
program_block.cpp
Go to the documentation of this file.
10
12{
14 .operand(static_cast<uint16_t>(0))
16 .operand(address.base_offset)
17 .build();
19 .operand(address.pointer_address)
21 .operand(actual_address)
22 .build();
23 switch (address.mode) {
25 instructions.push_back(set_pointer_instruction);
27 break;
28 }
30 instructions.push_back(set_base_offset_instruction);
32 break;
33 }
35 instructions.push_back(set_pointer_instruction);
36 instructions.push_back(set_base_offset_instruction);
39 break;
40 }
42 break;
43 }
44}
45
47{
48 // hack: just converting it to AddressRef and using the same function
49 auto address_ref = AddressRef{ .tag = bb::avm2::ValueTag::U32,
50 .pointer_address = address.pointer_address,
51 .base_offset = address.base_offset,
52 .mode = address.mode };
53 preprocess_memory_addresses(address_ref, actual_address);
54}
55
57{
61 if (!a.has_value() || !b.has_value() || !result.has_value()) {
62 return;
63 }
64 preprocess_memory_addresses(instruction.a_address, a.value().first);
65 preprocess_memory_addresses(instruction.b_address, b.value().first);
66 preprocess_memory_addresses(instruction.result_address, result.value().first);
67
69 .operand(a.value().second)
70 .operand(b.value().second)
71 .operand(result.value().second)
72 .build();
73 instructions.push_back(add_8_instruction);
74 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
75}
76
78{
79
83 if (!a.has_value() || !b.has_value() || !result.has_value()) {
84 return;
85 }
86 preprocess_memory_addresses(instruction.a_address, a.value().first);
87 preprocess_memory_addresses(instruction.b_address, b.value().first);
88 preprocess_memory_addresses(instruction.result_address, result.value().first);
90 .operand(a.value().second)
91 .operand(b.value().second)
92 .operand(result.value().second)
93 .build();
94 instructions.push_back(sub_8_instruction);
95 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
96}
97
99{
102 auto result = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
103 if (!a.has_value() || !b.has_value() || !result.has_value()) {
104 return;
105 }
106 preprocess_memory_addresses(instruction.a_address, a.value().first);
107 preprocess_memory_addresses(instruction.b_address, b.value().first);
108 preprocess_memory_addresses(instruction.result_address, result.value().first);
110 .operand(a.value().second)
111 .operand(b.value().second)
112 .operand(result.value().second)
113 .build();
114 instructions.push_back(mul_8_instruction);
115 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
116}
117
119{
122 auto result = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
123 if (!a.has_value() || !b.has_value() || !result.has_value()) {
124 return;
125 }
126 preprocess_memory_addresses(instruction.a_address, a.value().first);
127 preprocess_memory_addresses(instruction.b_address, b.value().first);
128 preprocess_memory_addresses(instruction.result_address, result.value().first);
130 .operand(a.value().second)
131 .operand(b.value().second)
132 .operand(result.value().second)
133 .build();
134 instructions.push_back(div_8_instruction);
135 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
136}
137
139{
142 auto result = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
143 if (!a.has_value() || !b.has_value() || !result.has_value()) {
144 return;
145 }
146 preprocess_memory_addresses(instruction.a_address, a.value().first);
147 preprocess_memory_addresses(instruction.b_address, b.value().first);
148 preprocess_memory_addresses(instruction.result_address, result.value().first);
150 .operand(a.value().second)
151 .operand(b.value().second)
152 .operand(result.value().second)
153 .build();
154 instructions.push_back(eq_8_instruction);
156}
157
159{
160
163 auto result = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
164 if (!a.has_value() || !b.has_value() || !result.has_value()) {
165 return;
166 }
167 preprocess_memory_addresses(instruction.a_address, a.value().first);
168 preprocess_memory_addresses(instruction.b_address, b.value().first);
169 preprocess_memory_addresses(instruction.result_address, result.value().first);
171 .operand(a.value().second)
172 .operand(b.value().second)
173 .operand(result.value().second)
174 .build();
175 instructions.push_back(lt_8_instruction);
177}
178
180{
183 auto result = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
184 if (!a.has_value() || !b.has_value() || !result.has_value()) {
185 return;
186 }
187 preprocess_memory_addresses(instruction.a_address, a.value().first);
188 preprocess_memory_addresses(instruction.b_address, b.value().first);
189 preprocess_memory_addresses(instruction.result_address, result.value().first);
191 .operand(a.value().second)
192 .operand(b.value().second)
193 .operand(result.value().second)
194 .build();
195 instructions.push_back(lte_8_instruction);
197}
198
200{
203 auto result = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
204 if (!a.has_value() || !b.has_value() || !result.has_value()) {
205 return;
206 }
207
208 preprocess_memory_addresses(instruction.a_address, a.value().first);
209 preprocess_memory_addresses(instruction.b_address, b.value().first);
210 preprocess_memory_addresses(instruction.result_address, result.value().first);
212 .operand(a.value().second)
213 .operand(b.value().second)
214 .operand(result.value().second)
215 .build();
216 instructions.push_back(and_8_instruction);
217 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
218}
219
221{
224 auto result = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
225 if (!a.has_value() || !b.has_value() || !result.has_value()) {
226 return;
227 }
228
229 preprocess_memory_addresses(instruction.a_address, a.value().first);
230 preprocess_memory_addresses(instruction.b_address, b.value().first);
231 preprocess_memory_addresses(instruction.result_address, result.value().first);
233 .operand(a.value().second)
234 .operand(b.value().second)
235 .operand(result.value().second)
236 .build();
237 instructions.push_back(or_8_instruction);
238 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
239}
240
242{
245 auto result = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
246 if (!a.has_value() || !b.has_value() || !result.has_value()) {
247 return;
248 }
249
250 preprocess_memory_addresses(instruction.a_address, a.value().first);
251 preprocess_memory_addresses(instruction.b_address, b.value().first);
252 preprocess_memory_addresses(instruction.result_address, result.value().first);
254 .operand(a.value().second)
255 .operand(b.value().second)
256 .operand(result.value().second)
257 .build();
258 instructions.push_back(xor_8_instruction);
259 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
260}
261
263{
264
267 auto result = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
268 if (!a.has_value() || !b.has_value() || !result.has_value()) {
269 return;
270 }
271
272 preprocess_memory_addresses(instruction.a_address, a.value().first);
273 preprocess_memory_addresses(instruction.b_address, b.value().first);
274 preprocess_memory_addresses(instruction.result_address, result.value().first);
276 .operand(a.value().second)
277 .operand(b.value().second)
278 .operand(result.value().second)
279 .build();
280 instructions.push_back(shl_8_instruction);
281 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
282}
283
285{
286
289 auto result = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
290 if (!a.has_value() || !b.has_value() || !result.has_value()) {
291 return;
292 }
293
294 preprocess_memory_addresses(instruction.a_address, a.value().first);
295 preprocess_memory_addresses(instruction.b_address, b.value().first);
296 preprocess_memory_addresses(instruction.result_address, result.value().first);
298 .operand(a.value().second)
299 .operand(b.value().second)
300 .operand(result.value().second)
301 .build();
302 instructions.push_back(shr_8_instruction);
303 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
304}
305
307{
308 auto effective_address_operand = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
309 if (!effective_address_operand.has_value()) {
310 return;
311 }
312 preprocess_memory_addresses(instruction.result_address, effective_address_operand.value().first);
314 .operand(effective_address_operand.value().second)
315 .operand(instruction.value_tag.value)
316 .operand(instruction.value)
317 .build());
318 memory_manager.set_memory_address(instruction.value_tag.value, instruction.result_address.address);
319}
320
322{
323 auto effective_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
324 if (!effective_address_operand.has_value()) {
325 return;
326 }
327 preprocess_memory_addresses(instruction.result_address, effective_address_operand.value().first);
329 .operand(effective_address_operand.value().second)
330 .operand(instruction.value_tag.value)
331 .operand(instruction.value)
332 .build());
333 memory_manager.set_memory_address(instruction.value_tag.value, instruction.result_address.address);
334}
335
337{
338 auto effective_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
339 if (!effective_address_operand.has_value()) {
340 return;
341 }
342 preprocess_memory_addresses(instruction.result_address, effective_address_operand.value().first);
344 .operand(effective_address_operand.value().second)
345 .operand(instruction.value_tag.value)
346 .operand(instruction.value)
347 .build());
348 memory_manager.set_memory_address(instruction.value_tag.value, instruction.result_address.address);
349}
350
352{
353 auto effective_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
354 if (!effective_address_operand.has_value()) {
355 return;
356 }
357 preprocess_memory_addresses(instruction.result_address, effective_address_operand.value().first);
359 .operand(effective_address_operand.value().second)
360 .operand(instruction.value_tag.value)
361 .operand(instruction.value)
362 .build());
363 memory_manager.set_memory_address(instruction.value_tag.value, instruction.result_address.address);
364}
365
367{
368 auto effective_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
369 if (!effective_address_operand.has_value()) {
370 return;
371 }
373 (static_cast<uint128_t>(instruction.value_high) << 64) | static_cast<uint128_t>(instruction.value_low);
374 preprocess_memory_addresses(instruction.result_address, effective_address_operand.value().first);
376 .operand(effective_address_operand.value().second)
377 .operand(instruction.value_tag.value)
378 .operand(value)
379 .build());
380 memory_manager.set_memory_address(instruction.value_tag.value, instruction.result_address.address);
381}
382
384{
385 auto effective_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
386 if (!effective_address_operand.has_value()) {
387 return;
388 }
389 preprocess_memory_addresses(instruction.result_address, effective_address_operand.value().first);
391 .operand(effective_address_operand.value().second)
392 .operand(instruction.value_tag.value)
393 .operand(instruction.value)
394 .build());
395 memory_manager.set_memory_address(instruction.value_tag.value, instruction.result_address.address);
396}
397
399{
400 auto src_address_operand = memory_manager.get_memory_address_and_operand_8(instruction.src_address);
401 auto result_address_operand = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
402 if (!src_address_operand.has_value() || !result_address_operand.has_value()) {
403 return;
404 }
405 preprocess_memory_addresses(instruction.src_address, src_address_operand.value().first);
406 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
408 .operand(src_address_operand.value().second)
409 .operand(result_address_operand.value().second)
410 .build();
411 instructions.push_back(mov_8_instruction);
412 memory_manager.set_memory_address(instruction.src_address.tag, instruction.result_address.address);
413}
414
416{
417 auto src_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.src_address);
418 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
419 if (!src_address_operand.has_value() || !result_address_operand.has_value()) {
420 return;
421 }
422
423 preprocess_memory_addresses(instruction.src_address, src_address_operand.value().first);
424 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
426 .operand(src_address_operand.value().second)
427 .operand(result_address_operand.value().second)
428 .build();
429 instructions.push_back(mov_16_instruction);
430 memory_manager.set_memory_address(instruction.src_address.tag, instruction.result_address.address);
431}
432
434{
435 auto a_address_operand = memory_manager.get_memory_address_and_operand_8(instruction.a_address);
436 auto b_address_operand = memory_manager.get_memory_address_and_operand_8(instruction.b_address);
437 auto result_address_operand = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
438 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
439 return;
440 }
441
442 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
443 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
444 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
446 .operand(a_address_operand.value().second)
447 .operand(b_address_operand.value().second)
448 .operand(result_address_operand.value().second)
449 .build();
450 instructions.push_back(fdiv_8_instruction);
451 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
452}
453
455{
456 auto a_address_operand = memory_manager.get_memory_address_and_operand_8(instruction.a_address);
457 auto result_address_operand = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
458 if (!a_address_operand.has_value() || !result_address_operand.has_value()) {
459 return;
460 }
461
462 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
463 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
465 .operand(a_address_operand.value().second)
466 .operand(result_address_operand.value().second)
467 .build();
468 instructions.push_back(not_8_instruction);
469 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
470}
471
473{
474 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
475 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
476 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
477 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
478 return;
479 }
480
481 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
482 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
483 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
485 .operand(a_address_operand.value().second)
486 .operand(b_address_operand.value().second)
487 .operand(result_address_operand.value().second)
488 .build();
489 instructions.push_back(add_16_instruction);
490 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
491}
492
494{
495 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
496 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
497 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
498 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
499 return;
500 }
501
502 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
503 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
504 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
506 .operand(a_address_operand.value().second)
507 .operand(b_address_operand.value().second)
508 .operand(result_address_operand.value().second)
509 .build();
510 instructions.push_back(sub_16_instruction);
511 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
512}
513
515{
516 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
517 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
518 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
519 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
520 return;
521 }
522
523 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
524 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
525 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
527 .operand(a_address_operand.value().second)
528 .operand(b_address_operand.value().second)
529 .operand(result_address_operand.value().second)
530 .build();
531 instructions.push_back(mul_16_instruction);
532 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
533}
534
536{
537 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
538 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
539 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
540 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
541 return;
542 }
543
544 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
545 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
546 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
548 .operand(a_address_operand.value().second)
549 .operand(b_address_operand.value().second)
550 .operand(result_address_operand.value().second)
551 .build();
552 instructions.push_back(div_16_instruction);
553 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
554}
555
557{
558 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
559 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
560 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
561 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
562 return;
563 }
564
565 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
566 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
567 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
569 .operand(a_address_operand.value().second)
570 .operand(b_address_operand.value().second)
571 .operand(result_address_operand.value().second)
572 .build();
573 instructions.push_back(fdiv_16_instruction);
574 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
575}
576
578{
579 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
580 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
581 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
582 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
583 return;
584 }
585
586 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
587 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
588 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
590 .operand(a_address_operand.value().second)
591 .operand(b_address_operand.value().second)
592 .operand(result_address_operand.value().second)
593 .build();
594 instructions.push_back(eq_16_instruction);
596}
597
599{
600 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
601 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
602 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
603 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
604 return;
605 }
606
607 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
608 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
609 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
611 .operand(a_address_operand.value().second)
612 .operand(b_address_operand.value().second)
613 .operand(result_address_operand.value().second)
614 .build();
615 instructions.push_back(lt_16_instruction);
617}
618
620{
621 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
622 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
623 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
624 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
625 return;
626 }
627
628 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
629 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
630 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
632 .operand(a_address_operand.value().second)
633 .operand(b_address_operand.value().second)
634 .operand(result_address_operand.value().second)
635 .build();
636 instructions.push_back(lte_16_instruction);
638}
639
641{
642 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
643 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
644 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
645 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
646 return;
647 }
648
649 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
650 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
651 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
653 .operand(a_address_operand.value().second)
654 .operand(b_address_operand.value().second)
655 .operand(result_address_operand.value().second)
656 .build();
657 instructions.push_back(and_16_instruction);
658 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
659}
660
662{
663 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
664 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
665 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
666 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
667 return;
668 }
669
670 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
671 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
672 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
674 .operand(a_address_operand.value().second)
675 .operand(b_address_operand.value().second)
676 .operand(result_address_operand.value().second)
677 .build();
678 instructions.push_back(or_16_instruction);
679 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
680}
681
683{
684 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
685 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
686 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
687 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
688 return;
689 }
690
691 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
692 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
693 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
695 .operand(a_address_operand.value().second)
696 .operand(b_address_operand.value().second)
697 .operand(result_address_operand.value().second)
698 .build();
699 instructions.push_back(xor_16_instruction);
700 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
701}
702
704{
705 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
706 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
707 if (!a_address_operand.has_value() || !result_address_operand.has_value()) {
708 return;
709 }
710
711 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
712 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
714 .operand(a_address_operand.value().second)
715 .operand(result_address_operand.value().second)
716 .build();
717 instructions.push_back(not_16_instruction);
718 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
719}
720
722{
723 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
724 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
725 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
726 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
727 return;
728 }
729 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
730 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
731 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
732
734 .operand(a_address_operand.value().second)
735 .operand(b_address_operand.value().second)
736 .operand(result_address_operand.value().second)
737 .build();
738 instructions.push_back(shl_16_instruction);
739 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
740}
741
743{
744 auto a_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.a_address);
745 auto b_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.b_address);
746 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
747 if (!a_address_operand.has_value() || !b_address_operand.has_value() || !result_address_operand.has_value()) {
748 return;
749 }
750
751 preprocess_memory_addresses(instruction.a_address, a_address_operand.value().first);
752 preprocess_memory_addresses(instruction.b_address, b_address_operand.value().first);
753 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
755 .operand(a_address_operand.value().second)
756 .operand(b_address_operand.value().second)
757 .operand(result_address_operand.value().second)
758 .build();
759 instructions.push_back(shr_16_instruction);
760 memory_manager.set_memory_address(instruction.a_address.tag, instruction.result_address.address);
761}
762
764{
765 auto src_address_operand = memory_manager.get_memory_address_and_operand_8(instruction.src_address);
766 auto result_address_operand = memory_manager.get_memory_address_and_operand_8(instruction.result_address);
767 if (!src_address_operand.has_value() || !result_address_operand.has_value()) {
768 return;
769 }
770
771 preprocess_memory_addresses(instruction.src_address, src_address_operand.value().first);
772 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
774 .operand(src_address_operand.value().second)
775 .operand(result_address_operand.value().second)
776 .operand(instruction.target_tag.value)
777 .build();
778 instructions.push_back(cast_8_instruction);
779 memory_manager.set_memory_address(instruction.target_tag.value, instruction.result_address.address);
780}
781
783{
784 auto src_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.src_address);
785 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
786 if (!src_address_operand.has_value() || !result_address_operand.has_value()) {
787 return;
788 }
789
790 preprocess_memory_addresses(instruction.src_address, src_address_operand.value().first);
791 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
793 .operand(src_address_operand.value().second)
794 .operand(result_address_operand.value().second)
795 .operand(instruction.target_tag.value)
796 .build();
797 instructions.push_back(cast_16_instruction);
798 memory_manager.set_memory_address(instruction.target_tag.value, instruction.result_address.address);
799}
800
802{
803 auto src_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.src_address);
804 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
805 if (!src_address_operand.has_value() || !result_address_operand.has_value()) {
806 return;
807 }
808 preprocess_memory_addresses(instruction.src_address, src_address_operand.value().first);
809 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
810 auto set_slot_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF,
811 .result_address = instruction.result_address,
812 .value = instruction.slot };
813 this->process_set_ff_instruction(set_slot_instruction);
815 .operand(src_address_operand.value().second)
816 .operand(result_address_operand.value().second)
817 .build();
818 instructions.push_back(sstore_instruction);
820}
821
823{
824 auto slot_addr = memory_manager.get_slot(instruction.slot_index);
825 if (!slot_addr.has_value()) {
826 return;
827 }
828
829 auto set_slot_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF,
830 .result_address = instruction.slot_address,
831 .value = *slot_addr };
832 this->process_set_ff_instruction(set_slot_instruction);
833 auto slot_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.slot_address);
834 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
835 if (!slot_address_operand.has_value() || !result_address_operand.has_value()) {
836 return;
837 }
838 preprocess_memory_addresses(instruction.slot_address, slot_address_operand.value().first);
839 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
840
842 .operand(slot_address_operand.value().second)
843 .operand(result_address_operand.value().second)
844 .build();
845 instructions.push_back(sload_instruction);
847}
848
850{
851 auto instruction_type = static_cast<uint8_t>(instruction.type % 12);
852 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
853 if (!result_address_operand.has_value()) {
854 return;
855 }
856 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
858 .operand(result_address_operand.value().second)
859 .operand(instruction_type)
860 .build();
861 instructions.push_back(getenvvar_instruction);
862 // special case for timestamp, it returns a 64-bit value
863 if (instruction_type == 6) {
865 } else {
867 }
868}
869
871{
872 auto nullifier_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.nullifier_address);
873 if (!nullifier_address_operand.has_value()) {
874 return;
875 }
876 preprocess_memory_addresses(instruction.nullifier_address, nullifier_address_operand.value().first);
878 .operand(nullifier_address_operand.value().second)
879 .build();
880 instructions.push_back(emitnulifier_instruction);
881}
882
884{
885 auto nullifier_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.nullifier_address);
886 auto contract_address_operand =
888 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
889 if (!nullifier_address_operand.has_value() || !contract_address_operand.has_value() ||
890 !result_address_operand.has_value()) {
891 return;
892 }
893
894 preprocess_memory_addresses(instruction.nullifier_address, nullifier_address_operand.value().first);
895 preprocess_memory_addresses(instruction.contract_address_address, contract_address_operand.value().first);
896 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
897 auto get_contract_address_instruction =
898 GETENVVAR_Instruction{ .result_address = instruction.contract_address_address, .type = 0 };
899 this->process_getenvvar_instruction(get_contract_address_instruction);
900
902 .operand(nullifier_address_operand.value().second)
903 .operand(contract_address_operand.value().second)
904 .operand(result_address_operand.value().second)
905 .build();
906 instructions.push_back(nullifierexists_instruction);
908}
909
911{
912 auto set_note_hash_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF,
913 .result_address = instruction.note_hash_address,
914 .value = instruction.note_hash };
915 this->process_set_ff_instruction(set_note_hash_instruction);
916
917 // EMITNOTEHASH expects UINT16 operand
918 auto note_hash_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.note_hash_address);
919 if (!note_hash_address_operand.has_value()) {
920 return;
921 }
922 preprocess_memory_addresses(instruction.note_hash_address, note_hash_address_operand.value().first);
923
925 .operand(note_hash_address_operand.value().second)
926 .build();
927 instructions.push_back(emitnotehash_instruction);
929}
930
932{
934 if (!note_hash.has_value()) {
935 return;
936 }
937 auto leaf_index = memory_manager.get_leaf_index(instruction.notehash_index);
938 if (!leaf_index.has_value()) {
939 return;
940 }
942 auto note_hash_counter = static_cast<uint64_t>(*leaf_index);
944 auto unique_note_computed_hash = bb::avm2::simulation::unconstrained_make_unique_note_hash(
945 siloed_note_computed_hash, FIRST_NULLIFIER, note_hash_counter);
946
947 auto set_note_hash_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF,
948 .result_address = instruction.notehash_address,
949 .value = unique_note_computed_hash };
950 this->process_set_ff_instruction(set_note_hash_instruction);
951 auto set_leaf_index_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::U64,
952 .result_address = instruction.leaf_index_address,
953 .value = *leaf_index };
954 this->process_set_ff_instruction(set_leaf_index_instruction);
955
956 auto notehash_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.notehash_address);
957 auto leaf_index_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.leaf_index_address);
958 auto result_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.result_address);
959 if (!notehash_address_operand.has_value() || !leaf_index_address_operand.has_value() ||
960 !result_address_operand.has_value()) {
961 return;
962 }
963 preprocess_memory_addresses(instruction.notehash_address, notehash_address_operand.value().first);
964 preprocess_memory_addresses(instruction.leaf_index_address, leaf_index_address_operand.value().first);
965 preprocess_memory_addresses(instruction.result_address, result_address_operand.value().first);
966
968 .operand(notehash_address_operand.value().second)
969 .operand(leaf_index_address_operand.value().second)
970 .operand(result_address_operand.value().second)
971 .build();
972 instructions.push_back(notehashexists_instruction);
974}
975
977{
978 auto copy_size_set_instruction = SET_32_Instruction{ .value_tag = bb::avm2::MemoryTag::U32,
979 .result_address = instruction.copy_size_address,
980 .value = instruction.copy_size };
981 this->process_set_32_instruction(copy_size_set_instruction);
982 auto cd_start_set_instruction = SET_32_Instruction{ .value_tag = bb::avm2::MemoryTag::U32,
983 .result_address = instruction.cd_start_address,
984 .value = instruction.cd_start };
985 this->process_set_32_instruction(cd_start_set_instruction);
986 // CALLDATACOPY expects UINT16 operands for all three addresses
987 auto copy_size_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.copy_size_address);
988 auto cd_start_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.cd_start_address);
989 auto dst_address_operand = memory_manager.get_memory_address_and_operand_16(instruction.dst_address);
990 if (!copy_size_address_operand.has_value() || !cd_start_address_operand.has_value() ||
991 !dst_address_operand.has_value()) {
992 return;
993 }
994
995 preprocess_memory_addresses(instruction.copy_size_address, copy_size_address_operand.value().first);
996 preprocess_memory_addresses(instruction.cd_start_address, cd_start_address_operand.value().first);
997 preprocess_memory_addresses(instruction.dst_address, dst_address_operand.value().first);
999 .operand(copy_size_address_operand.value().second)
1000 .operand(cd_start_address_operand.value().second)
1001 .operand(dst_address_operand.value().second)
1002 .build();
1003 instructions.push_back(calldatacopy_instruction);
1004
1005 // setting calldata_addr to u32 to avoid overflows
1006 auto loop_upper_bound =
1007 static_cast<uint32_t>(std::min((instruction.dst_address.address) + instruction.copy_size, 65535U));
1008 for (uint32_t calldata_addr = instruction.dst_address.address; calldata_addr < loop_upper_bound; calldata_addr++) {
1010 }
1011}
1012
1016{
1018 // if the block is called by INTERNALCALL, just insert INTERNALRETURN
1019 if (caller != nullptr) {
1020 auto internalreturn_instruction =
1022 instructions.push_back(internalreturn_instruction);
1023 return;
1024 }
1025
1027 if (!return_addr.has_value()) {
1028 return_addr = std::optional<uint32_t>(0);
1029 }
1030
1031 // TODO(defkit): return_size_offset should be const and defined by fuzzer
1032
1033 uint16_t return_size_offset = 5U;
1034 // Ensure operands are created as U16 to match wire format (UINT16)
1036 .operand(return_size_offset)
1038 .operand(static_cast<uint16_t>(return_size))
1039 .build();
1040 instructions.push_back(set_size_instruction);
1041 // RETURN expects UINT16 operands, ensure we cast to uint16_t explicitly
1043 .operand(static_cast<uint16_t>(return_size_offset))
1044 .operand(static_cast<uint16_t>(return_addr.value()))
1045 .build();
1046 instructions.push_back(return_instruction);
1047}
1048
1049void ProgramBlock::finalize_with_jump(ProgramBlock* target_block, bool copy_memory_manager)
1050{
1052 successors.push_back(target_block);
1053 target_block->predecessors.push_back(this);
1054 target_block->caller = this->caller;
1055 if (copy_memory_manager) {
1056 target_block->memory_manager = memory_manager;
1057 }
1058}
1059
1061 ProgramBlock* target_else_block,
1062 uint16_t condition_offset,
1063 bool copy_memory_manager)
1064{
1066 successors.push_back(target_then_block);
1067 successors.push_back(target_else_block);
1069 target_then_block->predecessors.push_back(this);
1070 target_else_block->predecessors.push_back(this);
1071 target_then_block->caller = this->caller;
1072 target_else_block->caller = this->caller;
1073 if (copy_memory_manager) {
1074 target_then_block->memory_manager = memory_manager;
1075 target_else_block->memory_manager = memory_manager;
1076 }
1077}
1078
1080{
1081 auto internalcall_instruction =
1083 instructions.push_back(internalcall_instruction);
1085 this->successors.push_back(target_block);
1086 target_block->predecessors.push_back(this);
1087 target_block->caller = this->caller;
1088}
1089
1091{
1092 for (auto [instruction_index, target_block] : internal_call_instruction_indicies_to_patch) {
1093 auto internalcall_instruction = instructions.at(instruction_index);
1094 if (target_block->offset == -1) {
1095 throw std::runtime_error("Target block offset is not set, should not happen");
1096 }
1097 auto internalcall_instruction_builder =
1099 .operand(static_cast<uint32_t>(target_block->offset));
1100 instructions.at(instruction_index) = internalcall_instruction_builder.build();
1101 }
1103}
1104
1106{
1108 if (!condition_addr.has_value()) {
1109 return std::nullopt;
1110 }
1111 return condition_addr;
1112}
1113
1118
1120{
1121 std::visit(
1123 [this](ADD_8_Instruction instruction) { return this->process_add_8_instruction(instruction); },
1124 [this](SUB_8_Instruction instruction) { return this->process_sub_8_instruction(instruction); },
1125 [this](MUL_8_Instruction instruction) { return this->process_mul_8_instruction(instruction); },
1126 [this](DIV_8_Instruction instruction) { return this->process_div_8_instruction(instruction); },
1127 [this](EQ_8_Instruction instruction) { return this->process_eq_8_instruction(instruction); },
1128 [this](LT_8_Instruction instruction) { return this->process_lt_8_instruction(instruction); },
1129 [this](LTE_8_Instruction instruction) { return this->process_lte_8_instruction(instruction); },
1130 [this](AND_8_Instruction instruction) { return this->process_and_8_instruction(instruction); },
1131 [this](OR_8_Instruction instruction) { return this->process_or_8_instruction(instruction); },
1132 [this](XOR_8_Instruction instruction) { return this->process_xor_8_instruction(instruction); },
1133 [this](SHL_8_Instruction instruction) { return this->process_shl_8_instruction(instruction); },
1134 [this](SHR_8_Instruction instruction) { return this->process_shr_8_instruction(instruction); },
1135 [this](SET_8_Instruction instruction) { return this->process_set_8_instruction(instruction); },
1136 [this](SET_16_Instruction instruction) { return this->process_set_16_instruction(instruction); },
1137 [this](SET_32_Instruction instruction) { return this->process_set_32_instruction(instruction); },
1138 [this](SET_64_Instruction instruction) { return this->process_set_64_instruction(instruction); },
1139 [this](SET_128_Instruction instruction) { return this->process_set_128_instruction(instruction); },
1140 [this](SET_FF_Instruction instruction) { return this->process_set_ff_instruction(instruction); },
1141 [this](MOV_8_Instruction instruction) { return this->process_mov_8_instruction(instruction); },
1142 [this](MOV_16_Instruction instruction) { return this->process_mov_16_instruction(instruction); },
1143 [this](FDIV_8_Instruction instruction) { return this->process_fdiv_8_instruction(instruction); },
1144 [this](NOT_8_Instruction instruction) { return this->process_not_8_instruction(instruction); },
1145 [this](ADD_16_Instruction instruction) { return this->process_add_16_instruction(instruction); },
1146 [this](SUB_16_Instruction instruction) { return this->process_sub_16_instruction(instruction); },
1147 [this](MUL_16_Instruction instruction) { return this->process_mul_16_instruction(instruction); },
1148 [this](DIV_16_Instruction instruction) { return this->process_div_16_instruction(instruction); },
1149 [this](FDIV_16_Instruction instruction) { return this->process_fdiv_16_instruction(instruction); },
1150 [this](EQ_16_Instruction instruction) { return this->process_eq_16_instruction(instruction); },
1151 [this](LT_16_Instruction instruction) { return this->process_lt_16_instruction(instruction); },
1152 [this](LTE_16_Instruction instruction) { return this->process_lte_16_instruction(instruction); },
1153 [this](AND_16_Instruction instruction) { return this->process_and_16_instruction(instruction); },
1154 [this](OR_16_Instruction instruction) { return this->process_or_16_instruction(instruction); },
1155 [this](XOR_16_Instruction instruction) { return this->process_xor_16_instruction(instruction); },
1156 [this](NOT_16_Instruction instruction) { return this->process_not_16_instruction(instruction); },
1157 [this](SHL_16_Instruction instruction) { return this->process_shl_16_instruction(instruction); },
1158 [this](SHR_16_Instruction instruction) { return this->process_shr_16_instruction(instruction); },
1159 [this](CAST_8_Instruction instruction) { return this->process_cast_8_instruction(instruction); },
1160 [this](CAST_16_Instruction instruction) { return this->process_cast_16_instruction(instruction); },
1161 [this](SSTORE_Instruction instruction) { return this->process_sstore_instruction(instruction); },
1162 [this](SLOAD_Instruction instruction) { return this->process_sload_instruction(instruction); },
1163 [this](GETENVVAR_Instruction instruction) { return this->process_getenvvar_instruction(instruction); },
1165 return this->process_emitnulifier_instruction(instruction);
1166 },
1168 return this->process_nullifierexists_instruction(instruction);
1169 },
1171 return this->process_emitnotehash_instruction(instruction);
1172 },
1174 return this->process_notehashexists_instruction(instruction);
1175 },
1177 return this->process_calldatacopy_instruction(instruction);
1178 },
1179 [](auto) { throw std::runtime_error("Unknown instruction"); },
1180 },
1181 instruction);
1182}
1183
1184std::vector<bb::avm2::simulation::Instruction> ProgramBlock::get_instructions()
1185{
1186 return instructions;
1187}
::FuzzInstruction FuzzInstruction
const FF FIRST_NULLIFIER
Definition constants.hpp:21
const FF CONTRACT_ADDRESS
Definition constants.hpp:33
std::optional< bb::avm2::FF > get_emitted_note_hash(uint16_t note_hash_index)
std::optional< std::pair< uint32_t, bb::avm2::testing::OperandBuilder > > get_memory_address_and_operand_8(AddressRef address)
std::optional< bb::avm2::FF > get_slot(uint16_t slot_offset_index)
bool is_memory_address_set(uint16_t address)
std::optional< uint16_t > get_leaf_index(uint16_t note_hash_index)
void set_memory_address(bb::avm2::MemoryTag tag, uint32_t address)
std::optional< std::pair< uint32_t, bb::avm2::testing::OperandBuilder > > get_memory_address_and_operand_16(AddressRef address)
void append_slot(bb::avm2::FF slot)
std::optional< uint32_t > get_memory_offset(bb::avm2::MemoryTag tag, uint32_t address_index)
void append_emitted_note_hash(bb::avm2::FF note_hash)
void process_shr_16_instruction(SHR_16_Instruction instruction)
void process_set_8_instruction(SET_8_Instruction instruction)
std::vector< ProgramBlock * > predecessors
void process_sload_instruction(SLOAD_Instruction instruction)
void finalize_with_return(uint8_t return_size, MemoryTagWrapper return_value_tag, uint16_t return_value_offset_index)
finalize the program block with a return instruction Tries to find memory address with the given retu...
std::vector< bb::avm2::simulation::Instruction > get_instructions()
void insert_internal_call(ProgramBlock *target_block)
insert INTERNALCALL instruction with 0 offset
bool is_memory_address_set(uint16_t address)
void process_emitnotehash_instruction(EMITNOTEHASH_Instruction instruction)
void process_xor_16_instruction(XOR_16_Instruction instruction)
ProgramBlock * caller
the block that called this block by INTERNALCALL This field is copied to predecessors on every CFG in...
void process_or_16_instruction(OR_16_Instruction instruction)
void patch_internal_calls()
in insert_internal_call we insert INTERNALCALL instruction with 0 offset, because we don't know the r...
void finalize_with_jump(ProgramBlock *target_block, bool copy_memory_manager=true)
finalize the block with a jump Sets the terminator type to JUMP, adds the target block to the success...
uint16_t condition_offset_index
the offset index of the condition variable (for JUMP_IF)
void process_lte_16_instruction(LTE_16_Instruction instruction)
void process_eq_8_instruction(EQ_8_Instruction instruction)
void process_fdiv_8_instruction(FDIV_8_Instruction instruction)
void process_nullifierexists_instruction(NULLIFIEREXISTS_Instruction instruction)
void process_not_8_instruction(NOT_8_Instruction instruction)
void process_add_8_instruction(ADD_8_Instruction instruction)
void process_and_16_instruction(AND_16_Instruction instruction)
MemoryManager memory_manager
void process_sub_8_instruction(SUB_8_Instruction instruction)
void process_shl_8_instruction(SHL_8_Instruction instruction)
void process_notehashexists_instruction(NOTEHASHEXISTS_Instruction instruction)
void process_div_16_instruction(DIV_16_Instruction instruction)
void process_instruction(FuzzInstruction instruction)
process the instruction
void process_emitnulifier_instruction(EMITNULLIFIER_Instruction instruction)
void process_fdiv_16_instruction(FDIV_16_Instruction instruction)
void process_shl_16_instruction(SHL_16_Instruction instruction)
void process_mul_16_instruction(MUL_16_Instruction instruction)
void process_set_ff_instruction(SET_FF_Instruction instruction)
void process_sstore_instruction(SSTORE_Instruction instruction)
std::map< size_t, ProgramBlock * > internal_call_instruction_indicies_to_patch
void process_div_8_instruction(DIV_8_Instruction instruction)
void process_and_8_instruction(AND_8_Instruction instruction)
void process_lt_16_instruction(LT_16_Instruction instruction)
std::vector< ProgramBlock * > successors
void process_sub_16_instruction(SUB_16_Instruction instruction)
void process_or_8_instruction(OR_8_Instruction instruction)
void process_cast_8_instruction(CAST_8_Instruction instruction)
void process_cast_16_instruction(CAST_16_Instruction instruction)
void process_not_16_instruction(NOT_16_Instruction instruction)
void process_set_64_instruction(SET_64_Instruction instruction)
void process_calldatacopy_instruction(CALLDATACOPY_Instruction instruction)
void process_mov_8_instruction(MOV_8_Instruction instruction)
std::optional< uint16_t > get_terminating_condition_value()
void process_mul_8_instruction(MUL_8_Instruction instruction)
void process_set_16_instruction(SET_16_Instruction instruction)
void process_add_16_instruction(ADD_16_Instruction instruction)
void process_xor_8_instruction(XOR_8_Instruction instruction)
void process_eq_16_instruction(EQ_16_Instruction instruction)
void preprocess_memory_addresses(AddressRef address, uint32_t actual_address)
preprocess the memory addresses Sets M[0] = base_offset for Relative/IndirectRelative modes Sets M[po...
void process_lte_8_instruction(LTE_8_Instruction instruction)
void finalize_with_jump_if(ProgramBlock *target_then_block, ProgramBlock *target_else_block, uint16_t condition_offset, bool copy_memory_manager=true)
finalize the block with a jump if Sets the terminator type to JUMP_IF, adds the target blocks to the ...
void process_set_32_instruction(SET_32_Instruction instruction)
void process_getenvvar_instruction(GETENVVAR_Instruction instruction)
TerminatorType terminator_type
void process_lt_8_instruction(LT_8_Instruction instruction)
std::vector< bb::avm2::simulation::Instruction > instructions
void process_shr_8_instruction(SHR_8_Instruction instruction)
void process_mov_16_instruction(MOV_16_Instruction instruction)
void process_set_128_instruction(SET_128_Instruction instruction)
simulation::Instruction build() const
InstructionBuilder & operand(OperandBuilder operand)
FF a
FF b
Instruction instruction
FF unconstrained_make_unique_note_hash(const FF &siloed_note_hash, const FF &first_nullifier, uint64_t note_hash_counter)
Definition merkle.cpp:41
FF unconstrained_silo_note_hash(const AztecAddress &contract_address, const FF &note_hash)
Definition merkle.cpp:36
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
unsigned __int128 uint128_t
Definition serialize.hpp:44
mem[result_offset] = mem[a_address] + mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] + mem[b_address]
mem[result_offset] = mem[a_address] & mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] & mem[b_address]
MemoryTagWrapper tag
CALLDATACOPY: M[dstOffset:dstOffset+M[copySizeOffset]] = calldata[M[cdStartOffset]:M[cdStartOffset]+M...
CAST_16: cast mem[src_offset_index] to target_tag and store at dst_offset.
CAST_8: cast mem[src_offset_index] to target_tag and store at dst_offset.
mem[result_offset] = mem[a_address] / mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] / mem[b_address]
EMITNOTEHASH: M[note_hash_offset] = note_hash; emit note hash to the note hash tree.
EMITNULIFIER: inserts new nullifier to the nullifier tree.
mem[result_offset] = mem[a_address] == mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] == mem[b_address]
GETENVVAR: M[result_offset] = getenvvar(type)
ResultAddressRef result_address
mem[result_offset] = mem[a_address] < mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] < mem[b_address]
mem[result_offset] = mem[a_address] <= mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] <= mem[b_address]
MOV_16 instruction: mem[dst_offset] = mem[src_offset].
MOV_8 instruction: mem[dst_offset] = mem[src_offset].
mem[result_offset] = mem[a_address] * mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] * mem[b_address]
Wrapper for MemoryTag to allow for msgpack packing and unpacking.
NOTEHASHEXISTS: M[result_offset] = NOTEHASHEXISTS(M[notehash_offset], M[leaf_index_offset]) len = len...
NULLIFIEREXISTS: checks if nullifier exists in the nullifier tree Gets contract's address by GETENVVA...
mem[result_offset] = mem[a_address] | mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] | mem[b_address]
SET_128 instruction.
SET_16 instruction.
SET_32 instruction.
MemoryTagWrapper value_tag
SET_64 instruction.
SET_8 instruction.
SET_FF instruction.
MemoryTagWrapper value_tag
mem[result_offset] = mem[a_address] << mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] << mem[b_address]
mem[result_offset] = mem[a_address] >> mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] >> mem[b_address]
SLOAD: M[slot_offset] = slot; M[result_offset] = S[M[slotOffset]].
SSTORE: M[slot_offset_index] = slot; S[M[slotOffset]] = M[srcOffset].
mem[result_offset] = mem[a_address] - mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] - mem[b_address]
mem[result_offset] = mem[a_address] ^ mem[b_address] (16-bit)
mem[result_offset] = mem[a_address] ^ mem[b_address]