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 -> RegUsageGet 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) -> instrApply a given mapping to all the register references in this instruction.
isJumpishInstr :: instr -> BoolChecks 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 -> BoolCheck 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) -> instrChange the destination of this jump instruction. Used in the linear allocator when adding fixup blocks for join points.
mkSpillInstr :: NCGConfig -> Reg -> Int -> Int -> [instr]An instruction to spill a register into a spill slot.
mkLoadInstr :: NCGConfig -> Reg -> Int -> Int -> [instr]An instruction to reload a register from a spill slot.
takeDeltaInstr :: instr -> Maybe IntSee if this instruction is telling us the current C stack delta
isMetaInstr :: instr -> BoolCheck 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 :: Platform -> Reg -> Reg -> instrCopy 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]pprInstr :: Platform -> instr -> SDocPretty-print an instruction
mkComment :: FastString -> [instr]
Instances4Instruction
Instruction InstrDefined in ghc-9.10.3 · GHC.CmmToAsm.AArch64 · orphanInstruction instance for aarch64
Instruction InstrDefined in ghc-9.10.3 · GHC.CmmToAsm.PPC · orphanInstruction instance for powerpc
Instruction InstrDefined in ghc-9.10.3 · GHC.CmmToAsm.X86 · orphanInstruction instance for x86 instruction set.
Instruction instr => Instruction (InstrSR instr)Defined in ghc-9.10.3 · GHC.CmmToAsm.Reg.Liveness