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

Commit

Permalink
Change Rep type of SIMD to be immutable string
Browse files Browse the repository at this point in the history
  • Loading branch information
ngzhian committed Jan 10, 2020
1 parent f641145 commit 6b80519
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
10 changes: 4 additions & 6 deletions interpreter/exec/simd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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
7 changes: 3 additions & 4 deletions interpreter/exec/v128.ml
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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)

0 comments on commit 6b80519

Please sign in to comment.