1 -----------------------------------------------------------------------------
3 -- Code generation for coverage
5 -- (c) Galois Connections, Inc. 2006
7 -----------------------------------------------------------------------------
9 module StgCmmHpc ( initHpc, mkTickBox ) where
25 mkTickBox :: Module -> Int -> CmmAGraph
27 = mkStore tick_box (CmmMachOp (MO_Add W64)
28 [ CmmLoad tick_box b64
29 , CmmLit (CmmInt 1 W64)
32 tick_box = cmmIndex W64
33 (CmmLit $ CmmLabel $ mkHpcTicksLabel $ mod)
36 initHpc :: Module -> HpcInfo -> FCode CmmAGraph
37 -- Emit top-level tables for HPC and return code to initialise
38 initHpc _ (NoHpcInfo {})
40 initHpc this_mod (HpcInfo tickCount hashNo)
41 = getCode $ whenC opt_Hpc $
42 do { emitData ReadOnlyData
43 [ CmmDataLabel mkHpcModuleNameLabel
44 , CmmString $ map (fromIntegral . ord)
48 ; emitData Data $ [ CmmDataLabel (mkHpcTicksLabel this_mod)
50 [ CmmStaticLit (CmmInt 0 W64)
51 | _ <- take tickCount [0::Int ..]
54 ; id <- newTemp bWord -- TODO FIXME NOW
57 (CmmLit $ CmmLabel $ mkForeignLabel mod_alloc Nothing False)
58 [ (mkLblExpr mkHpcModuleNameLabel,AddrHint)
59 , (CmmLit $ mkIntCLit tickCount,NoHint)
60 , (CmmLit $ mkIntCLit hashNo,NoHint)
61 , (CmmLit $ CmmLabel $ mkHpcTicksLabel $ this_mod,AddrHint)
65 mod_alloc = mkFastString "hs_hpc_module"
66 module_name_str = moduleNameString (Module.moduleName this_mod)
67 full_name_str = if modulePackageId this_mod == mainPackageId
69 else packageIdString (modulePackageId this_mod) ++ "/" ++