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

Safe Haskell | Ignore
Language | GHC2021

GHC.Stg.Syntax

Synopsis

- data StgArg
  - = StgVarArg Id
  - | StgLitArg Literal
- data GenStgTopBinding (pass :: StgPass)
  - = StgTopLifted (GenStgBinding pass)
  - | StgTopStringLit Id ByteString
- data GenStgBinding (pass :: StgPass)
  - = StgNonRec (BinderP pass) (GenStgRhs pass)
  - | StgRec [(BinderP pass, GenStgRhs pass)]
- data GenStgExpr (pass :: StgPass)
  - = StgApp Id [StgArg]
  - | StgLit Literal
  - | StgConApp DataCon ConstructorNumber [StgArg] [[PrimRep]]
  - | StgOpApp StgOp [StgArg] Type
  - | StgCase (GenStgExpr pass) (BinderP pass) AltType [GenStgAlt pass]
  - | StgLet (XLet pass) (GenStgBinding pass) (GenStgExpr pass)
  - | StgLetNoEscape (XLetNoEscape pass) (GenStgBinding pass) (GenStgExpr pass)
  - | StgTick StgTickish (GenStgExpr pass)
- data GenStgRhs (pass :: StgPass)
  - = StgRhsClosure (XRhsClosure pass) CostCentreStack !UpdateFlag [BinderP pass] (GenStgExpr pass) Type
  - | StgRhsCon CostCentreStack DataCon ConstructorNumber [StgTickish] [StgArg] Type
- data GenStgAlt (pass :: StgPass) = GenStgAlt {
  - alt_con :: !AltCon
  - alt_bndrs :: ![BinderP pass]
  - alt_rhs :: !(GenStgExpr pass)
  }
- data AltType
  - = PolyAlt
  - | MultiValAlt Int
  - | AlgAlt TyCon
  - | PrimAlt PrimRep
- data StgPass
  - = Vanilla
  - | LiftLams
  - | InferTaggedBinders
  - | InferTagged
  - | CodeGen
- type family BinderP (pass :: StgPass)
- type family XRhsClosure (pass :: StgPass)
- type family XLet (pass :: StgPass)
- type family XLetNoEscape (pass :: StgPass)
- data NoExtFieldSilent
- noExtFieldSilent :: NoExtFieldSilent
- type OutputablePass (pass :: StgPass) = (Outputable (XLet pass), Outputable (XLetNoEscape pass), Outputable (XRhsClosure pass), OutputableBndr (BinderP pass))
- data UpdateFlag
  - = ReEntrant
  - | Updatable
  - | SingleEntry
  - | JumpedTo
- isUpdatable :: UpdateFlag -> Bool
- data ConstructorNumber
  - = NoNumber
  - | Numbered Int
- type StgTopBinding = GenStgTopBinding 'Vanilla
- type StgBinding = GenStgBinding 'Vanilla
- type StgExpr = GenStgExpr 'Vanilla
- type StgRhs = GenStgRhs 'Vanilla
- type StgAlt = GenStgAlt 'Vanilla
- type CgStgTopBinding = GenStgTopBinding 'CodeGen
- type CgStgBinding = GenStgBinding 'CodeGen
- type CgStgExpr = GenStgExpr 'CodeGen
- type CgStgRhs = GenStgRhs 'CodeGen
- type CgStgAlt = GenStgAlt 'CodeGen
- type TgStgTopBinding = GenStgTopBinding 'CodeGen
- type TgStgBinding = GenStgBinding 'CodeGen
- type TgStgExpr = GenStgExpr 'CodeGen
- type TgStgRhs = GenStgRhs 'CodeGen
- type TgStgAlt = GenStgAlt 'CodeGen
- type LlStgTopBinding = GenStgTopBinding 'LiftLams
- type LlStgBinding = GenStgBinding 'LiftLams
- type LlStgExpr = GenStgExpr 'LiftLams
- type LlStgRhs = GenStgRhs 'LiftLams
- type LlStgAlt = GenStgAlt 'LiftLams
- type InStgArg = StgArg
- type InStgTopBinding = StgTopBinding
- type InStgBinding = StgBinding
- type InStgExpr = StgExpr
- type InStgRhs = StgRhs
- type InStgAlt = StgAlt
- type OutStgArg = StgArg
- type OutStgTopBinding = StgTopBinding
- type OutStgBinding = StgBinding
- type OutStgExpr = StgExpr
- type OutStgRhs = StgRhs
- type OutStgAlt = StgAlt
- data StgOp
  - = StgPrimOp PrimOp
  - | StgPrimCallOp PrimCall
  - | StgFCallOp ForeignCall Type
- stgRhsArity :: StgRhs -> Int
- freeVarsOfRhs :: forall (pass :: StgPass). XRhsClosure pass ~ DIdSet => GenStgRhs pass -> DIdSet
- stgArgType :: StgArg -> Type
- stgArgRep :: StgArg -> [PrimRep]
- stgArgRep1 :: StgArg -> PrimOrVoidRep
- stgArgRepU :: StgArg -> PrimRep
- stgArgRep_maybe :: StgArg -> Maybe [PrimRep]
- stgCaseBndrInScope :: AltType -> Bool -> Bool
- data StgPprOpts = StgPprOpts {
  - stgSccEnabled :: !Bool
  }
- panicStgPprOpts :: StgPprOpts
- shortStgPprOpts :: StgPprOpts
- pprStgArg :: StgArg -> SDoc
- pprStgExpr :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> GenStgExpr pass -> SDoc
- pprStgRhs :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> GenStgRhs pass -> SDoc
- pprStgBinding :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> GenStgBinding pass -> SDoc
- pprStgAlt :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> Bool -> GenStgAlt pass -> SDoc
- pprGenStgTopBinding :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> GenStgTopBinding pass -> SDoc
- pprStgTopBinding :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> GenStgTopBinding pass -> SDoc
- pprGenStgTopBindings :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> [GenStgTopBinding pass] -> SDoc
- pprStgTopBindings :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> [GenStgTopBinding pass] -> SDoc

# Documentation

data StgArg Source #

Constructors

StgVarArg Id |
StgLitArg Literal |

#### Instances

Instances details

Outputable StgArg Source # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: StgArg -> SDoc Source #

data GenStgTopBinding (pass :: StgPass) Source #

A top-level binding.

Constructors

StgTopLifted (GenStgBinding pass) |
StgTopStringLit Id ByteString |

data GenStgBinding (pass :: StgPass) Source #

Constructors

StgNonRec (BinderP pass) (GenStgRhs pass) |
StgRec [(BinderP pass, GenStgRhs pass)] |

#### Instances

Instances details

OutputablePass pass => Outputable (GenStgBinding pass) Source # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: GenStgBinding pass -> SDoc Source #

data GenStgExpr (pass :: StgPass) Source #

Constructors

StgApp Id [StgArg] |
StgLit Literal |
StgConApp DataCon ConstructorNumber [StgArg] [[PrimRep]] |
StgOpApp StgOp [StgArg] Type |
StgCase (GenStgExpr pass) (BinderP pass) AltType [GenStgAlt pass] |
StgLet (XLet pass) (GenStgBinding pass) (GenStgExpr pass) |
StgLetNoEscape (XLetNoEscape pass) (GenStgBinding pass) (GenStgExpr pass) |
StgTick StgTickish (GenStgExpr pass) |

#### Instances

Instances details

OutputablePass pass => Outputable (GenStgExpr pass) Source # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: GenStgExpr pass -> SDoc Source #

data GenStgRhs (pass :: StgPass) Source #

Constructors

StgRhsClosure |

Fields

- (XRhsClosure pass)

  Extension point for non-global free var list just before `CodeGen`.

- CostCentreStack

  CCS to be attached (default is CurrentCCS)

- !UpdateFlag

  `ReEntrant` | `Updatable` | `SingleEntry`

- [BinderP pass]

  arguments; if empty, then not a function; as above, order is important.

- (GenStgExpr pass)

  body

- Type

  result type

StgRhsCon CostCentreStack DataCon ConstructorNumber [StgTickish] [StgArg] Type |

#### Instances

Instances details

OutputablePass pass => Outputable (GenStgRhs pass) Source # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: GenStgRhs pass -> SDoc Source #

data GenStgAlt (pass :: StgPass) Source #

Constructors

GenStgAlt |

Fields

- alt_con :: !AltCon
- alt_bndrs :: ![BinderP pass]
- alt_rhs :: !(GenStgExpr pass)

data AltType Source #

Constructors

PolyAlt |
MultiValAlt Int |
AlgAlt TyCon |
PrimAlt PrimRep |

#### Instances

Instances details

Outputable AltType Source # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: AltType -> SDoc Source #

data StgPass Source #

Used as a data type index for the stgSyn AST

Constructors

Vanilla |
LiftLams | Use internally by the lambda lifting pass
InferTaggedBinders | Tag inference information on binders. See Note [Tag inference passes] in GHC.Stg.InferTags
InferTagged | Tag inference information put on relevant StgApp nodes See Note [Tag inference passes] in GHC.Stg.InferTags
CodeGen |

type family BinderP (pass :: StgPass) Source #

#### Instances

Instances details

type BinderP 'CodeGen Source # |
Instance details Defined in GHC.Stg.Syntax type BinderP 'CodeGen = Id
type BinderP 'InferTagged Source # |
Instance details Defined in GHC.Stg.Syntax type BinderP 'InferTagged = Id
type BinderP 'InferTaggedBinders Source # |
Instance details Defined in GHC.Stg.Syntax type BinderP 'InferTaggedBinders = (Id, TagSig)
type BinderP 'LiftLams Source # |
Instance details Defined in GHC.Stg.Syntax type BinderP 'LiftLams = BinderInfo
type BinderP 'Vanilla Source # |
Instance details Defined in GHC.Stg.Syntax type BinderP 'Vanilla = Id

type family XRhsClosure (pass :: StgPass) Source #

#### Instances

Instances details

type XRhsClosure 'CodeGen Source # | Code gen needs to track non-global free vars
Instance details Defined in GHC.Stg.Syntax type XRhsClosure 'CodeGen = DIdSet
type XRhsClosure 'InferTagged Source # |
Instance details Defined in GHC.Stg.Syntax type XRhsClosure 'InferTagged = NoExtFieldSilent
type XRhsClosure 'InferTaggedBinders Source # |
Instance details Defined in GHC.Stg.Syntax type XRhsClosure 'InferTaggedBinders = XRhsClosure 'CodeGen
type XRhsClosure 'LiftLams Source # |
Instance details Defined in GHC.Stg.Syntax type XRhsClosure 'LiftLams = DIdSet
type XRhsClosure 'Vanilla Source # |
Instance details Defined in GHC.Stg.Syntax type XRhsClosure 'Vanilla = NoExtFieldSilent

type family XLet (pass :: StgPass) Source #

#### Instances

Instances details

type XLet 'CodeGen Source # |
Instance details Defined in GHC.Stg.Syntax type XLet 'CodeGen = NoExtFieldSilent
type XLet 'InferTagged Source # |
Instance details Defined in GHC.Stg.Syntax type XLet 'InferTagged = NoExtFieldSilent
type XLet 'InferTaggedBinders Source # |
Instance details Defined in GHC.Stg.Syntax type XLet 'InferTaggedBinders = XLet 'CodeGen
type XLet 'LiftLams Source # |
Instance details Defined in GHC.Stg.Syntax type XLet 'LiftLams = Skeleton
type XLet 'Vanilla Source # |
Instance details Defined in GHC.Stg.Syntax type XLet 'Vanilla = NoExtFieldSilent

type family XLetNoEscape (pass :: StgPass) Source #

#### Instances

Instances details

type XLetNoEscape 'CodeGen Source # |
Instance details Defined in GHC.Stg.Syntax type XLetNoEscape 'CodeGen = NoExtFieldSilent
type XLetNoEscape 'InferTagged Source # |
Instance details Defined in GHC.Stg.Syntax type XLetNoEscape 'InferTagged = NoExtFieldSilent
type XLetNoEscape 'InferTaggedBinders Source # |
Instance details Defined in GHC.Stg.Syntax type XLetNoEscape 'InferTaggedBinders = XLetNoEscape 'CodeGen
type XLetNoEscape 'LiftLams Source # |
Instance details Defined in GHC.Stg.Syntax type XLetNoEscape 'LiftLams = Skeleton
type XLetNoEscape 'Vanilla Source # |
Instance details Defined in GHC.Stg.Syntax type XLetNoEscape 'Vanilla = NoExtFieldSilent

data NoExtFieldSilent Source #

Like `NoExtField`, but with an `Outputable` instance that returns `empty`.

#### Instances

Instances details

Data NoExtFieldSilent Source # |

Instance details

Defined in GHC.Stg.Syntax

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NoExtFieldSilent -> c NoExtFieldSilent Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NoExtFieldSilent Source #

toConstr :: NoExtFieldSilent -> Constr Source #

dataTypeOf :: NoExtFieldSilent -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c NoExtFieldSilent) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NoExtFieldSilent) Source #

gmapT :: (forall b. Data b => b -> b) -> NoExtFieldSilent -> NoExtFieldSilent Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NoExtFieldSilent -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NoExtFieldSilent -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> NoExtFieldSilent -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> NoExtFieldSilent -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> NoExtFieldSilent -> m NoExtFieldSilent Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NoExtFieldSilent -> m NoExtFieldSilent Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NoExtFieldSilent -> m NoExtFieldSilent Source #

Outputable NoExtFieldSilent Source # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: NoExtFieldSilent -> SDoc Source #
Eq NoExtFieldSilent Source # |
Instance details Defined in GHC.Stg.Syntax Methods (==) :: NoExtFieldSilent -> NoExtFieldSilent -> Bool Source # (/=) :: NoExtFieldSilent -> NoExtFieldSilent -> Bool Source #
Ord NoExtFieldSilent Source # |

Instance details

Defined in GHC.Stg.Syntax

Methods

compare :: NoExtFieldSilent -> NoExtFieldSilent -> Ordering Source #

(<) :: NoExtFieldSilent -> NoExtFieldSilent -> Bool Source #

(<=) :: NoExtFieldSilent -> NoExtFieldSilent -> Bool Source #

(>) :: NoExtFieldSilent -> NoExtFieldSilent -> Bool Source #

(>=) :: NoExtFieldSilent -> NoExtFieldSilent -> Bool Source #

max :: NoExtFieldSilent -> NoExtFieldSilent -> NoExtFieldSilent Source #

min :: NoExtFieldSilent -> NoExtFieldSilent -> NoExtFieldSilent Source #

noExtFieldSilent :: NoExtFieldSilent Source #

Used when constructing a term with an unused extension point that should not appear in pretty-printed output at all.

type OutputablePass (pass :: StgPass) = (Outputable (XLet pass), Outputable (XLetNoEscape pass), Outputable (XRhsClosure pass), OutputableBndr (BinderP pass)) Source #

data UpdateFlag Source #

Constructors

ReEntrant | A `ReEntrant` closure may be entered multiple times, but should not be updated or blackholed.
Updatable | An `Updatable` closure should be updated after evaluation (and may be blackholed during evaluation).
SingleEntry | A `SingleEntry` closure will only be entered once, and so need not be updated but may safely be blackholed.
JumpedTo | A `JumpedTo` (join-point) closure is entered once or multiple times but has no heap-allocated associated closure.

#### Instances

Instances details

Show UpdateFlag Source # |
Instance details Defined in GHC.Stg.Syntax Methods showsPrec :: Int -> UpdateFlag -> ShowS Source # show :: UpdateFlag -> String Source # showList :: [UpdateFlag] -> ShowS Source #
Outputable UpdateFlag Source # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: UpdateFlag -> SDoc Source #
Eq UpdateFlag Source # |
Instance details Defined in GHC.Stg.Syntax Methods (==) :: UpdateFlag -> UpdateFlag -> Bool Source # (/=) :: UpdateFlag -> UpdateFlag -> Bool Source #

isUpdatable :: UpdateFlag -> Bool Source #

data ConstructorNumber Source #

When `-fdistinct-constructor-tables` is turned on then each usage of a constructor is given an unique number and an info table is generated for each different constructor.

Constructors

NoNumber |
Numbered Int |

#### Instances

Instances details

Outputable ConstructorNumber Source # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: ConstructorNumber -> SDoc Source #

type StgTopBinding = GenStgTopBinding 'Vanilla Source #

type StgBinding = GenStgBinding 'Vanilla Source #

type StgExpr = GenStgExpr 'Vanilla Source #

type StgRhs = GenStgRhs 'Vanilla Source #

type StgAlt = GenStgAlt 'Vanilla Source #

type CgStgTopBinding = GenStgTopBinding 'CodeGen Source #

type CgStgBinding = GenStgBinding 'CodeGen Source #

type CgStgExpr = GenStgExpr 'CodeGen Source #

type CgStgRhs = GenStgRhs 'CodeGen Source #

type CgStgAlt = GenStgAlt 'CodeGen Source #

type TgStgTopBinding = GenStgTopBinding 'CodeGen Source #

type TgStgBinding = GenStgBinding 'CodeGen Source #

type TgStgExpr = GenStgExpr 'CodeGen Source #

type TgStgRhs = GenStgRhs 'CodeGen Source #

type TgStgAlt = GenStgAlt 'CodeGen Source #

type LlStgTopBinding = GenStgTopBinding 'LiftLams Source #

type LlStgBinding = GenStgBinding 'LiftLams Source #

type LlStgExpr = GenStgExpr 'LiftLams Source #

type LlStgRhs = GenStgRhs 'LiftLams Source #

type LlStgAlt = GenStgAlt 'LiftLams Source #

type InStgArg = StgArg Source #

type InStgTopBinding = StgTopBinding Source #

type InStgBinding = StgBinding Source #

type InStgExpr = StgExpr Source #

type InStgRhs = StgRhs Source #

type InStgAlt = StgAlt Source #

type OutStgArg = StgArg Source #

type OutStgTopBinding = StgTopBinding Source #

type OutStgBinding = StgBinding Source #

type OutStgExpr = StgExpr Source #

type OutStgRhs = StgRhs Source #

type OutStgAlt = StgAlt Source #

data StgOp Source #

Constructors

StgPrimOp PrimOp |
StgPrimCallOp PrimCall |
StgFCallOp ForeignCall Type |

#### Instances

Instances details

Outputable StgOp Source # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: StgOp -> SDoc Source #

stgRhsArity :: StgRhs -> Int Source #

freeVarsOfRhs :: forall (pass :: StgPass). XRhsClosure pass ~ DIdSet => GenStgRhs pass -> DIdSet Source #

stgArgType :: StgArg -> Type Source #

Type of an `StgArg`

Very half baked because we have lost the type arguments.

This function should be avoided: in STG we aren't supposed to look at types, but only PrimReps. Use `stgArgRep`, `stgArgRep_maybe`, `stgArgRep1` instaed.

stgArgRep :: StgArg -> [PrimRep] Source #

stgArgRep1 :: StgArg -> PrimOrVoidRep Source #

Assumes that the argument has at most one PrimRep, which holds after unarisation. See Note [Post-unarisation invariants] in GHC.Stg.Unarise. See Note [VoidRep] in GHC.Types.RepType.

stgArgRepU :: StgArg -> PrimRep Source #

Assumes that the argument has exactly one PrimRep. See Note [VoidRep] in GHC.Types.RepType.

stgArgRep_maybe :: StgArg -> Maybe [PrimRep] Source #

stgCaseBndrInScope Source #

Arguments

:: AltType |
-> Bool | unarised?
-> Bool |

Given an alt type and whether the program is unarised, return whether the case binder is in scope.

Case binders of unboxed tuple or unboxed sum type always dead after the unariser has run. See Note [Post-unarisation invariants] in GHC.Stg.Unarise.

data StgPprOpts Source #

STG pretty-printing options

Constructors

StgPprOpts |

Fields

- stgSccEnabled :: !Bool

  Enable cost-centres

panicStgPprOpts :: StgPprOpts Source #

STG pretty-printing options used for panic messages

shortStgPprOpts :: StgPprOpts Source #

STG pretty-printing options used for short messages

pprStgArg :: StgArg -> SDoc Source #

pprStgExpr :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> GenStgExpr pass -> SDoc Source #

pprStgRhs :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> GenStgRhs pass -> SDoc Source #

pprStgBinding :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> GenStgBinding pass -> SDoc Source #

pprStgAlt :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> Bool -> GenStgAlt pass -> SDoc Source #

pprGenStgTopBinding :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> GenStgTopBinding pass -> SDoc Source #

pprStgTopBinding :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> GenStgTopBinding pass -> SDoc Source #

pprGenStgTopBindings :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> [GenStgTopBinding pass] -> SDoc Source #

pprStgTopBindings :: forall (pass :: StgPass). OutputablePass pass => StgPprOpts -> [GenStgTopBinding pass] -> SDoc Source #