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

Commit cac3342

Browse files
committed
Add encoding for v128 type and v128.const
1 parent 1d97ea2 commit cac3342

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

interpreter/binary/encode.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ let encode m =
9595
| I64Type -> vs7 (-0x02)
9696
| F32Type -> vs7 (-0x03)
9797
| F64Type -> vs7 (-0x04)
98-
| V128Type -> failwith "TODO v128"
98+
| V128Type -> vs7 (-0x05)
9999

100100
let elem_type = function
101101
| FuncRefType -> vs7 (-0x10)
@@ -134,6 +134,7 @@ let encode m =
134134
open Memory
135135

136136
let op n = u8 n
137+
let simd_op n = op 0xfd; op n
137138
let end_ () = op 0x0b
138139

139140
let memop {align; offset; _} = vu32 (Int32.of_int align); vu32 offset
@@ -224,8 +225,7 @@ let encode m =
224225
| Const {it = I64 c; _} -> op 0x42; vs64 c
225226
| Const {it = F32 c; _} -> op 0x43; f32 c
226227
| Const {it = F64 c; _} -> op 0x44; f64 c
227-
| Const {it = V128 c; _} ->
228-
failwith "TODO v128"
228+
| Const {it = V128 c; _} -> simd_op 0x02; Bytes.iter (put s) (V128.to_bits c)
229229

230230
| Test (I32 I32Op.Eqz) -> op 0x45
231231
| Test (I64 I64Op.Eqz) -> op 0x50

0 commit comments

Comments
 (0)