pub struct InstDecoder { /* private fields */ }
Expand description

an x86_64 instruction decoder.

fundamentally this is one or two primitives with no additional state kept during decoding. it can be copied cheaply, hashed cheaply, compared cheaply. if you really want to share an InstDecoder between threads, you could - but you might want to clone it instead.

unless you’re using an Arc<Mutex<InstDecoder>>, which is fine but i’d be very curious about the design requiring that.

Implementations§

source§

impl InstDecoder

source

pub fn minimal() -> Self

instantiates an x86_64 decoder that decodes the bare minimum of x86_64.

pedantic and only decodes what the spec says is well-defined, rejecting undefined sequences and any instructions defined by extensions.

source

pub fn decode_slice(&self, data: &[u8]) -> Result<Instruction, DecodeError>

helper to decode an instruction directly from a byte slice.

this lets callers avoid the work of setting up a yaxpeax_arch::U8Reader for the slice to decode.

source

pub fn sse3(&self) -> bool

source

pub fn with_sse3(self) -> Self

source

pub fn ssse3(&self) -> bool

source

pub fn with_ssse3(self) -> Self

source

pub fn monitor(&self) -> bool

source

pub fn with_monitor(self) -> Self

source

pub fn vmx(&self) -> bool

source

pub fn with_vmx(self) -> Self

source

pub fn fma3(&self) -> bool

source

pub fn with_fma3(self) -> Self

source

pub fn cmpxchg16b(&self) -> bool

source

pub fn with_cmpxchg16b(self) -> Self

source

pub fn sse4_1(&self) -> bool

source

pub fn with_sse4_1(self) -> Self

source

pub fn sse4_2(&self) -> bool

source

pub fn with_sse4_2(self) -> Self

source

pub fn with_sse4(self) -> Self

source

pub fn movbe(&self) -> bool

source

pub fn with_movbe(self) -> Self

source

pub fn popcnt(&self) -> bool

source

pub fn with_popcnt(self) -> Self

source

pub fn aesni(&self) -> bool

source

pub fn with_aesni(self) -> Self

source

pub fn xsave(&self) -> bool

source

pub fn with_xsave(self) -> Self

source

pub fn rdrand(&self) -> bool

source

pub fn with_rdrand(self) -> Self

source

pub fn sgx(&self) -> bool

source

pub fn with_sgx(self) -> Self

source

pub fn bmi1(&self) -> bool

source

pub fn with_bmi1(self) -> Self

source

pub fn avx2(&self) -> bool

source

pub fn with_avx2(self) -> Self

source

pub fn bmi2(&self) -> bool

bmi2 indicates support for the BZHI, MULX, PDEP, PEXT, RORX, SARX, SHRX, and SHLX instructions. bmi2 is implemented in all x86_64 chips that implement bmi, except the amd piledriver and steamroller microarchitectures.

source

pub fn with_bmi2(self) -> Self

source

pub fn invpcid(&self) -> bool

source

pub fn with_invpcid(self) -> Self

source

pub fn mpx(&self) -> bool

source

pub fn with_mpx(self) -> Self

source

pub fn avx512_f(&self) -> bool

source

pub fn with_avx512_f(self) -> Self

source

pub fn avx512_dq(&self) -> bool

source

pub fn with_avx512_dq(self) -> Self

source

pub fn rdseed(&self) -> bool

source

pub fn with_rdseed(self) -> Self

source

pub fn adx(&self) -> bool

source

pub fn with_adx(self) -> Self

source

pub fn avx512_fma(&self) -> bool

source

pub fn with_avx512_fma(self) -> Self

source

pub fn pcommit(&self) -> bool

source

pub fn with_pcommit(self) -> Self

source

pub fn clflushopt(&self) -> bool

source

pub fn with_clflushopt(self) -> Self

source

pub fn clwb(&self) -> bool

source

pub fn with_clwb(self) -> Self

source

pub fn avx512_pf(&self) -> bool

source

pub fn with_avx512_pf(self) -> Self

source

pub fn avx512_er(&self) -> bool

source

pub fn with_avx512_er(self) -> Self

source

pub fn avx512_cd(&self) -> bool

source

pub fn with_avx512_cd(self) -> Self

source

pub fn sha(&self) -> bool

source

pub fn with_sha(self) -> Self

source

pub fn avx512_bw(&self) -> bool

source

pub fn with_avx512_bw(self) -> Self

source

pub fn avx512_vl(&self) -> bool

source

pub fn with_avx512_vl(self) -> Self

source

pub fn prefetchwt1(&self) -> bool

source

pub fn with_prefetchwt1(self) -> Self

source

pub fn avx512_vbmi(&self) -> bool

source

pub fn with_avx512_vbmi(self) -> Self

source

pub fn avx512_vbmi2(&self) -> bool

source

pub fn with_avx512_vbmi2(self) -> Self

source

pub fn gfni(&self) -> bool

source

pub fn with_gfni(self) -> Self

source

pub fn vaes(&self) -> bool

source

pub fn with_vaes(self) -> Self

source

pub fn pclmulqdq(&self) -> bool

source

pub fn with_pclmulqdq(self) -> Self

source

pub fn avx_vnni(&self) -> bool

source

pub fn with_avx_vnni(self) -> Self

source

pub fn avx512_bitalg(&self) -> bool

source

pub fn with_avx512_bitalg(self) -> Self

source

pub fn avx512_vpopcntdq(&self) -> bool

source

pub fn with_avx512_vpopcntdq(self) -> Self

source

pub fn avx512_4vnniw(&self) -> bool

source

pub fn with_avx512_4vnniw(self) -> Self

source

pub fn avx512_4fmaps(&self) -> bool

source

pub fn with_avx512_4fmaps(self) -> Self

source

pub fn avx512(&self) -> bool

returns true if this InstDecoder has all avx512 features enabled.

source

pub fn with_avx512(self) -> Self

enable all avx512 features on this InstDecoder. no real CPU, at time of writing, actually has such a feature combination, but this is a useful overestimate for avx512 generally.

source

pub fn cx8(&self) -> bool

source

pub fn with_cx8(self) -> Self

source

pub fn syscall(&self) -> bool

source

pub fn with_syscall(self) -> Self

source

pub fn rdtscp(&self) -> bool

source

pub fn with_rdtscp(self) -> Self

source

pub fn abm(&self) -> bool

source

pub fn with_abm(self) -> Self

source

pub fn sse4a(&self) -> bool

source

pub fn with_sse4a(self) -> Self

source

pub fn _3dnowprefetch(&self) -> bool

source

pub fn with_3dnowprefetch(self) -> Self

source

pub fn xop(&self) -> bool

source

pub fn with_xop(self) -> Self

source

pub fn skinit(&self) -> bool

source

pub fn with_skinit(self) -> Self

source

pub fn tbm(&self) -> bool

source

pub fn with_tbm(self) -> Self

source

pub fn intel_quirks(&self) -> bool

source

pub fn with_intel_quirks(self) -> Self

source

pub fn amd_quirks(&self) -> bool

source

pub fn with_amd_quirks(self) -> Self

source

pub fn avx(&self) -> bool

source

pub fn with_avx(self) -> Self

source

pub fn svm(&self) -> bool

source

pub fn with_svm(self) -> Self

source

pub fn lahfsahf(&self) -> bool

lahfsahf is only unset for early revisions of 64-bit amd and intel chips. unfortunately the clearest documentation on when these instructions were reintroduced into 64-bit architectures seems to be wikipedia:

Early AMD64 and Intel 64 CPUs lacked LAHF and SAHF instructions in 64-bit mode. AMD
introduced these instructions (also in 64-bit mode) with their Athlon 64, Opteron and
Turion 64 revision D processors in March 2005[48][49][50] while Intel introduced the
instructions with the Pentium 4 G1 stepping in December 2005. The 64-bit version of Windows
8.1 requires this feature.[47]

this puts reintroduction of these instructions somewhere in the middle of prescott and k8 lifecycles, for intel and amd respectively. because there is no specific uarch where these features become enabled, prescott and k8 default to not supporting these instructions, where later uarches support these instructions.

source

pub fn with_lahfsahf(self) -> Self

source

pub fn cmov(&self) -> bool

source

pub fn with_cmov(self) -> Self

source

pub fn f16c(&self) -> bool

source

pub fn with_f16c(self) -> Self

source

pub fn fma4(&self) -> bool

source

pub fn with_fma4(self) -> Self

source

pub fn prefetchw(&self) -> bool

source

pub fn with_prefetchw(self) -> Self

source

pub fn tsx(&self) -> bool

source

pub fn with_tsx(self) -> Self

source

pub fn lzcnt(&self) -> bool

source

pub fn with_lzcnt(self) -> Self

Trait Implementations§

source§

impl AnnotatingDecoder<Arch> for InstDecoder

source§

impl Clone for InstDecoder

source§

fn clone(&self) -> InstDecoder

Returns a copy 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 Decoder<Arch> for InstDecoder

source§

fn decode<T: Reader<<Arch as Arch>::Address, <Arch as Arch>::Word>>( &self, words: &mut T ) -> Result<Instruction, <Arch as Arch>::DecodeError>

decode one instruction for this architecture from the crate::Reader of this architecture’s Word.
source§

fn decode_into<T: Reader<<Arch as Arch>::Address, <Arch as Arch>::Word>>( &self, instr: &mut Instruction, words: &mut T ) -> Result<(), <Arch as Arch>::DecodeError>

decode one instruction for this architecture from the crate::Reader of this architecture’s Word, writing into the provided inst. Read more
source§

impl Default for InstDecoder

source§

fn default() -> Self

Instantiates an x86_64 decoder that probably decodes what you want.

Attempts to match real processors in interpretation of undefined sequences, and decodes any instruction defined in any extension.

source§

impl Display for InstDecoder

source§

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

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

impl Hash for InstDecoder

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for InstDecoder

source§

fn cmp(&self, other: &InstDecoder) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for InstDecoder

source§

fn eq(&self, other: &InstDecoder) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for InstDecoder

source§

fn partial_cmp(&self, other: &InstDecoder) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for InstDecoder

source§

impl Eq for InstDecoder

source§

impl StructuralEq for InstDecoder

source§

impl StructuralPartialEq for InstDecoder

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.