Instruction

ghc-8.6.3: The GHC API

Safe Haskell | None
Language | Haskell2010

Instruction

Synopsis

- data RegUsage = RU [Reg] [Reg]
- noUsage :: RegUsage
- data GenBasicBlock i = BasicBlock BlockId [i]
- blockId :: GenBasicBlock i -> BlockId
- newtype ListGraph i = ListGraph [GenBasicBlock i]
- type NatCmm instr = GenCmmGroup CmmStatics (LabelMap CmmStatics) (ListGraph instr)
- type NatCmmDecl statics instr = GenCmmDecl statics (LabelMap CmmStatics) (ListGraph instr)
- type NatBasicBlock instr = GenBasicBlock instr
- topInfoTable :: GenCmmDecl a (LabelMap i) (ListGraph b) -> Maybe i
- entryBlocks :: GenCmmDecl a (LabelMap i) (ListGraph b) -> [BlockId]
- class Instruction instr where
  - regUsageOfInstr :: Platform -> instr -> RegUsage
  - patchRegsOfInstr :: instr -> (Reg -> Reg) -> instr
  - isJumpishInstr :: instr -> Bool
  - jumpDestsOfInstr :: instr -> [BlockId]
  - patchJumpInstr :: instr -> (BlockId -> BlockId) -> instr
  - mkSpillInstr :: DynFlags -> Reg -> Int -> Int -> instr
  - mkLoadInstr :: DynFlags -> Reg -> Int -> Int -> instr
  - takeDeltaInstr :: instr -> Maybe Int
  - isMetaInstr :: instr -> Bool
  - mkRegRegMoveInstr :: Platform -> Reg -> Reg -> instr
  - takeRegRegMoveInstr :: instr -> Maybe (Reg, Reg)
  - mkJumpInstr :: BlockId -> [instr]
  - mkStackAllocInstr :: Platform -> Int -> [instr]
  - mkStackDeallocInstr :: Platform -> Int -> [instr]

# Documentation

data RegUsage #

Holds a list of source and destination registers used by a particular instruction.

Machine registers that are pre-allocated to stgRegs are filtered out, because they are uninteresting from a register allocation standpoint. (We wouldn't want them to end up on the free list!)

As far as we are concerned, the fixed registers simply don't exist (for allocation purposes, anyway).

Constructors

RU [Reg] [Reg] |

noUsage :: RegUsage #

No regs read or written to.

data GenBasicBlock i #

Constructors

BasicBlock BlockId [i] |

Instances

Outputable instr => Outputable (GenBasicBlock instr) # |
Instance details Defined in Cmm Methods ppr :: GenBasicBlock instr -> SDoc # pprPrec :: Rational -> GenBasicBlock instr -> SDoc #

blockId :: GenBasicBlock i -> BlockId #

The branch block id is that of the first block in the branch, which is that branch's entry point

newtype ListGraph i #

Constructors

ListGraph [GenBasicBlock i] |

Instances

Outputable instr => Outputable (ListGraph instr) # |
Instance details Defined in Cmm Methods ppr :: ListGraph instr -> SDoc # pprPrec :: Rational -> ListGraph instr -> SDoc #

type NatCmm instr = GenCmmGroup CmmStatics (LabelMap CmmStatics) (ListGraph instr) #

type NatCmmDecl statics instr = GenCmmDecl statics (LabelMap CmmStatics) (ListGraph instr) #

type NatBasicBlock instr = GenBasicBlock instr #

topInfoTable :: GenCmmDecl a (LabelMap i) (ListGraph b) -> Maybe i #

Returns the info table associated with the CmmDecl's entry point, if any.

entryBlocks :: GenCmmDecl a (LabelMap i) (ListGraph b) -> [BlockId] #

Return the list of BlockIds in a CmmDecl that are entry points for this proc (i.e. they may be jumped to from outside this proc).

class Instruction instr where #

Common things that we can do with instructions, on all architectures. These are used by the shared parts of the native code generator, specifically the register allocators.

Methods

regUsageOfInstr :: Platform -> instr -> RegUsage #

Get the registers that are being used by this instruction. regUsage doesn't need to do any trickery for jumps and such. Just state precisely the regs read and written by that insn. The consequences of control flow transfers, as far as register allocation goes, are taken care of by the register allocator.

patchRegsOfInstr :: instr -> (Reg -> Reg) -> instr #

Apply a given mapping to all the register references in this instruction.

isJumpishInstr :: instr -> Bool #

Checks whether this instruction is a jump/branch instruction. One that can change the flow of control in a way that the register allocator needs to worry about.

jumpDestsOfInstr :: instr -> [BlockId] #

Give the possible destinations of this jump instruction. Must be defined for all jumpish instructions.

patchJumpInstr :: instr -> (BlockId -> BlockId) -> instr #

Change the destination of this jump instruction. Used in the linear allocator when adding fixup blocks for join points.

mkSpillInstr #

Arguments

:: DynFlags |
-> Reg | the reg to spill
-> Int | the current stack delta
-> Int | spill slot to use
-> instr |

An instruction to spill a register into a spill slot.

mkLoadInstr #

Arguments

:: DynFlags |
-> Reg | the reg to reload.
-> Int | the current stack delta
-> Int | the spill slot to use
-> instr |

An instruction to reload a register from a spill slot.

takeDeltaInstr :: instr -> Maybe Int #

See if this instruction is telling us the current C stack delta

isMetaInstr :: instr -> Bool #

Check whether this instruction is some meta thing inserted into the instruction stream for other purposes.

Not something that has to be treated as a real machine instruction and have its registers allocated.

eg, comments, delta, ldata, etc.

mkRegRegMoveInstr #

Arguments

:: Platform |
-> Reg | source register
-> Reg | destination register
-> instr |

Copy the value in a register to another one. Must work for all register classes.

takeRegRegMoveInstr :: instr -> Maybe (Reg, Reg) #

Take the source and destination from this reg -> reg move instruction or Nothing if it's not one

mkJumpInstr :: BlockId -> [instr] #

Make an unconditional jump instruction. For architectures with branch delay slots, its ok to put a NOP after the jump. Don't fill the delay slot with an instruction that references regs or you'll confuse the linear allocator.

mkStackAllocInstr :: Platform -> Int -> [instr] #

mkStackDeallocInstr :: Platform -> Int -> [instr] #

Instances

Instruction Instr # | Instruction instance for x86 instruction set.
Instance details Defined in X86.Instr Methods regUsageOfInstr :: Platform -> Instr -> RegUsage # patchRegsOfInstr :: Instr -> (Reg -> Reg) -> Instr # isJumpishInstr :: Instr -> Bool # jumpDestsOfInstr :: Instr -> [BlockId] # patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr # mkSpillInstr :: DynFlags -> Reg -> Int -> Int -> Instr # mkLoadInstr :: DynFlags -> Reg -> Int -> Int -> Instr # takeDeltaInstr :: Instr -> Maybe Int # isMetaInstr :: Instr -> Bool # mkRegRegMoveInstr :: Platform -> Reg -> Reg -> Instr # takeRegRegMoveInstr :: Instr -> Maybe (Reg, Reg) # mkJumpInstr :: BlockId -> [Instr] # mkStackAllocInstr :: Platform -> Int -> [Instr] # mkStackDeallocInstr :: Platform -> Int -> [Instr] #
Instruction Instr # | instance for sparc instruction set
Instance details Defined in SPARC.Instr Methods regUsageOfInstr :: Platform -> Instr -> RegUsage # patchRegsOfInstr :: Instr -> (Reg -> Reg) -> Instr # isJumpishInstr :: Instr -> Bool # jumpDestsOfInstr :: Instr -> [BlockId] # patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr # mkSpillInstr :: DynFlags -> Reg -> Int -> Int -> Instr # mkLoadInstr :: DynFlags -> Reg -> Int -> Int -> Instr # takeDeltaInstr :: Instr -> Maybe Int # isMetaInstr :: Instr -> Bool # mkRegRegMoveInstr :: Platform -> Reg -> Reg -> Instr # takeRegRegMoveInstr :: Instr -> Maybe (Reg, Reg) # mkJumpInstr :: BlockId -> [Instr] # mkStackAllocInstr :: Platform -> Int -> [Instr] # mkStackDeallocInstr :: Platform -> Int -> [Instr] #
Instruction Instr # | Instruction instance for powerpc
Instance details Defined in PPC.Instr Methods regUsageOfInstr :: Platform -> Instr -> RegUsage # patchRegsOfInstr :: Instr -> (Reg -> Reg) -> Instr # isJumpishInstr :: Instr -> Bool # jumpDestsOfInstr :: Instr -> [BlockId] # patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr # mkSpillInstr :: DynFlags -> Reg -> Int -> Int -> Instr # mkLoadInstr :: DynFlags -> Reg -> Int -> Int -> Instr # takeDeltaInstr :: Instr -> Maybe Int # isMetaInstr :: Instr -> Bool # mkRegRegMoveInstr :: Platform -> Reg -> Reg -> Instr # takeRegRegMoveInstr :: Instr -> Maybe (Reg, Reg) # mkJumpInstr :: BlockId -> [Instr] # mkStackAllocInstr :: Platform -> Int -> [Instr] # mkStackDeallocInstr :: Platform -> Int -> [Instr] #
Instruction instr => Instruction (InstrSR instr) # |
Instance details Defined in RegAlloc.Liveness Methods regUsageOfInstr :: Platform -> InstrSR instr -> RegUsage # patchRegsOfInstr :: InstrSR instr -> (Reg -> Reg) -> InstrSR instr # isJumpishInstr :: InstrSR instr -> Bool # jumpDestsOfInstr :: InstrSR instr -> [BlockId] # patchJumpInstr :: InstrSR instr -> (BlockId -> BlockId) -> InstrSR instr # mkSpillInstr :: DynFlags -> Reg -> Int -> Int -> InstrSR instr # mkLoadInstr :: DynFlags -> Reg -> Int -> Int -> InstrSR instr # takeDeltaInstr :: InstrSR instr -> Maybe Int # isMetaInstr :: InstrSR instr -> Bool # mkRegRegMoveInstr :: Platform -> Reg -> Reg -> InstrSR instr # takeRegRegMoveInstr :: InstrSR instr -> Maybe (Reg, Reg) # mkJumpInstr :: BlockId -> [InstrSR instr] # mkStackAllocInstr :: Platform -> Int -> [InstrSR instr] # mkStackDeallocInstr :: Platform -> Int -> [InstrSR instr] #