summaryrefslogtreecommitdiff
path: root/compiler/GHC
diff options
context:
space:
mode:
authorDai <daig@users.noreply.github.com>2022-10-14 13:07:43 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-10-19 10:45:45 -0400
commit5b3a992f5d166007c3c5a22f120ed08e0a27f01a (patch)
tree4da760b794be76a6298acefa62e3be4c61b3794e /compiler/GHC
parent99dc3e3d76daab80a5c5209a3e0c44c9e4664e06 (diff)
downloadhaskell-5b3a992f5d166007c3c5a22f120ed08e0a27f01a.tar.gz
Add VecSlot for unboxed sums of SIMD vectors
This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187
Diffstat (limited to 'compiler/GHC')
-rw-r--r--compiler/GHC/Cmm/Utils.hs3
-rw-r--r--compiler/GHC/Stg/Unarise.hs2
-rw-r--r--compiler/GHC/Types/Literal.hs3
-rw-r--r--compiler/GHC/Types/RepType.hs6
4 files changed, 10 insertions, 4 deletions
diff --git a/compiler/GHC/Cmm/Utils.hs b/compiler/GHC/Cmm/Utils.hs
index 3671366d07..7524ba7c5e 100644
--- a/compiler/GHC/Cmm/Utils.hs
+++ b/compiler/GHC/Cmm/Utils.hs
@@ -113,7 +113,7 @@ primRepCmmType platform = \case
AddrRep -> bWord platform
FloatRep -> f32
DoubleRep -> f64
- (VecRep len rep) -> vec len (primElemRepCmmType rep)
+ VecRep len rep -> vec len (primElemRepCmmType rep)
slotCmmType :: Platform -> SlotTy -> CmmType
slotCmmType platform = \case
@@ -123,6 +123,7 @@ slotCmmType platform = \case
Word64Slot -> b64
FloatSlot -> f32
DoubleSlot -> f64
+ VecSlot l e -> vec l (primElemRepCmmType e)
primElemRepCmmType :: PrimElemRep -> CmmType
primElemRepCmmType Int8ElemRep = b8
diff --git a/compiler/GHC/Stg/Unarise.hs b/compiler/GHC/Stg/Unarise.hs
index 440b184d44..8dfdeb607c 100644
--- a/compiler/GHC/Stg/Unarise.hs
+++ b/compiler/GHC/Stg/Unarise.hs
@@ -694,6 +694,8 @@ ubxSumRubbishArg WordSlot = StgLitArg (LitNumber LitNumWord 0)
ubxSumRubbishArg Word64Slot = StgLitArg (LitNumber LitNumWord64 0)
ubxSumRubbishArg FloatSlot = StgLitArg (LitFloat 0)
ubxSumRubbishArg DoubleSlot = StgLitArg (LitDouble 0)
+ubxSumRubbishArg (VecSlot n e) = StgLitArg (LitRubbish vec_rep)
+ where vec_rep = primRepToRuntimeRep (VecRep n e)
--------------------------------------------------------------------------------
diff --git a/compiler/GHC/Types/Literal.hs b/compiler/GHC/Types/Literal.hs
index 199d744034..9997859afc 100644
--- a/compiler/GHC/Types/Literal.hs
+++ b/compiler/GHC/Types/Literal.hs
@@ -67,6 +67,7 @@ module GHC.Types.Literal
import GHC.Prelude
import GHC.Builtin.Types.Prim
+import GHC.Core.TyCo.Rep ( RuntimeRepType )
import GHC.Core.Type
import GHC.Utils.Outputable
import GHC.Data.FastString
@@ -131,7 +132,7 @@ data Literal
-- that can be represented as a Literal. Create
-- with 'nullAddrLit'
- | LitRubbish Type -- ^ A nonsense value of the given
+ | LitRubbish RuntimeRepType -- ^ A nonsense value of the given
-- representation. See Note [Rubbish literals].
--
-- The Type argument, rr, is of kind RuntimeRep.
diff --git a/compiler/GHC/Types/RepType.hs b/compiler/GHC/Types/RepType.hs
index 993694e1c3..30eb12c7a7 100644
--- a/compiler/GHC/Types/RepType.hs
+++ b/compiler/GHC/Types/RepType.hs
@@ -286,7 +286,7 @@ layoutUbxSum sum_slots0 arg_slots0 =
--
-- TODO(michalt): We should probably introduce `SlotTy`s for 8-/16-/32-bit
-- values, so that we can pack things more tightly.
-data SlotTy = PtrLiftedSlot | PtrUnliftedSlot | WordSlot | Word64Slot | FloatSlot | DoubleSlot
+data SlotTy = PtrLiftedSlot | PtrUnliftedSlot | WordSlot | Word64Slot | FloatSlot | DoubleSlot | VecSlot Int PrimElemRep
deriving (Eq, Ord)
-- Constructor order is important! If slot A could fit into slot B
-- then slot A must occur first. E.g. FloatSlot before DoubleSlot
@@ -301,6 +301,7 @@ instance Outputable SlotTy where
ppr WordSlot = text "WordSlot"
ppr DoubleSlot = text "DoubleSlot"
ppr FloatSlot = text "FloatSlot"
+ ppr (VecSlot n e) = text "VecSlot" <+> ppr n <+> ppr e
typeSlotTy :: UnaryType -> Maybe SlotTy
typeSlotTy ty
@@ -326,7 +327,7 @@ primRepSlot Word64Rep = Word64Slot
primRepSlot AddrRep = WordSlot
primRepSlot FloatRep = FloatSlot
primRepSlot DoubleRep = DoubleSlot
-primRepSlot VecRep{} = pprPanic "primRepSlot" (text "No slot for VecRep")
+primRepSlot (VecRep n e) = VecSlot n e
slotPrimRep :: SlotTy -> PrimRep
slotPrimRep PtrLiftedSlot = LiftedRep
@@ -335,6 +336,7 @@ slotPrimRep Word64Slot = Word64Rep
slotPrimRep WordSlot = WordRep
slotPrimRep DoubleSlot = DoubleRep
slotPrimRep FloatSlot = FloatRep
+slotPrimRep (VecSlot n e) = VecRep n e
-- | Returns the bigger type if one fits into the other. (commutative)
--