implement v128.imul

This commit is contained in:
Ilya Rezvov
2023-09-08 22:39:12 -06:00
parent 369cad8a25
commit d98d1b718f
3 changed files with 15 additions and 1 deletions
+8
View File
@@ -1446,6 +1446,14 @@ eval budget store inst FunctionInstance { funcType, moduleInstance, code = Funct
_ -> error "impossible due to validation"
in
return $ Done ctx { stack = VV128 r : rest }
step ctx@EvalCtx{ stack = (VV128 v2:VV128 v1:rest) } (IBinOp (BS128 shape) IMul) =
let r = case shape of
I16x8 -> lanewise @Word16 shape v1 v2 (*)
I32x4 -> lanewise @Word32 shape v1 v2 (*)
I64x2 -> lanewise @Word64 shape v1 v2 (*)
_ -> error "impossible due to validation"
in
return $ Done ctx { stack = VV128 r : rest }
step ctx@EvalCtx{ stack = (VV128 v2:VV128 v1:rest) } (IBinOp (BS128 shape) IAddSatU) =
let r = case shape of
I8x16 -> lanewise @Word8 shape v1 v2 $ \a b ->
+6
View File
@@ -421,6 +421,9 @@ import Language.Wasm.Lexer (
'i16x8.add_sat_u' { Lexeme _ (TKeyword "i16x8.add_sat_u") }
'i8x16.sub_sat_u' { Lexeme _ (TKeyword "i8x16.sub_sat_u") }
'i16x8.sub_sat_u' { Lexeme _ (TKeyword "i16x8.sub_sat_u") }
'i16x8.mul' { Lexeme _ (TKeyword "i16x8.mul") }
'i32x4.mul' { Lexeme _ (TKeyword "i32x4.mul") }
'i64x2.mul' { Lexeme _ (TKeyword "i64x2.mul") }
'i8x16.abs' { Lexeme _ (TKeyword "i8x16.abs") }
'i16x8.abs' { Lexeme _ (TKeyword "i16x8.abs") }
'i32x4.abs' { Lexeme _ (TKeyword "i32x4.abs") }
@@ -899,6 +902,9 @@ plaininstr :: { PlainInstr }
| 'i16x8.add_sat_u' { IBinOp (BS128 I16x8) IAddSatU }
| 'i8x16.sub_sat_u' { IBinOp (BS128 I8x16) ISubSatU }
| 'i16x8.sub_sat_u' { IBinOp (BS128 I16x8) ISubSatU }
| 'i16x8.mul' { IBinOp (BS128 I16x8) IMul }
| 'i32x4.mul' { IBinOp (BS128 I32x4) IMul }
| 'i64x2.mul' { IBinOp (BS128 I64x2) IMul }
| 'i8x16.shl' { IBinOp (BS128 I8x16) IShl }
| 'i16x8.shl' { IBinOp (BS128 I16x8) IShl }
| 'i32x4.shl' { IBinOp (BS128 I32x4) IShl }