CLabel

ghc-8.4.4: The GHC API

Safe Haskell | None
Language | Haskell2010

CLabel

Contents

- Conversions

Synopsis

- data CLabel
- data ForeignLabelSource
  - = ForeignLabelInPackage UnitId
  - | ForeignLabelInExternalPackage
  - | ForeignLabelInThisPackage
- pprDebugCLabel :: CLabel -> SDoc
- mkClosureLabel :: Name -> CafInfo -> CLabel
- mkTopSRTLabel :: Unique -> CLabel
- mkInfoTableLabel :: Name -> CafInfo -> CLabel
- mkEntryLabel :: Name -> CafInfo -> CLabel
- mkRednCountsLabel :: Name -> CLabel
- mkConInfoTableLabel :: Name -> CafInfo -> CLabel
- mkLargeSRTLabel :: Unique -> CLabel
- mkApEntryLabel :: Bool -> Int -> CLabel
- mkApInfoTableLabel :: 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
- mkSplitMarkerLabel :: CLabel
- mkDirty_MUT_VAR_Label :: CLabel
- mkUpdInfoLabel :: CLabel
- mkBHUpdInfoLabel :: CLabel
- mkIndStaticInfoLabel :: CLabel
- mkMainCapabilityLabel :: CLabel
- mkMAP_FROZEN_infoLabel :: CLabel
- mkMAP_FROZEN0_infoLabel :: CLabel
- mkMAP_DIRTY_infoLabel :: CLabel
- mkSMAP_FROZEN_infoLabel :: CLabel
- mkSMAP_FROZEN0_infoLabel :: CLabel
- mkSMAP_DIRTY_infoLabel :: CLabel
- mkBadAlignmentLabel :: CLabel
- mkArrWords_infoLabel :: CLabel
- mkTopTickyCtrLabel :: CLabel
- mkCAFBlackHoleInfoTableLabel :: CLabel
- mkRtsPrimOpLabel :: PrimOp -> CLabel
- mkRtsSlowFastTickyCtrLabel :: String -> CLabel
- mkSelectorInfoLabel :: Bool -> Int -> CLabel
- mkSelectorEntryLabel :: 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 -> 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
  - = CodeStub
  - | SymbolPtr
  - | GotSymbolPtr
  - | GotSymbolOffset
- 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 :: DynFlags -> Module -> CLabel -> Bool
- toClosureLbl :: CLabel -> CLabel
- toSlowEntryLbl :: CLabel -> CLabel
- toEntryLbl :: CLabel -> CLabel
- toInfoLbl :: CLabel -> CLabel
- hasHaskellName :: CLabel -> Maybe Name
- pprCLabel :: Platform -> CLabel -> SDoc

# Documentation

data CLabel #

`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.

Instances

Eq CLabel # |
Instance details Defined in CLabel Methods (==) :: CLabel -> CLabel -> Bool # (/=) :: CLabel -> CLabel -> Bool #
Ord CLabel # |
Instance details Defined in CLabel Methods compare :: CLabel -> CLabel -> Ordering # (<) :: CLabel -> CLabel -> Bool # (<=) :: CLabel -> CLabel -> Bool # (>) :: CLabel -> CLabel -> Bool # (>=) :: CLabel -> CLabel -> Bool # max :: CLabel -> CLabel -> CLabel # min :: CLabel -> CLabel -> CLabel #
Outputable CLabel # |
Instance details Defined in CLabel Methods ppr :: CLabel -> SDoc # pprPrec :: Rational -> CLabel -> SDoc #

data ForeignLabelSource #

Record where a foreign label is stored.

Constructors

ForeignLabelInPackage UnitId | 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 currenly 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

Eq ForeignLabelSource # |
Instance details Defined in CLabel Methods (==) :: ForeignLabelSource -> ForeignLabelSource -> Bool # (/=) :: ForeignLabelSource -> ForeignLabelSource -> Bool #
Ord ForeignLabelSource # |
Instance details Defined in CLabel Methods compare :: ForeignLabelSource -> ForeignLabelSource -> Ordering # (<) :: ForeignLabelSource -> ForeignLabelSource -> Bool # (<=) :: ForeignLabelSource -> ForeignLabelSource -> Bool # (>) :: ForeignLabelSource -> ForeignLabelSource -> Bool # (>=) :: ForeignLabelSource -> ForeignLabelSource -> Bool # max :: ForeignLabelSource -> ForeignLabelSource -> ForeignLabelSource # min :: ForeignLabelSource -> ForeignLabelSource -> ForeignLabelSource #
Outputable ForeignLabelSource # |
Instance details Defined in CLabel Methods ppr :: ForeignLabelSource -> SDoc # pprPrec :: Rational -> ForeignLabelSource -> SDoc #

pprDebugCLabel :: CLabel -> SDoc #

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.

mkClosureLabel :: Name -> CafInfo -> CLabel #

mkTopSRTLabel :: Unique -> CLabel #

mkInfoTableLabel :: Name -> CafInfo -> CLabel #

mkEntryLabel :: Name -> CafInfo -> CLabel #

mkRednCountsLabel :: Name -> CLabel #

mkConInfoTableLabel :: Name -> CafInfo -> CLabel #

mkLargeSRTLabel :: Unique -> CLabel #

mkApEntryLabel :: Bool -> Int -> CLabel #

mkApInfoTableLabel :: 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 #

Construct a label for a DWARF Debug Information Entity (DIE) describing another symbol.

mkSplitMarkerLabel :: CLabel #

mkDirty_MUT_VAR_Label :: CLabel #

mkUpdInfoLabel :: CLabel #

mkBHUpdInfoLabel :: CLabel #

mkIndStaticInfoLabel :: CLabel #

mkMainCapabilityLabel :: CLabel #

mkMAP_FROZEN_infoLabel :: CLabel #

mkMAP_FROZEN0_infoLabel :: CLabel #

mkMAP_DIRTY_infoLabel :: CLabel #

mkSMAP_FROZEN_infoLabel :: CLabel #

mkSMAP_FROZEN0_infoLabel :: CLabel #

mkSMAP_DIRTY_infoLabel :: CLabel #

mkBadAlignmentLabel :: CLabel #

mkArrWords_infoLabel :: CLabel #

mkTopTickyCtrLabel :: CLabel #

mkCAFBlackHoleInfoTableLabel :: CLabel #

mkRtsPrimOpLabel :: PrimOp -> CLabel #

mkRtsSlowFastTickyCtrLabel :: String -> CLabel #

mkSelectorInfoLabel :: Bool -> Int -> CLabel #

mkSelectorEntryLabel :: 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 -> FastString -> CLabel #

mkCmmClosureLabel :: UnitId -> FastString -> CLabel #

mkRtsApFastLabel :: FastString -> CLabel #

mkPrimCallLabel :: PrimCall -> CLabel #

mkForeignLabel :: FastString -> Maybe Int -> ForeignLabelSource -> FunctionOrData -> CLabel #

Make a foreign label

addLabelSize :: CLabel -> Int -> CLabel #

Update the label size field in a ForeignLabel

foreignLabelStdcallInfo :: CLabel -> Maybe Int #

Get the label size field from a ForeignLabel

isBytesLabel :: CLabel -> Bool #

Whether label is a top-level string literal

isForeignLabel :: CLabel -> Bool #

Whether label is a non-haskell label (defined in C code)

isSomeRODataLabel :: CLabel -> Bool #

Whether label is a .rodata label

isStaticClosureLabel :: CLabel -> Bool #

Whether label is a static closure label (can come from haskell or cmm)

mkCCLabel :: CostCentre -> CLabel #

mkCCSLabel :: CostCentreStack -> CLabel #

data DynamicLinkerLabelInfo #

Constructors

CodeStub |
SymbolPtr |
GotSymbolPtr |
GotSymbolOffset |

Instances

Eq DynamicLinkerLabelInfo # |
Instance details Defined in CLabel Methods (==) :: DynamicLinkerLabelInfo -> DynamicLinkerLabelInfo -> Bool # (/=) :: DynamicLinkerLabelInfo -> DynamicLinkerLabelInfo -> Bool #
Ord DynamicLinkerLabelInfo # |
Instance details Defined in CLabel Methods compare :: DynamicLinkerLabelInfo -> DynamicLinkerLabelInfo -> Ordering # (<) :: DynamicLinkerLabelInfo -> DynamicLinkerLabelInfo -> Bool # (<=) :: DynamicLinkerLabelInfo -> DynamicLinkerLabelInfo -> Bool # (>) :: DynamicLinkerLabelInfo -> DynamicLinkerLabelInfo -> Bool # (>=) :: DynamicLinkerLabelInfo -> DynamicLinkerLabelInfo -> Bool # max :: DynamicLinkerLabelInfo -> DynamicLinkerLabelInfo -> DynamicLinkerLabelInfo # min :: DynamicLinkerLabelInfo -> DynamicLinkerLabelInfo -> 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 #

If a label is a local block label then return just its `BlockId`, otherwise `Nothing`.

externallyVisibleCLabel :: CLabel -> Bool #

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 #

Check whether a label corresponds to a C function that has a prototype in a system header somehere, or is built-in to the C compiler. For these labels we avoid generating our own C prototypes.

isCFunctionLabel :: CLabel -> Bool #

isGcPtrLabel :: CLabel -> Bool #

labelDynamic :: DynFlags -> Module -> CLabel -> Bool #

# Conversions

toClosureLbl :: CLabel -> CLabel #

toSlowEntryLbl :: CLabel -> CLabel #

toEntryLbl :: CLabel -> CLabel #

toInfoLbl :: CLabel -> CLabel #

hasHaskellName :: CLabel -> Maybe Name #

pprCLabel :: Platform -> CLabel -> SDoc #