This repository was archived by the owner on Dec 22, 2021. It is now read-only.
File tree 3 files changed +12
-7
lines changed
3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ let encode m =
62
62
let vs32 i = vs64 (Int64. of_int32 i)
63
63
let f32 x = u32 (F32. to_bits x)
64
64
let f64 x = u64 (F64. to_bits x)
65
+ let v128 v = String. iter (put s) (V128. to_bits v)
65
66
66
67
let len i =
67
68
if Int32. to_int (Int32. of_int i) <> i then
@@ -95,7 +96,7 @@ let encode m =
95
96
| I64Type -> vs7 (- 0x02 )
96
97
| F32Type -> vs7 (- 0x03 )
97
98
| F64Type -> vs7 (- 0x04 )
98
- | V128Type -> failwith " TODO v128 "
99
+ | V128Type -> vs7 ( - 0x05 )
99
100
100
101
let elem_type = function
101
102
| FuncRefType -> vs7 (- 0x10 )
@@ -134,6 +135,7 @@ let encode m =
134
135
open Memory
135
136
136
137
let op n = u8 n
138
+ let simd_op n = op 0xfd ; op n
137
139
let end_ () = op 0x0b
138
140
139
141
let memop {align; offset; _} = vu32 (Int32. of_int align); vu32 offset
@@ -224,8 +226,7 @@ let encode m =
224
226
| Const {it = I64 c ; _} -> op 0x42 ; vs64 c
225
227
| Const {it = F32 c ; _} -> op 0x43 ; f32 c
226
228
| Const {it = F64 c ; _} -> op 0x44 ; f64 c
227
- | Const {it = V128 c ; _} ->
228
- failwith " TODO v128"
229
+ | Const {it = V128 c ; _} -> simd_op 0x02 ; v128 c
229
230
230
231
| Test (I32 I32Op. Eqz) -> op 0x45
231
232
| Test (I64 I64Op. Eqz) -> op 0x50
Original file line number Diff line number Diff line change 20
20
val to_string : t -> string
21
21
val bytewidth : int
22
22
val of_strings : shape -> string list -> t
23
+ val of_bits : string -> t
24
+ val to_bits : t -> string
23
25
end
24
26
25
27
module type S =
33
35
val of_strings : shape -> string list -> t
34
36
end
35
37
36
- module Make (Rep : RepType ) : S with type bits = Rep. t =
38
+ module Make (Rep : RepType ) : S with type bits = string =
37
39
struct
38
40
type t = Rep .t
39
- type bits = Rep .t
41
+ type bits = string
40
42
41
43
let default = Rep. make Rep. bytewidth (chr 0 )
42
44
let to_string = Rep. to_string (* FIXME very very wrong *)
43
- let to_bits x = x
44
- let of_bits x = x
45
+ let of_bits = Rep. of_bits
46
+ let to_bits = Rep. to_bits
45
47
let of_strings = Rep. of_strings
46
48
end
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ include Simd.Make
2
2
(struct
3
3
include Bytes
4
4
let bytewidth = 16
5
+ let of_bits = Bytes. of_string
6
+ let to_bits = Bytes. to_string
5
7
6
8
let of_strings shape ss =
7
9
if List. length ss <> Simd. lanes shape then raise (Invalid_argument " wrong length" );
You can’t perform that action at this time.
0 commit comments