ghc-8.2.2: The GHC API

Safe Haskell | None
Language | Haskell2010

StgCmmMonad

Synopsis

- data FCode a
- initC :: IO CgState
- runC :: DynFlags -> Module -> CgState -> FCode a -> (a, CgState)
- thenC :: FCode () -> FCode a -> FCode a
- thenFC :: FCode a -> (a -> FCode c) -> FCode c
- listCs :: [FCode ()] -> FCode ()
- returnFC :: a -> FCode a
- fixC :: (a -> FCode a) -> FCode a
- newUnique :: FCode Unique
- newUniqSupply :: FCode UniqSupply
- emitLabel :: BlockId -> FCode ()
- emit :: CmmAGraph -> FCode ()
- emitDecl :: CmmDecl -> FCode ()
- emitProc :: Maybe CmmInfoTable -> CLabel -> [GlobalReg] -> CmmAGraphScoped -> Int -> 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 ()
- emitComment :: FastString -> FCode ()
- emitTick :: CmmTickish -> FCode ()
- emitUnwind :: [(GlobalReg, Maybe CmmExpr)] -> FCode ()
- getCmm :: FCode () -> FCode CmmGroup
- aGraphToGraph :: CmmAGraphScoped -> FCode CmmGraph
- getCodeR :: FCode a -> FCode (a, CmmAGraph)
- getCode :: FCode a -> FCode CmmAGraph
- getCodeScoped :: FCode a -> FCode (a, CmmAGraphScoped)
- getHeapUsage :: (VirtualHpOffset -> FCode a) -> FCode a
- 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]
- 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
- 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
- initUpdFrameOff :: DynFlags -> 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
- getInfoDown :: FCode CgInfoDownwards
- getDynFlags :: HasDynFlags m => m DynFlags
- getThisPackage :: FCode UnitId
- data CgIdInfo = CgIdInfo {
  - cg_id :: Id
  - cg_lf :: LambdaFormInfo
  - cg_loc :: CgLoc
  }
- getBinds :: FCode CgBindings
- setBinds :: CgBindings -> FCode ()
- data CgInfoDownwards = MkCgInfoDown {
  - cgd_dflags :: DynFlags
  - cgd_mod :: Module
  - cgd_updfr_off :: UpdFrameOffset
  - cgd_ticky :: CLabel
  - cgd_sequel :: Sequel
  - cgd_self_loop :: Maybe SelfLoopInfo
  - cgd_tick_scope :: CmmTickScope
  }
- data CgState = MkCgState {
  - cgs_stmts :: CmmAGraph
  - cgs_tops :: OrdList CmmDecl
  - cgs_binds :: CgBindings
  - cgs_hp_usg :: HeapUsage
  - cgs_uniqs :: UniqSupply
  }

# Documentation

data FCode a #

Instances

Monad FCode # |
Methods (>>=) :: FCode a -> (a -> FCode b) -> FCode b Source # (>>) :: FCode a -> FCode b -> FCode b Source # return :: a -> FCode a Source # fail :: String -> FCode a Source #
Functor FCode # |
Methods fmap :: (a -> b) -> FCode a -> FCode b Source # (<$) :: a -> FCode b -> FCode a Source #
Applicative FCode # |
Methods pure :: a -> FCode a Source # (<*>) :: FCode (a -> b) -> FCode a -> FCode b Source # liftA2 :: (a -> b -> c) -> FCode a -> FCode b -> FCode c Source # (*>) :: FCode a -> FCode b -> FCode b Source # (<*) :: FCode a -> FCode b -> FCode a Source #
MonadUnique FCode # |
Methods getUniqueSupplyM :: FCode UniqSupply # getUniqueM :: FCode Unique # getUniquesM :: FCode [Unique] #
HasDynFlags FCode # |
Methods getDynFlags :: FCode DynFlags #

initC :: IO CgState #

runC :: DynFlags -> Module -> CgState -> FCode a -> (a, CgState) #

thenC :: FCode () -> FCode a -> FCode a infixr 9 #

thenFC :: FCode a -> (a -> FCode c) -> FCode c infixr 9 #

listCs :: [FCode ()] -> FCode () #

returnFC :: a -> FCode a #

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

newUnique :: FCode Unique #

newUniqSupply :: FCode UniqSupply #

emitLabel :: BlockId -> FCode () #

emit :: CmmAGraph -> FCode () #

emitDecl :: CmmDecl -> FCode () #

emitProc :: Maybe CmmInfoTable -> CLabel -> [GlobalReg] -> CmmAGraphScoped -> Int -> 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 () #

emitComment :: FastString -> FCode () #

emitTick :: CmmTickish -> FCode () #

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

getCmm :: FCode () -> FCode CmmGroup #

aGraphToGraph :: CmmAGraphScoped -> FCode CmmGraph #

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

getCode :: FCode a -> FCode CmmAGraph #

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

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

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

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

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

type ConTagZ = Int #

A *zero-indexed* constructor tag

data Sequel #

Constructors

Return |
AssignTo [LocalReg] Bool |

Instances

Outputable Sequel # |
Methods ppr :: Sequel -> SDoc # pprPrec :: Rational -> Sequel -> SDoc #

data ReturnKind #

Constructors

AssignedDirectly |
ReturnedTo BlockId ByteOff |

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

getSequel :: FCode Sequel #

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

getTickyCtrLabel :: FCode CLabel #

tickScope :: FCode a -> FCode a #

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 #

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

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

getUpdFrameOff :: FCode UpdFrameOffset #

initUpdFrameOff :: DynFlags -> UpdFrameOffset #

data HeapUsage #

Constructors

HeapUsage |

Fields

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

getInfoDown :: FCode CgInfoDownwards #

getDynFlags :: HasDynFlags m => m DynFlags #

getThisPackage :: FCode UnitId #

data CgIdInfo #

Constructors

CgIdInfo |

Fields

- cg_id :: Id
- cg_lf :: LambdaFormInfo
- cg_loc :: CgLoc

Instances

Outputable CgIdInfo # |
Methods ppr :: CgIdInfo -> SDoc # pprPrec :: Rational -> CgIdInfo -> SDoc #

getBinds :: FCode CgBindings #

setBinds :: CgBindings -> FCode () #

data CgInfoDownwards #

Constructors

MkCgInfoDown |

Fields

- cgd_dflags :: DynFlags
- cgd_mod :: Module
- cgd_updfr_off :: UpdFrameOffset
- cgd_ticky :: CLabel
- cgd_sequel :: Sequel
- cgd_self_loop :: Maybe SelfLoopInfo
- cgd_tick_scope :: CmmTickScope

data CgState #

Constructors

MkCgState |

Fields

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