--
-- Object-file symbols (called CLabel for histerical raisins).
--
--- (c) The University of Glasgow 2004
+-- (c) The University of Glasgow 2004-2006
--
-----------------------------------------------------------------------------
mkClosureLabel,
mkSRTLabel,
- mkSRTDescLabel,
mkInfoTableLabel,
mkEntryLabel,
mkSlowEntryLabel,
mkRednCountsLabel,
mkConInfoTableLabel,
mkStaticInfoTableLabel,
+ mkLargeSRTLabel,
mkApEntryLabel,
mkApInfoTableLabel,
mkClosureTableLabel,
mkSplitMarkerLabel,
mkDirty_MUT_VAR_Label,
mkUpdInfoLabel,
- mkSeqInfoLabel,
mkIndStaticInfoLabel,
mkMainCapabilityLabel,
mkMAP_FROZEN_infoLabel,
mkPicBaseLabel,
mkDeadStripPreventer,
+ mkHpcTicksLabel,
+ mkHpcModuleNameLabel,
+
infoLblToEntryLbl, entryLblToInfoLbl,
- needsCDecl, isAsmTemp, externallyVisibleCLabel,
+ needsCDecl, isAsmTemp, maybeAsmTemp, externallyVisibleCLabel,
CLabelType(..), labelType, labelDynamic,
pprCLabel
#include "HsVersions.h"
-import Packages ( HomeModules )
-import StaticFlags ( opt_Static, opt_DoTickyProfiling )
-import Packages ( isHomeModule, isDllName )
-import DataCon ( ConTag )
-import Module ( moduleFS, Module )
-import Name ( Name, isExternalName )
-import Unique ( pprUnique, Unique )
-import PrimOp ( PrimOp )
-import Config ( cLeadingUnderscore )
-import CostCentre ( CostCentre, CostCentreStack )
+import StaticFlags
+import Packages
+import DataCon
+import PackageConfig
+import Module
+import Name
+import Unique
+import PrimOp
+import Config
+import CostCentre
import Outputable
import FastString
| DeadStripPreventer CLabel
-- label before an info table to prevent excessive dead-stripping on darwin
+ | HpcTicksLabel Module -- Per-module table of tick locations
+ | HpcModuleNameLabel -- Per-module name of the module for Hpc
+
+ | LargeSRTLabel -- Label of an StgLargeSRT
+ {-# UNPACK #-} !Unique
+
+ | LargeBitmapLabel -- A bitmap (function or case return)
+ {-# UNPACK #-} !Unique
+
deriving (Eq, Ord)
data IdLabelInfo
= Closure -- Label for closure
| SRT -- Static reference table
- | SRTDesc -- Static reference table descriptor
| InfoTable -- Info tables for closures; always read-only
| Entry -- entry point
| Slow -- slow entry point
| RednCounts -- Label of place to keep Ticky-ticky info for
-- this Id
- | Bitmap -- A bitmap (function or case return)
-
| ConEntry -- constructor entry point
| ConInfoTable -- corresponding info table
| StaticConEntry -- static constructor entry point
-- These are always local:
mkSRTLabel name = IdLabel name SRT
-mkSRTDescLabel name = IdLabel name SRTDesc
mkSlowEntryLabel name = IdLabel name Slow
-mkBitmapLabel name = IdLabel name Bitmap
mkRednCountsLabel name = IdLabel name RednCounts
-- These have local & (possibly) external variants:
mkLocalEntryLabel name = IdLabel name Entry
mkLocalClosureTableLabel name = IdLabel name ClosureTable
-mkClosureLabel hmods name
- | isDllName hmods name = DynIdLabel name Closure
+mkClosureLabel this_pkg name
+ | isDllName this_pkg name = DynIdLabel name Closure
| otherwise = IdLabel name Closure
-mkInfoTableLabel hmods name
- | isDllName hmods name = DynIdLabel name InfoTable
+mkInfoTableLabel this_pkg name
+ | isDllName this_pkg name = DynIdLabel name InfoTable
| otherwise = IdLabel name InfoTable
-mkEntryLabel hmods name
- | isDllName hmods name = DynIdLabel name Entry
+mkEntryLabel this_pkg name
+ | isDllName this_pkg name = DynIdLabel name Entry
| otherwise = IdLabel name Entry
-mkClosureTableLabel hmods name
- | isDllName hmods name = DynIdLabel name ClosureTable
+mkClosureTableLabel this_pkg name
+ | isDllName this_pkg name = DynIdLabel name ClosureTable
| otherwise = IdLabel name ClosureTable
mkLocalConInfoTableLabel con = IdLabel con ConInfoTable
mkStaticInfoTableLabel name False = IdLabel name StaticInfoTable
mkStaticInfoTableLabel name True = DynIdLabel name StaticInfoTable
-mkConEntryLabel hmods name
- | isDllName hmods name = DynIdLabel name ConEntry
+mkConEntryLabel this_pkg name
+ | isDllName this_pkg name = DynIdLabel name ConEntry
| otherwise = IdLabel name ConEntry
-mkStaticConEntryLabel hmods name
- | isDllName hmods name = DynIdLabel name StaticConEntry
+mkStaticConEntryLabel this_pkg name
+ | isDllName this_pkg name = DynIdLabel name StaticConEntry
| otherwise = IdLabel name StaticConEntry
+mkLargeSRTLabel uniq = LargeSRTLabel uniq
+mkBitmapLabel uniq = LargeBitmapLabel uniq
mkReturnPtLabel uniq = CaseLabel uniq CaseReturnPt
mkReturnInfoLabel uniq = CaseLabel uniq CaseReturnInfo
mkStringLitLabel = StringLitLabel
mkAsmTempLabel = AsmTempLabel
-mkModuleInitLabel :: HomeModules -> Module -> String -> CLabel
-mkModuleInitLabel hmods mod way
- = ModuleInitLabel mod way $! (not (isHomeModule hmods mod))
+mkModuleInitLabel :: PackageId -> Module -> String -> CLabel
+mkModuleInitLabel this_pkg mod way
+ = ModuleInitLabel mod way $! modulePackageId mod /= this_pkg
-mkPlainModuleInitLabel :: HomeModules -> Module -> CLabel
-mkPlainModuleInitLabel hmods mod
- = PlainModuleInitLabel mod $! (not (isHomeModule hmods mod))
+mkPlainModuleInitLabel :: PackageId -> Module -> CLabel
+mkPlainModuleInitLabel this_pkg mod
+ = PlainModuleInitLabel mod $! modulePackageId mod /= this_pkg
-- Some fixed runtime system labels
mkSplitMarkerLabel = RtsLabel (RtsCode SLIT("__stg_split_marker"))
mkDirty_MUT_VAR_Label = RtsLabel (RtsCode SLIT("dirty_MUT_VAR"))
mkUpdInfoLabel = RtsLabel (RtsInfo SLIT("stg_upd_frame"))
-mkSeqInfoLabel = RtsLabel (RtsInfo SLIT("stg_seq_frame"))
mkIndStaticInfoLabel = RtsLabel (RtsInfo SLIT("stg_IND_STATIC"))
mkMainCapabilityLabel = RtsLabel (RtsData SLIT("MainCapability"))
mkMAP_FROZEN_infoLabel = RtsLabel (RtsInfo SLIT("stg_MUT_ARR_PTRS_FROZEN0"))
mkRtsSlowTickyCtrLabel :: String -> CLabel
mkRtsSlowTickyCtrLabel pat = RtsLabel (RtsSlowTickyCtr pat)
+ -- Coverage
+
+mkHpcTicksLabel = HpcTicksLabel
+mkHpcModuleNameLabel = HpcModuleNameLabel
+
-- Dynamic linking
mkDynamicLinkerLabel :: DynamicLinkerLabelInfo -> CLabel -> CLabel
-- don't bother declaring SRT & Bitmap labels, we always make sure
-- they are defined before use.
needsCDecl (IdLabel _ SRT) = False
-needsCDecl (IdLabel _ SRTDesc) = False
-needsCDecl (IdLabel _ Bitmap) = False
+needsCDecl (LargeSRTLabel _) = False
+needsCDecl (LargeBitmapLabel _) = False
needsCDecl (IdLabel _ _) = True
needsCDecl (DynIdLabel _ _) = True
needsCDecl (CaseLabel _ _) = True
needsCDecl (ForeignLabel _ _ _) = False
needsCDecl (CC_Label _) = True
needsCDecl (CCS_Label _) = True
+needsCDecl (HpcTicksLabel _) = True
+needsCDecl HpcModuleNameLabel = False
-- Whether the label is an assembler temporary:
isAsmTemp (AsmTempLabel _) = True
isAsmTemp _ = False
+maybeAsmTemp :: CLabel -> Maybe Unique
+maybeAsmTemp (AsmTempLabel uq) = Just uq
+maybeAsmTemp _ = Nothing
+
-- -----------------------------------------------------------------------------
-- Is a CLabel visible outside this object file or not?
externallyVisibleCLabel (CC_Label _) = True
externallyVisibleCLabel (CCS_Label _) = True
externallyVisibleCLabel (DynamicLinkerLabel _ _) = False
+externallyVisibleCLabel (HpcTicksLabel _) = True
+externallyVisibleCLabel HpcModuleNameLabel = False
+externallyVisibleCLabel (LargeBitmapLabel _) = False
+externallyVisibleCLabel (LargeSRTLabel _) = False
-- -----------------------------------------------------------------------------
-- Finding the "type" of a CLabel
labelType (CaseLabel _ _) = CodeLabel
labelType (ModuleInitLabel _ _ _) = CodeLabel
labelType (PlainModuleInitLabel _ _) = CodeLabel
+labelType (LargeSRTLabel _) = DataLabel
+labelType (LargeBitmapLabel _) = DataLabel
labelType (IdLabel _ info) = idInfoLabelType info
labelType (DynIdLabel _ info) = idInfoLabelType info
case info of
InfoTable -> DataLabel
Closure -> DataLabel
- Bitmap -> DataLabel
ConInfoTable -> DataLabel
StaticInfoTable -> DataLabel
ClosureTable -> DataLabel
+-- krc: aie! a ticky counter label is data
+ RednCounts -> DataLabel
_ -> CodeLabel
pprCLbl (CaseLabel u CaseDefault)
= hcat [pprUnique u, ptext SLIT("_dflt")]
+pprCLbl (LargeSRTLabel u) = pprUnique u <> pp_cSEP <> ptext SLIT("srtd")
+pprCLbl (LargeBitmapLabel u) = text "b" <> pprUnique u <> pp_cSEP <> ptext SLIT("btm")
+-- Some bitsmaps for tuple constructors have a numeric tag (e.g. '7')
+-- until that gets resolved we'll just force them to start
+-- with a letter so the label will be legal assmbly code.
+
+
pprCLbl (RtsLabel (RtsCode str)) = ptext str
pprCLbl (RtsLabel (RtsData str)) = ptext str
pprCLbl (RtsLabel (RtsCodeFS str)) = ftext str
pprCLbl (PlainModuleInitLabel mod _)
= ptext SLIT("__stginit_") <> ppr mod
+pprCLbl (HpcTicksLabel mod)
+ = ptext SLIT("_hpc_tickboxes_") <> ppr mod <> ptext SLIT("_hpc")
+
+pprCLbl HpcModuleNameLabel
+ = ptext SLIT("_hpc_module_name_str")
+
ppIdFlavor :: IdLabelInfo -> SDoc
ppIdFlavor x = pp_cSEP <>
(case x of
Closure -> ptext SLIT("closure")
SRT -> ptext SLIT("srt")
- SRTDesc -> ptext SLIT("srtd")
InfoTable -> ptext SLIT("info")
Entry -> ptext SLIT("entry")
Slow -> ptext SLIT("slow")
RednCounts -> ptext SLIT("ct")
- Bitmap -> ptext SLIT("btm")
ConEntry -> ptext SLIT("con_entry")
ConInfoTable -> ptext SLIT("con_info")
StaticConEntry -> ptext SLIT("static_entry")
pprDynamicLinkerAsmLabel :: DynamicLinkerLabelInfo -> CLabel -> SDoc
-#if darwin_TARGET_OS
-pprDynamicLinkerAsmLabel SymbolPtr lbl
- = char 'L' <> pprCLabel lbl <> text "$non_lazy_ptr"
+#if x86_64_TARGET_ARCH && darwin_TARGET_OS
+pprDynamicLinkerAsmLabel GotSymbolPtr lbl
+ = pprCLabel lbl <> text "@GOTPCREL"
+pprDynamicLinkerAsmLabel GotSymbolOffset lbl
+ = pprCLabel lbl
+pprDynamicLinkerAsmLabel _ _
+ = panic "pprDynamicLinkerAsmLabel"
+#elif darwin_TARGET_OS
pprDynamicLinkerAsmLabel CodeStub lbl
= char 'L' <> pprCLabel lbl <> text "$stub"
+pprDynamicLinkerAsmLabel SymbolPtr lbl
+ = char 'L' <> pprCLabel lbl <> text "$non_lazy_ptr"
+pprDynamicLinkerAsmLabel _ _
+ = panic "pprDynamicLinkerAsmLabel"
#elif powerpc_TARGET_ARCH && linux_TARGET_OS
pprDynamicLinkerAsmLabel CodeStub lbl
= pprCLabel lbl <> text "@plt"
pprDynamicLinkerAsmLabel SymbolPtr lbl
= text ".LC_" <> pprCLabel lbl
+pprDynamicLinkerAsmLabel _ _
+ = panic "pprDynamicLinkerAsmLabel"
+#elif x86_64_TARGET_ARCH && linux_TARGET_OS
+pprDynamicLinkerAsmLabel CodeStub lbl
+ = pprCLabel lbl <> text "@plt"
+pprDynamicLinkerAsmLabel GotSymbolPtr lbl
+ = pprCLabel lbl <> text "@gotpcrel"
+pprDynamicLinkerAsmLabel GotSymbolOffset lbl
+ = pprCLabel lbl
+pprDynamicLinkerAsmLabel SymbolPtr lbl
+ = text ".LC_" <> pprCLabel lbl
#elif linux_TARGET_OS
pprDynamicLinkerAsmLabel CodeStub lbl
= pprCLabel lbl <> text "@plt"
+pprDynamicLinkerAsmLabel SymbolPtr lbl
+ = text ".LC_" <> pprCLabel lbl
pprDynamicLinkerAsmLabel GotSymbolPtr lbl
= pprCLabel lbl <> text "@got"
pprDynamicLinkerAsmLabel GotSymbolOffset lbl
= pprCLabel lbl <> text "@gotoff"
-pprDynamicLinkerAsmLabel SymbolPtr lbl
- = text ".LC_" <> pprCLabel lbl
#elif mingw32_TARGET_OS
pprDynamicLinkerAsmLabel SymbolPtr lbl
= text "__imp_" <> pprCLabel lbl
-#endif
pprDynamicLinkerAsmLabel _ _
= panic "pprDynamicLinkerAsmLabel"
+#else
+pprDynamicLinkerAsmLabel _ _
+ = panic "pprDynamicLinkerAsmLabel"
+#endif