ghc-9.10.3: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.CmmToAsm.Reg.Linear.State

Description

State monad for the linear register allocator.

Synopsis

- data RA_State freeRegs = RA_State {
  - ra_blockassig :: BlockAssignment freeRegs
  - ra_freeregs :: !freeRegs
  - ra_assig :: RegMap Loc
  - ra_delta :: Int
  - ra_stack :: StackMap
  - ra_us :: UniqSupply
  - ra_spills :: [SpillReason]
  - ra_config :: !NCGConfig
  - ra_fixups :: [(BlockId, BlockId, BlockId)]
  }
- data RegM freeRegs a
- runR :: NCGConfig -> BlockAssignment freeRegs -> freeRegs -> RegMap Loc -> StackMap -> UniqSupply -> RegM freeRegs a -> (BlockAssignment freeRegs, StackMap, RegAllocStats, a)
- spillR :: Instruction instr => Reg -> Unique -> RegM freeRegs ([instr], Int)
- loadR :: Instruction instr => Reg -> Int -> RegM freeRegs [instr]
- getFreeRegsR :: RegM freeRegs freeRegs
- setFreeRegsR :: freeRegs -> RegM freeRegs ()
- getAssigR :: RegM freeRegs (RegMap Loc)
- setAssigR :: RegMap Loc -> RegM freeRegs ()
- getBlockAssigR :: RegM freeRegs (BlockAssignment freeRegs)
- setBlockAssigR :: BlockAssignment freeRegs -> RegM freeRegs ()
- setDeltaR :: Int -> RegM freeRegs ()
- getDeltaR :: RegM freeRegs Int
- getUniqueR :: RegM freeRegs Unique
- getConfig :: RegM a NCGConfig
- getPlatform :: RegM a Platform
- recordSpill :: SpillReason -> RegM freeRegs ()
- recordFixupBlock :: BlockId -> BlockId -> BlockId -> RegM freeRegs ()

# Documentation

data RA_State freeRegs Source #

The register allocator state

Constructors

RA_State |

Fields

- ra_blockassig :: BlockAssignment freeRegs

  the current mapping from basic blocks to the register assignments at the beginning of that block.

- ra_freeregs :: !freeRegs

  free machine registers

- ra_assig :: RegMap Loc

  assignment of temps to locations

- ra_delta :: Int

  current stack delta

- ra_stack :: StackMap

  free stack slots for spilling

- ra_us :: UniqSupply

  unique supply for generating names for join point fixup blocks.

- ra_spills :: [SpillReason]

  Record why things were spilled, for -ddrop-asm-stats. Just keep a list here instead of a map of regs -> reasons. We don't want to slow down the allocator if we're not going to emit the stats.

- ra_config :: !NCGConfig

  Native code generator configuration

- ra_fixups :: [(BlockId, BlockId, BlockId)]

  (from,fixup,to) : We inserted fixup code between from and to

data RegM freeRegs a Source #

The register allocator monad type.

#### Instances

Instances details

Applicative (RegM freeRegs) Source # |
Instance details Defined in GHC.CmmToAsm.Reg.Linear.State Methods pure :: a -> RegM freeRegs a # (<*>) :: RegM freeRegs (a -> b) -> RegM freeRegs a -> RegM freeRegs b # liftA2 :: (a -> b -> c) -> RegM freeRegs a -> RegM freeRegs b -> RegM freeRegs c # (*>) :: RegM freeRegs a -> RegM freeRegs b -> RegM freeRegs b # (<*) :: RegM freeRegs a -> RegM freeRegs b -> RegM freeRegs a #
Functor (RegM freeRegs) Source # |
Instance details Defined in GHC.CmmToAsm.Reg.Linear.State Methods fmap :: (a -> b) -> RegM freeRegs a -> RegM freeRegs b # (<$) :: a -> RegM freeRegs b -> RegM freeRegs a #
Monad (RegM freeRegs) Source # |
Instance details Defined in GHC.CmmToAsm.Reg.Linear.State Methods (>>=) :: RegM freeRegs a -> (a -> RegM freeRegs b) -> RegM freeRegs b # (>>) :: RegM freeRegs a -> RegM freeRegs b -> RegM freeRegs b # return :: a -> RegM freeRegs a #

runR :: NCGConfig -> BlockAssignment freeRegs -> freeRegs -> RegMap Loc -> StackMap -> UniqSupply -> RegM freeRegs a -> (BlockAssignment freeRegs, StackMap, RegAllocStats, a) Source #

Run a computation in the RegM register allocator monad.

spillR :: Instruction instr => Reg -> Unique -> RegM freeRegs ([instr], Int) Source #

loadR :: Instruction instr => Reg -> Int -> RegM freeRegs [instr] Source #

getFreeRegsR :: RegM freeRegs freeRegs Source #

setFreeRegsR :: freeRegs -> RegM freeRegs () Source #

getAssigR :: RegM freeRegs (RegMap Loc) Source #

setAssigR :: RegMap Loc -> RegM freeRegs () Source #

getBlockAssigR :: RegM freeRegs (BlockAssignment freeRegs) Source #

setBlockAssigR :: BlockAssignment freeRegs -> RegM freeRegs () Source #

setDeltaR :: Int -> RegM freeRegs () Source #

getDeltaR :: RegM freeRegs Int Source #

getUniqueR :: RegM freeRegs Unique Source #

getConfig :: RegM a NCGConfig Source #

Get native code generator configuration

getPlatform :: RegM a Platform Source #

Get target platform from native code generator configuration

recordSpill :: SpillReason -> RegM freeRegs () Source #

Record that a spill instruction was inserted, for profiling.

recordFixupBlock :: BlockId -> BlockId -> BlockId -> RegM freeRegs () Source #

Record a created fixup block