Add the Int64X2# primitive type and associated primops.

parent 7816845c
......@@ -387,6 +387,8 @@ emitPrimOp _ res IndexOffAddrOp_DoubleX2 args = doIndexOffAddrOp
emitPrimOp _ res IndexOffAddrOp_DoubleAsDoubleX2 args = doIndexOffAddrOpAs Nothing vec2f64 f64 res args
emitPrimOp _ res IndexOffAddrOp_Int32X4 args = doIndexOffAddrOp Nothing vec4b32 res args
emitPrimOp _ res IndexOffAddrOp_Int32AsInt32X4 args = doIndexOffAddrOpAs Nothing vec4b32 b32 res args
emitPrimOp _ res IndexOffAddrOp_Int64X2 args = doIndexOffAddrOp Nothing vec2b64 res args
emitPrimOp _ res IndexOffAddrOp_Int64AsInt64X2 args = doIndexOffAddrOpAs Nothing vec2b64 b64 res args
-- ReadXXXoffAddr, which are identical, for our purposes, to IndexXXXoffAddr.
......@@ -412,6 +414,8 @@ emitPrimOp _ res ReadOffAddrOp_DoubleX2 args = doIndexOffAddrOp N
emitPrimOp _ res ReadOffAddrOp_DoubleAsDoubleX2 args = doIndexOffAddrOpAs Nothing vec2f64 b64 res args
emitPrimOp _ res ReadOffAddrOp_Int32X4 args = doIndexOffAddrOp Nothing vec4b32 res args
emitPrimOp _ res ReadOffAddrOp_Int32AsInt32X4 args = doIndexOffAddrOpAs Nothing vec4b32 b32 res args
emitPrimOp _ res ReadOffAddrOp_Int64X2 args = doIndexOffAddrOp Nothing vec2b64 res args
emitPrimOp _ res ReadOffAddrOp_Int64AsInt64X2 args = doIndexOffAddrOpAs Nothing vec2b64 b64 res args
-- IndexXXXArray
......@@ -437,6 +441,8 @@ emitPrimOp _ res IndexByteArrayOp_DoubleX2 args = doIndexByteArrayO
emitPrimOp _ res IndexByteArrayOp_DoubleAsDoubleX2 args = doIndexByteArrayOpAs Nothing vec2f64 f64 res args
emitPrimOp _ res IndexByteArrayOp_Int32X4 args = doIndexByteArrayOp Nothing vec4b32 res args
emitPrimOp _ res IndexByteArrayOp_Int32AsInt32X4 args = doIndexByteArrayOpAs Nothing vec4b32 b32 res args
emitPrimOp _ res IndexByteArrayOp_Int64X2 args = doIndexByteArrayOp Nothing vec2b64 res args
emitPrimOp _ res IndexByteArrayOp_Int64AsInt64X2 args = doIndexByteArrayOpAs Nothing vec2b64 b64 res args
-- ReadXXXArray, identical to IndexXXXArray.
......@@ -462,6 +468,8 @@ emitPrimOp _ res ReadByteArrayOp_DoubleX2 args = doIndexByteArrayOp
emitPrimOp _ res ReadByteArrayOp_DoubleAsDoubleX2 args = doIndexByteArrayOpAs Nothing vec2f64 f64 res args
emitPrimOp _ res ReadByteArrayOp_Int32X4 args = doIndexByteArrayOp Nothing vec4b32 res args
emitPrimOp _ res ReadByteArrayOp_Int32AsInt32X4 args = doIndexByteArrayOpAs Nothing vec4b32 b32 res args
emitPrimOp _ res ReadByteArrayOp_Int64X2 args = doIndexByteArrayOp Nothing vec2b64 res args
emitPrimOp _ res ReadByteArrayOp_Int64AsInt64X2 args = doIndexByteArrayOpAs Nothing vec2b64 b64 res args
-- WriteXXXoffAddr
......@@ -487,6 +495,8 @@ emitPrimOp _ res WriteOffAddrOp_DoubleX2 args = doWriteOffAddrOp No
emitPrimOp _ res WriteOffAddrOp_DoubleAsDoubleX2 args = doWriteOffAddrOp Nothing f64 res args
emitPrimOp _ res WriteOffAddrOp_Int32X4 args = doWriteOffAddrOp Nothing vec4b32 res args
emitPrimOp _ res WriteOffAddrOp_Int32AsInt32X4 args = doWriteOffAddrOp Nothing b32 res args
emitPrimOp _ res WriteOffAddrOp_Int64X2 args = doWriteOffAddrOp Nothing vec2b64 res args
emitPrimOp _ res WriteOffAddrOp_Int64AsInt64X2 args = doWriteOffAddrOp Nothing b64 res args
-- WriteXXXArray
......@@ -512,6 +522,8 @@ emitPrimOp _ res WriteByteArrayOp_DoubleX2 args = doWriteByteArrayO
emitPrimOp _ res WriteByteArrayOp_DoubleAsDoubleX2 args = doWriteByteArrayOp Nothing f64 res args
emitPrimOp _ res WriteByteArrayOp_Int32X4 args = doWriteByteArrayOp Nothing vec4b32 res args
emitPrimOp _ res WriteByteArrayOp_Int32AsInt32X4 args = doWriteByteArrayOp Nothing b32 res args
emitPrimOp _ res WriteByteArrayOp_Int64X2 args = doWriteByteArrayOp Nothing vec2b64 res args
emitPrimOp _ res WriteByteArrayOp_Int64AsInt64X2 args = doWriteByteArrayOp Nothing b64 res args
-- Copying and setting byte arrays
emitPrimOp _ [] CopyByteArrayOp [src,src_off,dst,dst_off,n] =
......@@ -589,6 +601,24 @@ emitPrimOp dflags res@[_,_,_,_] Int32X4UnpackOp [arg] =
emitPrimOp dflags [res] Int32X4InsertOp [v,e,i] =
doVecInsertOp (Just (mo_WordTo32 dflags)) vec4b32 v e i res
emitPrimOp _ [res] Int64ToInt64X2Op [e] =
doVecPackOp Nothing vec2b64 zero [e,e] res
where
zero :: CmmExpr
zero = CmmLit $ CmmVec (replicate 2 (CmmInt 0 W64))
emitPrimOp _ [res] Int64X2PackOp es@[_,_] =
doVecPackOp Nothing vec2b64 zero es res
where
zero :: CmmExpr
zero = CmmLit $ CmmVec (replicate 2 (CmmInt 0 W64))
emitPrimOp _ res@[_,_] Int64X2UnpackOp [arg] =
doVecUnpackOp Nothing vec2b64 arg res
emitPrimOp _ [res] Int64X2InsertOp [v,e,i] =
doVecInsertOp Nothing vec2b64 v e i res
-- The rest just translate straightforwardly
emitPrimOp dflags [res] op [arg]
| nopOp op
......@@ -916,6 +946,13 @@ translateOp _ Int32X4QuotOp = Just (MO_VS_Quot 4 W32)
translateOp _ Int32X4RemOp = Just (MO_VS_Rem 4 W32)
translateOp _ Int32X4NegOp = Just (MO_VS_Neg 4 W32)
translateOp _ Int64X2AddOp = Just (MO_V_Add 2 W64)
translateOp _ Int64X2SubOp = Just (MO_V_Sub 2 W64)
translateOp _ Int64X2MulOp = Just (MO_V_Mul 2 W64)
translateOp _ Int64X2QuotOp = Just (MO_VS_Quot 2 W64)
translateOp _ Int64X2RemOp = Just (MO_VS_Rem 2 W64)
translateOp _ Int64X2NegOp = Just (MO_VS_Neg 2 W64)
-- Conversions
translateOp dflags Int2DoubleOp = Just (MO_SF_Conv (wordWidth dflags) W64)
......
......@@ -1421,11 +1421,13 @@ typeNatMulTyFamNameKey = mkPreludeTyConUnique 163
typeNatExpTyFamNameKey = mkPreludeTyConUnique 164
-- SIMD vector types (Unique keys)
floatX4PrimTyConKey, doubleX2PrimTyConKey, int32X4PrimTyConKey :: Unique
floatX4PrimTyConKey, doubleX2PrimTyConKey, int32X4PrimTyConKey,
int64X2PrimTyConKey :: Unique
floatX4PrimTyConKey = mkPreludeTyConUnique 170
doubleX2PrimTyConKey = mkPreludeTyConUnique 171
int32X4PrimTyConKey = mkPreludeTyConUnique 172
int64X2PrimTyConKey = mkPreludeTyConUnique 173
---------------- Template Haskell -------------------
-- USES TyConUniques 200-299
......
......@@ -78,7 +78,8 @@ module TysPrim(
-- * SIMD
floatX4PrimTyCon, floatX4PrimTy,
doubleX2PrimTyCon, doubleX2PrimTy,
int32X4PrimTyCon, int32X4PrimTy
int32X4PrimTyCon, int32X4PrimTy,
int64X2PrimTyCon, int64X2PrimTy
) where
#include "HsVersions.h"
......@@ -144,6 +145,7 @@ primTyCons
, floatX4PrimTyCon
, doubleX2PrimTyCon
, int32X4PrimTyCon
, int64X2PrimTyCon
]
mkPrimTc :: FastString -> Unique -> TyCon -> Name
......@@ -153,7 +155,7 @@ mkPrimTc fs unique tycon
(ATyCon tycon) -- Relevant TyCon
UserSyntax -- None are built-in syntax
charPrimTyConName, intPrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, floatX4PrimTyConName, doubleX2PrimTyConName, int32X4PrimTyConName :: Name
charPrimTyConName, intPrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, floatX4PrimTyConName, doubleX2PrimTyConName, int32X4PrimTyConName, int64X2PrimTyConName :: Name
charPrimTyConName = mkPrimTc (fsLit "Char#") charPrimTyConKey charPrimTyCon
intPrimTyConName = mkPrimTc (fsLit "Int#") intPrimTyConKey intPrimTyCon
int32PrimTyConName = mkPrimTc (fsLit "Int32#") int32PrimTyConKey int32PrimTyCon
......@@ -184,6 +186,7 @@ threadIdPrimTyConName = mkPrimTc (fsLit "ThreadId#") threadIdPrimTyConKe
floatX4PrimTyConName = mkPrimTc (fsLit "FloatX4#") floatX4PrimTyConKey floatX4PrimTyCon
doubleX2PrimTyConName = mkPrimTc (fsLit "DoubleX2#") doubleX2PrimTyConKey doubleX2PrimTyCon
int32X4PrimTyConName = mkPrimTc (fsLit "Int32X4#") int32X4PrimTyConKey int32X4PrimTyCon
int64X2PrimTyConName = mkPrimTc (fsLit "Int64X2#") int64X2PrimTyConKey int64X2PrimTyCon
\end{code}
%************************************************************************
......@@ -763,4 +766,9 @@ int32X4PrimTy :: Type
int32X4PrimTy = mkTyConTy int32X4PrimTyCon
int32X4PrimTyCon :: TyCon
int32X4PrimTyCon = pcPrimTyCon0 int32X4PrimTyConName (VecRep 4 Int32ElemRep)
int64X2PrimTy :: Type
int64X2PrimTy = mkTyConTy int64X2PrimTyCon
int64X2PrimTyCon :: TyCon
int64X2PrimTyCon = pcPrimTyCon0 int64X2PrimTyConName (VecRep 2 Int64ElemRep)
\end{code}
......@@ -2488,6 +2488,103 @@ primop WriteOffAddrOp_Int32AsInt32X4 "writeInt32OffAddrAsInt32X4#" GenPrimOp
Addr# -> Int# -> Int32X4# -> State# s -> State# s
with has_side_effects = True
can_fail = True
------------------------------------------------------------------------
section "Int64 SIMD Vectors"
{Operations on SIMD vectors of 2 64-bit signed integers.}
------------------------------------------------------------------------
primtype Int64X2#
primop Int64ToInt64X2Op "int64ToInt64X2#" GenPrimOp
INT64 -> Int64X2#
primop Int64X2InsertOp "insertInt64X2#" GenPrimOp
Int64X2# -> INT64 -> Int# -> Int64X2#
with can_fail = True
primop Int64X2PackOp "packInt64X2#" GenPrimOp
INT64 -> INT64 -> Int64X2#
primop Int64X2UnpackOp "unpackInt64X2#" GenPrimOp
Int64X2# -> (# INT64, INT64 #)
primop Int64X2AddOp "plusInt64X2#" Dyadic
Int64X2# -> Int64X2# -> Int64X2#
with commutable = True
primop Int64X2SubOp "minusInt64X2#" Dyadic
Int64X2# -> Int64X2# -> Int64X2#
primop Int64X2MulOp "timesInt64X2#" Dyadic
Int64X2# -> Int64X2# -> Int64X2#
with commutable = True
primop Int64X2QuotOp "quotInt64X2#" Dyadic
Int64X2# -> Int64X2# -> Int64X2#
with can_fail = True
primop Int64X2RemOp "remInt64X2#" Dyadic
Int64X2# -> Int64X2# -> Int64X2#
with can_fail = True
primop Int64X2NegOp "negateInt64X2#" Monadic
Int64X2# -> Int64X2#
primop IndexByteArrayOp_Int64X2 "indexInt64X2Array#" GenPrimOp
ByteArray# -> Int# -> Int64X2#
with can_fail = True
primop ReadByteArrayOp_Int64X2 "readInt64X2Array#" GenPrimOp
MutableByteArray# s -> Int# -> State# s -> (# State# s, Int64X2# #)
with has_side_effects = True
can_fail = True
primop WriteByteArrayOp_Int64X2 "writeInt64X2Array#" GenPrimOp
MutableByteArray# s -> Int# -> Int64X2# -> State# s -> State# s
with has_side_effects = True
can_fail = True
primop IndexOffAddrOp_Int64X2 "indexInt64X2OffAddr#" GenPrimOp
Addr# -> Int# -> Int64X2#
with can_fail = True
primop ReadOffAddrOp_Int64X2 "readInt64X2OffAddr#" GenPrimOp
Addr# -> Int# -> State# s -> (# State# s, Int64X2# #)
with has_side_effects = True
primop WriteOffAddrOp_Int64X2 "writeInt64X2OffAddr#" GenPrimOp
Addr# -> Int# -> Int64X2# -> State# s -> State# s
with has_side_effects = True
can_fail = True
primop IndexByteArrayOp_Int64AsInt64X2 "indexInt64ArrayAsInt64X2#" GenPrimOp
ByteArray# -> Int# -> Int64X2#
with can_fail = True
primop ReadByteArrayOp_Int64AsInt64X2 "readInt64ArrayAsInt64X2#" GenPrimOp
MutableByteArray# s -> Int# -> State# s -> (# State# s, Int64X2# #)
with has_side_effects = True
can_fail = True
primop WriteByteArrayOp_Int64AsInt64X2 "writeInt64ArrayAsInt64X2#" GenPrimOp
MutableByteArray# s -> Int# -> Int64X2# -> State# s -> State# s
with has_side_effects = True
can_fail = True
primop IndexOffAddrOp_Int64AsInt64X2 "indexInt64OffAddrAsInt64X2#" GenPrimOp
Addr# -> Int# -> Int64X2#
with can_fail = True
primop ReadOffAddrOp_Int64AsInt64X2 "readInt64OffAddrAsInt64X2#" GenPrimOp
Addr# -> Int# -> State# s -> (# State# s, Int64X2# #)
with has_side_effects = True
can_fail = True
primop WriteOffAddrOp_Int64AsInt64X2 "writeInt64OffAddrAsInt64X2#" GenPrimOp
Addr# -> Int# -> Int64X2# -> State# s -> State# s
with has_side_effects = True
can_fail = True
------------------------------------------------------------------------
--- ---
......
......@@ -554,6 +554,7 @@ gen_wrappers (Info _ entries)
llvmOnlyTyCon "FloatX4#" = True
llvmOnlyTyCon "DoubleX2#" = True
llvmOnlyTyCon "Int32X4#" = True
llvmOnlyTyCon "Int64X2#" = True
llvmOnlyTyCon _ = False
gen_primop_list :: Info -> String
......@@ -676,6 +677,7 @@ ppType (TyApp "Double#" []) = "doublePrimTy"
ppType (TyApp "FloatX4#" []) = "floatX4PrimTy"
ppType (TyApp "DoubleX2#" []) = "doubleX2PrimTy"
ppType (TyApp "Int32X4#" []) = "int32X4PrimTy"
ppType (TyApp "Int64X2#" []) = "int64X2PrimTy"
ppType (TyApp "ByteArray#" []) = "byteArrayPrimTy"
ppType (TyApp "RealWorld" []) = "realWorldTy"
ppType (TyApp "ThreadId#" []) = "threadIdPrimTy"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment