Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
alu.hpp
Go to the documentation of this file.
1// AUTOGENERATED FILE
2#pragma once
3
4#include <string_view>
5
10
11namespace bb::avm2 {
12
13template <typename FF_> class aluImpl {
14 public:
15 using FF = FF_;
16
17 static constexpr std::array<size_t, 63> SUBRELATION_PARTIAL_LENGTHS = {
18 3, 3, 3, 3, 3, 2, 5, 5, 4, 3, 3, 4, 6, 3, 6, 5, 3, 3, 4, 3, 3, 6, 3, 6, 3, 5, 3, 3, 3, 6, 6, 3,
19 3, 5, 6, 3, 6, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 6, 6, 5, 2, 3, 4, 3, 3, 3, 3, 2, 2, 3, 3, 4, 3
20 };
21
22 template <typename AllEntities> inline static bool skip(const AllEntities& in)
23 {
24 using C = ColumnAndShifts;
25
26 return (in.get(C::alu_sel)).is_zero();
27 }
28
29 template <typename ContainerOverSubrelations, typename AllEntities>
30 void static accumulate(ContainerOverSubrelations& evals,
31 const AllEntities& in,
32 [[maybe_unused]] const RelationParameters<FF>&,
33 [[maybe_unused]] const FF& scaling_factor);
34};
35
36template <typename FF> class alu : public Relation<aluImpl<FF>> {
37 public:
38 static constexpr const std::string_view NAME = "alu";
39
40 static std::string get_subrelation_label(size_t index)
41 {
42 switch (index) {
43 case 4:
44 return "ERR_CHECK";
45 case 5:
46 return "OP_ID_CHECK";
47 case 6:
48 return "TAG_IS_FF";
49 case 7:
50 return "TAG_IS_U128";
51 case 8:
52 return "C_TAG_CHECK";
53 case 11:
54 return "TAG_ERR_CHECK";
55 case 12:
56 return "AB_TAGS_CHECK";
57 case 14:
58 return "A_DECOMPOSITION";
59 case 15:
60 return "B_DECOMPOSITION";
61 case 17:
62 return "A_LO_BITS";
63 case 18:
64 return "A_HI_BITS";
65 case 21:
66 return "ALU_ADD_SUB";
67 case 23:
68 return "ALU_MUL_NON_U128";
69 case 25:
70 return "ALU_MUL_U128";
71 case 29:
72 return "ALU_DIV_U128_CHECK";
73 case 30:
74 return "ALU_DIV_U128";
75 case 33:
76 return "DIV_0_ERR";
77 case 34:
78 return "ALU_FDIV_DIV_NON_U128";
79 case 36:
80 return "EQ_OP_MAIN";
81 case 42:
82 return "LT_SWAP_INPUTS_A";
83 case 43:
84 return "LT_SWAP_INPUTS_B";
85 case 44:
86 return "LTE_NEGATE_RESULT_C";
87 case 46:
88 return "NOT_OP_MAIN";
89 case 47:
90 return "SHL_TWO_POW_SHIFT";
91 case 48:
92 return "ALU_SHL";
93 case 49:
94 return "ALU_SHR";
95 case 52:
96 return "SHIFTS_LO_BITS";
97 case 57:
98 return "SEL_TRUNC_NON_TRIVIAL";
99 case 58:
100 return "SEL_TRUNCATE";
101 case 59:
102 return "TRUNC_TRIVIAL_CASE";
103 case 60:
104 return "SMALL_TRUNC_VAL_IS_LO";
105 case 61:
106 return "TRUNC_LO_128_DECOMPOSITION";
107 case 62:
108 return "TRUNC_MID_BITS";
109 }
110 return std::to_string(index);
111 }
112
113 // Subrelation indices constants, to be used in tests.
114 static constexpr size_t SR_ERR_CHECK = 4;
115 static constexpr size_t SR_OP_ID_CHECK = 5;
116 static constexpr size_t SR_TAG_IS_FF = 6;
117 static constexpr size_t SR_TAG_IS_U128 = 7;
118 static constexpr size_t SR_C_TAG_CHECK = 8;
119 static constexpr size_t SR_TAG_ERR_CHECK = 11;
120 static constexpr size_t SR_AB_TAGS_CHECK = 12;
121 static constexpr size_t SR_A_DECOMPOSITION = 14;
122 static constexpr size_t SR_B_DECOMPOSITION = 15;
123 static constexpr size_t SR_A_LO_BITS = 17;
124 static constexpr size_t SR_A_HI_BITS = 18;
125 static constexpr size_t SR_ALU_ADD_SUB = 21;
126 static constexpr size_t SR_ALU_MUL_NON_U128 = 23;
127 static constexpr size_t SR_ALU_MUL_U128 = 25;
128 static constexpr size_t SR_ALU_DIV_U128_CHECK = 29;
129 static constexpr size_t SR_ALU_DIV_U128 = 30;
130 static constexpr size_t SR_DIV_0_ERR = 33;
131 static constexpr size_t SR_ALU_FDIV_DIV_NON_U128 = 34;
132 static constexpr size_t SR_EQ_OP_MAIN = 36;
133 static constexpr size_t SR_LT_SWAP_INPUTS_A = 42;
134 static constexpr size_t SR_LT_SWAP_INPUTS_B = 43;
135 static constexpr size_t SR_LTE_NEGATE_RESULT_C = 44;
136 static constexpr size_t SR_NOT_OP_MAIN = 46;
137 static constexpr size_t SR_SHL_TWO_POW_SHIFT = 47;
138 static constexpr size_t SR_ALU_SHL = 48;
139 static constexpr size_t SR_ALU_SHR = 49;
140 static constexpr size_t SR_SHIFTS_LO_BITS = 52;
141 static constexpr size_t SR_SEL_TRUNC_NON_TRIVIAL = 57;
142 static constexpr size_t SR_SEL_TRUNCATE = 58;
143 static constexpr size_t SR_TRUNC_TRIVIAL_CASE = 59;
144 static constexpr size_t SR_SMALL_TRUNC_VAL_IS_LO = 60;
145 static constexpr size_t SR_TRUNC_LO_128_DECOMPOSITION = 61;
146 static constexpr size_t SR_TRUNC_MID_BITS = 62;
147};
148
149} // namespace bb::avm2
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
static constexpr size_t SR_OP_ID_CHECK
Definition alu.hpp:115
static constexpr size_t SR_SHIFTS_LO_BITS
Definition alu.hpp:140
static constexpr size_t SR_LT_SWAP_INPUTS_B
Definition alu.hpp:134
static constexpr size_t SR_ALU_SHR
Definition alu.hpp:139
static constexpr size_t SR_SEL_TRUNC_NON_TRIVIAL
Definition alu.hpp:141
static constexpr size_t SR_AB_TAGS_CHECK
Definition alu.hpp:120
static constexpr const std::string_view NAME
Definition alu.hpp:38
static constexpr size_t SR_SEL_TRUNCATE
Definition alu.hpp:142
static constexpr size_t SR_A_HI_BITS
Definition alu.hpp:124
static constexpr size_t SR_A_LO_BITS
Definition alu.hpp:123
static constexpr size_t SR_TRUNC_MID_BITS
Definition alu.hpp:146
static constexpr size_t SR_SMALL_TRUNC_VAL_IS_LO
Definition alu.hpp:144
static constexpr size_t SR_B_DECOMPOSITION
Definition alu.hpp:122
static constexpr size_t SR_TRUNC_LO_128_DECOMPOSITION
Definition alu.hpp:145
static constexpr size_t SR_LTE_NEGATE_RESULT_C
Definition alu.hpp:135
static constexpr size_t SR_C_TAG_CHECK
Definition alu.hpp:118
static constexpr size_t SR_ERR_CHECK
Definition alu.hpp:114
static constexpr size_t SR_DIV_0_ERR
Definition alu.hpp:130
static constexpr size_t SR_A_DECOMPOSITION
Definition alu.hpp:121
static std::string get_subrelation_label(size_t index)
Definition alu.hpp:40
static constexpr size_t SR_LT_SWAP_INPUTS_A
Definition alu.hpp:133
static constexpr size_t SR_TAG_ERR_CHECK
Definition alu.hpp:119
static constexpr size_t SR_EQ_OP_MAIN
Definition alu.hpp:132
static constexpr size_t SR_ALU_DIV_U128
Definition alu.hpp:129
static constexpr size_t SR_ALU_DIV_U128_CHECK
Definition alu.hpp:128
static constexpr size_t SR_NOT_OP_MAIN
Definition alu.hpp:136
static constexpr size_t SR_SHL_TWO_POW_SHIFT
Definition alu.hpp:137
static constexpr size_t SR_TAG_IS_U128
Definition alu.hpp:117
static constexpr size_t SR_ALU_MUL_U128
Definition alu.hpp:127
static constexpr size_t SR_ALU_FDIV_DIV_NON_U128
Definition alu.hpp:131
static constexpr size_t SR_TAG_IS_FF
Definition alu.hpp:116
static constexpr size_t SR_TRUNC_TRIVIAL_CASE
Definition alu.hpp:143
static constexpr size_t SR_ALU_SHL
Definition alu.hpp:138
static constexpr size_t SR_ALU_ADD_SUB
Definition alu.hpp:125
static constexpr size_t SR_ALU_MUL_NON_U128
Definition alu.hpp:126
static bool skip(const AllEntities &in)
Definition alu.hpp:22
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
Definition alu_impl.hpp:10
static constexpr std::array< size_t, 63 > SUBRELATION_PARTIAL_LENGTHS
Definition alu.hpp:17
ColumnAndShifts
Definition columns.hpp:35
AvmFlavorSettings::FF FF
Definition field.hpp:10
std::string to_string(bb::avm2::ValueTag tag)
Container for parameters used by the grand product (permutation, lookup) Honk relations.