| ghc-6.12.3: The GHC API | Contents | Index

RegAlloc.Liveness

Synopsis

type RegSet = UniqSet Reg
type RegMap a = UniqFM a
emptyRegMap :: UniqFM a
type BlockMap a = BlockEnv a
emptyBlockMap :: BlockEnv a
type LiveCmmTop instr = GenCmmTop CmmStatic LiveInfo (ListGraph (GenBasicBlock (LiveInstr instr)))

data LiveInstr instr

= Instr instr (Maybe Liveness)
| SPILL Reg Int
| RELOAD Int Reg

data Liveness = Liveness {

liveBorn :: RegSet
liveDieRead :: RegSet
liveDieWrite :: RegSet

}

data LiveInfo = LiveInfo [CmmStatic] (Maybe BlockId) (BlockMap RegSet)
type LiveBasicBlock instr = GenBasicBlock (LiveInstr instr)
mapBlockTop :: (LiveBasicBlock instr -> LiveBasicBlock instr) -> LiveCmmTop instr -> LiveCmmTop instr
mapBlockTopM :: Monad m => (LiveBasicBlock instr -> m (LiveBasicBlock instr)) -> LiveCmmTop instr -> m (LiveCmmTop instr)
mapGenBlockTop :: (GenBasicBlock i -> GenBasicBlock i) -> GenCmmTop d h (ListGraph i) -> GenCmmTop d h (ListGraph i)
mapGenBlockTopM :: Monad m => (GenBasicBlock i -> m (GenBasicBlock i)) -> GenCmmTop d h (ListGraph i) -> m (GenCmmTop d h (ListGraph i))
stripLive :: Instruction instr => LiveCmmTop instr -> NatCmmTop instr
stripLiveBlock :: Instruction instr => LiveBasicBlock instr -> NatBasicBlock instr
slurpConflicts :: Instruction instr => LiveCmmTop instr -> (Bag (UniqSet Reg), Bag (Reg, Reg))
slurpReloadCoalesce :: Instruction instr => LiveCmmTop instr -> Bag (Reg, Reg)
eraseDeltasLive :: Instruction instr => LiveCmmTop instr -> LiveCmmTop instr
patchEraseLive :: Instruction instr => (Reg -> Reg) -> LiveCmmTop instr -> LiveCmmTop instr
patchRegsLiveInstr :: Instruction instr => (Reg -> Reg) -> LiveInstr instr -> LiveInstr instr
regLiveness :: Instruction instr => NatCmmTop instr -> UniqSM (LiveCmmTop instr)

Documentation
type RegSet = UniqSet Reg
type RegMap a = UniqFM a
emptyRegMap :: UniqFM a
type BlockMap a = BlockEnv a
emptyBlockMap :: BlockEnv a
type LiveCmmTop instr = GenCmmTop CmmStatic LiveInfo (ListGraph (GenBasicBlock (LiveInstr instr)))
A top level thing which carries liveness information.
data LiveInstr instr

An instruction with liveness information.
Constructors

Instr instr (Maybe Liveness) |
SPILL Reg Int | spill this reg to a stack slot
RELOAD Int Reg | reload this reg from a stack slot

Instances

Outputable instr => Outputable (LiveInstr instr)

data Liveness

Liveness information. The regs which die are ones which are no longer live in the *next* instruction in this sequence. (NB. if the instruction is a jump, these registers might still be live at the jump target(s) - you have to check the liveness at the destination block to find out).
Constructors

Liveness | registers that died because they were clobbered by something.

liveBorn :: RegSet | registers born in this instruction (written to for first time).
liveDieRead :: RegSet | registers that died because they were read for the last time.
liveDieWrite :: RegSet |

data LiveInfo

Stash regs live on entry to each basic block in the info part of the cmm code.
Constructors

LiveInfo [CmmStatic] (Maybe BlockId) (BlockMap RegSet) |

Instances

Outputable LiveInfo

type LiveBasicBlock instr = GenBasicBlock (LiveInstr instr)
A basic block with liveness information.
mapBlockTop :: (LiveBasicBlock instr -> LiveBasicBlock instr) -> LiveCmmTop instr -> LiveCmmTop instr
map a function across all the basic blocks in this code
mapBlockTopM :: Monad m => (LiveBasicBlock instr -> m (LiveBasicBlock instr)) -> LiveCmmTop instr -> m (LiveCmmTop instr)
map a function across all the basic blocks in this code (monadic version)
mapGenBlockTop :: (GenBasicBlock i -> GenBasicBlock i) -> GenCmmTop d h (ListGraph i) -> GenCmmTop d h (ListGraph i)
mapGenBlockTopM :: Monad m => (GenBasicBlock i -> m (GenBasicBlock i)) -> GenCmmTop d h (ListGraph i) -> m (GenCmmTop d h (ListGraph i))
map a function across all the basic blocks in this code (monadic version)
stripLive :: Instruction instr => LiveCmmTop instr -> NatCmmTop instr
Strip away liveness information, yielding NatCmmTop
stripLiveBlock :: Instruction instr => LiveBasicBlock instr -> NatBasicBlock instr
Strip away liveness information from a basic block, and make real spill instructions out of SPILL, RELOAD pseudos along the way.
slurpConflicts :: Instruction instr => LiveCmmTop instr -> (Bag (UniqSet Reg), Bag (Reg, Reg))
Slurp out the list of register conflicts and reg-reg moves from this top level thing. Slurping of conflicts and moves is wrapped up together so we don't have to make two passes over the same code when we want to build the graph.
slurpReloadCoalesce :: Instruction instr => LiveCmmTop instr -> Bag (Reg, Reg)
For spill/reloads SPILL v1, slot1 ... RELOAD slot1, v2 If we can arrange that v1 and v2 are allocated to the same hreg it's more likely the spill/reload instrs can be cleaned and replaced by a nop reg-reg move.
eraseDeltasLive :: Instruction instr => LiveCmmTop instr -> LiveCmmTop instr
Erase Delta instructions.
patchEraseLive :: Instruction instr => (Reg -> Reg) -> LiveCmmTop instr -> LiveCmmTop instr
Patch the registers in this code according to this register mapping. also erase reg -> reg moves when the reg is the same. also erase reg -> reg moves when the destination dies in this instr.
patchRegsLiveInstr :: Instruction instr => (Reg -> Reg) -> LiveInstr instr -> LiveInstr instr
Patch registers in this LiveInstr, including the liveness information.
regLiveness :: Instruction instr => NatCmmTop instr -> UniqSM (LiveCmmTop instr)
Produced by Haddock version 2.6.1