implement rest of unary float operations for simd

This commit is contained in:
Ilya Rezvov
2023-09-10 17:28:37 -06:00
parent 368ab45de5
commit 22198d8d76
3 changed files with 61 additions and 1 deletions
+44
View File
@@ -1743,6 +1743,50 @@ 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 v:rest) } (FUnOp (BS128 shape) FCeil) =
let r = case shape of
F32x4 -> ByteArray.byteArrayFromList
$ floatToWord . floatCeil . wordToFloat . ByteArray.indexByteArray @Word32 v
<$> [0..3]
F64x2 -> ByteArray.byteArrayFromList
$ doubleToWord . doubleCeil . wordToDouble . ByteArray.indexByteArray @Word64 v
<$> [0..1]
_ -> error "impossible due to validation"
in
return $ Done ctx { stack = VV128 r : rest }
step ctx@EvalCtx{ stack = (VV128 v:rest) } (FUnOp (BS128 shape) FFloor) =
let r = case shape of
F32x4 -> ByteArray.byteArrayFromList
$ floatToWord . floatFloor . wordToFloat . ByteArray.indexByteArray @Word32 v
<$> [0..3]
F64x2 -> ByteArray.byteArrayFromList
$ doubleToWord . doubleFloor . wordToDouble . ByteArray.indexByteArray @Word64 v
<$> [0..1]
_ -> error "impossible due to validation"
in
return $ Done ctx { stack = VV128 r : rest }
step ctx@EvalCtx{ stack = (VV128 v:rest) } (FUnOp (BS128 shape) FTrunc) =
let r = case shape of
F32x4 -> ByteArray.byteArrayFromList
$ floatToWord . floatTrunc . wordToFloat . ByteArray.indexByteArray @Word32 v
<$> [0..3]
F64x2 -> ByteArray.byteArrayFromList
$ doubleToWord . doubleTrunc . wordToDouble . ByteArray.indexByteArray @Word64 v
<$> [0..1]
_ -> error "impossible due to validation"
in
return $ Done ctx { stack = VV128 r : rest }
step ctx@EvalCtx{ stack = (VV128 v:rest) } (FUnOp (BS128 shape) FNearest) =
let r = case shape of
F32x4 -> ByteArray.byteArrayFromList
$ floatToWord . nearest . wordToFloat . ByteArray.indexByteArray @Word32 v
<$> [0..3]
F64x2 -> ByteArray.byteArrayFromList
$ doubleToWord . nearest . wordToDouble . ByteArray.indexByteArray @Word64 v
<$> [0..1]
_ -> error "impossible due to validation"
in
return $ Done ctx { stack = VV128 r : rest }
step ctx@EvalCtx{ stack = (VV128 v:rest) } (FUnOp (BS128 shape) FSqrt) =
let r = case shape of
F32x4 -> ByteArray.byteArrayFromList