ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.CmmToAsm.Monad

Contents

- 64-bit registers on 32-bit architectures

Synopsis

- data NcgImpl statics instr jumpDest = NcgImpl {
  - ncgConfig :: !NCGConfig
  - 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
  - pprNatCmmDeclS :: NatCmmDecl statics instr -> SDoc
  - pprNatCmmDeclH :: NatCmmDecl statics instr -> HDoc
  - maxSpillSlots :: Int
  - allocatableRegs :: [RealReg]
  - ncgAllocMoreStack :: Int -> NatCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr, [(BlockId, BlockId)])
  - ncgMakeFarBranches :: LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr]
  - extractUnwindPoints :: [instr] -> [UnwindPoint]
  - invertCondBranches :: Maybe CFG -> LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr]
  }
- data NatM_State = NatM_State {
  - natm_us :: UniqSupply
  - natm_delta :: Int
  - natm_imports :: [CLabel]
  - natm_pic :: Maybe Reg
  - natm_config :: NCGConfig
  - natm_fileid :: DwarfFiles
  - natm_debug_map :: LabelMap DebugBlock
  - natm_cfg :: CFG
  }
- mkNatM_State :: UniqSupply -> Int -> NCGConfig -> DwarfFiles -> LabelMap DebugBlock -> CFG -> NatM_State
- data NatM a
- 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
- setDeltaNat :: Int -> NatM ()
- getConfig :: NatM NCGConfig
- getPlatform :: NatM Platform
- getDeltaNat :: NatM Int
- getThisModuleNat :: NatM Module
- getBlockIdNat :: NatM BlockId
- getNewLabelNat :: NatM CLabel
- getNewRegNat :: Format -> NatM Reg
- getPicBaseMaybeNat :: NatM (Maybe Reg)
- getPicBaseNat :: Format -> NatM Reg
- getCfgWeights :: NatM Weights
- getFileId :: FastString -> NatM Int
- getDebugBlock :: Label -> NatM (Maybe DebugBlock)
- type DwarfFiles = UniqFM FastString (FastString, Int)
- data Reg64 = Reg64 !Reg !Reg
- data RegCode64 code = RegCode64 code !Reg !Reg
- getNewReg64 :: NatM Reg64
- localReg64 :: HasDebugCallStack => LocalReg -> Reg64

# Documentation

data NcgImpl statics instr jumpDest Source #

Constructors

NcgImpl |

Fields

- ncgConfig :: !NCGConfig
- 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
- pprNatCmmDeclS :: NatCmmDecl statics instr -> SDoc

  `GenModule` is only for printing internal labels. See Note [Internal proc labels] in CLabel.

- pprNatCmmDeclH :: NatCmmDecl statics instr -> HDoc
- maxSpillSlots :: Int
- allocatableRegs :: [RealReg]
- 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 RawCmmStatics -> [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 GHC.Cmm.DebugBlock and Note [Unwinding information in the NCG] in this module.

- invertCondBranches :: Maybe CFG -> LabelMap RawCmmStatics -> [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_config :: NCGConfig
- 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 -> NCGConfig -> DwarfFiles -> LabelMap DebugBlock -> CFG -> NatM_State Source #

data NatM a Source #

#### Instances

Instances details

Applicative NatM Source # |
Instance details Defined in GHC.CmmToAsm.Monad 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 #
Functor NatM Source # |
Instance details Defined in GHC.CmmToAsm.Monad Methods fmap :: (a -> b) -> NatM a -> NatM b Source # (<$) :: a -> NatM b -> NatM a Source #
Monad NatM Source # |
Instance details Defined in GHC.CmmToAsm.Monad Methods (>>=) :: NatM a -> (a -> NatM b) -> NatM b Source # (>>) :: NatM a -> NatM b -> NatM b Source # return :: a -> NatM a Source #
CmmMakeDynamicReferenceM NatM Source # |
Instance details Defined in GHC.CmmToAsm.PIC Methods addImport :: CLabel -> NatM () Source #
MonadUnique NatM Source # |
Instance details Defined in GHC.CmmToAsm.Monad Methods getUniqueSupplyM :: NatM UniqSupply Source # getUniqueM :: NatM Unique Source # getUniquesM :: NatM [Unique] Source #
HasModule NatM Source # |
Instance details Defined in GHC.CmmToAsm.Monad Methods getModule :: 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 #

setDeltaNat :: Int -> NatM () Source #

getConfig :: NatM NCGConfig Source #

Get native code generator configuration

getPlatform :: NatM Platform Source #

Get target platform from native code generator configuration

getDeltaNat :: NatM Int Source #

getThisModuleNat :: NatM Module Source #

getBlockIdNat :: NatM BlockId Source #

getNewLabelNat :: NatM CLabel Source #

getNewRegNat :: Format -> NatM Reg Source #

getPicBaseMaybeNat :: NatM (Maybe Reg) Source #

getPicBaseNat :: Format -> NatM Reg Source #

getCfgWeights :: NatM Weights Source #

Get CFG edge weights

getFileId :: FastString -> NatM Int Source #

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

type DwarfFiles = UniqFM FastString (FastString, Int) Source #

# 64-bit registers on 32-bit architectures

data Reg64 Source #

Two 32-bit regs used as a single virtual 64-bit register

Constructors

Reg64 |

Fields

- !Reg

  Higher part

- !Reg

  Lower part

data RegCode64 code Source #

Two 32-bit regs used as a single virtual 64-bit register and the code to set them appropriately

Constructors

RegCode64 |

Fields

- code

  Code to initialize the registers

- !Reg

  Higher part

- !Reg

  Lower part

getNewReg64 :: NatM Reg64 Source #

Return a virtual 64-bit register

localReg64 :: HasDebugCallStack => LocalReg -> Reg64 Source #

Convert a 64-bit LocalReg into two virtual 32-bit regs.

Used to handle 64-bit "registers" on 32-bit architectures