@@ -74,7 +74,6 @@ impl FuzzerBuilder {
74
74
75
75
/// Inserts an add instruction between two values
76
76
pub fn insert_add_instruction_checked ( & mut self , lhs : Id < Value > , rhs : Id < Value > ) -> Id < Value > {
77
-
78
77
self . builder . insert_binary ( lhs, BinaryOp :: Add { unchecked : false } , rhs)
79
78
}
80
79
@@ -83,13 +82,11 @@ impl FuzzerBuilder {
83
82
lhs : Id < Value > ,
84
83
rhs : Id < Value > ,
85
84
) -> Id < Value > {
86
-
87
85
self . builder . insert_binary ( lhs, BinaryOp :: Add { unchecked : true } , rhs)
88
86
}
89
87
90
88
/// Inserts a subtract instruction between two values
91
89
pub fn insert_sub_instruction_checked ( & mut self , lhs : Id < Value > , rhs : Id < Value > ) -> Id < Value > {
92
-
93
90
self . builder . insert_binary ( lhs, BinaryOp :: Sub { unchecked : false } , rhs)
94
91
}
95
92
@@ -98,13 +95,11 @@ impl FuzzerBuilder {
98
95
lhs : Id < Value > ,
99
96
rhs : Id < Value > ,
100
97
) -> Id < Value > {
101
-
102
98
self . builder . insert_binary ( lhs, BinaryOp :: Sub { unchecked : true } , rhs)
103
99
}
104
100
105
101
/// Inserts a multiply instruction between two values
106
102
pub fn insert_mul_instruction_checked ( & mut self , lhs : Id < Value > , rhs : Id < Value > ) -> Id < Value > {
107
-
108
103
self . builder . insert_binary ( lhs, BinaryOp :: Mul { unchecked : false } , rhs)
109
104
}
110
105
@@ -113,31 +108,26 @@ impl FuzzerBuilder {
113
108
lhs : Id < Value > ,
114
109
rhs : Id < Value > ,
115
110
) -> Id < Value > {
116
-
117
111
self . builder . insert_binary ( lhs, BinaryOp :: Mul { unchecked : true } , rhs)
118
112
}
119
113
120
114
/// Inserts a divide instruction between two values
121
115
pub fn insert_div_instruction ( & mut self , lhs : Id < Value > , rhs : Id < Value > ) -> Id < Value > {
122
-
123
116
self . builder . insert_binary ( lhs, BinaryOp :: Div , rhs)
124
117
}
125
118
126
119
/// Inserts a modulo instruction between two values
127
120
pub fn insert_mod_instruction ( & mut self , lhs : Id < Value > , rhs : Id < Value > ) -> Id < Value > {
128
-
129
121
self . builder . insert_binary ( lhs, BinaryOp :: Mod , rhs)
130
122
}
131
123
132
124
/// Inserts a not instruction for the given value
133
125
pub fn insert_not_instruction ( & mut self , lhs : Id < Value > ) -> Id < Value > {
134
-
135
126
self . builder . insert_not ( lhs)
136
127
}
137
128
138
129
/// Inserts a cast instruction to the current numeric type
139
130
pub fn insert_simple_cast ( & mut self , value : Id < Value > ) -> Id < Value > {
140
-
141
131
self . builder . insert_cast ( value, self . numeric_type )
142
132
}
143
133
@@ -151,50 +141,45 @@ impl FuzzerBuilder {
151
141
match self . numeric_type {
152
142
NumericType :: Signed { bit_size : _ } => {
153
143
let res1 = self . builder . insert_cast ( value, NumericType :: Signed { bit_size : size } ) ;
154
-
144
+
155
145
self . insert_simple_cast ( res1)
156
146
}
157
147
NumericType :: Unsigned { bit_size : _ } => {
158
148
let res1 =
159
149
self . builder . insert_cast ( value, NumericType :: Unsigned { bit_size : size } ) ;
160
-
150
+
161
151
self . insert_simple_cast ( res1)
162
152
}
163
- NumericType :: NativeField => {
164
- value
165
- }
153
+ NumericType :: NativeField => value,
166
154
}
167
155
}
168
156
169
157
/// Inserts an equals comparison instruction between two values
170
158
pub fn insert_eq_instruction ( & mut self , lhs : Id < Value > , rhs : Id < Value > ) -> Id < Value > {
171
159
let res1 = self . builder . insert_binary ( lhs, BinaryOp :: Eq , rhs) ;
172
-
160
+
173
161
self . insert_simple_cast ( res1)
174
162
}
175
163
176
164
/// Inserts a less than comparison instruction between two values
177
165
pub fn insert_lt_instruction ( & mut self , lhs : Id < Value > , rhs : Id < Value > ) -> Id < Value > {
178
166
let res1 = self . builder . insert_binary ( lhs, BinaryOp :: Lt , rhs) ;
179
-
167
+
180
168
self . insert_simple_cast ( res1)
181
169
}
182
170
183
171
/// Inserts a bitwise AND instruction between two values
184
172
pub fn insert_and_instruction ( & mut self , lhs : Id < Value > , rhs : Id < Value > ) -> Id < Value > {
185
-
186
173
self . builder . insert_binary ( lhs, BinaryOp :: And , rhs)
187
174
}
188
175
189
176
/// Inserts a bitwise OR instruction between two values
190
177
pub fn insert_or_instruction ( & mut self , lhs : Id < Value > , rhs : Id < Value > ) -> Id < Value > {
191
-
192
178
self . builder . insert_binary ( lhs, BinaryOp :: Or , rhs)
193
179
}
194
180
195
181
/// Inserts a bitwise XOR instruction between two values
196
182
pub fn insert_xor_instruction ( & mut self , lhs : Id < Value > , rhs : Id < Value > ) -> Id < Value > {
197
-
198
183
self . builder . insert_binary ( lhs, BinaryOp :: Xor , rhs)
199
184
}
200
185
@@ -205,13 +190,13 @@ impl FuzzerBuilder {
205
190
match self . numeric_type {
206
191
NumericType :: Signed { bit_size : _ } => {
207
192
let rhs_value = self . builder . insert_cast ( rhs, NumericType :: Signed { bit_size : 8 } ) ;
208
-
193
+
209
194
self . builder . insert_binary ( lhs, BinaryOp :: Shl , rhs_value)
210
195
}
211
196
NumericType :: Unsigned { bit_size : _ } => {
212
197
let rhs_value =
213
198
self . builder . insert_cast ( rhs, NumericType :: Unsigned { bit_size : 8 } ) ;
214
-
199
+
215
200
self . builder . insert_binary ( lhs, BinaryOp :: Shl , rhs_value)
216
201
}
217
202
_ => {
@@ -228,13 +213,13 @@ impl FuzzerBuilder {
228
213
NumericType :: Signed { bit_size : _ } => {
229
214
let rhs_value =
230
215
self . builder . insert_cast ( rhs, NumericType :: Unsigned { bit_size : 8 } ) ;
231
-
216
+
232
217
self . builder . insert_binary ( lhs, BinaryOp :: Shr , rhs_value)
233
218
}
234
219
NumericType :: Unsigned { bit_size : _ } => {
235
220
let rhs_value =
236
221
self . builder . insert_cast ( rhs, NumericType :: Unsigned { bit_size : 8 } ) ;
237
-
222
+
238
223
self . builder . insert_binary ( lhs, BinaryOp :: Shr , rhs_value)
239
224
}
240
225
_ => {
@@ -251,7 +236,7 @@ impl FuzzerBuilder {
251
236
elems. push ( helpers:: u32_to_id_value ( elem) ) ;
252
237
}
253
238
let types = vec ! [ self . type_. clone( ) ; elements. len( ) ] ;
254
-
239
+
255
240
self . builder . insert_make_array (
256
241
im:: Vector :: from ( elems) ,
257
242
Type :: Array ( Arc :: new ( types) , elements. len ( ) as u32 ) ,
@@ -262,7 +247,7 @@ impl FuzzerBuilder {
262
247
pub fn insert_array_get ( & mut self , array : Id < Value > , index : u32 ) -> Id < Value > {
263
248
let index_var =
264
249
self . builder . numeric_constant ( index, NumericType :: Unsigned { bit_size : 32 } ) ;
265
-
250
+
266
251
self . builder . insert_array_get ( array, index_var, self . type_ . clone ( ) )
267
252
}
268
253
@@ -275,7 +260,7 @@ impl FuzzerBuilder {
275
260
) -> Id < Value > {
276
261
let index_var =
277
262
self . builder . numeric_constant ( index, NumericType :: Unsigned { bit_size : 32 } ) ;
278
-
263
+
279
264
self . builder . insert_array_set ( array, index_var, value)
280
265
}
281
266
0 commit comments