1 {- BlockId module should probably go away completely, being superseded by Label -}
3 ( BlockId, mkBlockId -- ToDo: BlockId should be abstract, but it isn't yet
5 , IsSet(..), setInsertList, setDeleteList, setUnions
6 , IsMap(..), mapInsertList, mapDeleteList, mapUnions
7 , emptyBlockSet, emptyBlockMap
8 , blockLbl, infoTblLbl, retPtLbl
17 import Compiler.Hoopl hiding (Unique)
18 import Compiler.Hoopl.GHC (uniqueToInt, uniqueToLbl, lblToUnique)
20 ----------------------------------------------------------------
21 --- Block Ids, their environments, and their sets
23 {- Note [Unique BlockId]
24 ~~~~~~~~~~~~~~~~~~~~~~~~
25 Although a 'BlockId' is a local label, for reasons of implementation,
26 'BlockId's must be unique within an entire compilation unit. The reason
27 is that each local label is mapped to an assembly-language label, and in
28 most assembly languages allow, a label is visible throughout the entire
29 compilation unit in which it appears.
34 instance Uniquable BlockId where
35 getUnique label = getUnique (uniqueToInt $ lblToUnique label)
37 mkBlockId :: Unique -> BlockId
38 mkBlockId unique = uniqueToLbl $ intToUnique $ getKey unique
40 instance Outputable BlockId where
41 ppr label = ppr (getUnique label)
43 retPtLbl :: BlockId -> CLabel
44 retPtLbl label = mkReturnPtLabel $ getUnique label
46 blockLbl :: BlockId -> CLabel
47 blockLbl label = mkEntryLabel (mkFCallName (getUnique label) "block") NoCafRefs
49 infoTblLbl :: BlockId -> CLabel
50 infoTblLbl label = mkInfoTableLabel (mkFCallName (getUnique label) "block") NoCafRefs
52 -- Block environments: Id blocks
53 type BlockEnv a = LabelMap a
55 instance Outputable a => Outputable (BlockEnv a) where
58 emptyBlockMap :: BlockEnv a
59 emptyBlockMap = mapEmpty
62 type BlockSet = LabelSet
64 instance Outputable BlockSet where
67 emptyBlockSet :: BlockSet
68 emptyBlockSet = setEmpty