Add a class HasDynFlags(getDynFlags)
[ghc.git] / compiler / codeGen / CgHpc.hs
1 -----------------------------------------------------------------------------
2 --
3 -- Code generation for coverage
4 --
5 -- (c) Galois Connections, Inc. 2006
6 --
7 -----------------------------------------------------------------------------
8
9 module CgHpc (cgTickBox, hpcTable) where
10
11 import OldCmm
12 import CLabel
13 import Module
14 import OldCmmUtils
15 import CgUtils
16 import CgMonad
17 import HscTypes
18
19 cgTickBox :: Module -> Int -> Code
20 cgTickBox mod n = do
21 let tick_box = (cmmIndex W64
22 (CmmLit $ CmmLabel $ mkHpcTicksLabel $ mod)
23 n
24 )
25 stmtsC [ CmmStore tick_box
26 (CmmMachOp (MO_Add W64)
27 [ CmmLoad tick_box b64
28 , CmmLit (CmmInt 1 W64)
29 ])
30 ]
31
32 hpcTable :: Module -> HpcInfo -> Code
33 hpcTable this_mod (HpcInfo hpc_tickCount _) = do
34 emitDataLits (mkHpcTicksLabel this_mod) $
35 [ CmmInt 0 W64
36 | _ <- take hpc_tickCount [0::Int ..]
37 ]
38
39 hpcTable _ (NoHpcInfo {}) = error "TODO: impossible"