{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}

-- | Register classes for architectures which have registers
-- for scalar floating-point values that are separate from all vector registers.
module GHC.Platform.Reg.Class.Separate
  ( RegClass ( RcInteger, RcFloat, RcVector )
  , pprRegClass, allRegClasses
  )

where

import GHC.Utils.Outputable ( SDoc, text )
import GHC.Platform.Reg.Class ( RegClass(..) )

pattern RcInteger, RcFloat, RcVector :: RegClass
pattern $mRcInteger :: forall {r}. RegClass -> ((# #) -> r) -> ((# #) -> r) -> r
$bRcInteger :: RegClass
RcInteger = RegClass 0
pattern $mRcFloat :: forall {r}. RegClass -> ((# #) -> r) -> ((# #) -> r) -> r
$bRcFloat :: RegClass
RcFloat   = RegClass 1
pattern $mRcVector :: forall {r}. RegClass -> ((# #) -> r) -> ((# #) -> r) -> r
$bRcVector :: RegClass
RcVector  = RegClass 2
{-# COMPLETE RcInteger, RcFloat, RcVector #-}

pprRegClass :: RegClass -> SDoc
pprRegClass :: RegClass -> SDoc
pprRegClass = \case
  RegClass
RcInteger -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"I"
  RegClass
RcFloat   -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"F"
  RegClass
RcVector  -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"V"

allRegClasses :: [RegClass]
allRegClasses :: [RegClass]
allRegClasses = [RegClass
RcInteger, RegClass
RcFloat, RegClass
RcVector]