Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : simd
http://hackage.haskell.org/trac/ghc/changeset/3874183904c924e4c1b63e57f030fca9725d9dde >--------------------------------------------------------------- commit 3874183904c924e4c1b63e57f030fca9725d9dde Author: Geoffrey Mainland <[email protected]> Date: Thu Nov 3 07:59:58 2011 +0000 Add more FloatX4# primops. >--------------------------------------------------------------- compiler/cmm/CmmMachOp.hs | 21 ++++++++++++++++++--- compiler/codeGen/CgPrimOp.hs | 6 +++++- compiler/llvmGen/LlvmCodeGen/CodeGen.hs | 12 +++++++++++- compiler/nativeGen/X86/CodeGen.hs | 4 ++++ compiler/prelude/primops.txt.pp | 14 ++++++++++++++ 5 files changed, 52 insertions(+), 5 deletions(-) diff --git a/compiler/cmm/CmmMachOp.hs b/compiler/cmm/CmmMachOp.hs index 52f335e..48af8a6 100644 --- a/compiler/cmm/CmmMachOp.hs +++ b/compiler/cmm/CmmMachOp.hs @@ -104,11 +104,15 @@ data MachOp | MO_FF_Conv Width Width -- Float -> Float -- Vector element insertion and extraction operations - | MO_V_Insert Length Width + | MO_V_Insert Length Width | MO_V_Extract Length Width -- Float vector operations - | MO_VF_Add Length Width + | MO_VF_Add Length Width + | MO_VF_Sub Length Width + | MO_VF_Neg Length Width -- unary - + | MO_VF_Mul Length Width + | MO_VF_Quot Length Width deriving (Eq, Show) pprMachOp :: MachOp -> SDoc @@ -349,6 +353,10 @@ machOpResultType mop tys = MO_V_Extract {} -> vecType ty1 MO_VF_Add {} -> ty1 + MO_VF_Sub {} -> ty1 + MO_VF_Mul {} -> ty1 + MO_VF_Quot {} -> ty1 + MO_VF_Neg {} -> ty1 where (ty1:_) = tys @@ -416,7 +424,14 @@ machOpArgReps op = MO_FS_Conv from _ -> [from] MO_FF_Conv from _ -> [from] - MO_VF_Add _ r -> [r,r] + MO_V_Insert l r -> [typeWidth (vec l (cmmFloat r)),r,wordWidth] + MO_V_Extract l r -> [typeWidth (vec l (cmmFloat r)),wordWidth] + + MO_VF_Add _ r -> [r,r] + MO_VF_Sub _ r -> [r,r] + MO_VF_Mul _ r -> [r,r] + MO_VF_Quot _ r -> [r,r] + MO_VF_Neg _ r -> [r] ----------------------------------------------------------------------------- -- CallishMachOp diff --git a/compiler/codeGen/CgPrimOp.hs b/compiler/codeGen/CgPrimOp.hs index 51c3f5b..2875fe6 100644 --- a/compiler/codeGen/CgPrimOp.hs +++ b/compiler/codeGen/CgPrimOp.hs @@ -563,7 +563,11 @@ translateOp SameMutableByteArrayOp = Just mo_wordEq translateOp SameTVarOp = Just mo_wordEq translateOp EqStablePtrOp = Just mo_wordEq -translateOp FloatX4AddOp = Just (MO_VF_Add 4 W32) +translateOp FloatX4AddOp = Just (MO_VF_Add 4 W32) +translateOp FloatX4SubOp = Just (MO_VF_Sub 4 W32) +translateOp FloatX4MulOp = Just (MO_VF_Mul 4 W32) +translateOp FloatX4DivOp = Just (MO_VF_Quot 4 W32) +translateOp FloatX4NegOp = Just (MO_VF_Neg 4 W32) translateOp _ = Nothing diff --git a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs index 50c326e..fac3029 100644 --- a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs +++ b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs @@ -754,6 +754,13 @@ genMachOp env _ op [x] = case op of MO_FF_Conv from to -> sameConv from (widthToLlvmFloat to) LM_Fptrunc LM_Fpext + MO_VF_Neg len w -> + let ty = widthToLlvmFloat w + vecty = LMVector len ty + all0 = LMFloatLit (-0) ty + all0s = LMLitVar $ LMVectorLit (replicate len all0) vecty + in negate vecty all0s LM_MO_FSub + a -> panic $ "genMachOp: unmatched unary CmmMachOp! (" ++ show a ++ ")" where @@ -879,7 +886,10 @@ genMachOp_slow env opt op [x, y] = case op of MO_U_Shr _ -> genBinMach LM_MO_LShr MO_S_Shr _ -> genBinMach LM_MO_AShr - MO_VF_Add _ _ -> genBinMach LM_MO_FAdd + MO_VF_Add _ _ -> genBinMach LM_MO_FAdd + MO_VF_Sub _ _ -> genBinMach LM_MO_FSub + MO_VF_Mul _ _ -> genBinMach LM_MO_FMul + MO_VF_Quot _ _ -> genBinMach LM_MO_FDiv a -> panic $ "genMachOp: unmatched binary CmmMachOp! (" ++ show a ++ ")" diff --git a/compiler/nativeGen/X86/CodeGen.hs b/compiler/nativeGen/X86/CodeGen.hs index 8c8f75c..86248d1 100644 --- a/compiler/nativeGen/X86/CodeGen.hs +++ b/compiler/nativeGen/X86/CodeGen.hs @@ -176,6 +176,10 @@ stmtToInstrs stmt = do isVecExpr (CmmMachOp (MO_V_Insert {}) _) = True isVecExpr (CmmMachOp (MO_V_Extract {}) _) = True isVecExpr (CmmMachOp (MO_VF_Add {}) _) = True + isVecExpr (CmmMachOp (MO_VF_Sub {}) _) = True + isVecExpr (CmmMachOp (MO_VF_Mul {}) _) = True + isVecExpr (CmmMachOp (MO_VF_Quot {}) _) = True + isVecExpr (CmmMachOp (MO_VF_Neg {}) _) = True isVecExpr _ = False diff --git a/compiler/prelude/primops.txt.pp b/compiler/prelude/primops.txt.pp index fe7a283..9e95b29 100644 --- a/compiler/prelude/primops.txt.pp +++ b/compiler/prelude/primops.txt.pp @@ -1953,6 +1953,20 @@ primop FloatX4AddOp "plusFloatX4#" Dyadic FloatX4# -> FloatX4# -> FloatX4# with commutable = True +primop FloatX4SubOp "minusFloatX4#" Dyadic + FloatX4# -> FloatX4# -> FloatX4# + +primop FloatX4MulOp "timesFloatX4#" Dyadic + FloatX4# -> FloatX4# -> FloatX4# + with commutable = True + +primop FloatX4DivOp "divideFloatX4#" Dyadic + FloatX4# -> FloatX4# -> FloatX4# + with can_fail = True + +primop FloatX4NegOp "negateFloatX4#" Monadic + FloatX4# -> FloatX4# + primop IndexByteArrayOp_FloatX4 "indexFloatX4Array#" GenPrimOp ByteArray# -> Int# -> FloatX4# _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
