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

where

import GhcPrelude

import  Outputable
import  Unique


-- | The class of a register.
--      Used in the register allocator.
--      We treat all registers in a class as being interchangable.
--
data RegClass
        = RcInteger
        | RcFloat
        | RcDouble
        | RcDoubleSSE -- x86 only: the SSE regs are a separate class
        deriving RegClass -> RegClass -> Bool
(RegClass -> RegClass -> Bool)
-> (RegClass -> RegClass -> Bool) -> Eq RegClass
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 RcInteger = Int -> Unique
mkRegClassUnique 0
    getUnique RcFloat   = Int -> Unique
mkRegClassUnique 1
    getUnique RcDouble  = Int -> Unique
mkRegClassUnique 2
    getUnique RcDoubleSSE = Int -> Unique
mkRegClassUnique 3

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