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

-- | Register classes for architectures which don't have separate registers
-- for scalar floating-point values separate from vector registers.
module GHC.Platform.Reg.Class.Unified
  ( RegClass ( RcInteger, RcFloatOrVector )
  , pprRegClass, allRegClasses
  )

where

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

pattern RcInteger, RcFloatOrVector :: RegClass
pattern $mRcInteger :: forall {r}. RegClass -> ((# #) -> r) -> ((# #) -> r) -> r
$bRcInteger :: RegClass
RcInteger       = RegClass 0
pattern $mRcFloatOrVector :: forall {r}. RegClass -> ((# #) -> r) -> ((# #) -> r) -> r
$bRcFloatOrVector :: RegClass
RcFloatOrVector = RegClass 1
{-# COMPLETE RcInteger, RcFloatOrVector #-}

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

allRegClasses :: [RegClass]
allRegClasses :: [RegClass]
allRegClasses = [RegClass
RcInteger, RegClass
RcFloatOrVector]