ghc-lib-parser-9.10.1.20250103: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Cmm

Contents

- Cmm top-level datatypes
  - Blocks containing lists
- Info Tables
- Statements, expressions and types
- Pretty-printing

Synopsis

- type CmmProgram = [CmmGroup]
- type CmmGroup = GenCmmGroup CmmStatics CmmTopInfo CmmGraph
- type CmmGroupSRTs = GenCmmGroup RawCmmStatics CmmTopInfo CmmGraph
- type RawCmmGroup = GenCmmGroup RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
- type GenCmmGroup d h g = [GenCmmDecl d h g]
- type CmmDecl = GenCmmDecl CmmStatics CmmTopInfo CmmGraph
- type CmmDeclSRTs = GenCmmDecl RawCmmStatics CmmTopInfo CmmGraph
- data GenCmmDecl d h g
  - = CmmProc h CLabel [GlobalReg] g
  - | CmmData Section d
- type CmmDataDecl = GenCmmDataDecl CmmStatics
- cmmDataDeclCmmDecl :: GenCmmDataDecl d -> GenCmmDecl d h g
- type CmmGraph = GenCmmGraph CmmNode
- data GenCmmGraph (n :: Extensibility -> Extensibility -> Type) = CmmGraph {
  - g_entry :: BlockId
  - g_graph :: Graph n C C
  }
- toBlockMap :: CmmGraph -> LabelMap CmmBlock
- revPostorder :: CmmGraph -> [CmmBlock]
- toBlockList :: CmmGraph -> [CmmBlock]
- type CmmBlock = Block CmmNode C C
- type RawCmmDecl = GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
- data Section = Section SectionType CLabel
- data SectionType
  - = Text
  - | Data
  - | ReadOnlyData
  - | RelocatableReadOnlyData
  - | UninitialisedData
  - | InitArray
  - | FiniArray
  - | CString
  - | OtherSection String
- data GenCmmStatics (rawOnly :: Bool) where
  - CmmStatics :: CLabel -> CmmInfoTable -> CostCentreStack -> [CmmLit] -> [CmmLit] -> GenCmmStatics 'False
  - CmmStaticsRaw :: forall (rawOnly :: Bool). CLabel -> [CmmStatic] -> GenCmmStatics rawOnly
- type CmmStatics = GenCmmStatics 'False
- type RawCmmStatics = GenCmmStatics 'True
- data CmmStatic
  - = CmmStaticLit CmmLit
  - | CmmUninitialised Int
  - | CmmString ByteString
  - | CmmFileEmbed FilePath Int
- data SectionProtection
  - = ReadWriteSection
  - | ReadOnlySection
  - | WriteProtectedSection
- sectionProtection :: Section -> SectionProtection
- data GenBasicBlock i = BasicBlock BlockId [i]
- blockId :: GenBasicBlock i -> BlockId
- newtype ListGraph i = ListGraph [GenBasicBlock i]
- pprBBlock :: Outputable stmt => GenBasicBlock stmt -> SDoc
- data CmmTopInfo = TopInfo {
  - info_tbls :: LabelMap CmmInfoTable
  - stack_info :: CmmStackInfo
  }
- data CmmStackInfo = StackInfo {
  - arg_space :: ByteOff
  - do_layout :: Bool
  }
- data CmmInfoTable = CmmInfoTable {
  - cit_lbl :: CLabel
  - cit_rep :: SMRep
  - cit_prof :: ProfilingInfo
  - cit_srt :: Maybe CLabel
  - cit_clo :: Maybe (Id, CostCentreStack)
  }
- topInfoTable :: forall a (n :: Extensibility -> Extensibility -> Type). GenCmmDecl a CmmTopInfo (GenCmmGraph n) -> Maybe CmmInfoTable
- data ClosureTypeInfo
  - = Constr ConTagZ ConstrDescription
  - | Fun FunArity ArgDescr
  - | Thunk
  - | ThunkSelector SelectorOffset
  - | BlackHole
  - | IndStatic
- data ProfilingInfo
  - = NoProfilingInfo
  - | ProfilingInfo ByteString ByteString
- type ConstrDescription = ByteString
- module GHC.Cmm.Node
- module GHC.Cmm.Expr
- pprCmmGroup :: (OutputableP Platform d, OutputableP Platform info, OutputableP Platform g) => Platform -> GenCmmGroup d info g -> SDoc
- pprSection :: Platform -> Section -> SDoc
- pprStatic :: Platform -> CmmStatic -> SDoc

# Cmm top-level datatypes

type CmmProgram = [CmmGroup] #

type CmmGroup = GenCmmGroup CmmStatics CmmTopInfo CmmGraph #

Cmm group before SRT generation

type CmmGroupSRTs = GenCmmGroup RawCmmStatics CmmTopInfo CmmGraph #

Cmm group with SRTs

type RawCmmGroup = GenCmmGroup RawCmmStatics (LabelMap RawCmmStatics) CmmGraph #

Raw cmm group (TODO (osa): not sure what that means)

type GenCmmGroup d h g = [GenCmmDecl d h g] #

type CmmDecl = GenCmmDecl CmmStatics CmmTopInfo CmmGraph #

type CmmDeclSRTs = GenCmmDecl RawCmmStatics CmmTopInfo CmmGraph #

data GenCmmDecl d h g #

A top-level chunk, abstracted over the type of the contents of the basic blocks (Cmm or instructions are the likely instantiations).

Constructors

CmmProc h CLabel [GlobalReg] g |
CmmData Section d |

#### Instances

Instances details

(OutputableP Platform d, OutputableP Platform info, OutputableP Platform i) => OutputableP Platform (GenCmmDecl d info i) # |
Instance details Defined in GHC.Cmm Methods pdoc :: Platform -> GenCmmDecl d info i -> SDoc #
Functor (GenCmmDecl d h) # |
Instance details Defined in GHC.Cmm Methods fmap :: (a -> b) -> GenCmmDecl d h a -> GenCmmDecl d h b # (<$) :: a -> GenCmmDecl d h b -> GenCmmDecl d h a #

type CmmDataDecl = GenCmmDataDecl CmmStatics #

cmmDataDeclCmmDecl :: GenCmmDataDecl d -> GenCmmDecl d h g #

type CmmGraph = GenCmmGraph CmmNode #

data GenCmmGraph (n :: Extensibility -> Extensibility -> Type) #

Constructors

CmmGraph |

Fields

- g_entry :: BlockId
- g_graph :: Graph n C C

#### Instances

Instances details

OutputableP Platform CmmGraph # |
Instance details Defined in GHC.Cmm Methods pdoc :: Platform -> CmmGraph -> SDoc #

toBlockMap :: CmmGraph -> LabelMap CmmBlock #

revPostorder :: CmmGraph -> [CmmBlock] #

toBlockList :: CmmGraph -> [CmmBlock] #

type CmmBlock = Block CmmNode C C #

type RawCmmDecl = GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph #

data Section #

Constructors

Section SectionType CLabel |

data SectionType #

Constructors

Text |
Data |
ReadOnlyData |
RelocatableReadOnlyData |
UninitialisedData |
InitArray |
FiniArray |
CString |
OtherSection String |

#### Instances

Instances details

Show SectionType # |
Instance details Defined in GHC.Cmm Methods showsPrec :: Int -> SectionType -> ShowS # show :: SectionType -> String # showList :: [SectionType] -> ShowS #

data GenCmmStatics (rawOnly :: Bool) where #

Constructors

CmmStatics :: CLabel -> CmmInfoTable -> CostCentreStack -> [CmmLit] -> [CmmLit] -> GenCmmStatics 'False |
CmmStaticsRaw :: forall (rawOnly :: Bool). CLabel -> [CmmStatic] -> GenCmmStatics rawOnly | Static data, after SRTs are generated

#### Instances

Instances details

OutputableP Platform (GenCmmStatics a) # |
Instance details Defined in GHC.Cmm Methods pdoc :: Platform -> GenCmmStatics a -> SDoc #

type CmmStatics = GenCmmStatics 'False #

type RawCmmStatics = GenCmmStatics 'True #

data CmmStatic #

Constructors

CmmStaticLit CmmLit | a literal value, size given by cmmLitRep of the literal.
CmmUninitialised Int | uninitialised data, N bytes long
CmmString ByteString | string of 8-bit values only, not zero terminated.
CmmFileEmbed FilePath Int | an embedded binary file and its byte length

#### Instances

Instances details

Outputable CmmStatic # |
Instance details Defined in GHC.Cmm Methods ppr :: CmmStatic -> SDoc #
OutputableP Platform CmmStatic # |
Instance details Defined in GHC.Cmm Methods pdoc :: Platform -> CmmStatic -> SDoc #

data SectionProtection #

Constructors

ReadWriteSection |
ReadOnlySection |
WriteProtectedSection |

#### Instances

Instances details

Eq SectionProtection # |
Instance details Defined in GHC.Cmm Methods (==) :: SectionProtection -> SectionProtection -> Bool # (/=) :: SectionProtection -> SectionProtection -> Bool #

sectionProtection :: Section -> SectionProtection #

Should a data in this section be considered constant at runtime

## Blocks containing lists

data GenBasicBlock i #

Constructors

BasicBlock BlockId [i] |

#### Instances

Instances details

Functor GenBasicBlock # |
Instance details Defined in GHC.Cmm Methods fmap :: (a -> b) -> GenBasicBlock a -> GenBasicBlock b # (<$) :: a -> GenBasicBlock b -> GenBasicBlock a #
OutputableP env instr => OutputableP env (GenBasicBlock instr) # |
Instance details Defined in GHC.Cmm Methods pdoc :: env -> GenBasicBlock instr -> SDoc #
Outputable instr => Outputable (GenBasicBlock instr) # |
Instance details Defined in GHC.Cmm Methods ppr :: GenBasicBlock instr -> SDoc #

blockId :: GenBasicBlock i -> BlockId #

The branch block id is that of the first block in the branch, which is that branch's entry point

newtype ListGraph i #

Constructors

ListGraph [GenBasicBlock i] |

#### Instances

Instances details

Functor ListGraph # |
Instance details Defined in GHC.Cmm Methods fmap :: (a -> b) -> ListGraph a -> ListGraph b # (<$) :: a -> ListGraph b -> ListGraph a #
OutputableP env instr => OutputableP env (ListGraph instr) # |
Instance details Defined in GHC.Cmm Methods pdoc :: env -> ListGraph instr -> SDoc #
Outputable instr => Outputable (ListGraph instr) # |
Instance details Defined in GHC.Cmm Methods ppr :: ListGraph instr -> SDoc #

pprBBlock :: Outputable stmt => GenBasicBlock stmt -> SDoc #

# Info Tables

data CmmTopInfo #

CmmTopInfo is attached to each CmmDecl (see defn of CmmGroup), and contains the extra info (beyond the executable code) that belongs to that CmmDecl.

Constructors

TopInfo |

Fields

- info_tbls :: LabelMap CmmInfoTable
- stack_info :: CmmStackInfo

#### Instances

Instances details

OutputableP Platform CmmTopInfo # |
Instance details Defined in GHC.Cmm Methods pdoc :: Platform -> CmmTopInfo -> SDoc #

data CmmStackInfo #

Constructors

StackInfo |

Fields

- arg_space :: ByteOff
- do_layout :: Bool

#### Instances

Instances details

Outputable CmmStackInfo # |
Instance details Defined in GHC.Cmm Methods ppr :: CmmStackInfo -> SDoc #

data CmmInfoTable #

Info table as a haskell data type

Constructors

CmmInfoTable |

Fields

- cit_lbl :: CLabel
- cit_rep :: SMRep
- cit_prof :: ProfilingInfo
- cit_srt :: Maybe CLabel
- cit_clo :: Maybe (Id, CostCentreStack)

#### Instances

Instances details

Eq CmmInfoTable # |
Instance details Defined in GHC.Cmm Methods (==) :: CmmInfoTable -> CmmInfoTable -> Bool # (/=) :: CmmInfoTable -> CmmInfoTable -> Bool #
Ord CmmInfoTable # |
Instance details Defined in GHC.Cmm Methods compare :: CmmInfoTable -> CmmInfoTable -> Ordering # (<) :: CmmInfoTable -> CmmInfoTable -> Bool # (<=) :: CmmInfoTable -> CmmInfoTable -> Bool # (>) :: CmmInfoTable -> CmmInfoTable -> Bool # (>=) :: CmmInfoTable -> CmmInfoTable -> Bool # max :: CmmInfoTable -> CmmInfoTable -> CmmInfoTable # min :: CmmInfoTable -> CmmInfoTable -> CmmInfoTable #
OutputableP Platform CmmInfoTable # |
Instance details Defined in GHC.Cmm Methods pdoc :: Platform -> CmmInfoTable -> SDoc #

topInfoTable :: forall a (n :: Extensibility -> Extensibility -> Type). GenCmmDecl a CmmTopInfo (GenCmmGraph n) -> Maybe CmmInfoTable #

data ClosureTypeInfo #

Constructors

Constr ConTagZ ConstrDescription |
Fun FunArity ArgDescr |
Thunk |
ThunkSelector SelectorOffset |
BlackHole |
IndStatic |

#### Instances

Instances details

Outputable ClosureTypeInfo # |
Instance details Defined in GHC.Runtime.Heap.Layout Methods ppr :: ClosureTypeInfo -> SDoc #
Eq ClosureTypeInfo # |
Instance details Defined in GHC.Runtime.Heap.Layout Methods (==) :: ClosureTypeInfo -> ClosureTypeInfo -> Bool # (/=) :: ClosureTypeInfo -> ClosureTypeInfo -> Bool #
Ord ClosureTypeInfo # |

Instance details

Defined in GHC.Runtime.Heap.Layout

Methods

compare :: ClosureTypeInfo -> ClosureTypeInfo -> Ordering #

(<) :: ClosureTypeInfo -> ClosureTypeInfo -> Bool #

(<=) :: ClosureTypeInfo -> ClosureTypeInfo -> Bool #

(>) :: ClosureTypeInfo -> ClosureTypeInfo -> Bool #

(>=) :: ClosureTypeInfo -> ClosureTypeInfo -> Bool #

max :: ClosureTypeInfo -> ClosureTypeInfo -> ClosureTypeInfo #

min :: ClosureTypeInfo -> ClosureTypeInfo -> ClosureTypeInfo #

data ProfilingInfo #

Constructors

NoProfilingInfo |
ProfilingInfo ByteString ByteString |

#### Instances

Instances details

Eq ProfilingInfo # |
Instance details Defined in GHC.Cmm Methods (==) :: ProfilingInfo -> ProfilingInfo -> Bool # (/=) :: ProfilingInfo -> ProfilingInfo -> Bool #
Ord ProfilingInfo # |

Instance details

Defined in GHC.Cmm

Methods

compare :: ProfilingInfo -> ProfilingInfo -> Ordering #

(<) :: ProfilingInfo -> ProfilingInfo -> Bool #

(<=) :: ProfilingInfo -> ProfilingInfo -> Bool #

(>) :: ProfilingInfo -> ProfilingInfo -> Bool #

(>=) :: ProfilingInfo -> ProfilingInfo -> Bool #

max :: ProfilingInfo -> ProfilingInfo -> ProfilingInfo #

min :: ProfilingInfo -> ProfilingInfo -> ProfilingInfo #

type ConstrDescription = ByteString #

# Statements, expressions and types

module GHC.Cmm.Node

module GHC.Cmm.Expr

# Pretty-printing

pprCmmGroup :: (OutputableP Platform d, OutputableP Platform info, OutputableP Platform g) => Platform -> GenCmmGroup d info g -> SDoc #

pprSection :: Platform -> Section -> SDoc #

pprStatic :: Platform -> CmmStatic -> SDoc #