implement v128.load[32|64]_zero
This commit is contained in:
@@ -895,6 +895,14 @@ eval budget store inst FunctionInstance { funcType, moduleInstance, code = Funct
|
||||
makeLoadInstr @Word64 ctx offset 8 $ \rest val ->
|
||||
let v = ByteArray.byteArrayFromListN 2 [val, val] in
|
||||
Done ctx { stack = VV128 v : rest }
|
||||
step ctx (V128Load32Zero MemArg { offset }) =
|
||||
makeLoadInstr @Word32 ctx offset 4 $ \rest val ->
|
||||
let v = ByteArray.byteArrayFromListN 4 $ val : [0, 0, 0] in
|
||||
Done ctx { stack = VV128 v : rest }
|
||||
step ctx (V128Load64Zero MemArg { offset }) =
|
||||
makeLoadInstr @Word64 ctx offset 8 $ \rest val ->
|
||||
let v = ByteArray.byteArrayFromListN 2 [val, 0] 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 }) =
|
||||
|
||||
@@ -155,6 +155,8 @@ import Language.Wasm.Lexer (
|
||||
'v128.load16_splat' { Lexeme _ (TKeyword "v128.load16_splat") }
|
||||
'v128.load32_splat' { Lexeme _ (TKeyword "v128.load32_splat") }
|
||||
'v128.load64_splat' { Lexeme _ (TKeyword "v128.load64_splat") }
|
||||
'v128.load32_zero' { Lexeme _ (TKeyword "v128.load32_zero") }
|
||||
'v128.load64_zero' { Lexeme _ (TKeyword "v128.load64_zero") }
|
||||
'i32.load8_s' { Lexeme _ (TKeyword "i32.load8_s") }
|
||||
'i32.load8_u' { Lexeme _ (TKeyword "i32.load8_u") }
|
||||
'i32.load16_s' { Lexeme _ (TKeyword "i32.load16_s") }
|
||||
@@ -571,6 +573,8 @@ plaininstr :: { PlainInstr }
|
||||
| 'v128.load16_splat' memarg2 { V128Load16Splat $2 }
|
||||
| 'v128.load32_splat' memarg4 { V128Load32Splat $2 }
|
||||
| 'v128.load64_splat' memarg8 { V128Load64Splat $2 }
|
||||
| 'v128.load32_zero' memarg4 { V128Load32Zero $2 }
|
||||
| 'v128.load64_zero' memarg8 { V128Load64Zero $2 }
|
||||
| 'i32.load8_s' memarg1 { I32Load8S $2 }
|
||||
| 'i32.load8_u' memarg1 { I32Load8U $2 }
|
||||
| 'i32.load16_s' memarg2 { I32Load16S $2 }
|
||||
@@ -1441,6 +1445,8 @@ data PlainInstr =
|
||||
| V128Load16Splat MemArg
|
||||
| V128Load32Splat MemArg
|
||||
| V128Load64Splat MemArg
|
||||
| V128Load32Zero MemArg
|
||||
| V128Load64Zero MemArg
|
||||
| I32Load8S MemArg
|
||||
| I32Load8U MemArg
|
||||
| I32Load16S MemArg
|
||||
@@ -1968,6 +1974,8 @@ desugarize fields = do
|
||||
synInstrToStruct _ (PlainInstr (V128Load16Splat memArg)) = return $ S.V128Load16Splat memArg
|
||||
synInstrToStruct _ (PlainInstr (V128Load32Splat memArg)) = return $ S.V128Load32Splat memArg
|
||||
synInstrToStruct _ (PlainInstr (V128Load64Splat memArg)) = return $ S.V128Load64Splat memArg
|
||||
synInstrToStruct _ (PlainInstr (V128Load32Zero memArg)) = return $ S.V128Load32Zero memArg
|
||||
synInstrToStruct _ (PlainInstr (V128Load64Zero memArg)) = return $ S.V128Load64Zero memArg
|
||||
synInstrToStruct _ (PlainInstr (I32Load8S memArg)) = return $ S.I32Load8S memArg
|
||||
synInstrToStruct _ (PlainInstr (I32Load8U memArg)) = return $ S.I32Load8U memArg
|
||||
synInstrToStruct _ (PlainInstr (I32Load16S memArg)) = return $ S.I32Load16S memArg
|
||||
|
||||
@@ -169,6 +169,8 @@ data Instruction index =
|
||||
| V128Load16Splat MemArg
|
||||
| V128Load32Splat MemArg
|
||||
| V128Load64Splat MemArg
|
||||
| V128Load32Zero MemArg
|
||||
| V128Load64Zero MemArg
|
||||
| I32Load8S MemArg
|
||||
| I32Load8U MemArg
|
||||
| I32Load16S MemArg
|
||||
|
||||
@@ -352,6 +352,12 @@ getInstrType _ (V128Load32Splat memarg) = do
|
||||
getInstrType _ (V128Load64Splat memarg) = do
|
||||
checkMemoryInstr 8 memarg
|
||||
return $ I32 ==> V128
|
||||
getInstrType _ (V128Load32Zero memarg) = do
|
||||
checkMemoryInstr 4 memarg
|
||||
return $ I32 ==> V128
|
||||
getInstrType _ (V128Load64Zero memarg) = do
|
||||
checkMemoryInstr 8 memarg
|
||||
return $ I32 ==> V128
|
||||
getInstrType _ (I32Load8S memarg) = do
|
||||
checkMemoryInstr 1 memarg
|
||||
return $ I32 ==> I32
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ main = do
|
||||
filter (List.isPrefixOf "simd") .
|
||||
filter (List.isSuffixOf ".wast")
|
||||
<$> Directory.listDirectory "tests/spec"
|
||||
let files = ["simd_load_splat.wast"]
|
||||
let files = ["simd_load_extend.wast"]
|
||||
scriptTestCases <- (`mapM` files) $ \file -> do
|
||||
test <- LBS.readFile ("tests/spec/" ++ file)
|
||||
return $ testCase file $ do
|
||||
|
||||
Reference in New Issue
Block a user