Make dumpIfSet_dyn_or use dumpSDoc
[ghc-hetmet.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 CgMonad
16 import HscTypes
17
18 cgTickBox :: Module -> Int -> Code
19 cgTickBox mod n = do
20        let tick_box = (cmmIndex W64
21                        (CmmLit $ CmmLabel $ mkHpcTicksLabel $ mod)
22                        n
23                       )
24        stmtsC [ CmmStore tick_box
25                          (CmmMachOp (MO_Add W64)
26                                                [ CmmLoad tick_box b64
27                                                , CmmLit (CmmInt 1 W64)
28                                                ])
29               ] 
30
31 hpcTable :: Module -> HpcInfo -> Code
32 hpcTable this_mod (HpcInfo hpc_tickCount _) = do
33                         emitData Data $ [ CmmDataLabel (mkHpcTicksLabel this_mod)
34                                         ] ++
35                                         [ CmmStaticLit (CmmInt 0 W64)
36                                         | _ <- take hpc_tickCount [0::Int ..]
37                                         ]
38
39 hpcTable _ (NoHpcInfo {}) = error "TODO: impossible"