Skip to main content

Instruction

Struct Instruction 

Source
pub struct Instruction {
    pub word: usize,
    pub opcode: u16,
    pub control: u32,
    pub extensions: Vec<u32>,
    pub saturate: bool,
    pub nonzero: bool,
    pub operands: Vec<Operand>,
    pub function: Option<u32>,
}
Expand description

An instruction as stored.

Fields§

§word: usize

The instruction’s first word in the token stream.

§opcode: u16

The opcode token’s low 11 bits (see opcode_name).

§control: u32

The opcode token’s bits 11 to 23: saturate and the opcode-specific controls (the test of a conditional, a resinfo return type, the interpolation of a declaration).

§extensions: Vec<u32>

The opcode’s extended tokens as stored (sample offsets, resource dimension, return type).

§saturate: bool

The saturate bit of the opcode token.

§nonzero: bool

A conditional (if, breakc, continuec) taken when its operand is nonzero (_nz), else when zero (_z).

§operands: Vec<Operand>

The operands, destination first where the instruction has one.

§function: Option<u32>

The call site an interface_call stores before its operand (the entry of the interface’s function tables it calls); None for other instructions.

Implementations§

Source§

impl Instruction

Source

pub fn precise_mask(&self) -> u8

The components the instruction is marked precise for (control bits 8 to 11, the token’s bits 19 to 22): bit 0 x to bit 3 w, zero where it is not marked. The compiler marks every instruction of a precise expression.

Source

pub fn sync_flags(&self) -> Option<SyncFlags>

What a sync instruction waits for; None for any other instruction.

Source

pub fn info_return(&self) -> Option<InfoReturn>

The type a resinfo or sample_info returns; None for any other instruction, and for a return type the token format does not define.

Source§

impl Instruction

Source

pub fn name(&self) -> &'static str

The opcode’s name (mov, add, …), or unknown opcode.

Source

pub fn sample_offset(&self) -> Option<[i32; 3]>

The sample offsets of the extended token of kind 1 (_aoffimmi), if the instruction has one.

Source

pub fn resource_dimension(&self) -> Option<(u32, u32)>

The resource dimension and structured stride of the extended token of kind 2.

Source

pub fn return_type(&self) -> Option<u32>

The return-type token of the extended token of kind 3 (four nibbles).

Source

pub fn format(&self) -> Option<OperandFormat>

The opcode’s operand format (see operand_format); decode has checked the operand count against it.

Source

pub fn destinations_and_sources(&self) -> Option<(&[Operand], &[Operand])>

The destination operands and the source operands, split as the opcode’s format says; None for an opcode with no format.

Trait Implementations§

Source§

impl Clone for Instruction

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Instruction

Source§

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

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.