Skip to main content

EncoderRequest

Struct EncoderRequest 

Source
pub struct EncoderRequest {
    pub mnemonic: Mnemonic,
    pub operands: [EncoderOperand; 5],
    pub operand_count: u8,
    pub operand_size: u8,
    pub address_size: u8,
    pub mask_reg: Option<Register>,
    pub zeroing_mode: EvexZeroingMode,
    pub preferred_encoding: Option<EncodableEncoding>,
    pub branch_type: BranchType,
    pub branch_width: BranchWidth,
    pub hints: EncoderHints,
}
Expand description

Request to encode an x86/x64 instruction

This structure contains all the information needed to encode an instruction, including the mnemonic, operands, and size overrides.

Fields§

§mnemonic: Mnemonic

The instruction mnemonic

§operands: [EncoderOperand; 5]

Operands for the instruction

§operand_count: u8

Number of valid operands

§operand_size: u8

Effective operand size override (0 = default, 16/32/64 = override)

§address_size: u8

Effective address size override (0 = default, 16/32/64 = override)

§mask_reg: Option<Register>

Mask register for AVX-512 (k0-k7), None for no masking

§zeroing_mode: EvexZeroingMode

Zeroing mode for AVX-512 masked operations

§preferred_encoding: Option<EncodableEncoding>

Preferred encoding type (None = auto-select)

§branch_type: BranchType

Branch type (None = auto-select, Short/Near/Far = explicit)

§branch_width: BranchWidth

Branch width (None = auto-select based on offset)

§hints: EncoderHints

Encoder hints for advanced features

Implementations§

Source§

impl EncoderRequest

Source

pub fn new(mnemonic: Mnemonic) -> Self

Create a new encoder request with the given mnemonic

Source

pub fn with_operand(self, operand: EncoderOperand) -> Self

Add an operand to the request

Operands are added in order. Up to MAX_ENCODER_OPERANDS operands can be added.

Source

pub fn with_reg(self, register: Register) -> Self

Add a register operand

Source

pub fn with_mem(self, memory: MemoryOperand) -> Self

Add a memory operand

Source

pub fn with_imm(self, value: u64) -> Self

Add an immediate operand

Source

pub fn with_rel(self, offset: i32) -> Self

Add a relative offset operand

Source

pub fn with_operand_size(self, size: u16) -> Self

Set the operand size override (16, 32, or 64 bits)

Source

pub fn with_address_size(self, size: u16) -> Self

Set the address size override (16, 32, or 64 bits)

Source

pub fn with_mask(self, mask: Register) -> Self

Set the mask register for AVX-512 operations (k0-k7)

Source

pub fn with_zeroing(self, zeroing: EvexZeroingMode) -> Self

Set the zeroing mode for AVX-512 masked operations

Source

pub fn with_zeroing_enabled(self) -> Self

Enable zeroing mode (convenience method)

Source

pub fn with_encoding(self, encoding: EncodableEncoding) -> Self

Set the preferred encoding type

Source

pub fn with_branch_type(self, branch_type: BranchType) -> Self

Set the branch type (Short, Near, Far)

Source

pub fn with_branch_width(self, branch_width: BranchWidth) -> Self

Set the branch width

Source

pub fn with_broadcast(self, mode: BroadcastMode) -> Self

Set broadcast mode for AVX-512

Source

pub fn with_rounding(self, mode: RoundingMode) -> Self

Set rounding mode for AVX-512

Source

pub fn with_sae(self) -> Self

Enable SAE (Suppress All Exceptions) for AVX-512

Source

pub fn with_hints(self, hints: EncoderHints) -> Self

Set encoder hints

Source

pub const fn has_mask(&self) -> bool

Check if AVX-512 masking is enabled

Source

pub const fn is_zeroing(&self) -> bool

Check if zeroing mode is enabled

Source

pub const fn has_preferred_encoding(&self) -> bool

Check if a specific encoding is requested

Source

pub const fn has_broadcast(&self) -> bool

Check if broadcast mode is enabled

Source

pub const fn has_rounding(&self) -> bool

Check if rounding mode is specified

Source

pub const fn has_sae(&self) -> bool

Check if SAE is enabled

Source

pub const fn has_branch_type(&self) -> bool

Check if a specific branch type is requested

Source

pub fn from_decoded(instruction: &DecodedInstruction) -> Self

Create from a decoded instruction

This is useful for re-encoding a decoded instruction, possibly with modifications.

Source

pub fn operand(&self, index: usize) -> Option<&EncoderOperand>

Get an operand by index

Source

pub fn operands(&self) -> impl Iterator<Item = &EncoderOperand>

Iterate over valid operands

Source

pub const fn has_operands(&self) -> bool

Check if the request has any operands

Source

pub const fn has_operand_size_override(&self) -> bool

Check if the request has an operand size override

Source

pub const fn has_address_size_override(&self) -> bool

Check if the request has an address size override

Source

pub fn has_memory_operand(&self) -> bool

Check if any operand is a memory operand

Source

pub fn has_immediate_operand(&self) -> bool

Check if any operand is an immediate

Source

pub fn has_relative_operand(&self) -> bool

Check if any operand is a relative offset

Source

pub fn has_zmm_operand(&self) -> bool

Check if any operand is a ZMM register (for AVX-512 detection)

Source

pub fn clear_operands(&mut self)

Clear all operands

Trait Implementations§

Source§

impl Clone for EncoderRequest

Source§

fn clone(&self) -> EncoderRequest

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EncoderRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EncoderRequest

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.