ghc-9.10.3: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.StgToCmm.Monad

Synopsis

- data FCode a
- initC :: IO CgState
- initFCodeState :: Platform -> FCodeState
- runC :: StgToCmmConfig -> FCodeState -> CgState -> FCode a -> (a, CgState)
- fixC :: (a -> FCode a) -> FCode a
- newUnique :: FCode Unique
- emitLabel :: BlockId -> FCode ()
- emit :: CmmAGraph -> FCode ()
- emitDecl :: CmmDecl -> FCode ()
- emitProcWithConvention :: Convention -> Maybe CmmInfoTable -> CLabel -> [CmmFormal] -> CmmAGraphScoped -> FCode ()
- emitProcWithStackFrame :: Convention -> Maybe CmmInfoTable -> CLabel -> [CmmFormal] -> [CmmFormal] -> CmmAGraphScoped -> Bool -> FCode ()
- emitOutOfLine :: BlockId -> CmmAGraphScoped -> FCode ()
- emitAssign :: CmmReg -> CmmExpr -> FCode ()
- emitStore :: CmmExpr -> CmmExpr -> FCode ()
- emitStore' :: AlignmentSpec -> CmmExpr -> CmmExpr -> FCode ()
- emitComment :: FastString -> FCode ()
- emitTick :: CmmTickish -> FCode ()
- emitUnwind :: [(GlobalReg, Maybe CmmExpr)] -> FCode ()
- newTemp :: MonadUnique m => CmmType -> m LocalReg
- getCmm :: FCode a -> FCode (a, CmmGroup)
- aGraphToGraph :: CmmAGraphScoped -> FCode CmmGraph
- getPlatform :: FCode Platform
- getProfile :: FCode Profile
- getCodeR :: FCode a -> FCode (a, CmmAGraph)
- getCode :: FCode a -> FCode CmmAGraph
- getCodeScoped :: FCode a -> FCode (a, CmmAGraphScoped)
- getHeapUsage :: (VirtualHpOffset -> FCode a) -> FCode a
- getContext :: FCode SDocContext
- mkCmmIfThenElse :: CmmExpr -> CmmAGraph -> CmmAGraph -> FCode CmmAGraph
- mkCmmIfThen :: CmmExpr -> CmmAGraph -> FCode CmmAGraph
- mkCmmIfGoto :: CmmExpr -> BlockId -> FCode CmmAGraph
- mkCmmIfThenElse' :: CmmExpr -> CmmAGraph -> CmmAGraph -> Maybe Bool -> FCode CmmAGraph
- mkCmmIfThen' :: CmmExpr -> CmmAGraph -> Maybe Bool -> FCode CmmAGraph
- mkCmmIfGoto' :: CmmExpr -> BlockId -> Maybe Bool -> FCode CmmAGraph
- mkCall :: CmmExpr -> (Convention, Convention) -> [CmmFormal] -> [CmmExpr] -> UpdFrameOffset -> [CmmExpr] -> FCode CmmAGraph
- mkCmmCall :: CmmExpr -> [CmmFormal] -> [CmmExpr] -> UpdFrameOffset -> FCode CmmAGraph
- forkClosureBody :: FCode () -> FCode ()
- forkLneBody :: FCode a -> FCode a
- forkAlts :: [FCode a] -> FCode [a]
- forkAltPair :: FCode a -> FCode a -> FCode (a, a)
- codeOnly :: FCode () -> FCode ()
- type ConTagZ = Int
- data Sequel
  - = Return
  - | AssignTo [LocalReg] Bool
- data ReturnKind
  - = AssignedDirectly
  - | ReturnedTo BlockId ByteOff
- withSequel :: Sequel -> FCode a -> FCode a
- getSequel :: FCode Sequel
- data SelfLoopInfo = MkSelfLoopInfo {
  - sli_id :: !Id
  - sli_arity :: !RepArity
  - sli_registers :: ![LocalReg]
  - sli_header_block :: !BlockId
  }
- setTickyCtrLabel :: CLabel -> FCode a -> FCode a
- getTickyCtrLabel :: FCode CLabel
- tickScope :: FCode a -> FCode a
- getTickScope :: FCode CmmTickScope
- withUpdFrameOff :: UpdFrameOffset -> FCode a -> FCode a
- getUpdFrameOff :: FCode UpdFrameOffset
- data HeapUsage = HeapUsage {
  - virtHp :: VirtualHpOffset
  - realHp :: VirtualHpOffset
  }
- type VirtualHpOffset = WordOff
- initHpUsage :: HeapUsage
- getHpUsage :: FCode HeapUsage
- setHpUsage :: HeapUsage -> FCode ()
- heapHWM :: HeapUsage -> VirtualHpOffset
- setVirtHp :: VirtualHpOffset -> FCode ()
- getVirtHp :: FCode VirtualHpOffset
- setRealHp :: VirtualHpOffset -> FCode ()
- getModuleName :: FCode Module
- getState :: FCode CgState
- setState :: CgState -> FCode ()
- getSelfLoop :: FCode (Maybe SelfLoopInfo)
- withSelfLoop :: SelfLoopInfo -> FCode a -> FCode a
- getStgToCmmConfig :: FCode StgToCmmConfig
- data CgIdInfo = CgIdInfo {
  - cg_id :: Id
  - cg_lf :: LambdaFormInfo
  - cg_loc :: CgLoc
  }
- getBinds :: FCode CgBindings
- setBinds :: CgBindings -> FCode ()
- data StgToCmmConfig = StgToCmmConfig {
  - stgToCmmProfile :: !Profile
  - stgToCmmThisModule :: Module
  - stgToCmmTmpDir :: !TempDir
  - stgToCmmContext :: !SDocContext
  - stgToCmmEmitDebugInfo :: !Bool
  - stgToCmmBinBlobThresh :: !(Maybe Word)
  - stgToCmmMaxInlAllocSize :: !Int
  - stgToCmmDoTicky :: !Bool
  - stgToCmmTickyAllocd :: !Bool
  - stgToCmmTickyLNE :: !Bool
  - stgToCmmTickyDynThunk :: !Bool
  - stgToCmmTickyTag :: !Bool
  - stgToCmmLoopification :: !Bool
  - stgToCmmAlignCheck :: !Bool
  - stgToCmmOptHpc :: !Bool
  - stgToCmmFastPAPCalls :: !Bool
  - stgToCmmSCCProfiling :: !Bool
  - stgToCmmEagerBlackHole :: !Bool
  - stgToCmmOrigThunkInfo :: !Bool
  - stgToCmmInfoTableMap :: !Bool
  - stgToCmmInfoTableMapWithFallback :: !Bool
  - stgToCmmInfoTableMapWithStack :: !Bool
  - stgToCmmOmitYields :: !Bool
  - stgToCmmOmitIfPragmas :: !Bool
  - stgToCmmPIC :: !Bool
  - stgToCmmPIE :: !Bool
  - stgToCmmExtDynRefs :: !Bool
  - stgToCmmDoBoundsCheck :: !Bool
  - stgToCmmDoTagCheck :: !Bool
  - stgToCmmAllowBigArith :: !Bool
  - stgToCmmAllowBigQuot :: !Bool
  - stgToCmmAllowQuotRemInstr :: !Bool
  - stgToCmmAllowQuotRem2 :: !Bool
  - stgToCmmAllowExtendedAddSubInstrs :: !Bool
  - stgToCmmAllowIntMul2Instr :: !Bool
  - stgToCmmAllowWordMul2Instr :: !Bool
  - stgToCmmAllowFMAInstr :: FMASign -> Bool
  - stgToCmmTickyAP :: !Bool
  - stgToCmmSaveFCallTargetToLocal :: !Bool
  - stgToCmmVecInstrsErr :: Maybe String
  - stgToCmmAvx :: !Bool
  - stgToCmmAvx2 :: !Bool
  - stgToCmmAvx512f :: !Bool
  }
- data CgState = MkCgState {
  - cgs_stmts :: CmmAGraph
  - cgs_tops :: OrdList CmmDecl
  - cgs_binds :: CgBindings
  - cgs_hp_usg :: HeapUsage
  - cgs_uniqs :: UniqSupply
  }

# Documentation

data FCode a Source #

#### Instances

Instances details

MonadUnique FCode Source # |
Instance details Defined in GHC.StgToCmm.Monad Methods getUniqueSupplyM :: FCode UniqSupply Source # getUniqueM :: FCode Unique Source # getUniquesM :: FCode [Unique] Source #
Applicative FCode Source # |
Instance details Defined in GHC.StgToCmm.Monad Methods pure :: a -> FCode a # (<*>) :: FCode (a -> b) -> FCode a -> FCode b # liftA2 :: (a -> b -> c) -> FCode a -> FCode b -> FCode c # (*>) :: FCode a -> FCode b -> FCode b # (<*) :: FCode a -> FCode b -> FCode a #
Functor FCode Source # |
Instance details Defined in GHC.StgToCmm.Monad Methods fmap :: (a -> b) -> FCode a -> FCode b # (<$) :: a -> FCode b -> FCode a #
Monad FCode Source # |
Instance details Defined in GHC.StgToCmm.Monad Methods (>>=) :: FCode a -> (a -> FCode b) -> FCode b # (>>) :: FCode a -> FCode b -> FCode b # return :: a -> FCode a #

initC :: IO CgState Source #

initFCodeState :: Platform -> FCodeState Source #

runC :: StgToCmmConfig -> FCodeState -> CgState -> FCode a -> (a, CgState) Source #

fixC :: (a -> FCode a) -> FCode a Source #

newUnique :: FCode Unique Source #

emitLabel :: BlockId -> FCode () Source #

emit :: CmmAGraph -> FCode () Source #

emitDecl :: CmmDecl -> FCode () Source #

emitProcWithConvention :: Convention -> Maybe CmmInfoTable -> CLabel -> [CmmFormal] -> CmmAGraphScoped -> FCode () Source #

emitProcWithStackFrame :: Convention -> Maybe CmmInfoTable -> CLabel -> [CmmFormal] -> [CmmFormal] -> CmmAGraphScoped -> Bool -> FCode () Source #

emitOutOfLine :: BlockId -> CmmAGraphScoped -> FCode () Source #

emitAssign :: CmmReg -> CmmExpr -> FCode () Source #

emitStore :: CmmExpr -> CmmExpr -> FCode () Source #

Assumes natural alignment.

emitStore' :: AlignmentSpec -> CmmExpr -> CmmExpr -> FCode () Source #

emitComment :: FastString -> FCode () Source #

emitTick :: CmmTickish -> FCode () Source #

emitUnwind :: [(GlobalReg, Maybe CmmExpr)] -> FCode () Source #

newTemp :: MonadUnique m => CmmType -> m LocalReg Source #

getCmm :: FCode a -> FCode (a, CmmGroup) Source #

aGraphToGraph :: CmmAGraphScoped -> FCode CmmGraph Source #

getPlatform :: FCode Platform Source #

getProfile :: FCode Profile Source #

getCodeR :: FCode a -> FCode (a, CmmAGraph) Source #

getCode :: FCode a -> FCode CmmAGraph Source #

getCodeScoped :: FCode a -> FCode (a, CmmAGraphScoped) Source #

Generate code into a fresh tick (sub-)scope and gather generated code

getHeapUsage :: (VirtualHpOffset -> FCode a) -> FCode a Source #

getContext :: FCode SDocContext Source #

mkCmmIfThenElse :: CmmExpr -> CmmAGraph -> CmmAGraph -> FCode CmmAGraph Source #

mkCmmIfThen :: CmmExpr -> CmmAGraph -> FCode CmmAGraph Source #

mkCmmIfGoto :: CmmExpr -> BlockId -> FCode CmmAGraph Source #

mkCmmIfThenElse' :: CmmExpr -> CmmAGraph -> CmmAGraph -> Maybe Bool -> FCode CmmAGraph Source #

mkCmmIfThen' :: CmmExpr -> CmmAGraph -> Maybe Bool -> FCode CmmAGraph Source #

mkCmmIfGoto' :: CmmExpr -> BlockId -> Maybe Bool -> FCode CmmAGraph Source #

mkCall :: CmmExpr -> (Convention, Convention) -> [CmmFormal] -> [CmmExpr] -> UpdFrameOffset -> [CmmExpr] -> FCode CmmAGraph Source #

mkCmmCall :: CmmExpr -> [CmmFormal] -> [CmmExpr] -> UpdFrameOffset -> FCode CmmAGraph Source #

forkClosureBody :: FCode () -> FCode () Source #

forkLneBody :: FCode a -> FCode a Source #

forkAlts :: [FCode a] -> FCode [a] Source #

forkAltPair :: FCode a -> FCode a -> FCode (a, a) Source #

codeOnly :: FCode () -> FCode () Source #

type ConTagZ = Int Source #

A *zero-indexed* constructor tag

data Sequel Source #

A Sequel tells what to do with the result of this expression

Constructors

Return | Return result(s) to continuation found on the stack.
AssignTo |

Fields

- [LocalReg]

  Put result(s) in these regs and fall through NB: no void arguments here

- Bool

  Should we adjust the heap pointer back to recover space that's unused on this path? We need to do this only if the expression may allocate (e.g. it's a foreign call or allocating primOp)

#### Instances

Instances details

Outputable Sequel Source # |
Instance details Defined in GHC.StgToCmm.Sequel Methods ppr :: Sequel -> SDoc Source #

data ReturnKind Source #

Constructors

AssignedDirectly |
ReturnedTo BlockId ByteOff |

withSequel :: Sequel -> FCode a -> FCode a Source #

getSequel :: FCode Sequel Source #

data SelfLoopInfo Source #

Constructors

MkSelfLoopInfo |

Fields

- sli_id :: !Id
- sli_arity :: !RepArity

  always equal to `idFunRepArity` of sli_id, i.e. unarised arity, including void arguments

- sli_registers :: ![LocalReg]

  Excludes void arguments (LocalReg is never void)

- sli_header_block :: !BlockId

setTickyCtrLabel :: CLabel -> FCode a -> FCode a Source #

getTickyCtrLabel :: FCode CLabel Source #

tickScope :: FCode a -> FCode a Source #

Places blocks generated by the given code into a fresh (sub-)scope. This will make sure that Cmm annotations in our scope will apply to the Cmm blocks generated therein - but not the other way around.

getTickScope :: FCode CmmTickScope Source #

The current tick scope. We will assign this to generated blocks.

withUpdFrameOff :: UpdFrameOffset -> FCode a -> FCode a Source #

getUpdFrameOff :: FCode UpdFrameOffset Source #

data HeapUsage Source #

Constructors

HeapUsage |

Fields

- virtHp :: VirtualHpOffset
- realHp :: VirtualHpOffset

type VirtualHpOffset = WordOff Source #

initHpUsage :: HeapUsage Source #

getHpUsage :: FCode HeapUsage Source #

setHpUsage :: HeapUsage -> FCode () Source #

heapHWM :: HeapUsage -> VirtualHpOffset Source #

setVirtHp :: VirtualHpOffset -> FCode () Source #

getVirtHp :: FCode VirtualHpOffset Source #

setRealHp :: VirtualHpOffset -> FCode () Source #

getModuleName :: FCode Module Source #

getState :: FCode CgState Source #

setState :: CgState -> FCode () Source #

getSelfLoop :: FCode (Maybe SelfLoopInfo) Source #

withSelfLoop :: SelfLoopInfo -> FCode a -> FCode a Source #

getStgToCmmConfig :: FCode StgToCmmConfig Source #

data CgIdInfo Source #

Constructors

CgIdInfo |

Fields

- cg_id :: Id

  Id that this is the info for

- cg_lf :: LambdaFormInfo
- cg_loc :: CgLoc

  `CmmExpr` for the *tagged* value

#### Instances

Instances details

OutputableP Platform CgIdInfo Source # |
Instance details Defined in GHC.StgToCmm.Monad Methods pdoc :: Platform -> CgIdInfo -> SDoc Source #

getBinds :: FCode CgBindings Source #

setBinds :: CgBindings -> FCode () Source #

data StgToCmmConfig Source #

Constructors

StgToCmmConfig |

Fields

- stgToCmmProfile :: !Profile

  Current profile

- stgToCmmThisModule :: Module

  The module being compiled. This field kept lazy for Cmm/Parser.y which preloads it with a panic

- stgToCmmTmpDir :: !TempDir

  Temp Dir for files used in compilation

- stgToCmmContext :: !SDocContext

  Context for StgToCmm phase

- stgToCmmEmitDebugInfo :: !Bool

  Whether we wish to output debug information

- stgToCmmBinBlobThresh :: !(Maybe Word)

  Threshold at which Binary literals (e.g. strings) are either dumped to a file and a CmmFileEmbed literal is emitted (over threshold), or become a CmmString Literal (under or at threshold). CmmFileEmbed is only supported with the NCG, thus a Just means two things: We have a threshold, and will be using the NCG. Conversely, a Nothing implies we are not using NCG and disables CmmFileEmbed. See Note [Embedding large binary blobs] in GHC.CmmToAsm.Ppr, and `cgTopBinding` in GHC.StgToCmm.

- stgToCmmMaxInlAllocSize :: !Int

  Max size, in bytes, of inline array allocations.

- stgToCmmDoTicky :: !Bool

  Ticky profiling enabled (cf `-ticky`)

- stgToCmmTickyAllocd :: !Bool

  True indicates ticky prof traces allocs of each named thing in addition to allocs _by_ that thing

- stgToCmmTickyLNE :: !Bool

  True indicates ticky uses name-specific counters for join-points (let-no-escape)

- stgToCmmTickyDynThunk :: !Bool

  True indicates ticky uses name-specific counters for dynamic thunks

- stgToCmmTickyTag :: !Bool

  True indicates ticky will count number of avoided tag checks by tag inference.

- stgToCmmLoopification :: !Bool

  Loopification enabled (cf `-floopification`)

- stgToCmmAlignCheck :: !Bool

  Insert alignment check (cf `-falignment-sanitisation`)

- stgToCmmOptHpc :: !Bool

  perform code generation for code coverage

- stgToCmmFastPAPCalls :: !Bool
- stgToCmmSCCProfiling :: !Bool

  Check if cost-centre profiling is enabled

- stgToCmmEagerBlackHole :: !Bool
- stgToCmmOrigThunkInfo :: !Bool

  Push `stg_orig_thunk_info` frames during thunk update.

- stgToCmmInfoTableMap :: !Bool

  true means generate C Stub for IPE map, See Note [Mapping Info Tables to Source Positions]

- stgToCmmInfoTableMapWithFallback :: !Bool

  Include info tables with fallback source locations in the info table map

- stgToCmmInfoTableMapWithStack :: !Bool

  Include info tables for STACK closures in the info table map

- stgToCmmOmitYields :: !Bool

  true means omit heap checks when no allocation is performed

- stgToCmmOmitIfPragmas :: !Bool

  true means don't generate interface programs (implied by -O0)

- stgToCmmPIC :: !Bool

  true if `-fPIC`

- stgToCmmPIE :: !Bool

  true if `-fPIE`

- stgToCmmExtDynRefs :: !Bool

  true if `-fexternal-dynamic-refs`, meaning generate code for linking against dynamic libraries

- stgToCmmDoBoundsCheck :: !Bool

  decides whether to check array bounds in StgToCmm.Prim or not

- stgToCmmDoTagCheck :: !Bool

  Verify tag inference predictions.

- stgToCmmAllowBigArith :: !Bool

  Allowed to emit larger than native size arithmetic (only LLVM and C backends)

- stgToCmmAllowBigQuot :: !Bool

  Allowed to emit larger than native size division operations

- stgToCmmAllowQuotRemInstr :: !Bool

  Allowed to generate QuotRem instructions

- stgToCmmAllowQuotRem2 :: !Bool

  Allowed to generate QuotRem

- stgToCmmAllowExtendedAddSubInstrs :: !Bool

  Allowed to generate AddWordC, SubWordC, Add2, etc.

- stgToCmmAllowIntMul2Instr :: !Bool

  Allowed to generate IntMul2 instruction

- stgToCmmAllowWordMul2Instr :: !Bool

  Allowed to generate WordMul2 instruction

- stgToCmmAllowFMAInstr :: FMASign -> Bool

  Allowed to generate FMA instruction

- stgToCmmTickyAP :: !Bool

  Disable use of precomputed standard thunks.

- stgToCmmSaveFCallTargetToLocal :: !Bool

  Save a foreign call target to a Cmm local, see Note [Saving foreign call target to local] for details

- stgToCmmVecInstrsErr :: Maybe String

  Error (if any) to raise when vector instructions are used, see `StgToCmm.Prim.checkVecCompatibility`

- stgToCmmAvx :: !Bool

  check for Advanced Vector Extensions

- stgToCmmAvx2 :: !Bool

  check for Advanced Vector Extensions 2

- stgToCmmAvx512f :: !Bool

  check for Advanced Vector 512-bit Extensions

data CgState Source #

Constructors

MkCgState |

Fields

- cgs_stmts :: CmmAGraph
- cgs_tops :: OrdList CmmDecl
- cgs_binds :: CgBindings
- cgs_hp_usg :: HeapUsage
- cgs_uniqs :: UniqSupply