Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit 4819d61

Browse files
authored
Merge pull request #172 from ngzhian/v128-rep-type-string
Change Rep type of SIMD to be immutable string
2 parents f641145 + 6b80519 commit 4819d61

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

interpreter/exec/simd.ml

+4-6
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ sig
2020
val to_string : t -> string
2121
val bytewidth : int
2222
val of_strings : shape -> string list -> t
23-
val of_bits : string -> t
24-
val to_bits : t -> string
2523
end
2624

2725
module type S =
@@ -35,14 +33,14 @@ sig
3533
val of_strings : shape -> string list -> t
3634
end
3735

38-
module Make (Rep : RepType) : S with type bits = string =
36+
module Make (Rep : RepType) : S with type bits = Rep.t =
3937
struct
4038
type t = Rep.t
41-
type bits = string
39+
type bits = Rep.t
4240

4341
let default = Rep.make Rep.bytewidth (chr 0)
4442
let to_string = Rep.to_string (* FIXME very very wrong *)
45-
let of_bits = Rep.of_bits
46-
let to_bits = Rep.to_bits
43+
let of_bits x = x
44+
let to_bits x = x
4745
let of_strings = Rep.of_strings
4846
end

interpreter/exec/v128.ml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
include Simd.Make
22
(struct
3-
include Bytes
3+
include String
44
let bytewidth = 16
5-
let of_bits = Bytes.of_string
6-
let to_bits = Bytes.to_string
5+
let to_string s = s
76

87
let of_strings shape ss =
98
if List.length ss <> Simd.lanes shape then raise (Invalid_argument "wrong length");
@@ -28,5 +27,5 @@ include Simd.Make
2827
List.iteri (fun i s -> set_int32_le b (i * 4) (F32.to_bits (F32.of_string s))) ss
2928
| Simd.F64x2 ->
3029
List.iteri (fun i s -> set_int64_le b (i * 8) (F64.to_bits (F64.of_string s))) ss);
31-
b
30+
Bytes.to_string b
3231
end)

0 commit comments

Comments
 (0)