Trait cranelift_codegen::machinst::MachInst
source · [−]pub trait MachInst: Clone + Debug {
type LabelUse: MachInstLabelUse;
Show 17 methods
fn get_regs(&self, collector: &mut RegUsageCollector<'_>);
fn map_regs<RUM: RegUsageMapper>(&mut self, maps: &RUM);
fn is_move(&self) -> Option<(Writable<Reg>, Reg)>;
fn is_term<'a>(&'a self) -> MachTerminator<'a>;
fn is_epilogue_placeholder(&self) -> bool;
fn gen_move(to_reg: Writable<Reg>, from_reg: Reg, ty: Type) -> Self;
fn gen_constant<F: FnMut(Type) -> Writable<Reg>>(
to_regs: ValueRegs<Writable<Reg>>,
value: u128,
ty: Type,
alloc_tmp: F
) -> SmallVec<[Self; 4]>;
fn gen_zero_len_nop() -> Self;
fn maybe_direct_reload(
&self,
reg: VirtualReg,
slot: SpillSlot
) -> Option<Self>;
fn rc_for_type(
ty: Type
) -> CodegenResult<(&'static [RegClass], &'static [Type])>;
fn gen_jump(target: MachLabel) -> Self;
fn gen_nop(preferred_size: usize) -> Self;
fn reg_universe(flags: &Flags) -> RealRegUniverse;
fn worst_case_size() -> CodeOffset;
fn ref_type_regclass(_flags: &Flags) -> RegClass;
fn is_included_in_clobbers(&self) -> bool { ... }
fn align_basic_block(offset: CodeOffset) -> CodeOffset { ... }
}
Expand description
A machine instruction.
Associated Types
A label-use kind: a type that describes the types of label references that can occur in an instruction.
Required methods
fn get_regs(&self, collector: &mut RegUsageCollector<'_>)
fn get_regs(&self, collector: &mut RegUsageCollector<'_>)
Return the registers referenced by this machine instruction along with the modes of reference (use, def, modify).
fn map_regs<RUM: RegUsageMapper>(&mut self, maps: &RUM)
fn map_regs<RUM: RegUsageMapper>(&mut self, maps: &RUM)
Map virtual registers to physical registers using the given virt->phys maps corresponding to the program points prior to, and after, this instruction.
If this is a simple move, return the (source, destination) tuple of registers.
fn is_term<'a>(&'a self) -> MachTerminator<'a>
fn is_term<'a>(&'a self) -> MachTerminator<'a>
Is this a terminator (branch or ret)? If so, return its type (ret/uncond/cond) and target if applicable.
fn is_epilogue_placeholder(&self) -> bool
fn is_epilogue_placeholder(&self) -> bool
Returns true if the instruction is an epilogue placeholder.
Generate a constant into a reg.
fn gen_zero_len_nop() -> Self
fn gen_zero_len_nop() -> Self
Generate a zero-length no-op.
fn maybe_direct_reload(&self, reg: VirtualReg, slot: SpillSlot) -> Option<Self>
fn maybe_direct_reload(&self, reg: VirtualReg, slot: SpillSlot) -> Option<Self>
Possibly operate on a value directly in a spill-slot rather than a register. Useful if the machine has register-memory instruction forms (e.g., add directly from or directly to memory), like x86.
fn rc_for_type(
ty: Type
) -> CodegenResult<(&'static [RegClass], &'static [Type])>
fn rc_for_type(
ty: Type
) -> CodegenResult<(&'static [RegClass], &'static [Type])>
Determine register class(es) to store the given Cranelift type, and the Cranelift type actually stored in the underlying register(s). May return an error if the type isn’t supported by this backend.
If the type requires multiple registers, then the list of registers is returned in little-endian order.
Note that the type actually stored in the register(s) may differ in the case that a value is split across registers: for example, on a 32-bit target, an I64 may be stored in two registers, each of which holds an I32. The actually-stored types are used only to inform the backend when generating spills and reloads for individual registers.
Generate a jump to another target. Used during lowering of control flow.
Generate a NOP. The preferred_size
parameter allows the caller to
request a NOP of that size, or as close to it as possible. The machine
backend may return a NOP whose binary encoding is smaller than the
preferred size, but must not return a NOP that is larger. However,
the instruction must have a nonzero size.
fn reg_universe(flags: &Flags) -> RealRegUniverse
fn reg_universe(flags: &Flags) -> RealRegUniverse
Get the register universe for this backend.
fn worst_case_size() -> CodeOffset
fn worst_case_size() -> CodeOffset
What is the worst-case instruction size emitted by this instruction type?
fn ref_type_regclass(_flags: &Flags) -> RegClass
fn ref_type_regclass(_flags: &Flags) -> RegClass
What is the register class used for reference types (GC-observable pointers)? Can be dependent on compilation flags.
Provided methods
fn is_included_in_clobbers(&self) -> bool
fn is_included_in_clobbers(&self) -> bool
Should this instruction be included in the clobber-set?
fn align_basic_block(offset: CodeOffset) -> CodeOffset
fn align_basic_block(offset: CodeOffset) -> CodeOffset
Align a basic block offset (from start of function). By default, no alignment occurs.