From 6b805197248f7e4dfa689d330c5d27a851f4b007 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Fri, 10 Jan 2020 10:52:56 -0800 Subject: [PATCH] Change Rep type of SIMD to be immutable string --- interpreter/exec/simd.ml | 10 ++++------ interpreter/exec/v128.ml | 7 +++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/interpreter/exec/simd.ml b/interpreter/exec/simd.ml index b61b44794..5a2b83de3 100644 --- a/interpreter/exec/simd.ml +++ b/interpreter/exec/simd.ml @@ -20,8 +20,6 @@ sig val to_string : t -> string val bytewidth : int val of_strings : shape -> string list -> t - val of_bits : string -> t - val to_bits : t -> string end module type S = @@ -35,14 +33,14 @@ sig val of_strings : shape -> string list -> t end -module Make (Rep : RepType) : S with type bits = string = +module Make (Rep : RepType) : S with type bits = Rep.t = struct type t = Rep.t - type bits = string + type bits = Rep.t let default = Rep.make Rep.bytewidth (chr 0) let to_string = Rep.to_string (* FIXME very very wrong *) - let of_bits = Rep.of_bits - let to_bits = Rep.to_bits + let of_bits x = x + let to_bits x = x let of_strings = Rep.of_strings end diff --git a/interpreter/exec/v128.ml b/interpreter/exec/v128.ml index 22a4bc121..33d6bd775 100644 --- a/interpreter/exec/v128.ml +++ b/interpreter/exec/v128.ml @@ -1,9 +1,8 @@ include Simd.Make (struct - include Bytes + include String let bytewidth = 16 - let of_bits = Bytes.of_string - let to_bits = Bytes.to_string + let to_string s = s let of_strings shape ss = if List.length ss <> Simd.lanes shape then raise (Invalid_argument "wrong length"); @@ -28,5 +27,5 @@ include Simd.Make List.iteri (fun i s -> set_int32_le b (i * 4) (F32.to_bits (F32.of_string s))) ss | Simd.F64x2 -> List.iteri (fun i s -> set_int64_le b (i * 8) (F64.to_bits (F64.of_string s))) ss); - b + Bytes.to_string b end)