Skip to content

Commit

Permalink
Clean up some SIMD TODOs (WebAssembly#367)
Browse files Browse the repository at this point in the history
Replace them with assert false, to indicate that those aren't supposed
to happen, rather than unimplemented.
  • Loading branch information
ngzhian authored Sep 29, 2020
1 parent b00d926 commit d9e9d22
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
4 changes: 1 addition & 3 deletions interpreter/binary/encode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions interpreter/exec/eval_numeric.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) =
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions interpreter/script/js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 *)
Expand Down
2 changes: 1 addition & 1 deletion interpreter/text/arrange.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d9e9d22

Please sign in to comment.