-- | An architecture independent description of a register's class.
module GHC.Platform.Reg.Class
        ( RegClass (..) )

where

import GHC.Prelude

import GHC.Utils.Outputable as Outputable
import GHC.Types.Unique
import GHC.Builtin.Uniques


-- | The class of a register.
--      Used in the register allocator.
--      We treat all registers in a class as being interchangeable.
--
data RegClass
        = RcInteger
        | RcFloat
        | RcDouble
        deriving RegClass -> RegClass -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegClass -> RegClass -> Bool
$c/= :: RegClass -> RegClass -> Bool
== :: RegClass -> RegClass -> Bool
$c== :: RegClass -> RegClass -> Bool
Eq


instance Uniquable RegClass where
    getUnique :: RegClass -> Unique
getUnique RegClass
RcInteger = Int -> Unique
mkRegClassUnique Int
0
    getUnique RegClass
RcFloat   = Int -> Unique
mkRegClassUnique Int
1
    getUnique RegClass
RcDouble  = Int -> Unique
mkRegClassUnique Int
2

instance Outputable RegClass where
    ppr :: RegClass -> SDoc
ppr RegClass
RcInteger       = forall doc. IsLine doc => String -> doc
Outputable.text String
"I"
    ppr RegClass
RcFloat         = forall doc. IsLine doc => String -> doc
Outputable.text String
"F"
    ppr RegClass
RcDouble        = forall doc. IsLine doc => String -> doc
Outputable.text String
"D"