Struct AddressComputation
pub struct AddressComputation {
pub offset: i64,
pub terms: [AddrTerm; 4],
}
Expand description
An address computation of a memory access.
The address computation is a sum of shift-then-multiplied values.
For example: A + (B >> 1) * 4 + offset
Fields§
§offset: i64
The offsets that is added to the computation.
terms: [AddrTerm; 4]
The terms in the computation. There are always four terms, but some terms may be effectively 0.
Implementations§
§impl AddressComputation
impl AddressComputation
pub fn compute<A: Arch>(
&self,
inputs: &Inputs<A>,
state: &SystemState<A>,
) -> u64
pub fn compute<A: Arch>( &self, inputs: &Inputs<A>, state: &SystemState<A>, ) -> u64
Computes the address accessed by the instruction when executed on state
, given that the computation uses inputs
.
pub fn compute_from_gpregs<A: Arch>(
&self,
inputs: &[A::GpReg],
state: &SystemState<A>,
) -> u64
pub fn compute_from_gpregs<A: Arch>( &self, inputs: &[A::GpReg], state: &SystemState<A>, ) -> u64
Computes the address accessed by the instruction when executed on state
, given that the computation uses inputs
.
pub fn evaluate_from_iter(&self, inputs: impl Iterator<Item = u64>) -> u64
pub fn evaluate_from_iter(&self, inputs: impl Iterator<Item = u64>) -> u64
Computes the address, using inputs
.
§impl AddressComputation
impl AddressComputation
pub fn unscaled_sum(num: usize) -> AddressComputation
pub fn unscaled_sum(num: usize) -> AddressComputation
An address computation of the form A + B + C
.
num
determines the number of inputs.
num
cannot be more than 4.
pub fn with_offset(self, offset: i64) -> AddressComputation
pub fn with_offset(self, offset: i64) -> AddressComputation
Returns a new computation with the offset replaced with the specified offset
.
pub fn with_added_offset(self, offset: i64) -> AddressComputation
pub fn with_added_offset(self, offset: i64) -> AddressComputation
Returns a new computation with the offset incremented with the specified offset
.
pub fn new_with_inferred_offset<A: Arch>(
terms: [AddrTerm; 4],
inputs: &Inputs<A>,
state: &SystemState<A>,
expected: u64,
) -> AddressComputation
pub fn new_with_inferred_offset<A: Arch>( terms: [AddrTerm; 4], inputs: &Inputs<A>, state: &SystemState<A>, expected: u64, ) -> AddressComputation
Returns a new computation with an offset inferred from the expected address expected
.
pub fn from_iter(
terms: impl Iterator<Item = AddrTerm>,
offset: i64,
) -> AddressComputation
pub fn from_iter( terms: impl Iterator<Item = AddrTerm>, offset: i64, ) -> AddressComputation
Returns a new computation with the terms (max 4) from terms
and the offset
specified.
pub fn constant_offset_with(&self, other: &AddressComputation) -> Option<i64>
pub fn constant_offset_with(&self, other: &AddressComputation) -> Option<i64>
Returns the fixed difference (other - self) between two address calculations, if they are given the same inputs
When adding this offset to the address for self
, you will obtain the adress for other
.
pub fn constant_offset_considering_inputs<A: Arch>(
&self,
inputs: &Inputs<A>,
other: &AddressComputation,
other_inputs: &Inputs<A>,
) -> Option<i64>
pub fn constant_offset_considering_inputs<A: Arch>( &self, inputs: &Inputs<A>, other: &AddressComputation, other_inputs: &Inputs<A>, ) -> Option<i64>
Returns the fixed difference (other - self) between two address calculations, if they are given the same inputs
When adding this offset to the address for self
, you will obtain the adress for other
.
pub fn add_constant_term(&mut self)
pub fn add_constant_term(&mut self)
Adds a new AddrTerm::identity
term if there are less than 4 terms.
Otherwise, does nothing.
pub fn remove_term(self, index: usize) -> AddressComputation
pub fn remove_term(self, index: usize) -> AddressComputation
Removes the term at position index
from the computation.
If there are less than index + 1
terms, the same computation is returned.
pub fn unify_terms(
self,
first_index: usize,
second_index: usize,
) -> Option<AddressComputation>
pub fn unify_terms( self, first_index: usize, second_index: usize, ) -> Option<AddressComputation>
Combines the two terms, assuming they have the same index.
For example, A + A * 2
would be unified to A * 3
.
Trait Implementations§
§impl Clone for AddressComputation
impl Clone for AddressComputation
§fn clone(&self) -> AddressComputation
fn clone(&self) -> AddressComputation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Computation for AddressComputation
impl Computation for AddressComputation
§fn evaluate<V: AsValue>(&self, inputs: &[V]) -> OwnedValue
fn evaluate<V: AsValue>(&self, inputs: &[V]) -> OwnedValue
inputs
.§fn display<'a, S: AsRef<str>>(
&'a self,
input_names: &'a [S],
) -> impl Display + Debug + 'a
fn display<'a, S: AsRef<str>>( &'a self, input_names: &'a [S], ) -> impl Display + Debug + 'a
input_names
in place of the inputs.§fn used_input_indices(&self) -> Vec<usize>
fn used_input_indices(&self) -> Vec<usize>
§fn remap_inputs(&mut self, map: &[Option<usize>])
fn remap_inputs(&mut self, map: &[Option<usize>])
new_index = map[old_index].unwrap_or(old_index)
.§fn is_identity(&self) -> bool
fn is_identity(&self) -> bool
§fn compare_eq<V: AsValue>(&self, inputs: &[V], expected: Value<'_>) -> bool
fn compare_eq<V: AsValue>(&self, inputs: &[V], expected: Value<'_>) -> bool
expected
matches the output of the computation.
This function can be more efficient than manually comparing the result of self.evaluate(..)
.
For example, we can avoid allocating a Vec
for OwnedValue::Bytes
results.§impl Debug for AddressComputation
impl Debug for AddressComputation
§impl<'de> Deserialize<'de> for AddressComputation
impl<'de> Deserialize<'de> for AddressComputation
§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
§impl Hash for AddressComputation
impl Hash for AddressComputation
§impl JsonSchema for AddressComputation
impl JsonSchema for AddressComputation
§fn schema_name() -> String
fn schema_name() -> String
§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read more§impl Ord for AddressComputation
impl Ord for AddressComputation
§fn cmp(&self, other: &AddressComputation) -> Ordering
fn cmp(&self, other: &AddressComputation) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl PartialEq for AddressComputation
impl PartialEq for AddressComputation
§impl PartialOrd for AddressComputation
impl PartialOrd for AddressComputation
§impl Serialize for AddressComputation
impl Serialize for AddressComputation
impl Copy for AddressComputation
impl Eq for AddressComputation
impl StructuralPartialEq for AddressComputation
Auto Trait Implementations§
impl Freeze for AddressComputation
impl RefUnwindSafe for AddressComputation
impl Send for AddressComputation
impl Sync for AddressComputation
impl Unpin for AddressComputation
impl UnwindSafe for AddressComputation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more