2 -- The above warning supression flag is a temporary kludge.
3 -- While working on this module you are encouraged to remove it and fix
4 -- any warnings in the module. See
5 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
8 -----------------------------------------------------------------------------
10 -- Code generation for coverage
12 -- (c) Galois Connections, Inc. 2006
14 -----------------------------------------------------------------------------
16 module CgHpc (cgTickBox, initHpc, hpcTable) where
35 cgTickBox :: Module -> Int -> Code
37 let tick_box = (cmmIndex W64
38 (CmmLit $ CmmLabel $ mkHpcTicksLabel $ mod)
41 stmtsC [ CmmStore tick_box
42 (CmmMachOp (MO_Add W64)
43 [ CmmLoad tick_box b64
44 , CmmLit (CmmInt 1 W64)
48 hpcTable :: Module -> HpcInfo -> Code
49 hpcTable this_mod (HpcInfo hpc_tickCount _) = do
51 [ CmmDataLabel mkHpcModuleNameLabel
52 , CmmString $ map (fromIntegral . ord)
56 emitData Data $ [ CmmDataLabel (mkHpcTicksLabel this_mod)
58 [ CmmStaticLit (CmmInt 0 W64)
59 | _ <- take hpc_tickCount [0::Int ..]
62 module_name_str = moduleNameString (Module.moduleName this_mod)
63 full_name_str = if modulePackageId this_mod == mainPackageId
65 else packageIdString (modulePackageId this_mod) ++ "/" ++
68 hpcTable this_mod (NoHpcInfo {}) = error "TODO: impossible"
70 initHpc :: Module -> HpcInfo -> Code
71 initHpc this_mod (HpcInfo tickCount hashNo)
72 = do { id <- newTemp bWord
77 (CmmLit $ CmmLabel $ mkForeignLabel mod_alloc Nothing False)
80 [ CmmHinted (mkLblExpr mkHpcModuleNameLabel) AddrHint
81 , CmmHinted (word32 tickCount) NoHint
82 , CmmHinted (word32 hashNo) NoHint
83 , CmmHinted (CmmLit $ CmmLabel $ mkHpcTicksLabel $ this_mod) AddrHint
86 NoC_SRT -- No SRT b/c we PlayRisky
90 word32 i = CmmLit (CmmInt (fromIntegral (fromIntegral i :: Word32)) W32)
91 mod_alloc = mkFastString "hs_hpc_module"