cranelift_codegen::isa::x64::encoding::vex

Struct VexInstruction

Source
pub struct VexInstruction { /* private fields */ }
Available on crate feature x86 only.
Expand description

Constructs a VEX-encoded instruction using a builder pattern. This approach makes it visually easier to transform something the manual’s syntax, VEX.128.66.0F 73 /7 ib to code: VexInstruction::new().length(...).prefix(...).map(...).w(true).opcode(0x1F).reg(...).rm(...).

Implementations§

Source§

impl VexInstruction

Source

pub fn new() -> Self

Construct a default VEX instruction.

Source

pub fn length(self, length: VexVectorLength) -> Self

Set the length of the instruction.

Source

pub fn prefix(self, prefix: LegacyPrefixes) -> Self

Set the legacy prefix byte of the instruction: None | 66 | F2 | F3. VEX instructions pack these into the prefix, not as separate bytes.

Source

pub fn map(self, map: OpcodeMap) -> Self

Set the opcode map byte of the instruction: None | 0F | 0F38 | 0F3A. VEX instructions pack these into the prefix, not as separate bytes.

Source

pub fn w(self, w: bool) -> Self

Set the W bit, denoted by .W1 or .W0 in the instruction string. Typically used to indicate an instruction using 64 bits of an operand (e.g. 64 bit lanes). EVEX packs this bit in the EVEX prefix; previous encodings used the REX prefix.

Source

pub fn opcode(self, opcode: u8) -> Self

Set the instruction opcode byte.

Source

pub fn reg(self, reg: impl Into<Register>) -> Self

Set the register to use for the reg bits; many instructions use this as the write operand.

Source

pub fn opcode_ext(self, n: u8) -> Self

Some instructions use the ModRM.reg field as an opcode extension. This is usually denoted by a /n field in the manual.

Source

pub fn rm(self, reg: impl Into<RegisterOrAmode>) -> Self

Set the register to use for the rm bits; many instructions use this as the “read from register/memory” operand. Setting this affects both the ModRM byte (rm section) and the VEX prefix (the extension bits for register encodings > 8).

Source

pub fn vvvv(self, reg: impl Into<Register>) -> Self

Set the vvvv register; some instructions allow using this as a second, non-destructive source register in 3-operand instructions (e.g. 2 read, 1 write).

Source

pub fn imm_reg(self, reg: impl Into<Register>) -> Self

Set the imm byte when used for a register. The reg bits are stored in imm8[7:4] with the lower bits unused. Overrides a previously set Self::imm field.

Source

pub fn imm(self, imm: u8) -> Self

Set the imm byte. Overrides a previously set Self::imm_reg field.

Source

pub fn encode(&self, sink: &mut MachBuffer<Inst>)

Emit the VEX-encoded instruction to the provided buffer.

Trait Implementations§

Source§

impl Default for VexInstruction

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.