%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: CLabel.lhs,v 1.28 1999/10/13 16:39:10 simonmar Exp $
+% $Id: CLabel.lhs,v 1.35 2000/05/18 13:55:36 sewardj Exp $
%
\section[CLabel]{@CLabel@: Information to make C Labels}
mkStaticConEntryLabel,
mkRednCountsLabel,
mkConInfoTableLabel,
- mkStaticClosureLabel,
mkStaticInfoTableLabel,
mkApEntryLabel,
mkApInfoTableLabel,
mkAsmTempLabel,
+ mkModuleInitLabel,
+
mkErrorStdEntryLabel,
+
+ mkStgUpdatePAPLabel,
mkUpdInfoLabel,
+ mkSeqInfoLabel,
+ mkIndInfoLabel,
+ mkIndStaticInfoLabel,
+ mkRtsGCEntryLabel,
+ mkMainRegTableLabel,
+ mkCharlikeClosureLabel,
+ mkIntlikeClosureLabel,
+ mkTopClosureLabel,
+ mkErrorIO_innardsLabel,
+ mkMAP_FROZEN_infoLabel,
+
mkTopTickyCtrLabel,
+ mkBlackHoleInfoTableLabel,
mkCAFBlackHoleInfoTableLabel,
mkSECAFBlackHoleInfoTableLabel,
mkRtsPrimOpLabel,
+ moduleRegdLabel,
+
mkSelectorInfoLabel,
mkSelectorEntryLabel,
import CmdLineOpts ( opt_Static, opt_DoTickyProfiling )
import CStrings ( pp_cSEP )
import DataCon ( ConTag, DataCon )
-import Module ( isDynamicModule )
-import Name ( Name, getName, isExternallyVisibleName, nameModule, isLocallyDefinedName )
+import Module ( ModuleName )
+import Name ( Name, getName, isDllName, isExternallyVisibleName )
import TyCon ( TyCon )
import Unique ( pprUnique, Unique )
import PrimOp ( PrimOp, pprPrimOp )
| AsmTempLabel Unique
+ | ModuleInitLabel ModuleName
+
| RtsLabel RtsLabelInfo
| CC_Label CostCentre
data DataConLabelInfo
= ConEntry -- the only kind of entry pt for constructors
| ConInfoTbl -- corresponding info table
-
- | StaticClosure -- Static constructor closure
- -- e.g., nullary constructor
| StaticConEntry -- static constructor entry point
| StaticInfoTbl -- corresponding info table
deriving (Eq, Ord)
| RtsBlackHoleInfoTbl FAST_STRING -- black hole with info table name
- | RtsUpdInfo
+ | RtsUpdInfo -- upd_frame_info
+ | RtsSeqInfo -- seq_frame_info
+ | RtsGCEntryLabel String -- a heap check fail handler, eg stg_chk_2
+ | RtsMainRegTable -- MainRegTable (??? Capabilities wurble ???)
+ | Rts_Closure String -- misc rts closures, eg CHARLIKE_closure
+ | Rts_Info String -- misc rts itbls, eg MUT_ARR_PTRS_FROZEN_info
+ | Rts_Code String -- misc rts code, eg ErrorIO_innards
| RtsSelectorInfoTbl Bool{-updatable-} Int{-offset-} -- Selector thunks
| RtsSelectorEntry Bool{-updatable-} Int{-offset-}
| RtsTopTickyCtr
+ | RtsModuleRegd
+
deriving (Eq, Ord)
-- Label Type: for generating C declarations.
mkRednCountsLabel id = IdLabel id RednCounts
-mkStaticClosureLabel con = DataConLabel con StaticClosure
mkStaticInfoTableLabel con = DataConLabel con StaticInfoTbl
mkConInfoTableLabel con = DataConLabel con ConInfoTbl
mkConEntryLabel con = DataConLabel con ConEntry
mkAsmTempLabel = AsmTempLabel
+mkModuleInitLabel = ModuleInitLabel
+
-- Some fixed runtime system labels
mkErrorStdEntryLabel = RtsLabel RtsShouldNeverHappenCode
+
+mkStgUpdatePAPLabel = RtsLabel (Rts_Code "stg_update_PAP")
mkUpdInfoLabel = RtsLabel RtsUpdInfo
+mkSeqInfoLabel = RtsLabel RtsSeqInfo
+mkIndInfoLabel = RtsLabel (Rts_Info "IND_info")
+mkIndStaticInfoLabel = RtsLabel (Rts_Info "IND_STATIC_info")
+mkRtsGCEntryLabel str = RtsLabel (RtsGCEntryLabel str)
+mkMainRegTableLabel = RtsLabel RtsMainRegTable
+mkCharlikeClosureLabel = RtsLabel (Rts_Closure "CHARLIKE_closure")
+mkIntlikeClosureLabel = RtsLabel (Rts_Closure "INTLIKE_closure")
+mkTopClosureLabel = RtsLabel (Rts_Closure "TopClosure")
+mkErrorIO_innardsLabel = RtsLabel (Rts_Code "ErrorIO_innards")
+mkMAP_FROZEN_infoLabel = RtsLabel (Rts_Info "MUT_ARR_PTRS_FROZEN_info")
+
mkTopTickyCtrLabel = RtsLabel RtsTopTickyCtr
+mkBlackHoleInfoTableLabel = RtsLabel (RtsBlackHoleInfoTbl SLIT("BLACKHOLE_info"))
mkCAFBlackHoleInfoTableLabel = RtsLabel (RtsBlackHoleInfoTbl SLIT("CAF_BLACKHOLE_info"))
mkSECAFBlackHoleInfoTableLabel = if opt_DoTickyProfiling then
RtsLabel (RtsBlackHoleInfoTbl SLIT("SE_CAF_BLACKHOLE_info"))
panic "mkSECAFBlackHoleInfoTableLabel requires -ticky"
mkRtsPrimOpLabel primop = RtsLabel (RtsPrimOp primop)
+moduleRegdLabel = RtsLabel RtsModuleRegd
+
mkSelectorInfoLabel upd off = RtsLabel (RtsSelectorInfoTbl upd off)
mkSelectorEntryLabel upd off = RtsLabel (RtsSelectorEntry upd off)
needsCDecl (TyConLabel _) = True
needsCDecl (AsmTempLabel _) = False
+needsCDecl (ModuleInitLabel _) = False
needsCDecl (RtsLabel _) = False
needsCDecl (CC_Label _) = False
needsCDecl (CCS_Label _) = False
externallyVisibleCLabel (TyConLabel tc) = True
externallyVisibleCLabel (CaseLabel _ _) = False
externallyVisibleCLabel (AsmTempLabel _) = False
+externallyVisibleCLabel (ModuleInitLabel _)= True
+externallyVisibleCLabel (RtsLabel RtsModuleRegd) = False --hack
externallyVisibleCLabel (RtsLabel _) = True
externallyVisibleCLabel (IdLabel id _) = isExternallyVisibleName id
externallyVisibleCLabel (CC_Label _) = False -- not strictly true
case info of
ConInfoTbl -> InfoTblType
StaticInfoTbl -> InfoTblType
- StaticClosure -> ClosureType
_ -> CodeType
labelType _ = DataType
labelDynamic :: CLabel -> Bool
labelDynamic lbl =
case lbl of
- RtsLabel _ -> not opt_Static -- i.e., is the RTS in a DLL or not?
- IdLabel n k | not (isLocallyDefinedName n) -> isDynamicModule (nameModule n)
- DataConLabel n k | not (isLocallyDefinedName n) -> isDynamicModule (nameModule n)
- TyConLabel tc | not (isLocallyDefinedName (getName tc)) -> isDynamicModule (nameModule (getName tc))
- _ -> False
-
+ RtsLabel _ -> not opt_Static -- i.e., is the RTS in a DLL or not?
+ IdLabel n k -> isDllName n
+ DataConLabel n k -> isDllName n
+ TyConLabel tc -> isDllName (getName tc)
+ _ -> False
\end{code}
dflt Default case alternative
btm Large bitmap vector
closure Static closure
- static_closure Static closure (???)
con_entry Dynamic Constructor entry code
con_info Dynamic Constructor info table
static_entry Static Constructor entry code
static_info Static Constructor info table
sel_info Selector info table
sel_entry Selector entry code
+ cc Cost centre
+ ccs Cost centre stack
\begin{code}
-- specialised for PprAsm: saves lots of arg passing in NCG
pprCLbl (RtsLabel RtsShouldNeverHappenCode) = ptext SLIT("stg_error_entry")
-pprCLbl (RtsLabel RtsUpdInfo) = ptext SLIT("Upd_frame_info")
+pprCLbl (RtsLabel RtsUpdInfo) = ptext SLIT("upd_frame_info")
+pprCLbl (RtsLabel RtsSeqInfo) = ptext SLIT("seq_frame_info")
+pprCLbl (RtsLabel RtsMainRegTable) = ptext SLIT("MainRegTable")
+pprCLbl (RtsLabel (RtsGCEntryLabel str)) = text str
+pprCLbl (RtsLabel (Rts_Closure str)) = text str
+pprCLbl (RtsLabel (Rts_Info str)) = text str
+pprCLbl (RtsLabel (Rts_Code str)) = text str
pprCLbl (RtsLabel RtsTopTickyCtr) = ptext SLIT("top_ct")
pprCLbl (RtsLabel (RtsPrimOp primop))
= pprPrimOp primop <> ptext SLIT("_fast")
+pprCLbl (RtsLabel RtsModuleRegd)
+ = ptext SLIT("module_registered")
+
pprCLbl (TyConLabel tc)
= hcat [ppr tc, pp_cSEP, ptext SLIT("closure_tbl")]
pprCLbl (CC_Label cc) = ppr cc
pprCLbl (CCS_Label ccs) = ppr ccs
+pprCLbl (ModuleInitLabel mod) = ptext SLIT("__init_") <> ptext mod
+
ppIdFlavor :: IdLabelInfo -> SDoc
ppIdFlavor x = pp_cSEP <>
ppConFlavor x = pp_cSEP <>
(case x of
- StaticClosure -> ptext SLIT("static_closure")
ConEntry -> ptext SLIT("con_entry")
ConInfoTbl -> ptext SLIT("con_info")
StaticConEntry -> ptext SLIT("static_entry")