module BlockId
( BlockId, mkBlockId
, BlockSet, BlockEnv
, IsSet(..), setInsertList, setDeleteList, setUnions
, IsMap(..), mapInsertList, mapDeleteList, mapUnions
, emptyBlockSet, emptyBlockMap
, blockLbl, infoTblLbl, retPtLbl
) where
import CLabel
import IdInfo
import Name
import Outputable
import Unique
import Compiler.Hoopl hiding (Unique)
import Compiler.Hoopl.GHC (uniqueToInt, uniqueToLbl, lblToUnique)
type BlockId = Label
instance Uniquable BlockId where
getUnique label = getUnique (uniqueToInt $ lblToUnique label)
mkBlockId :: Unique -> BlockId
mkBlockId unique = uniqueToLbl $ intToUnique $ getKey unique
instance Outputable BlockId where
ppr label = ppr (getUnique label)
retPtLbl :: BlockId -> CLabel
retPtLbl label = mkReturnPtLabel $ getUnique label
blockLbl :: BlockId -> CLabel
blockLbl label = mkEntryLabel (mkFCallName (getUnique label) "block") NoCafRefs
infoTblLbl :: BlockId -> CLabel
infoTblLbl label = mkInfoTableLabel (mkFCallName (getUnique label) "block") NoCafRefs
type BlockEnv a = LabelMap a
instance Outputable a => Outputable (BlockEnv a) where
ppr = ppr . mapToList
emptyBlockMap :: BlockEnv a
emptyBlockMap = mapEmpty
type BlockSet = LabelSet
instance Outputable BlockSet where
ppr = ppr . setElems
emptyBlockSet :: BlockSet
emptyBlockSet = setEmpty