Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data CLabel
- newtype NeedExternDecl = NeedExternDecl Bool
- data ForeignLabelSource
- pprDebugCLabel :: CLabel -> SDoc
- mkClosureLabel :: Name -> CafInfo -> CLabel
- mkSRTLabel :: Unique -> CLabel
- mkInfoTableLabel :: Name -> CafInfo -> CLabel
- mkEntryLabel :: Name -> CafInfo -> CLabel
- mkRednCountsLabel :: Name -> CLabel
- mkConInfoTableLabel :: Name -> CafInfo -> CLabel
- mkApEntryLabel :: DynFlags -> Bool -> Int -> CLabel
- mkApInfoTableLabel :: DynFlags -> Bool -> Int -> CLabel
- mkClosureTableLabel :: Name -> CafInfo -> CLabel
- mkBytesLabel :: Name -> CLabel
- mkLocalBlockLabel :: Unique -> CLabel
- mkLocalClosureLabel :: Name -> CafInfo -> CLabel
- mkLocalInfoTableLabel :: Name -> CafInfo -> CLabel
- mkLocalClosureTableLabel :: Name -> CafInfo -> CLabel
- mkBlockInfoTableLabel :: Name -> CafInfo -> CLabel
- mkBitmapLabel :: Unique -> CLabel
- mkStringLitLabel :: Unique -> CLabel
- mkAsmTempLabel :: Uniquable a => a -> CLabel
- mkAsmTempDerivedLabel :: CLabel -> FastString -> CLabel
- mkAsmTempEndLabel :: CLabel -> CLabel
- mkAsmTempDieLabel :: CLabel -> CLabel
- mkDirty_MUT_VAR_Label :: CLabel
- mkNonmovingWriteBarrierEnabledLabel :: CLabel
- mkUpdInfoLabel :: CLabel
- mkBHUpdInfoLabel :: CLabel
- mkIndStaticInfoLabel :: CLabel
- mkMainCapabilityLabel :: CLabel
- mkMAP_FROZEN_CLEAN_infoLabel :: CLabel
- mkMAP_FROZEN_DIRTY_infoLabel :: CLabel
- mkMAP_DIRTY_infoLabel :: CLabel
- mkSMAP_FROZEN_CLEAN_infoLabel :: CLabel
- mkSMAP_FROZEN_DIRTY_infoLabel :: CLabel
- mkSMAP_DIRTY_infoLabel :: CLabel
- mkBadAlignmentLabel :: CLabel
- mkArrWords_infoLabel :: CLabel
- mkSRTInfoLabel :: Int -> CLabel
- mkTopTickyCtrLabel :: CLabel
- mkCAFBlackHoleInfoTableLabel :: CLabel
- mkRtsPrimOpLabel :: PrimOp -> CLabel
- mkRtsSlowFastTickyCtrLabel :: String -> CLabel
- mkSelectorInfoLabel :: DynFlags -> Bool -> Int -> CLabel
- mkSelectorEntryLabel :: DynFlags -> Bool -> Int -> CLabel
- mkCmmInfoLabel :: UnitId -> FastString -> CLabel
- mkCmmEntryLabel :: UnitId -> FastString -> CLabel
- mkCmmRetInfoLabel :: UnitId -> FastString -> CLabel
- mkCmmRetLabel :: UnitId -> FastString -> CLabel
- mkCmmCodeLabel :: UnitId -> FastString -> CLabel
- mkCmmDataLabel :: UnitId -> NeedExternDecl -> FastString -> CLabel
- mkRtsCmmDataLabel :: FastString -> CLabel
- mkCmmClosureLabel :: UnitId -> FastString -> CLabel
- mkRtsApFastLabel :: FastString -> CLabel
- mkPrimCallLabel :: PrimCall -> CLabel
- mkForeignLabel :: FastString -> Maybe Int -> ForeignLabelSource -> FunctionOrData -> CLabel
- addLabelSize :: CLabel -> Int -> CLabel
- foreignLabelStdcallInfo :: CLabel -> Maybe Int
- isBytesLabel :: CLabel -> Bool
- isForeignLabel :: CLabel -> Bool
- isSomeRODataLabel :: CLabel -> Bool
- isStaticClosureLabel :: CLabel -> Bool
- mkCCLabel :: CostCentre -> CLabel
- mkCCSLabel :: CostCentreStack -> CLabel
- data DynamicLinkerLabelInfo
- mkDynamicLinkerLabel :: DynamicLinkerLabelInfo -> CLabel -> CLabel
- dynamicLinkerLabelInfo :: CLabel -> Maybe (DynamicLinkerLabelInfo, CLabel)
- mkPicBaseLabel :: CLabel
- mkDeadStripPreventer :: CLabel -> CLabel
- mkHpcTicksLabel :: Module -> CLabel
- hasCAF :: CLabel -> Bool
- needsCDecl :: CLabel -> Bool
- maybeLocalBlockLabel :: CLabel -> Maybe BlockId
- externallyVisibleCLabel :: CLabel -> Bool
- isMathFun :: CLabel -> Bool
- isCFunctionLabel :: CLabel -> Bool
- isGcPtrLabel :: CLabel -> Bool
- labelDynamic :: NCGConfig -> Module -> CLabel -> Bool
- isLocalCLabel :: Module -> CLabel -> Bool
- mayRedirectTo :: CLabel -> CLabel -> Bool
- toClosureLbl :: CLabel -> CLabel
- toSlowEntryLbl :: CLabel -> CLabel
- toEntryLbl :: CLabel -> CLabel
- toInfoLbl :: CLabel -> CLabel
- hasHaskellName :: CLabel -> Maybe Name
- pprCLabel :: DynFlags -> CLabel -> SDoc
- isInfoTableLabel :: CLabel -> Bool
- isConInfoTableLabel :: CLabel -> Bool
- isIdLabel :: CLabel -> Bool
- isTickyLabel :: CLabel -> Bool
Documentation
CLabel
is an abstract type that supports the following operations:
- Pretty printing
- In a C file, does it need to be declared before use? (i.e. is it guaranteed to be already in scope in the places we need to refer to it?)
- If it needs to be declared, what type (code or data) should it be declared to have?
- Is it visible outside this object file or not?
- Is it "dynamic" (see details below)
- Eq and Ord, so that we can make sets of CLabels (currently only used in outputting C as far as I can tell, to avoid generating more than one declaration for any given label).
- Converting an info table label into an entry label.
CLabel usage is a bit messy in GHC as they are used in a number of different contexts:
- By the C-- AST to identify labels
- By the unregisterised C code generator ("PprC") for naming functions (hence
the name
CLabel
) - By the native and LLVM code generators to identify labels
For extra fun, each of these uses a slightly different subset of constructors
(e.g. AsmTempLabel
and AsmTempDerivedLabel
are used only in the NCG and
LLVM backends).
In general, we use IdLabel
to represent Haskell things early in the
pipeline. However, later optimization passes will often represent blocks they
create with LocalBlockLabel
where there is no obvious Name
to hang off the
label.
newtype NeedExternDecl Source #
Indicate if GHC.CmmToC has to generate an extern declaration for the label (e.g. "extern StgWordArray(foo)"). The type is fixed to StgWordArray.
Symbols from the RTS don't need "extern" declarations because they are
exposed via "includes/Stg.h" with the appropriate type. See needsCDecl
.
The fixed StgWordArray type led to "conflicting types" issues with user provided Cmm files (not in the RTS) that declare data of another type (#15467 and test for #17920). Hence the Cmm parser considers that labels in data sections don't need the "extern" declaration (just add one explicitly if you need it).
See https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes for why extern declaration are needed at all.
Instances
Eq NeedExternDecl Source # | |
Defined in GHC.Cmm.CLabel (==) :: NeedExternDecl -> NeedExternDecl -> Bool # (/=) :: NeedExternDecl -> NeedExternDecl -> Bool # | |
Ord NeedExternDecl Source # | |
Defined in GHC.Cmm.CLabel compare :: NeedExternDecl -> NeedExternDecl -> Ordering # (<) :: NeedExternDecl -> NeedExternDecl -> Bool # (<=) :: NeedExternDecl -> NeedExternDecl -> Bool # (>) :: NeedExternDecl -> NeedExternDecl -> Bool # (>=) :: NeedExternDecl -> NeedExternDecl -> Bool # max :: NeedExternDecl -> NeedExternDecl -> NeedExternDecl # min :: NeedExternDecl -> NeedExternDecl -> NeedExternDecl # |
data ForeignLabelSource Source #
Record where a foreign label is stored.
ForeignLabelInPackage Unit | Label is in a named package |
ForeignLabelInExternalPackage | Label is in some external, system package that doesn't also contain compiled Haskell code, and is not associated with any .hi files. We don't have to worry about Haskell code being inlined from external packages. It is safe to treat the RTS package as "external". |
ForeignLabelInThisPackage | Label is in the package currently being compiled. This is only used for creating hacky tmp labels during code generation. Don't use it in any code that might be inlined across a package boundary (ie, core code) else the information will be wrong relative to the destination module. |
Instances
Outputable ForeignLabelSource Source # | |
Defined in GHC.Cmm.CLabel | |
Eq ForeignLabelSource Source # | |
Defined in GHC.Cmm.CLabel (==) :: ForeignLabelSource -> ForeignLabelSource -> Bool # (/=) :: ForeignLabelSource -> ForeignLabelSource -> Bool # | |
Ord ForeignLabelSource Source # | |
Defined in GHC.Cmm.CLabel compare :: ForeignLabelSource -> ForeignLabelSource -> Ordering # (<) :: ForeignLabelSource -> ForeignLabelSource -> Bool # (<=) :: ForeignLabelSource -> ForeignLabelSource -> Bool # (>) :: ForeignLabelSource -> ForeignLabelSource -> Bool # (>=) :: ForeignLabelSource -> ForeignLabelSource -> Bool # max :: ForeignLabelSource -> ForeignLabelSource -> ForeignLabelSource # min :: ForeignLabelSource -> ForeignLabelSource -> ForeignLabelSource # |
pprDebugCLabel :: CLabel -> SDoc Source #
For debugging problems with the CLabel representation. We can't make a Show instance for CLabel because lots of its components don't have instances. The regular Outputable instance only shows the label name, and not its other info.
mkSRTLabel :: Unique -> CLabel Source #
mkRednCountsLabel :: Name -> CLabel Source #
mkBytesLabel :: Name -> CLabel Source #
mkLocalBlockLabel :: Unique -> CLabel Source #
mkBitmapLabel :: Unique -> CLabel Source #
mkStringLitLabel :: Unique -> CLabel Source #
mkAsmTempLabel :: Uniquable a => a -> CLabel Source #
mkAsmTempDerivedLabel :: CLabel -> FastString -> CLabel Source #
mkAsmTempEndLabel :: CLabel -> CLabel Source #
mkAsmTempDieLabel :: CLabel -> CLabel Source #
Construct a label for a DWARF Debug Information Entity (DIE) describing another symbol.
mkSRTInfoLabel :: Int -> CLabel Source #
mkRtsPrimOpLabel :: PrimOp -> CLabel Source #
mkCmmInfoLabel :: UnitId -> FastString -> CLabel Source #
mkCmmEntryLabel :: UnitId -> FastString -> CLabel Source #
mkCmmRetInfoLabel :: UnitId -> FastString -> CLabel Source #
mkCmmRetLabel :: UnitId -> FastString -> CLabel Source #
mkCmmCodeLabel :: UnitId -> FastString -> CLabel Source #
mkCmmDataLabel :: UnitId -> NeedExternDecl -> FastString -> CLabel Source #
mkRtsCmmDataLabel :: FastString -> CLabel Source #
mkCmmClosureLabel :: UnitId -> FastString -> CLabel Source #
mkRtsApFastLabel :: FastString -> CLabel Source #
mkPrimCallLabel :: PrimCall -> CLabel Source #
mkForeignLabel :: FastString -> Maybe Int -> ForeignLabelSource -> FunctionOrData -> CLabel Source #
Make a foreign label
isBytesLabel :: CLabel -> Bool Source #
Whether label is a top-level string literal
isForeignLabel :: CLabel -> Bool Source #
Whether label is a non-haskell label (defined in C code)
isSomeRODataLabel :: CLabel -> Bool Source #
Whether label is a .rodata label
isStaticClosureLabel :: CLabel -> Bool Source #
Whether label is a static closure label (can come from haskell or cmm)
mkCCLabel :: CostCentre -> CLabel Source #
mkCCSLabel :: CostCentreStack -> CLabel Source #
data DynamicLinkerLabelInfo Source #
Instances
mkDeadStripPreventer :: CLabel -> CLabel Source #
mkHpcTicksLabel :: Module -> CLabel Source #
Predicates
needsCDecl :: CLabel -> Bool Source #
externallyVisibleCLabel :: CLabel -> Bool Source #
Is a CLabel visible outside this object file or not? From the point of view of the code generator, a name is externally visible if it has to be declared as exported in the .o file's symbol table; that is, made non-static.
isMathFun :: CLabel -> Bool Source #
Check whether a label corresponds to a C function that has a prototype in a system header somewhere, or is built-in to the C compiler. For these labels we avoid generating our own C prototypes.
isCFunctionLabel :: CLabel -> Bool Source #
isGcPtrLabel :: CLabel -> Bool Source #
labelDynamic :: NCGConfig -> Module -> CLabel -> Bool Source #
Does a CLabel
need dynamic linkage?
When referring to data in code, we need to know whether
that data resides in a DLL or not. [Win32 only.]
labelDynamic
returns True
if the label is located
in a DLL, be it a data reference or not.
Conversions
toClosureLbl :: CLabel -> CLabel Source #
toSlowEntryLbl :: CLabel -> CLabel Source #
toEntryLbl :: CLabel -> CLabel Source #
isInfoTableLabel :: CLabel -> Bool Source #
Whether label is points to some kind of info table
isConInfoTableLabel :: CLabel -> Bool Source #
Whether label is points to constructor info table
isTickyLabel :: CLabel -> Bool Source #