module BlockId
( BlockId, mkBlockId
, newBlockId
, blockLbl, infoTblLbl
) where
import CLabel
import IdInfo
import Name
import Outputable
import Unique
import UniqSupply
import Compiler.Hoopl as Hoopl hiding (Unique)
import Compiler.Hoopl.Internals (uniqueToLbl, lblToUnique)
type BlockId = Hoopl.Label
instance Uniquable BlockId where
getUnique label = getUnique (lblToUnique label)
instance Outputable BlockId where
ppr label = ppr (getUnique label)
mkBlockId :: Unique -> BlockId
mkBlockId unique = uniqueToLbl $ intToUnique $ getKey unique
newBlockId :: MonadUnique m => m BlockId
newBlockId = mkBlockId <$> getUniqueM
blockLbl :: BlockId -> CLabel
blockLbl label = mkEntryLabel (mkFCallName (getUnique label) "block") NoCafRefs
infoTblLbl :: BlockId -> CLabel
infoTblLbl label = mkInfoTableLabel (mkFCallName (getUnique label) "block") NoCafRefs