NCGMonad

ghc-8.10.0.20191123: The GHC API

Safe Haskell | None
Language | Haskell2010

NCGMonad

Synopsis

- data NcgImpl statics instr jumpDest = NcgImpl {
  - cmmTopCodeGen :: RawCmmDecl -> NatM [NatCmmDecl statics instr]
  - generateJumpTableForInstr :: instr -> Maybe (NatCmmDecl statics instr)
  - getJumpDestBlockId :: jumpDest -> Maybe BlockId
  - canShortcut :: instr -> Maybe jumpDest
  - shortcutStatics :: (BlockId -> Maybe jumpDest) -> statics -> statics
  - shortcutJump :: (BlockId -> Maybe jumpDest) -> instr -> instr
  - pprNatCmmDecl :: NatCmmDecl statics instr -> SDoc
  - maxSpillSlots :: Int
  - allocatableRegs :: [RealReg]
  - ncgExpandTop :: [NatCmmDecl statics instr] -> [NatCmmDecl statics instr]
  - ncgAllocMoreStack :: Int -> NatCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr, [(BlockId, BlockId)])
  - ncgMakeFarBranches :: LabelMap CmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr]
  - extractUnwindPoints :: [instr] -> [UnwindPoint]
  - invertCondBranches :: Maybe CFG -> LabelMap CmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr]
  }
- data NatM_State = NatM_State {
  - natm_us :: UniqSupply
  - natm_delta :: Int
  - natm_imports :: [CLabel]
  - natm_pic :: Maybe Reg
  - natm_dflags :: DynFlags
  - natm_this_module :: Module
  - natm_modloc :: ModLocation
  - natm_fileid :: DwarfFiles
  - natm_debug_map :: LabelMap DebugBlock
  - natm_cfg :: CFG
  }
- mkNatM_State :: UniqSupply -> Int -> DynFlags -> Module -> ModLocation -> DwarfFiles -> LabelMap DebugBlock -> CFG -> NatM_State
- data NatM result
- initNat :: NatM_State -> NatM a -> (a, NatM_State)
- addImportNat :: CLabel -> NatM ()
- addNodeBetweenNat :: BlockId -> BlockId -> BlockId -> NatM ()
- addImmediateSuccessorNat :: BlockId -> BlockId -> NatM ()
- updateCfgNat :: (CFG -> CFG) -> NatM ()
- getUniqueNat :: NatM Unique
- mapAccumLNat :: (acc -> x -> NatM (acc, y)) -> acc -> [x] -> NatM (acc, [y])
- setDeltaNat :: Int -> NatM ()
- getDeltaNat :: NatM Int
- getThisModuleNat :: NatM Module
- getBlockIdNat :: NatM BlockId
- getNewLabelNat :: NatM CLabel
- getNewRegNat :: Format -> NatM Reg
- getNewRegPairNat :: Format -> NatM (Reg, Reg)
- getPicBaseMaybeNat :: NatM (Maybe Reg)
- getPicBaseNat :: Format -> NatM Reg
- getDynFlags :: HasDynFlags m => m DynFlags
- getModLoc :: NatM ModLocation
- getFileId :: FastString -> NatM Int
- getDebugBlock :: Label -> NatM (Maybe DebugBlock)
- type DwarfFiles = UniqFM (FastString, Int)

# Documentation

data NcgImpl statics instr jumpDest Source #

Constructors

NcgImpl |
Fields cmmTopCodeGen :: RawCmmDecl -> NatM [NatCmmDecl statics instr] generateJumpTableForInstr :: instr -> Maybe (NatCmmDecl statics instr) getJumpDestBlockId :: jumpDest -> Maybe BlockId canShortcut :: instr -> Maybe jumpDest shortcutStatics :: (BlockId -> Maybe jumpDest) -> statics -> statics shortcutJump :: (BlockId -> Maybe jumpDest) -> instr -> instr pprNatCmmDecl :: NatCmmDecl statics instr -> SDoc maxSpillSlots :: Int allocatableRegs :: [RealReg] ncgExpandTop :: [NatCmmDecl statics instr] -> [NatCmmDecl statics instr] ncgAllocMoreStack :: Int -> NatCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr, [(BlockId, BlockId)]) The list of block ids records the redirected jumps to allow us to update the CFG. ncgMakeFarBranches :: LabelMap CmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr] extractUnwindPoints :: [instr] -> [UnwindPoint] given the instruction sequence of a block, produce a list of the block's `UnwindPoint`s See Note [What is this unwinding business?] in Debug and Note [Unwinding information in the NCG] in this module. invertCondBranches :: Maybe CFG -> LabelMap CmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr] Turn the sequence of `jcc l1; jmp l2` into `jncc l2; block_l1` when possible.

data NatM_State Source #

Constructors

NatM_State |
Fields natm_us :: UniqSupply natm_delta :: Int natm_imports :: [CLabel] natm_pic :: Maybe Reg natm_dflags :: DynFlags natm_this_module :: Module natm_modloc :: ModLocation natm_fileid :: DwarfFiles natm_debug_map :: LabelMap DebugBlock natm_cfg :: CFG Having a CFG with additional information is essential for some operations. However we can't reconstruct all information once we generated instructions. So instead we update the CFG as we go.

mkNatM_State :: UniqSupply -> Int -> DynFlags -> Module -> ModLocation -> DwarfFiles -> LabelMap DebugBlock -> CFG -> NatM_State Source #

data NatM result Source #

#### Instances

Instances details

Monad NatM # |
Instance details Defined in NCGMonad Methods (>>=) :: NatM a -> (a -> NatM b) -> NatM b Source # (>>) :: NatM a -> NatM b -> NatM b Source # return :: a -> NatM a Source #
Functor NatM # |
Instance details Defined in NCGMonad Methods fmap :: (a -> b) -> NatM a -> NatM b Source # (<$) :: a -> NatM b -> NatM a Source #
Applicative NatM # |
Instance details Defined in NCGMonad Methods pure :: a -> NatM a Source # (<*>) :: NatM (a -> b) -> NatM a -> NatM b Source # liftA2 :: (a -> b -> c) -> NatM a -> NatM b -> NatM c Source # (*>) :: NatM a -> NatM b -> NatM b Source # (<*) :: NatM a -> NatM b -> NatM a Source #
MonadUnique NatM # |
Instance details Defined in NCGMonad Methods getUniqueSupplyM :: NatM UniqSupply Source # getUniqueM :: NatM Unique Source # getUniquesM :: NatM [Unique] Source #
HasDynFlags NatM # |
Instance details Defined in NCGMonad Methods getDynFlags :: NatM DynFlags Source #
CmmMakeDynamicReferenceM NatM # |
Instance details Defined in PIC Methods addImport :: CLabel -> NatM () Source # getThisModule :: NatM Module Source #

initNat :: NatM_State -> NatM a -> (a, NatM_State) Source #

addImportNat :: CLabel -> NatM () Source #

addNodeBetweenNat :: BlockId -> BlockId -> BlockId -> NatM () Source #

Record that we added a block between `from` and `old`.

addImmediateSuccessorNat :: BlockId -> BlockId -> NatM () Source #

Place `succ` after `block` and change any edges block -> X to `succ` -> X

updateCfgNat :: (CFG -> CFG) -> NatM () Source #

getUniqueNat :: NatM Unique Source #

mapAccumLNat :: (acc -> x -> NatM (acc, y)) -> acc -> [x] -> NatM (acc, [y]) Source #

setDeltaNat :: Int -> NatM () Source #

getDeltaNat :: NatM Int Source #

getThisModuleNat :: NatM Module Source #

getBlockIdNat :: NatM BlockId Source #

getNewLabelNat :: NatM CLabel Source #

getNewRegNat :: Format -> NatM Reg Source #

getNewRegPairNat :: Format -> NatM (Reg, Reg) Source #

getPicBaseMaybeNat :: NatM (Maybe Reg) Source #

getPicBaseNat :: Format -> NatM Reg Source #

getDynFlags :: HasDynFlags m => m DynFlags Source #

getModLoc :: NatM ModLocation Source #

getFileId :: FastString -> NatM Int Source #

getDebugBlock :: Label -> NatM (Maybe DebugBlock) Source #

type DwarfFiles = UniqFM (FastString, Int) Source #