ghc-lib-parser-9.10.1.20250103: 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
- 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
- isDllConApp :: Platform -> Bool -> Module -> DataCon -> [StgArg] -> Bool
- 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 #

Constructors

StgVarArg Id |
StgLitArg Literal |

#### Instances

Instances details

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

data GenStgTopBinding (pass :: StgPass) #

A top-level binding.

Constructors

StgTopLifted (GenStgBinding pass) |
StgTopStringLit Id ByteString |

data GenStgBinding (pass :: StgPass) #

Constructors

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

#### Instances

Instances details

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

data GenStgExpr (pass :: StgPass) #

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) # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: GenStgExpr pass -> SDoc #

data GenStgRhs (pass :: StgPass) #

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) # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: GenStgRhs pass -> SDoc #

data GenStgAlt (pass :: StgPass) #

Constructors

GenStgAlt |

Fields

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

data AltType #

Constructors

PolyAlt |
MultiValAlt Int |
AlgAlt TyCon |
PrimAlt PrimRep |

#### Instances

Instances details

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

data StgPass #

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) #

#### Instances

Instances details

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

type family XRhsClosure (pass :: StgPass) #

#### Instances

Instances details

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

type family XLet (pass :: StgPass) #

#### Instances

Instances details

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

type family XLetNoEscape (pass :: StgPass) #

#### Instances

Instances details

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

data NoExtFieldSilent #

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

#### Instances

Instances details

Data NoExtFieldSilent # |

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 #

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

toConstr :: NoExtFieldSilent -> Constr #

dataTypeOf :: NoExtFieldSilent -> DataType #

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

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

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

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

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

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

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

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

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

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

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

Instance details

Defined in GHC.Stg.Syntax

Methods

compare :: NoExtFieldSilent -> NoExtFieldSilent -> Ordering #

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

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

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

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

max :: NoExtFieldSilent -> NoExtFieldSilent -> NoExtFieldSilent #

min :: NoExtFieldSilent -> NoExtFieldSilent -> NoExtFieldSilent #

noExtFieldSilent :: NoExtFieldSilent #

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)) #

data UpdateFlag #

Constructors

ReEntrant |
Updatable |
SingleEntry |

#### Instances

Instances details

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

isUpdatable :: UpdateFlag -> Bool #

data ConstructorNumber #

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 # |
Instance details Defined in GHC.Stg.Syntax Methods ppr :: ConstructorNumber -> SDoc #

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 #

Constructors

StgPrimOp PrimOp |
StgPrimCallOp PrimCall |
StgFCallOp ForeignCall Type |

#### Instances

Instances details

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

stgRhsArity :: StgRhs -> Int #

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

isDllConApp :: Platform -> Bool -> Module -> DataCon -> [StgArg] -> Bool #

Does this constructor application refer to anything in a different *Windows* DLL? If so, we can't allocate it statically

stgArgType :: StgArg -> Type #

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] #

stgArgRep1 :: StgArg -> PrimOrVoidRep #

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 #

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

stgArgRep_maybe :: StgArg -> Maybe [PrimRep] #

stgCaseBndrInScope #

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 #

STG pretty-printing options

Constructors

StgPprOpts |

Fields

- stgSccEnabled :: !Bool

  Enable cost-centres

panicStgPprOpts :: StgPprOpts #

STG pretty-printing options used for panic messages

shortStgPprOpts :: StgPprOpts #

STG pretty-printing options used for short messages

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 #