- then ppCostCentreLbl cc
- else
- if ifaceStyle sty
- then ppCostCentreIface cc
- else text (costCentreStr cc)
-
-ppCostCentreLbl cc = ptext SLIT("CC_") <> identToC (_PK_ (costCentreStr cc))
-ppCostCentreIface cc = doubleQuotes (text (costCentreStr cc))
-ppCostCentreName cc = doubleQuotes (text (stringToC (costCentreName cc)))
-
-costCentreStr (NoCostCentre) = "NO_CC"
-costCentreStr (AllCafsCC m _) = "CAFs." ++ _UNPK_ m
-costCentreStr (AllDictsCC m _ d) = "DICTs." ++ _UNPK_ m
-costCentreStr (NormalCC kind mod_name grp_name is_dupd is_caf)
- = case is_caf of { IsCafCC -> "CAF:"; _ -> "" }
- ++ moduleString mod_name
- ++ case kind of { UserCC name -> _UNPK_ name;
- AutoCC id -> getOccString id ++ "/AUTO";
- DictCC id -> getOccString id ++ "/DICT"
- }
- -- ToDo: group name
- ++ case is_dupd of { ADupdCC -> "/DUPD"; _ -> "" }
-
--- This is the name to go in the cost centre declaration
-costCentreName (NoCostCentre) = "NO_CC"
-costCentreName (AllCafsCC _ _) = "CAFs_in_..."
-costCentreName (AllDictsCC _ _ _) = "DICTs_in_..."
-costCentreName (NormalCC kind mod_name grp_name is_dupd is_caf)
- = case is_caf of { IsCafCC -> "CAF:"; _ -> "" }
- ++ case kind of { UserCC name -> _UNPK_ name;
- AutoCC id -> getOccString id;
- DictCC id -> getOccString id
- }
-\end{code}
-
-Cost Centre Declarations
-
-\begin{code}
-#ifdef DEBUG
-pprCostCentreDecl is_local (NoCostCentre)
- = panic "pprCostCentreDecl: no cost centre!"
-#endif
-pprCostCentreDecl is_local cc
- = if is_local then
- hcat [
- ptext SLIT("CC_DECLARE"),char '(',
- cc_ident, comma,
- ppCostCentreName cc, comma,
- pp_str mod_name, comma,
- pp_str grp_name, comma,
- ptext is_subsumed, comma,
- if externally_visible
- then empty
- else ptext SLIT("static"),
- text ");"]
- else
- hcat [ ptext SLIT("CC_EXTERN"),char '(', cc_ident, text ");" ]
- where
- cc_ident = ppCostCentreLbl cc
-
- pp_str s = doubleQuotes (ptext s)
-
- (mod_name, grp_name, is_subsumed, externally_visible)
- = get_cc_info cc
-
-
-get_cc_info :: CostCentre ->
- (FAST_STRING, -- module name
- FAST_STRING, -- group name
- FAST_STRING, -- subsumed value
- Bool) -- externally visible
-
-get_cc_info cc
- = case cc of
- AllCafsCC m g -> (m, g, cc_IS_CAF, True)
-
- AllDictsCC m g _ -> (m, g, cc_IS_DICT, True)
-
- NormalCC (DictCC i) m g is_dupd is_caf
- -> (m, g, cc_IS_DICT, externallyVisibleId i)
-
- NormalCC x m g is_dupd is_caf
- -> (m, g, do_caf is_caf,
- case x of { UserCC _ -> True; AutoCC i -> externallyVisibleId i})
- where
- cc_IS_CAF = SLIT("CC_IS_CAF")
- cc_IS_DICT = SLIT("CC_IS_DICT")
- cc_IS_BORING = SLIT("CC_IS_BORING")
-
- do_caf IsCafCC = cc_IS_CAF
- do_caf IsNotCafCC = cc_IS_BORING
+ then ppCostCentreLbl cc
+ else text (costCentreUserName cc)
+
+-- Printing in an interface file or in Core generally
+pprCostCentreCore (AllCafsCC {cc_mod = m})
+ = text "__sccC" <+> braces (ppr m)
+pprCostCentreCore (NormalCC {cc_name = n, cc_mod = m,
+ cc_is_caf = caf, cc_is_dupd = dup})
+ = text "__scc" <+> braces (hsep [
+ ftext n,
+ ppr m,
+ pp_dup dup,
+ pp_caf caf
+ ])
+
+pp_dup DupdCC = char '!'
+pp_dup other = empty
+
+pp_caf CafCC = text "__C"
+pp_caf other = empty
+
+
+-- Printing as a C label
+ppCostCentreLbl (NoCostCentre) = text "NONE_cc"
+ppCostCentreLbl (AllCafsCC {cc_mod = m}) = ppr m <> text "_CAFs_cc"
+ppCostCentreLbl (NormalCC {cc_name = n, cc_mod = m, cc_is_caf = is_caf})
+ = ppr m <> ftext n <>
+ text (case is_caf of { CafCC -> "_CAF"; _ -> "" }) <> text "_cc"
+
+-- This is the name to go in the user-displayed string,
+-- recorded in the cost centre declaration
+costCentreUserName (NoCostCentre) = "NO_CC"
+costCentreUserName (AllCafsCC {}) = "CAF"
+costCentreUserName cc@(NormalCC {cc_name = name, cc_is_caf = is_caf})
+ = case is_caf of { CafCC -> "CAF:"; _ -> "" } ++ decode (unpackFS name)