#[non_exhaustive]pub enum InstKind {
Plain,
Copy,
ParallelCopy,
Jump,
Branch,
Return,
Call,
Trap,
TailCall,
Switch,
}Expand description
What an instruction does to control flow, and which generic handling it gets.
§Examples
use backend_lang::target::InstKind;
use backend_lang::x86_64::{self, op};
assert_eq!(x86_64::TARGET.inst(op::JMP).unwrap().kind(), InstKind::Jump);
assert!(InstKind::Jump.is_terminator());
assert!(!InstKind::Call.is_terminator());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Plain
An ordinary instruction; control falls through.
Copy
ParallelCopy
Jump
An unconditional branch to one block, passing arguments.
Branch
A two-way conditional branch: a condition, then the taken and the not-taken block, each with arguments.
Return
A return from the function (the epilogue runs first).
Call
A call; control comes back to the next instruction.
Trap
An instruction that never falls through and never returns (ud2).
TailCall
A tail call: the epilogue runs, then control jumps to the callee, which returns to this function’s caller.
Switch
A multi-way branch through a table: a temporary definition, an index
register, then one target block per index (jmptbl). The targets
take no arguments. The temporary is written before the index is last
read, so the register allocator never gives the two one register.
Implementations§
Source§impl InstKind
impl InstKind
Sourcepub const fn is_terminator(self) -> bool
pub const fn is_terminator(self) -> bool
Whether the instruction ends a block: jumps, branches, returns, traps, tail calls, and table branches.
§Examples
use backend_lang::target::InstKind;
assert!(InstKind::Return.is_terminator());
assert!(!InstKind::Plain.is_terminator());