implement v128.load[8|16|32|64]_splat

This commit is contained in:
Ilya Rezvov
2023-09-08 10:29:30 -06:00
parent d9803479a0
commit d406776095
5 changed files with 49 additions and 1 deletions
+16
View File
@@ -879,6 +879,22 @@ eval budget store inst FunctionInstance { funcType, moduleInstance, code = Funct
else do
val <- ByteArray.freezeByteArray memory addr 16
return $ Done ctx { stack = VV128 val : rest }
step ctx (V128Load8Splat MemArg { offset }) =
makeLoadInstr @Word8 ctx offset 1 $ \rest val ->
let v = ByteArray.byteArrayFromListN 16 $ replicate 16 val in
Done ctx { stack = VV128 v : rest }
step ctx (V128Load16Splat MemArg { offset }) =
makeLoadInstr @Word16 ctx offset 2 $ \rest val ->
let v = ByteArray.byteArrayFromListN 8 $ replicate 8 val in
Done ctx { stack = VV128 v : rest }
step ctx (V128Load32Splat MemArg { offset }) =
makeLoadInstr @Word32 ctx offset 4 $ \rest val ->
let v = ByteArray.byteArrayFromListN 4 $ replicate 4 val in
Done ctx { stack = VV128 v : rest }
step ctx (V128Load64Splat MemArg { offset }) =
makeLoadInstr @Word64 ctx offset 8 $ \rest val ->
let v = ByteArray.byteArrayFromListN 2 [val, val] in
Done ctx { stack = VV128 v : rest }
step ctx (I32Load8U MemArg { offset }) =
makeLoadInstr @Word8 ctx offset 1 $ (\rest val -> Done ctx { stack = VI32 (fromIntegral val) : rest })
step ctx (I32Load8S MemArg { offset }) =