Struct falcon::il::Instruction

source ·
pub struct Instruction { /* private fields */ }
Expand description

An Instruction represents location, and non-semantical information about an Operation.

An instruction gives location to an Operation.

Methods are provided to create individual instructions, as all uses cases cannot be seen beforehand. However, it is generally poor-form to create an Instruction manually. You should use the methods on Block which correspond to the Operation you wish to create, and the Instruction will be created automatically.

Implementations§

source§

impl Instruction

source

pub fn new(index: usize, operation: Operation) -> Instruction

Create a new instruction with the given index and operation.

Warning

You almost never want to call this function. You should use the methods on il::Block which correspond to the operation you wish to append to that block.

source

pub fn assign(index: usize, dst: Scalar, src: Expression) -> Instruction

Create a new Assign instruction.

Warning

You almost never want to call this function. You should use the assign method on il::Block instead.

source

pub fn store( instruction_index: usize, index: Expression, src: Expression ) -> Instruction

Create a new Store instruction.

Warning

You almost never want to call this function. You should use the store method on il::Block instead.

source

pub fn load( instruction_index: usize, dst: Scalar, index: Expression ) -> Instruction

Create a new Load instruction.

Warning

You almost never want to call this function. You should use the load method on il::Block instead.

source

pub fn branch(index: usize, target: Expression) -> Instruction

Create a new Brc instruction.

Warning

You almost never want to call this function. You should use the brc method on il::Block instead.

source

pub fn intrinsic(index: usize, intrinsic: Intrinsic) -> Instruction

Create a new Intrinsic instruction.

Warning

You almost never want to call this function. You should use the intrinsic method on il::Block instead.

source

pub fn nop(index: usize) -> Instruction

Create a new Nop instruction.

Warning

You almost never want to call this function. You should use the nop method on il::Block instead.

source

pub fn placeholder(index: usize, operation: Operation) -> Instruction

Create a new Nop instruction as placeholder for the given Operation.

Warning

You almost never want to call this function. You should use the nop_placeholder method on il::Block instead.

source

pub fn is_assign(&self) -> bool

Returns true if the Operation for this Instruction is Operation::Assign

source

pub fn is_store(&self) -> bool

Returns true if the Operation for this Instruction is Operation::Store

source

pub fn is_load(&self) -> bool

Returns true if the Operation for this Instruction is Operation::Load

source

pub fn is_branch(&self) -> bool

Returns true if the Operation for this Instruction is Operation::Brc

source

pub fn operation(&self) -> &Operation

Get the Operation for this Instruction

source

pub fn operation_mut(&mut self) -> &mut Operation

Get a mutable reference to the Operation for this Instruction

source

pub fn index(&self) -> usize

Get the index for this Instruction.

An Instruction index is assigned by its parent Block and uniquely identifies the Instruction within the Block. Instruction indices need not be continuous, nor in order.

source

pub fn comment(&self) -> Option<&str>

Get the optional comment for this Instruction

source

pub fn set_comment(&mut self, comment: Option<String>)

Set the optional comment for this Instruction

source

pub fn address(&self) -> Option<u64>

Get the optional address for this Instruction

An Instruction will typically have an address if one was given by a translator. It is not uncommon for there to be a mixture of Instructions with and without comments. For example, applying SSA to a Function will cause Phi instructions to be inserted, and these instructions will not have addresses.

source

pub fn set_address(&mut self, address: Option<u64>)

Set the optional address for this Instruction

source

pub fn scalars_written(&self) -> Option<Vec<&Scalar>>

Get the Scalar which will be written by this Instruction.

source

pub fn scalar_written_mut(&mut self) -> Option<Vec<&mut Scalar>>

Get a mutable reference to the Scalar which will be written by this Instruction.

source

pub fn scalars_read(&self) -> Option<Vec<&Scalar>>

Get a Vec of each Scalar read by this Instruction.

source

pub fn scalars_read_mut(&mut self) -> Option<Vec<&mut Scalar>>

Get a Vec of mutable references for each Scalar read by this Instruction.

source

pub fn scalars(&self) -> Option<Vec<&Scalar>>

Get all the scalars used in this instruction

Trait Implementations§

source§

impl Clone for Instruction

source§

fn clone(&self) -> Instruction

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 Debug for Instruction

source§

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

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

impl Default for Instruction

source§

fn default() -> Instruction

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

impl<'de> Deserialize<'de> for Instruction

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Instruction

source§

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

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

impl Hash for Instruction

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 Instruction

source§

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

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

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

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

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

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

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

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

impl PartialEq<Instruction> for Instruction

source§

fn eq(&self, other: &Instruction) -> 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<Instruction> for Instruction

source§

fn partial_cmp(&self, other: &Instruction) -> 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 Serialize for Instruction

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Instruction

source§

impl StructuralEq for Instruction

source§

impl StructuralPartialEq for Instruction

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,