summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmMachOp.hs
diff options
context:
space:
mode:
authorAbhiroop Sarkar <asiamgenius@gmail.com>2018-09-27 15:28:46 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-07-03 09:33:39 -0400
commitacd795583625401c5554f8e04ec7efca18814011 (patch)
tree545e529eed21e78592ff326d4ebf9804095ad2cb /compiler/cmm/CmmMachOp.hs
parentdf3e5b744db29c085f5bc05f8b609197bcbf9b0c (diff)
downloadhaskell-acd795583625401c5554f8e04ec7efca18814011.tar.gz
Add support for SIMD operations in the NCG
This adds support for constructing vector types from Float#, Double# etc and performing arithmetic operations on them Cleaned-Up-By: Ben Gamari <ben@well-typed.com>
Diffstat (limited to 'compiler/cmm/CmmMachOp.hs')
-rw-r--r--compiler/cmm/CmmMachOp.hs25
1 files changed, 16 insertions, 9 deletions
diff --git a/compiler/cmm/CmmMachOp.hs b/compiler/cmm/CmmMachOp.hs
index 9740d21bef..38d9edb480 100644
--- a/compiler/cmm/CmmMachOp.hs
+++ b/compiler/cmm/CmmMachOp.hs
@@ -136,8 +136,9 @@ data MachOp
| MO_VU_Rem Length Width
-- Floting point vector element insertion and extraction operations
- | MO_VF_Insert Length Width -- Insert scalar into vector
- | MO_VF_Extract Length Width -- Extract scalar from vector
+ | MO_VF_Broadcast Length Width -- Broadcast a scalar into a vector
+ | MO_VF_Insert Length Width -- Insert scalar into vector
+ | MO_VF_Extract Length Width -- Extract scalar from vector
-- Floating point vector operations
| MO_VF_Add Length Width
@@ -430,6 +431,7 @@ machOpResultType dflags mop tys =
MO_VU_Quot l w -> cmmVec l (cmmBits w)
MO_VU_Rem l w -> cmmVec l (cmmBits w)
+ MO_VF_Broadcast l w -> cmmVec l (cmmFloat w)
MO_VF_Insert l w -> cmmVec l (cmmFloat w)
MO_VF_Extract _ w -> cmmFloat w
@@ -522,16 +524,21 @@ machOpArgReps dflags op =
MO_VU_Quot _ r -> [r,r]
MO_VU_Rem _ r -> [r,r]
- MO_VF_Insert l r -> [typeWidth (vec l (cmmFloat r)),r,wordWidth dflags]
- MO_VF_Extract l r -> [typeWidth (vec l (cmmFloat r)),wordWidth dflags]
+ -- offset is always W32 as mentioned in StgCmmPrim.hs
+ MO_VF_Broadcast l r -> [vecwidth l r, r]
+ MO_VF_Insert l r -> [vecwidth l r, r, W32]
+ MO_VF_Extract l r -> [vecwidth l r, W32]
- 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]
+ -- NOTE: The below is owing to the fact that floats use the SSE registers
+ MO_VF_Add l w -> [vecwidth l w, vecwidth l w]
+ MO_VF_Sub l w -> [vecwidth l w, vecwidth l w]
+ MO_VF_Mul l w -> [vecwidth l w, vecwidth l w]
+ MO_VF_Quot l w -> [vecwidth l w, vecwidth l w]
+ MO_VF_Neg l w -> [vecwidth l w]
MO_AlignmentCheck _ r -> [r]
+ where
+ vecwidth l w = widthFromBytes (l*widthInBytes w)
-----------------------------------------------------------------------------
-- CallishMachOp