Hoopl: remove dependency on Hoopl package
[ghc.git] / compiler / cmm / BlockId.hs
1 {-# LANGUAGE TypeSynonymInstances #-}
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
3
4 {- BlockId module should probably go away completely, being superseded by Label -}
5 module BlockId
6 ( BlockId, mkBlockId -- ToDo: BlockId should be abstract, but it isn't yet
7 , newBlockId
8 , blockLbl, infoTblLbl
9 ) where
10
11 import CLabel
12 import IdInfo
13 import Name
14 import Unique
15 import UniqSupply
16
17 import Hoopl.Label (Label, uniqueToLbl)
18 import Hoopl.Unique (intToUnique)
19
20 ----------------------------------------------------------------
21 --- Block Ids, their environments, and their sets
22
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.
30 -}
31
32 type BlockId = Label
33
34 mkBlockId :: Unique -> BlockId
35 mkBlockId unique = uniqueToLbl $ intToUnique $ getKey unique
36
37 newBlockId :: MonadUnique m => m BlockId
38 newBlockId = mkBlockId <$> getUniqueM
39
40 blockLbl :: BlockId -> CLabel
41 blockLbl label = mkEntryLabel (mkFCallName (getUnique label) "block") NoCafRefs
42
43 infoTblLbl :: BlockId -> CLabel
44 infoTblLbl label = mkInfoTableLabel (mkFCallName (getUnique label) "block") NoCafRefs