wasmparser/validator/operators/
simd.rs1use super::OperatorValidatorTemp;
2use crate::{MemArg, Result, ValType, WasmModuleResources};
3use crate::{V128, VisitSimdOperator};
4
5impl<'resources, R> OperatorValidatorTemp<'_, 'resources, R>
6where
7 R: WasmModuleResources,
8{
9 fn check_simd_lane_index(&self, index: u8, max: u8) -> Result<()> {
10 if index >= max {
11 bail!(self.offset, "SIMD index out of bounds");
12 }
13 Ok(())
14 }
15
16 fn check_v128_splat(&mut self, src_ty: ValType) -> Result<()> {
18 self.pop_operand(Some(src_ty))?;
19 self.push_operand(ValType::V128)?;
20 Ok(())
21 }
22
23 fn check_v128_binary_op(&mut self) -> Result<()> {
25 self.pop_operand(Some(ValType::V128))?;
26 self.pop_operand(Some(ValType::V128))?;
27 self.push_operand(ValType::V128)?;
28 Ok(())
29 }
30
31 fn check_v128_fbinary_op(&mut self) -> Result<()> {
33 self.check_floats_enabled()?;
34 self.check_v128_binary_op()
35 }
36
37 fn check_v128_unary_op(&mut self) -> Result<()> {
39 self.pop_operand(Some(ValType::V128))?;
40 self.push_operand(ValType::V128)?;
41 Ok(())
42 }
43
44 fn check_v128_funary_op(&mut self) -> Result<()> {
46 self.check_floats_enabled()?;
47 self.check_v128_unary_op()
48 }
49
50 fn check_v128_ternary_op(&mut self) -> Result<()> {
52 self.pop_operand(Some(ValType::V128))?;
53 self.pop_operand(Some(ValType::V128))?;
54 self.pop_operand(Some(ValType::V128))?;
55 self.push_operand(ValType::V128)?;
56 Ok(())
57 }
58
59 fn check_v128_bitmask_op(&mut self) -> Result<()> {
61 self.pop_operand(Some(ValType::V128))?;
62 self.push_operand(ValType::I32)?;
63 Ok(())
64 }
65
66 fn check_v128_shift_op(&mut self) -> Result<()> {
68 self.pop_operand(Some(ValType::I32))?;
69 self.pop_operand(Some(ValType::V128))?;
70 self.push_operand(ValType::V128)?;
71 Ok(())
72 }
73
74 fn check_v128_load_op(&mut self, memarg: MemArg) -> Result<()> {
76 let idx = self.check_memarg(memarg)?;
77 self.pop_operand(Some(idx))?;
78 self.push_operand(ValType::V128)?;
79 Ok(())
80 }
81}
82
83impl<'a, T> VisitSimdOperator<'a> for OperatorValidatorTemp<'_, '_, T>
84where
85 T: WasmModuleResources,
86{
87 fn visit_v128_load(&mut self, memarg: MemArg) -> Self::Output {
88 let ty = self.check_memarg(memarg)?;
89 self.pop_operand(Some(ty))?;
90 self.push_operand(ValType::V128)?;
91 Ok(())
92 }
93 fn visit_v128_store(&mut self, memarg: MemArg) -> Self::Output {
94 let ty = self.check_memarg(memarg)?;
95 self.pop_operand(Some(ValType::V128))?;
96 self.pop_operand(Some(ty))?;
97 Ok(())
98 }
99 fn visit_v128_const(&mut self, _value: V128) -> Self::Output {
100 self.push_operand(ValType::V128)?;
101 Ok(())
102 }
103 fn visit_i8x16_splat(&mut self) -> Self::Output {
104 self.check_v128_splat(ValType::I32)
105 }
106 fn visit_i16x8_splat(&mut self) -> Self::Output {
107 self.check_v128_splat(ValType::I32)
108 }
109 fn visit_i32x4_splat(&mut self) -> Self::Output {
110 self.check_v128_splat(ValType::I32)
111 }
112 fn visit_i64x2_splat(&mut self) -> Self::Output {
113 self.check_v128_splat(ValType::I64)
114 }
115 fn visit_f32x4_splat(&mut self) -> Self::Output {
116 self.check_floats_enabled()?;
117 self.check_v128_splat(ValType::F32)
118 }
119 fn visit_f64x2_splat(&mut self) -> Self::Output {
120 self.check_floats_enabled()?;
121 self.check_v128_splat(ValType::F64)
122 }
123 fn visit_i8x16_extract_lane_s(&mut self, lane: u8) -> Self::Output {
124 self.check_simd_lane_index(lane, 16)?;
125 self.pop_operand(Some(ValType::V128))?;
126 self.push_operand(ValType::I32)?;
127 Ok(())
128 }
129 fn visit_i8x16_extract_lane_u(&mut self, lane: u8) -> Self::Output {
130 self.visit_i8x16_extract_lane_s(lane)
131 }
132 fn visit_i16x8_extract_lane_s(&mut self, lane: u8) -> Self::Output {
133 self.check_simd_lane_index(lane, 8)?;
134 self.pop_operand(Some(ValType::V128))?;
135 self.push_operand(ValType::I32)?;
136 Ok(())
137 }
138 fn visit_i16x8_extract_lane_u(&mut self, lane: u8) -> Self::Output {
139 self.visit_i16x8_extract_lane_s(lane)
140 }
141 fn visit_i32x4_extract_lane(&mut self, lane: u8) -> Self::Output {
142 self.check_simd_lane_index(lane, 4)?;
143 self.pop_operand(Some(ValType::V128))?;
144 self.push_operand(ValType::I32)?;
145 Ok(())
146 }
147 fn visit_i8x16_replace_lane(&mut self, lane: u8) -> Self::Output {
148 self.check_simd_lane_index(lane, 16)?;
149 self.pop_operand(Some(ValType::I32))?;
150 self.pop_operand(Some(ValType::V128))?;
151 self.push_operand(ValType::V128)?;
152 Ok(())
153 }
154 fn visit_i16x8_replace_lane(&mut self, lane: u8) -> Self::Output {
155 self.check_simd_lane_index(lane, 8)?;
156 self.pop_operand(Some(ValType::I32))?;
157 self.pop_operand(Some(ValType::V128))?;
158 self.push_operand(ValType::V128)?;
159 Ok(())
160 }
161 fn visit_i32x4_replace_lane(&mut self, lane: u8) -> Self::Output {
162 self.check_simd_lane_index(lane, 4)?;
163 self.pop_operand(Some(ValType::I32))?;
164 self.pop_operand(Some(ValType::V128))?;
165 self.push_operand(ValType::V128)?;
166 Ok(())
167 }
168 fn visit_i64x2_extract_lane(&mut self, lane: u8) -> Self::Output {
169 self.check_simd_lane_index(lane, 2)?;
170 self.pop_operand(Some(ValType::V128))?;
171 self.push_operand(ValType::I64)?;
172 Ok(())
173 }
174 fn visit_i64x2_replace_lane(&mut self, lane: u8) -> Self::Output {
175 self.check_simd_lane_index(lane, 2)?;
176 self.pop_operand(Some(ValType::I64))?;
177 self.pop_operand(Some(ValType::V128))?;
178 self.push_operand(ValType::V128)?;
179 Ok(())
180 }
181 fn visit_f32x4_extract_lane(&mut self, lane: u8) -> Self::Output {
182 self.check_floats_enabled()?;
183 self.check_simd_lane_index(lane, 4)?;
184 self.pop_operand(Some(ValType::V128))?;
185 self.push_operand(ValType::F32)?;
186 Ok(())
187 }
188 fn visit_f32x4_replace_lane(&mut self, lane: u8) -> Self::Output {
189 self.check_floats_enabled()?;
190 self.check_simd_lane_index(lane, 4)?;
191 self.pop_operand(Some(ValType::F32))?;
192 self.pop_operand(Some(ValType::V128))?;
193 self.push_operand(ValType::V128)?;
194 Ok(())
195 }
196 fn visit_f64x2_extract_lane(&mut self, lane: u8) -> Self::Output {
197 self.check_floats_enabled()?;
198 self.check_simd_lane_index(lane, 2)?;
199 self.pop_operand(Some(ValType::V128))?;
200 self.push_operand(ValType::F64)?;
201 Ok(())
202 }
203 fn visit_f64x2_replace_lane(&mut self, lane: u8) -> Self::Output {
204 self.check_floats_enabled()?;
205 self.check_simd_lane_index(lane, 2)?;
206 self.pop_operand(Some(ValType::F64))?;
207 self.pop_operand(Some(ValType::V128))?;
208 self.push_operand(ValType::V128)?;
209 Ok(())
210 }
211 fn visit_f32x4_eq(&mut self) -> Self::Output {
212 self.check_v128_fbinary_op()
213 }
214 fn visit_f32x4_ne(&mut self) -> Self::Output {
215 self.check_v128_fbinary_op()
216 }
217 fn visit_f32x4_lt(&mut self) -> Self::Output {
218 self.check_v128_fbinary_op()
219 }
220 fn visit_f32x4_gt(&mut self) -> Self::Output {
221 self.check_v128_fbinary_op()
222 }
223 fn visit_f32x4_le(&mut self) -> Self::Output {
224 self.check_v128_fbinary_op()
225 }
226 fn visit_f32x4_ge(&mut self) -> Self::Output {
227 self.check_v128_fbinary_op()
228 }
229 fn visit_f64x2_eq(&mut self) -> Self::Output {
230 self.check_v128_fbinary_op()
231 }
232 fn visit_f64x2_ne(&mut self) -> Self::Output {
233 self.check_v128_fbinary_op()
234 }
235 fn visit_f64x2_lt(&mut self) -> Self::Output {
236 self.check_v128_fbinary_op()
237 }
238 fn visit_f64x2_gt(&mut self) -> Self::Output {
239 self.check_v128_fbinary_op()
240 }
241 fn visit_f64x2_le(&mut self) -> Self::Output {
242 self.check_v128_fbinary_op()
243 }
244 fn visit_f64x2_ge(&mut self) -> Self::Output {
245 self.check_v128_fbinary_op()
246 }
247 fn visit_f32x4_add(&mut self) -> Self::Output {
248 self.check_v128_fbinary_op()
249 }
250 fn visit_f32x4_sub(&mut self) -> Self::Output {
251 self.check_v128_fbinary_op()
252 }
253 fn visit_f32x4_mul(&mut self) -> Self::Output {
254 self.check_v128_fbinary_op()
255 }
256 fn visit_f32x4_div(&mut self) -> Self::Output {
257 self.check_v128_fbinary_op()
258 }
259 fn visit_f32x4_min(&mut self) -> Self::Output {
260 self.check_v128_fbinary_op()
261 }
262 fn visit_f32x4_max(&mut self) -> Self::Output {
263 self.check_v128_fbinary_op()
264 }
265 fn visit_f32x4_pmin(&mut self) -> Self::Output {
266 self.check_v128_fbinary_op()
267 }
268 fn visit_f32x4_pmax(&mut self) -> Self::Output {
269 self.check_v128_fbinary_op()
270 }
271 fn visit_f64x2_add(&mut self) -> Self::Output {
272 self.check_v128_fbinary_op()
273 }
274 fn visit_f64x2_sub(&mut self) -> Self::Output {
275 self.check_v128_fbinary_op()
276 }
277 fn visit_f64x2_mul(&mut self) -> Self::Output {
278 self.check_v128_fbinary_op()
279 }
280 fn visit_f64x2_div(&mut self) -> Self::Output {
281 self.check_v128_fbinary_op()
282 }
283 fn visit_f64x2_min(&mut self) -> Self::Output {
284 self.check_v128_fbinary_op()
285 }
286 fn visit_f64x2_max(&mut self) -> Self::Output {
287 self.check_v128_fbinary_op()
288 }
289 fn visit_f64x2_pmin(&mut self) -> Self::Output {
290 self.check_v128_fbinary_op()
291 }
292 fn visit_f64x2_pmax(&mut self) -> Self::Output {
293 self.check_v128_fbinary_op()
294 }
295 fn visit_i8x16_eq(&mut self) -> Self::Output {
296 self.check_v128_binary_op()
297 }
298 fn visit_i8x16_ne(&mut self) -> Self::Output {
299 self.check_v128_binary_op()
300 }
301 fn visit_i8x16_lt_s(&mut self) -> Self::Output {
302 self.check_v128_binary_op()
303 }
304 fn visit_i8x16_lt_u(&mut self) -> Self::Output {
305 self.check_v128_binary_op()
306 }
307 fn visit_i8x16_gt_s(&mut self) -> Self::Output {
308 self.check_v128_binary_op()
309 }
310 fn visit_i8x16_gt_u(&mut self) -> Self::Output {
311 self.check_v128_binary_op()
312 }
313 fn visit_i8x16_le_s(&mut self) -> Self::Output {
314 self.check_v128_binary_op()
315 }
316 fn visit_i8x16_le_u(&mut self) -> Self::Output {
317 self.check_v128_binary_op()
318 }
319 fn visit_i8x16_ge_s(&mut self) -> Self::Output {
320 self.check_v128_binary_op()
321 }
322 fn visit_i8x16_ge_u(&mut self) -> Self::Output {
323 self.check_v128_binary_op()
324 }
325 fn visit_i16x8_eq(&mut self) -> Self::Output {
326 self.check_v128_binary_op()
327 }
328 fn visit_i16x8_ne(&mut self) -> Self::Output {
329 self.check_v128_binary_op()
330 }
331 fn visit_i16x8_lt_s(&mut self) -> Self::Output {
332 self.check_v128_binary_op()
333 }
334 fn visit_i16x8_lt_u(&mut self) -> Self::Output {
335 self.check_v128_binary_op()
336 }
337 fn visit_i16x8_gt_s(&mut self) -> Self::Output {
338 self.check_v128_binary_op()
339 }
340 fn visit_i16x8_gt_u(&mut self) -> Self::Output {
341 self.check_v128_binary_op()
342 }
343 fn visit_i16x8_le_s(&mut self) -> Self::Output {
344 self.check_v128_binary_op()
345 }
346 fn visit_i16x8_le_u(&mut self) -> Self::Output {
347 self.check_v128_binary_op()
348 }
349 fn visit_i16x8_ge_s(&mut self) -> Self::Output {
350 self.check_v128_binary_op()
351 }
352 fn visit_i16x8_ge_u(&mut self) -> Self::Output {
353 self.check_v128_binary_op()
354 }
355 fn visit_i32x4_eq(&mut self) -> Self::Output {
356 self.check_v128_binary_op()
357 }
358 fn visit_i32x4_ne(&mut self) -> Self::Output {
359 self.check_v128_binary_op()
360 }
361 fn visit_i32x4_lt_s(&mut self) -> Self::Output {
362 self.check_v128_binary_op()
363 }
364 fn visit_i32x4_lt_u(&mut self) -> Self::Output {
365 self.check_v128_binary_op()
366 }
367 fn visit_i32x4_gt_s(&mut self) -> Self::Output {
368 self.check_v128_binary_op()
369 }
370 fn visit_i32x4_gt_u(&mut self) -> Self::Output {
371 self.check_v128_binary_op()
372 }
373 fn visit_i32x4_le_s(&mut self) -> Self::Output {
374 self.check_v128_binary_op()
375 }
376 fn visit_i32x4_le_u(&mut self) -> Self::Output {
377 self.check_v128_binary_op()
378 }
379 fn visit_i32x4_ge_s(&mut self) -> Self::Output {
380 self.check_v128_binary_op()
381 }
382 fn visit_i32x4_ge_u(&mut self) -> Self::Output {
383 self.check_v128_binary_op()
384 }
385 fn visit_i64x2_eq(&mut self) -> Self::Output {
386 self.check_v128_binary_op()
387 }
388 fn visit_i64x2_ne(&mut self) -> Self::Output {
389 self.check_v128_binary_op()
390 }
391 fn visit_i64x2_lt_s(&mut self) -> Self::Output {
392 self.check_v128_binary_op()
393 }
394 fn visit_i64x2_gt_s(&mut self) -> Self::Output {
395 self.check_v128_binary_op()
396 }
397 fn visit_i64x2_le_s(&mut self) -> Self::Output {
398 self.check_v128_binary_op()
399 }
400 fn visit_i64x2_ge_s(&mut self) -> Self::Output {
401 self.check_v128_binary_op()
402 }
403 fn visit_v128_and(&mut self) -> Self::Output {
404 self.check_v128_binary_op()
405 }
406 fn visit_v128_andnot(&mut self) -> Self::Output {
407 self.check_v128_binary_op()
408 }
409 fn visit_v128_or(&mut self) -> Self::Output {
410 self.check_v128_binary_op()
411 }
412 fn visit_v128_xor(&mut self) -> Self::Output {
413 self.check_v128_binary_op()
414 }
415 fn visit_i8x16_add(&mut self) -> Self::Output {
416 self.check_v128_binary_op()
417 }
418 fn visit_i8x16_add_sat_s(&mut self) -> Self::Output {
419 self.check_v128_binary_op()
420 }
421 fn visit_i8x16_add_sat_u(&mut self) -> Self::Output {
422 self.check_v128_binary_op()
423 }
424 fn visit_i8x16_sub(&mut self) -> Self::Output {
425 self.check_v128_binary_op()
426 }
427 fn visit_i8x16_sub_sat_s(&mut self) -> Self::Output {
428 self.check_v128_binary_op()
429 }
430 fn visit_i8x16_sub_sat_u(&mut self) -> Self::Output {
431 self.check_v128_binary_op()
432 }
433 fn visit_i8x16_min_s(&mut self) -> Self::Output {
434 self.check_v128_binary_op()
435 }
436 fn visit_i8x16_min_u(&mut self) -> Self::Output {
437 self.check_v128_binary_op()
438 }
439 fn visit_i8x16_max_s(&mut self) -> Self::Output {
440 self.check_v128_binary_op()
441 }
442 fn visit_i8x16_max_u(&mut self) -> Self::Output {
443 self.check_v128_binary_op()
444 }
445 fn visit_i16x8_add(&mut self) -> Self::Output {
446 self.check_v128_binary_op()
447 }
448 fn visit_i16x8_add_sat_s(&mut self) -> Self::Output {
449 self.check_v128_binary_op()
450 }
451 fn visit_i16x8_add_sat_u(&mut self) -> Self::Output {
452 self.check_v128_binary_op()
453 }
454 fn visit_i16x8_sub(&mut self) -> Self::Output {
455 self.check_v128_binary_op()
456 }
457 fn visit_i16x8_sub_sat_s(&mut self) -> Self::Output {
458 self.check_v128_binary_op()
459 }
460 fn visit_i16x8_sub_sat_u(&mut self) -> Self::Output {
461 self.check_v128_binary_op()
462 }
463 fn visit_i16x8_mul(&mut self) -> Self::Output {
464 self.check_v128_binary_op()
465 }
466 fn visit_i16x8_min_s(&mut self) -> Self::Output {
467 self.check_v128_binary_op()
468 }
469 fn visit_i16x8_min_u(&mut self) -> Self::Output {
470 self.check_v128_binary_op()
471 }
472 fn visit_i16x8_max_s(&mut self) -> Self::Output {
473 self.check_v128_binary_op()
474 }
475 fn visit_i16x8_max_u(&mut self) -> Self::Output {
476 self.check_v128_binary_op()
477 }
478 fn visit_i32x4_add(&mut self) -> Self::Output {
479 self.check_v128_binary_op()
480 }
481 fn visit_i32x4_sub(&mut self) -> Self::Output {
482 self.check_v128_binary_op()
483 }
484 fn visit_i32x4_mul(&mut self) -> Self::Output {
485 self.check_v128_binary_op()
486 }
487 fn visit_i32x4_min_s(&mut self) -> Self::Output {
488 self.check_v128_binary_op()
489 }
490 fn visit_i32x4_min_u(&mut self) -> Self::Output {
491 self.check_v128_binary_op()
492 }
493 fn visit_i32x4_max_s(&mut self) -> Self::Output {
494 self.check_v128_binary_op()
495 }
496 fn visit_i32x4_max_u(&mut self) -> Self::Output {
497 self.check_v128_binary_op()
498 }
499 fn visit_i32x4_dot_i16x8_s(&mut self) -> Self::Output {
500 self.check_v128_binary_op()
501 }
502 fn visit_i64x2_add(&mut self) -> Self::Output {
503 self.check_v128_binary_op()
504 }
505 fn visit_i64x2_sub(&mut self) -> Self::Output {
506 self.check_v128_binary_op()
507 }
508 fn visit_i64x2_mul(&mut self) -> Self::Output {
509 self.check_v128_binary_op()
510 }
511 fn visit_i8x16_avgr_u(&mut self) -> Self::Output {
512 self.check_v128_binary_op()
513 }
514 fn visit_i16x8_avgr_u(&mut self) -> Self::Output {
515 self.check_v128_binary_op()
516 }
517 fn visit_i8x16_narrow_i16x8_s(&mut self) -> Self::Output {
518 self.check_v128_binary_op()
519 }
520 fn visit_i8x16_narrow_i16x8_u(&mut self) -> Self::Output {
521 self.check_v128_binary_op()
522 }
523 fn visit_i16x8_narrow_i32x4_s(&mut self) -> Self::Output {
524 self.check_v128_binary_op()
525 }
526 fn visit_i16x8_narrow_i32x4_u(&mut self) -> Self::Output {
527 self.check_v128_binary_op()
528 }
529 fn visit_i16x8_extmul_low_i8x16_s(&mut self) -> Self::Output {
530 self.check_v128_binary_op()
531 }
532 fn visit_i16x8_extmul_high_i8x16_s(&mut self) -> Self::Output {
533 self.check_v128_binary_op()
534 }
535 fn visit_i16x8_extmul_low_i8x16_u(&mut self) -> Self::Output {
536 self.check_v128_binary_op()
537 }
538 fn visit_i16x8_extmul_high_i8x16_u(&mut self) -> Self::Output {
539 self.check_v128_binary_op()
540 }
541 fn visit_i32x4_extmul_low_i16x8_s(&mut self) -> Self::Output {
542 self.check_v128_binary_op()
543 }
544 fn visit_i32x4_extmul_high_i16x8_s(&mut self) -> Self::Output {
545 self.check_v128_binary_op()
546 }
547 fn visit_i32x4_extmul_low_i16x8_u(&mut self) -> Self::Output {
548 self.check_v128_binary_op()
549 }
550 fn visit_i32x4_extmul_high_i16x8_u(&mut self) -> Self::Output {
551 self.check_v128_binary_op()
552 }
553 fn visit_i64x2_extmul_low_i32x4_s(&mut self) -> Self::Output {
554 self.check_v128_binary_op()
555 }
556 fn visit_i64x2_extmul_high_i32x4_s(&mut self) -> Self::Output {
557 self.check_v128_binary_op()
558 }
559 fn visit_i64x2_extmul_low_i32x4_u(&mut self) -> Self::Output {
560 self.check_v128_binary_op()
561 }
562 fn visit_i64x2_extmul_high_i32x4_u(&mut self) -> Self::Output {
563 self.check_v128_binary_op()
564 }
565 fn visit_i16x8_q15mulr_sat_s(&mut self) -> Self::Output {
566 self.check_v128_binary_op()
567 }
568 fn visit_f32x4_ceil(&mut self) -> Self::Output {
569 self.check_v128_funary_op()
570 }
571 fn visit_f32x4_floor(&mut self) -> Self::Output {
572 self.check_v128_funary_op()
573 }
574 fn visit_f32x4_trunc(&mut self) -> Self::Output {
575 self.check_v128_funary_op()
576 }
577 fn visit_f32x4_nearest(&mut self) -> Self::Output {
578 self.check_v128_funary_op()
579 }
580 fn visit_f64x2_ceil(&mut self) -> Self::Output {
581 self.check_v128_funary_op()
582 }
583 fn visit_f64x2_floor(&mut self) -> Self::Output {
584 self.check_v128_funary_op()
585 }
586 fn visit_f64x2_trunc(&mut self) -> Self::Output {
587 self.check_v128_funary_op()
588 }
589 fn visit_f64x2_nearest(&mut self) -> Self::Output {
590 self.check_v128_funary_op()
591 }
592 fn visit_f32x4_abs(&mut self) -> Self::Output {
593 self.check_v128_funary_op()
594 }
595 fn visit_f32x4_neg(&mut self) -> Self::Output {
596 self.check_v128_funary_op()
597 }
598 fn visit_f32x4_sqrt(&mut self) -> Self::Output {
599 self.check_v128_funary_op()
600 }
601 fn visit_f64x2_abs(&mut self) -> Self::Output {
602 self.check_v128_funary_op()
603 }
604 fn visit_f64x2_neg(&mut self) -> Self::Output {
605 self.check_v128_funary_op()
606 }
607 fn visit_f64x2_sqrt(&mut self) -> Self::Output {
608 self.check_v128_funary_op()
609 }
610 fn visit_f32x4_demote_f64x2_zero(&mut self) -> Self::Output {
611 self.check_v128_funary_op()
612 }
613 fn visit_f64x2_promote_low_f32x4(&mut self) -> Self::Output {
614 self.check_v128_funary_op()
615 }
616 fn visit_f64x2_convert_low_i32x4_s(&mut self) -> Self::Output {
617 self.check_v128_funary_op()
618 }
619 fn visit_f64x2_convert_low_i32x4_u(&mut self) -> Self::Output {
620 self.check_v128_funary_op()
621 }
622 fn visit_i32x4_trunc_sat_f32x4_s(&mut self) -> Self::Output {
623 self.check_v128_funary_op()
624 }
625 fn visit_i32x4_trunc_sat_f32x4_u(&mut self) -> Self::Output {
626 self.check_v128_funary_op()
627 }
628 fn visit_i32x4_trunc_sat_f64x2_s_zero(&mut self) -> Self::Output {
629 self.check_v128_funary_op()
630 }
631 fn visit_i32x4_trunc_sat_f64x2_u_zero(&mut self) -> Self::Output {
632 self.check_v128_funary_op()
633 }
634 fn visit_f32x4_convert_i32x4_s(&mut self) -> Self::Output {
635 self.check_v128_funary_op()
636 }
637 fn visit_f32x4_convert_i32x4_u(&mut self) -> Self::Output {
638 self.check_v128_funary_op()
639 }
640 fn visit_v128_not(&mut self) -> Self::Output {
641 self.check_v128_unary_op()
642 }
643 fn visit_i8x16_abs(&mut self) -> Self::Output {
644 self.check_v128_unary_op()
645 }
646 fn visit_i8x16_neg(&mut self) -> Self::Output {
647 self.check_v128_unary_op()
648 }
649 fn visit_i8x16_popcnt(&mut self) -> Self::Output {
650 self.check_v128_unary_op()
651 }
652 fn visit_i16x8_abs(&mut self) -> Self::Output {
653 self.check_v128_unary_op()
654 }
655 fn visit_i16x8_neg(&mut self) -> Self::Output {
656 self.check_v128_unary_op()
657 }
658 fn visit_i32x4_abs(&mut self) -> Self::Output {
659 self.check_v128_unary_op()
660 }
661 fn visit_i32x4_neg(&mut self) -> Self::Output {
662 self.check_v128_unary_op()
663 }
664 fn visit_i64x2_abs(&mut self) -> Self::Output {
665 self.check_v128_unary_op()
666 }
667 fn visit_i64x2_neg(&mut self) -> Self::Output {
668 self.check_v128_unary_op()
669 }
670 fn visit_i16x8_extend_low_i8x16_s(&mut self) -> Self::Output {
671 self.check_v128_unary_op()
672 }
673 fn visit_i16x8_extend_high_i8x16_s(&mut self) -> Self::Output {
674 self.check_v128_unary_op()
675 }
676 fn visit_i16x8_extend_low_i8x16_u(&mut self) -> Self::Output {
677 self.check_v128_unary_op()
678 }
679 fn visit_i16x8_extend_high_i8x16_u(&mut self) -> Self::Output {
680 self.check_v128_unary_op()
681 }
682 fn visit_i32x4_extend_low_i16x8_s(&mut self) -> Self::Output {
683 self.check_v128_unary_op()
684 }
685 fn visit_i32x4_extend_high_i16x8_s(&mut self) -> Self::Output {
686 self.check_v128_unary_op()
687 }
688 fn visit_i32x4_extend_low_i16x8_u(&mut self) -> Self::Output {
689 self.check_v128_unary_op()
690 }
691 fn visit_i32x4_extend_high_i16x8_u(&mut self) -> Self::Output {
692 self.check_v128_unary_op()
693 }
694 fn visit_i64x2_extend_low_i32x4_s(&mut self) -> Self::Output {
695 self.check_v128_unary_op()
696 }
697 fn visit_i64x2_extend_high_i32x4_s(&mut self) -> Self::Output {
698 self.check_v128_unary_op()
699 }
700 fn visit_i64x2_extend_low_i32x4_u(&mut self) -> Self::Output {
701 self.check_v128_unary_op()
702 }
703 fn visit_i64x2_extend_high_i32x4_u(&mut self) -> Self::Output {
704 self.check_v128_unary_op()
705 }
706 fn visit_i16x8_extadd_pairwise_i8x16_s(&mut self) -> Self::Output {
707 self.check_v128_unary_op()
708 }
709 fn visit_i16x8_extadd_pairwise_i8x16_u(&mut self) -> Self::Output {
710 self.check_v128_unary_op()
711 }
712 fn visit_i32x4_extadd_pairwise_i16x8_s(&mut self) -> Self::Output {
713 self.check_v128_unary_op()
714 }
715 fn visit_i32x4_extadd_pairwise_i16x8_u(&mut self) -> Self::Output {
716 self.check_v128_unary_op()
717 }
718 fn visit_v128_bitselect(&mut self) -> Self::Output {
719 self.pop_operand(Some(ValType::V128))?;
720 self.pop_operand(Some(ValType::V128))?;
721 self.pop_operand(Some(ValType::V128))?;
722 self.push_operand(ValType::V128)?;
723 Ok(())
724 }
725 fn visit_i8x16_relaxed_swizzle(&mut self) -> Self::Output {
726 self.pop_operand(Some(ValType::V128))?;
727 self.pop_operand(Some(ValType::V128))?;
728 self.push_operand(ValType::V128)?;
729 Ok(())
730 }
731 fn visit_i32x4_relaxed_trunc_f32x4_s(&mut self) -> Self::Output {
732 self.check_v128_unary_op()
733 }
734 fn visit_i32x4_relaxed_trunc_f32x4_u(&mut self) -> Self::Output {
735 self.check_v128_unary_op()
736 }
737 fn visit_i32x4_relaxed_trunc_f64x2_s_zero(&mut self) -> Self::Output {
738 self.check_v128_unary_op()
739 }
740 fn visit_i32x4_relaxed_trunc_f64x2_u_zero(&mut self) -> Self::Output {
741 self.check_v128_unary_op()
742 }
743 fn visit_f32x4_relaxed_madd(&mut self) -> Self::Output {
744 self.check_v128_ternary_op()
745 }
746 fn visit_f32x4_relaxed_nmadd(&mut self) -> Self::Output {
747 self.check_v128_ternary_op()
748 }
749 fn visit_f64x2_relaxed_madd(&mut self) -> Self::Output {
750 self.check_v128_ternary_op()
751 }
752 fn visit_f64x2_relaxed_nmadd(&mut self) -> Self::Output {
753 self.check_v128_ternary_op()
754 }
755 fn visit_i8x16_relaxed_laneselect(&mut self) -> Self::Output {
756 self.check_v128_ternary_op()
757 }
758 fn visit_i16x8_relaxed_laneselect(&mut self) -> Self::Output {
759 self.check_v128_ternary_op()
760 }
761 fn visit_i32x4_relaxed_laneselect(&mut self) -> Self::Output {
762 self.check_v128_ternary_op()
763 }
764 fn visit_i64x2_relaxed_laneselect(&mut self) -> Self::Output {
765 self.check_v128_ternary_op()
766 }
767 fn visit_f32x4_relaxed_min(&mut self) -> Self::Output {
768 self.check_v128_binary_op()
769 }
770 fn visit_f32x4_relaxed_max(&mut self) -> Self::Output {
771 self.check_v128_binary_op()
772 }
773 fn visit_f64x2_relaxed_min(&mut self) -> Self::Output {
774 self.check_v128_binary_op()
775 }
776 fn visit_f64x2_relaxed_max(&mut self) -> Self::Output {
777 self.check_v128_binary_op()
778 }
779 fn visit_i16x8_relaxed_q15mulr_s(&mut self) -> Self::Output {
780 self.check_v128_binary_op()
781 }
782 fn visit_i16x8_relaxed_dot_i8x16_i7x16_s(&mut self) -> Self::Output {
783 self.check_v128_binary_op()
784 }
785 fn visit_i32x4_relaxed_dot_i8x16_i7x16_add_s(&mut self) -> Self::Output {
786 self.check_v128_ternary_op()
787 }
788 fn visit_v128_any_true(&mut self) -> Self::Output {
789 self.check_v128_bitmask_op()
790 }
791 fn visit_i8x16_all_true(&mut self) -> Self::Output {
792 self.check_v128_bitmask_op()
793 }
794 fn visit_i8x16_bitmask(&mut self) -> Self::Output {
795 self.check_v128_bitmask_op()
796 }
797 fn visit_i16x8_all_true(&mut self) -> Self::Output {
798 self.check_v128_bitmask_op()
799 }
800 fn visit_i16x8_bitmask(&mut self) -> Self::Output {
801 self.check_v128_bitmask_op()
802 }
803 fn visit_i32x4_all_true(&mut self) -> Self::Output {
804 self.check_v128_bitmask_op()
805 }
806 fn visit_i32x4_bitmask(&mut self) -> Self::Output {
807 self.check_v128_bitmask_op()
808 }
809 fn visit_i64x2_all_true(&mut self) -> Self::Output {
810 self.check_v128_bitmask_op()
811 }
812 fn visit_i64x2_bitmask(&mut self) -> Self::Output {
813 self.check_v128_bitmask_op()
814 }
815 fn visit_i8x16_shl(&mut self) -> Self::Output {
816 self.check_v128_shift_op()
817 }
818 fn visit_i8x16_shr_s(&mut self) -> Self::Output {
819 self.check_v128_shift_op()
820 }
821 fn visit_i8x16_shr_u(&mut self) -> Self::Output {
822 self.check_v128_shift_op()
823 }
824 fn visit_i16x8_shl(&mut self) -> Self::Output {
825 self.check_v128_shift_op()
826 }
827 fn visit_i16x8_shr_s(&mut self) -> Self::Output {
828 self.check_v128_shift_op()
829 }
830 fn visit_i16x8_shr_u(&mut self) -> Self::Output {
831 self.check_v128_shift_op()
832 }
833 fn visit_i32x4_shl(&mut self) -> Self::Output {
834 self.check_v128_shift_op()
835 }
836 fn visit_i32x4_shr_s(&mut self) -> Self::Output {
837 self.check_v128_shift_op()
838 }
839 fn visit_i32x4_shr_u(&mut self) -> Self::Output {
840 self.check_v128_shift_op()
841 }
842 fn visit_i64x2_shl(&mut self) -> Self::Output {
843 self.check_v128_shift_op()
844 }
845 fn visit_i64x2_shr_s(&mut self) -> Self::Output {
846 self.check_v128_shift_op()
847 }
848 fn visit_i64x2_shr_u(&mut self) -> Self::Output {
849 self.check_v128_shift_op()
850 }
851 fn visit_i8x16_swizzle(&mut self) -> Self::Output {
852 self.pop_operand(Some(ValType::V128))?;
853 self.pop_operand(Some(ValType::V128))?;
854 self.push_operand(ValType::V128)?;
855 Ok(())
856 }
857 fn visit_i8x16_shuffle(&mut self, lanes: [u8; 16]) -> Self::Output {
858 self.pop_operand(Some(ValType::V128))?;
859 self.pop_operand(Some(ValType::V128))?;
860 for i in lanes {
861 self.check_simd_lane_index(i, 32)?;
862 }
863 self.push_operand(ValType::V128)?;
864 Ok(())
865 }
866 fn visit_v128_load8_splat(&mut self, memarg: MemArg) -> Self::Output {
867 let ty = self.check_memarg(memarg)?;
868 self.pop_operand(Some(ty))?;
869 self.push_operand(ValType::V128)?;
870 Ok(())
871 }
872 fn visit_v128_load16_splat(&mut self, memarg: MemArg) -> Self::Output {
873 let ty = self.check_memarg(memarg)?;
874 self.pop_operand(Some(ty))?;
875 self.push_operand(ValType::V128)?;
876 Ok(())
877 }
878 fn visit_v128_load32_splat(&mut self, memarg: MemArg) -> Self::Output {
879 let ty = self.check_memarg(memarg)?;
880 self.pop_operand(Some(ty))?;
881 self.push_operand(ValType::V128)?;
882 Ok(())
883 }
884 fn visit_v128_load32_zero(&mut self, memarg: MemArg) -> Self::Output {
885 self.visit_v128_load32_splat(memarg)
886 }
887 fn visit_v128_load64_splat(&mut self, memarg: MemArg) -> Self::Output {
888 self.check_v128_load_op(memarg)
889 }
890 fn visit_v128_load64_zero(&mut self, memarg: MemArg) -> Self::Output {
891 self.check_v128_load_op(memarg)
892 }
893 fn visit_v128_load8x8_s(&mut self, memarg: MemArg) -> Self::Output {
894 self.check_v128_load_op(memarg)
895 }
896 fn visit_v128_load8x8_u(&mut self, memarg: MemArg) -> Self::Output {
897 self.check_v128_load_op(memarg)
898 }
899 fn visit_v128_load16x4_s(&mut self, memarg: MemArg) -> Self::Output {
900 self.check_v128_load_op(memarg)
901 }
902 fn visit_v128_load16x4_u(&mut self, memarg: MemArg) -> Self::Output {
903 self.check_v128_load_op(memarg)
904 }
905 fn visit_v128_load32x2_s(&mut self, memarg: MemArg) -> Self::Output {
906 self.check_v128_load_op(memarg)
907 }
908 fn visit_v128_load32x2_u(&mut self, memarg: MemArg) -> Self::Output {
909 self.check_v128_load_op(memarg)
910 }
911 fn visit_v128_load8_lane(&mut self, memarg: MemArg, lane: u8) -> Self::Output {
912 let idx = self.check_memarg(memarg)?;
913 self.check_simd_lane_index(lane, 16)?;
914 self.pop_operand(Some(ValType::V128))?;
915 self.pop_operand(Some(idx))?;
916 self.push_operand(ValType::V128)?;
917 Ok(())
918 }
919 fn visit_v128_load16_lane(&mut self, memarg: MemArg, lane: u8) -> Self::Output {
920 let idx = self.check_memarg(memarg)?;
921 self.check_simd_lane_index(lane, 8)?;
922 self.pop_operand(Some(ValType::V128))?;
923 self.pop_operand(Some(idx))?;
924 self.push_operand(ValType::V128)?;
925 Ok(())
926 }
927 fn visit_v128_load32_lane(&mut self, memarg: MemArg, lane: u8) -> Self::Output {
928 let idx = self.check_memarg(memarg)?;
929 self.check_simd_lane_index(lane, 4)?;
930 self.pop_operand(Some(ValType::V128))?;
931 self.pop_operand(Some(idx))?;
932 self.push_operand(ValType::V128)?;
933 Ok(())
934 }
935 fn visit_v128_load64_lane(&mut self, memarg: MemArg, lane: u8) -> Self::Output {
936 let idx = self.check_memarg(memarg)?;
937 self.check_simd_lane_index(lane, 2)?;
938 self.pop_operand(Some(ValType::V128))?;
939 self.pop_operand(Some(idx))?;
940 self.push_operand(ValType::V128)?;
941 Ok(())
942 }
943 fn visit_v128_store8_lane(&mut self, memarg: MemArg, lane: u8) -> Self::Output {
944 let idx = self.check_memarg(memarg)?;
945 self.check_simd_lane_index(lane, 16)?;
946 self.pop_operand(Some(ValType::V128))?;
947 self.pop_operand(Some(idx))?;
948 Ok(())
949 }
950 fn visit_v128_store16_lane(&mut self, memarg: MemArg, lane: u8) -> Self::Output {
951 let idx = self.check_memarg(memarg)?;
952 self.check_simd_lane_index(lane, 8)?;
953 self.pop_operand(Some(ValType::V128))?;
954 self.pop_operand(Some(idx))?;
955 Ok(())
956 }
957 fn visit_v128_store32_lane(&mut self, memarg: MemArg, lane: u8) -> Self::Output {
958 let idx = self.check_memarg(memarg)?;
959 self.check_simd_lane_index(lane, 4)?;
960 self.pop_operand(Some(ValType::V128))?;
961 self.pop_operand(Some(idx))?;
962 Ok(())
963 }
964 fn visit_v128_store64_lane(&mut self, memarg: MemArg, lane: u8) -> Self::Output {
965 let idx = self.check_memarg(memarg)?;
966 self.check_simd_lane_index(lane, 2)?;
967 self.pop_operand(Some(ValType::V128))?;
968 self.pop_operand(Some(idx))?;
969 Ok(())
970 }
971}