ghc-9.14.0.20251128: The GHC API
Safe HaskellNone
LanguageGHC2021

GHC.CmmToAsm.Instr

Synopsis

Documentation

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 :: Platform -> 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 *local block* destinations of this jump instruction. Must be defined for all jumpish instructions.

canFallthroughTo :: instr -> BlockId -> Bool #

Check if the instr always transfers control flow to the given block. Used by code layout to eliminate jumps that can be replaced by fall through.

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

:: NCGConfig 
-> RegWithFormat

the reg to spill

-> Int

the current stack delta

-> Int

spill slots to use

-> [instr]

instructions

An instruction to spill a register into a spill slot.

mkLoadInstr #

Arguments

:: NCGConfig 
-> RegWithFormat

the reg to reload.

-> Int

the current stack delta

-> Int

the spill slot to use

-> [instr]

instructions

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

:: NCGConfig 
-> Format 
-> Reg

source register

-> Reg

destination register

-> instr 

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

takeRegRegMoveInstr :: Platform -> 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] #

pprInstr :: Platform -> instr -> SDoc #

Pretty-print an instruction

mkComment :: FastString -> [instr] #

Instances

Instances details
Instruction Instr #

Instruction instance for aarch64

Instance details

Defined in GHC.CmmToAsm.AArch64

Instruction Instr #

Instruction instance for LA64

Instance details

Defined in GHC.CmmToAsm.LA64

Instruction Instr #

Instruction instance for powerpc

Instance details

Defined in GHC.CmmToAsm.PPC

Instruction Instr #

Instruction instance for RV64

Instance details

Defined in GHC.CmmToAsm.RV64

Instruction Instr #

Instruction instance for x86 instruction set.

Instance details

Defined in GHC.CmmToAsm.X86

Instruction instr => Instruction (InstrSR instr) # 
Instance details

Defined in GHC.CmmToAsm.Reg.Liveness

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 

Instances

Instances details
Outputable RegUsage # 
Instance details

Defined in GHC.CmmToAsm.RV64.Instr

Methods

ppr :: RegUsage -> SDoc #

Outputable RegUsage # 
Instance details

Defined in GHC.CmmToAsm.LA64.Instr

Methods

ppr :: RegUsage -> SDoc #

Outputable 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.

RegUsage = RU [regs] [regs]

Instance details

Defined in GHC.CmmToAsm.AArch64.Instr

Methods

ppr :: RegUsage -> SDoc #

Show RegUsage # 
Instance details

Defined in GHC.CmmToAsm.Instr

noUsage :: RegUsage #

No regs read or written to.