@@ -114,6 +114,10 @@ let simd_shape = function
114
114
| "f32x4" -> Simd. F32x4
115
115
| "f64x2" -> Simd. F64x2
116
116
| _ -> assert false
117
+
118
+ let only shapes s lexbuf =
119
+ if not (List. mem s shapes) then
120
+ error lexbuf " unknown operator"
117
121
}
118
122
119
123
let sign = '+' | '-'
@@ -389,35 +393,35 @@ rule token = parse
389
393
| " output" { OUTPUT }
390
394
391
395
| (simd_shape as s)" .neg"
392
- { if s <> " i32x4" && s <> " f32x4" && s <> " f64x2" then error lexbuf " unknown operator " ;
396
+ { only [ " i32x4" ; " f32x4" ; " f64x2" ] s lexbuf;
393
397
UNARY (simdop s unreachable unreachable i32x4_neg unreachable f32x4_neg f64x2_neg) }
394
398
| (simd_float_shape as s)" .sqrt" { UNARY (simd_float_op s f32x4_sqrt f64x2_sqrt) }
395
399
| (simd_shape as s)" .add"
396
- { if s <> " i32x4" && s <> " f32x4" && s <> " f64x2" then error lexbuf " unknown operator " ;
400
+ { only [ " i32x4" ; " f32x4" ; " f64x2" ] s lexbuf;
397
401
BINARY (simdop s unreachable unreachable i32x4_add unreachable f32x4_add f64x2_add) }
398
402
| (simd_shape as s)" .sub"
399
- { if s <> " i32x4" && s <> " f32x4" && s <> " f64x2" then error lexbuf " unknown operator " ;
403
+ { only [ " i32x4" ; " f32x4" ; " f64x2" ] s lexbuf;
400
404
BINARY (simdop s unreachable unreachable i32x4_sub unreachable f32x4_sub f64x2_sub) }
401
405
| (simd_shape as s)" .min_s"
402
- { if s <> " i32x4" then error lexbuf " unknown operator " ;
406
+ { only [ " i32x4" ] s lexbuf;
403
407
BINARY (simdop s unreachable unreachable i32x4_min_s unreachable unreachable unreachable) }
404
408
| (simd_shape as s)" .min_u"
405
- { if s <> " i32x4" then error lexbuf " unknown operator " ;
409
+ { only [ " i32x4" ] s lexbuf;
406
410
BINARY (simdop s unreachable unreachable i32x4_min_u unreachable unreachable unreachable) }
407
411
| (simd_shape as s)" .max_s"
408
- { if s <> " i32x4" then error lexbuf " unknown operator " ;
412
+ { only [ " i32x4" ] s lexbuf;
409
413
BINARY (simdop s unreachable unreachable i32x4_max_s unreachable unreachable unreachable) }
410
414
| (simd_shape as s)" .max_u"
411
- { if s <> " i32x4" then error lexbuf " unknown operator " ;
415
+ { only [ " i32x4" ] s lexbuf;
412
416
BINARY (simdop s unreachable unreachable i32x4_max_u unreachable unreachable unreachable) }
413
417
| (simd_shape as s)" .mul"
414
- { if s <> " i32x4" && s <> " f32x4" && s <> " f64x2" then error lexbuf " unknown operator " ;
418
+ { only [ " i32x4" ; " f32x4" ; " f64x2" ] s lexbuf;
415
419
BINARY (simdop s unreachable unreachable i32x4_mul unreachable f32x4_mul f64x2_mul) }
416
420
| (simd_float_shape as s)" .div" { BINARY (simd_float_op s f32x4_div f64x2_div) }
417
421
| (simd_float_shape as s)" .min" { BINARY (simd_float_op s f32x4_min f64x2_min) }
418
422
| (simd_float_shape as s)" .max" { BINARY (simd_float_op s f32x4_max f64x2_max) }
419
423
| (simd_shape as s)" .abs"
420
- { if s <> " i32x4" && s <> " f32x4" && s <> " f64x2" then error lexbuf " unknown operator " ;
424
+ { only [ " i32x4" ; " f32x4" ; " f64x2" ] s lexbuf;
421
425
UNARY (simdop s unreachable unreachable i32x4_abs unreachable f32x4_abs f64x2_abs) }
422
426
| (simd_shape as s) { SIMD_SHAPE (simd_shape s) }
423
427
0 commit comments