#[non_exhaustive]pub enum Operand {
Reg(Reg),
Imm(i64),
Mem(Mem),
Slot {
slot: StackSlot,
offset: i32,
},
Symbol(Symbol),
Cond(CondCode),
Block(BlockCall),
}Expand description
One operand of a machine instruction.
Which shapes an operand position takes is the instruction’s
OperandRule; Function::push checks
them.
§Examples
use backend_lang::mir::{Mem, Operand};
use backend_lang::x86_64::RDI;
let ops = [
Operand::Reg(RDI.into()),
Operand::Imm(-1),
Operand::Mem(Mem::base(RDI.into()).with_disp(8)),
];
assert!(matches!(ops[1], Operand::Imm(-1)));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Reg(Reg)
A register, virtual or physical.
Imm(i64)
An immediate: a signed value of the operation’s width.
Mem(Mem)
Memory at an address computed from registers.
Slot
Memory in a stack slot, offset bytes into it.
Symbol(Symbol)
A function, by name: a direct call target, or (as a memory operand of
lea) the function’s address.
Cond(CondCode)
A condition code.
Block(BlockCall)
A branch target with arguments.
Implementations§
Source§impl Operand
impl Operand
Sourcepub const fn slot(slot: StackSlot) -> Operand
pub const fn slot(slot: StackSlot) -> Operand
The stack slot itself (offset 0): the form block parameters, branch arguments, and copies use.
§Examples
use backend_lang::mir::{Operand, StackSlot};
let s = StackSlot::new(2);
assert_eq!(Operand::slot(s), Operand::Slot { slot: s, offset: 0 });Trait Implementations§
impl Copy for Operand
impl Eq for Operand
impl StructuralPartialEq for Operand
Auto Trait Implementations§
impl Freeze for Operand
impl RefUnwindSafe for Operand
impl Send for Operand
impl Sync for Operand
impl Unpin for Operand
impl UnsafeUnpin for Operand
impl UnwindSafe for Operand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more