From d9e9d222b5f85b5b510471997a1adeef376a9a66 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Tue, 29 Sep 2020 09:14:01 -0700 Subject: [PATCH] Clean up some SIMD TODOs (#367) Replace them with assert false, to indicate that those aren't supposed to happen, rather than unimplemented. --- interpreter/binary/encode.ml | 4 +--- interpreter/exec/eval_numeric.ml | 7 +++---- interpreter/script/js.ml | 12 ++++++------ interpreter/text/arrange.ml | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/interpreter/binary/encode.ml b/interpreter/binary/encode.ml index 3139116b76..1d39d3ffb6 100644 --- a/interpreter/binary/encode.ml +++ b/interpreter/binary/encode.ml @@ -291,7 +291,7 @@ let encode m = | Compare (F64 F64Op.Gt) -> op 0x64 | Compare (F64 F64Op.Le) -> op 0x65 | Compare (F64 F64Op.Ge) -> op 0x66 - | Compare (V128 _) -> failwith "TODO v128" + | Compare (V128 _) -> assert false | Unary (I32 I32Op.Clz) -> op 0x67 | Unary (I32 I32Op.Ctz) -> op 0x68 @@ -508,8 +508,6 @@ let encode m = | Binary (V128 V128Op.(V128 AndNot)) -> simd_op 0x4fl | Binary (V128 V128Op.(V128 Or)) -> simd_op 0x50l | Binary (V128 V128Op.(V128 Xor)) -> simd_op 0x51l - | Binary (V128 _) -> failwith "TODO v128" - | Ternary (V128Op.Bitselect) -> simd_op 0x52l diff --git a/interpreter/exec/eval_numeric.ml b/interpreter/exec/eval_numeric.ml index 358d60f0fd..44e27b0c36 100644 --- a/interpreter/exec/eval_numeric.ml +++ b/interpreter/exec/eval_numeric.ml @@ -162,7 +162,7 @@ struct | F64x2 Trunc -> to_value (SXX.F64x2.trunc (of_value 1 v)) | F64x2 Nearest -> to_value (SXX.F64x2.nearest (of_value 1 v)) | V128 Not -> to_value (SXX.V128.lognot (of_value 1 v)) - | _ -> failwith "TODO v128 unimplemented unop" + | _ -> assert false let binop (op : binop) = let f = match op with @@ -267,7 +267,7 @@ struct | V128 Or -> SXX.V128.or_ | V128 Xor -> SXX.V128.xor | V128 AndNot -> SXX.V128.andnot - | _ -> failwith "TODO v128 unimplemented binop" + | _ -> assert false in fun v1 v2 -> to_value (f (of_value 1 v1) (of_value 2 v2)) let testop (op : testop) = @@ -281,8 +281,7 @@ struct | _ -> assert false in fun v -> f (of_value 1 v) - (* FIXME *) - let relop op = failwith "TODO v128 unimplemented relop" + let relop op = assert false let extractop op v = let v128 = of_value 1 v in diff --git a/interpreter/script/js.ml b/interpreter/script/js.ml index 446fcf5da2..934718d04b 100644 --- a/interpreter/script/js.ml +++ b/interpreter/script/js.ml @@ -195,29 +195,29 @@ let eq_of = function | I64Type -> Values.I64 I64Op.Eq | F32Type -> Values.F32 F32Op.Eq | F64Type -> Values.F64 F64Op.Eq - | V128Type -> failwith "TODO v128" + | V128Type -> assert false let and_of = function | I32Type | F32Type -> Values.I32 I32Op.And | I64Type | F64Type -> Values.I64 I64Op.And - | V128Type -> failwith "TODO v128" + | V128Type -> Values.V128 V128Op.(V128 And) let reinterpret_of = function | I32Type -> I32Type, Nop | I64Type -> I64Type, Nop | F32Type -> I32Type, Convert (Values.I32 I32Op.ReinterpretFloat) | F64Type -> I64Type, Convert (Values.I64 I64Op.ReinterpretFloat) - | V128Type -> failwith "TODO v128" + | V128Type -> assert false let canonical_nan_of = function | I32Type | F32Type -> Values.I32 (F32.to_bits F32.pos_nan) | I64Type | F64Type -> Values.I64 (F64.to_bits F64.pos_nan) - | V128Type -> failwith "TODO v128" + | V128Type -> assert false let abs_mask_of = function | I32Type | F32Type -> Values.I32 Int32.max_int | I64Type | F64Type -> Values.I64 Int64.max_int - | V128Type -> failwith "TODO v128" + | V128Type -> assert false let invoke ft lits at = [ft @@ at], FuncImport (1l @@ at) @@ at, @@ -290,7 +290,7 @@ let assert_return ress ts at = in [ Const (Values.V128 mask @@ at) @@ at; - Binary (Values.V128 V128Op.(V128 And)) @@ at; + Binary (and_of V128Type) @@ at; Const (Values.V128 expected @@ at) @@ at; Binary (Values.V128 V128Op.(I8x16 Eq)) @@ at; (* If all lanes are non-zero, then they are equal *) diff --git a/interpreter/text/arrange.ml b/interpreter/text/arrange.ml index 012de7440a..f2507a513a 100644 --- a/interpreter/text/arrange.ml +++ b/interpreter/text/arrange.ml @@ -199,7 +199,7 @@ struct | I32x4 AllTrue -> "i32x4.all_true" | _ -> assert false - let relop xx = fun _ -> failwith "TODO v128" + let relop xx = assert false let unop xx (op : unop) = match op with | I8x16 Neg -> "i8x16.neg"