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
impl Instruction
sourcepub fn new(index: usize, operation: Operation) -> Instruction
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.
sourcepub fn assign(index: usize, dst: Scalar, src: Expression) -> Instruction
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.
sourcepub fn store(
instruction_index: usize,
index: Expression,
src: Expression
) -> Instruction
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.
sourcepub fn load(
instruction_index: usize,
dst: Scalar,
index: Expression
) -> Instruction
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.
sourcepub fn branch(index: usize, target: Expression) -> Instruction
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.
sourcepub fn intrinsic(index: usize, intrinsic: Intrinsic) -> Instruction
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.
sourcepub fn nop(index: usize) -> Instruction
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.
sourcepub fn placeholder(index: usize, operation: Operation) -> Instruction
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.
sourcepub fn is_assign(&self) -> bool
pub fn is_assign(&self) -> bool
Returns true
if the Operation
for this Instruction
is Operation::Assign
sourcepub fn is_store(&self) -> bool
pub fn is_store(&self) -> bool
Returns true
if the Operation
for this Instruction
is Operation::Store
sourcepub fn is_load(&self) -> bool
pub fn is_load(&self) -> bool
Returns true
if the Operation
for this Instruction
is Operation::Load
sourcepub fn is_branch(&self) -> bool
pub fn is_branch(&self) -> bool
Returns true
if the Operation
for this Instruction
is Operation::Brc
sourcepub fn operation_mut(&mut self) -> &mut Operation
pub fn operation_mut(&mut self) -> &mut Operation
Get a mutable reference to the Operation
for this Instruction
sourcepub fn index(&self) -> usize
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.
sourcepub fn set_comment(&mut self, comment: Option<String>)
pub fn set_comment(&mut self, comment: Option<String>)
Set the optional comment for this Instruction
sourcepub fn address(&self) -> Option<u64>
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 Instruction
s 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.
sourcepub fn set_address(&mut self, address: Option<u64>)
pub fn set_address(&mut self, address: Option<u64>)
Set the optional address for this Instruction
sourcepub fn scalars_written(&self) -> Option<Vec<&Scalar>>
pub fn scalars_written(&self) -> Option<Vec<&Scalar>>
Get the Scalar
which will be written by this Instruction
.
sourcepub fn scalar_written_mut(&mut self) -> Option<Vec<&mut Scalar>>
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
.
sourcepub fn scalars_read(&self) -> Option<Vec<&Scalar>>
pub fn scalars_read(&self) -> Option<Vec<&Scalar>>
Get a Vec of each Scalar
read by this Instruction
.
sourcepub fn scalars_read_mut(&mut self) -> Option<Vec<&mut Scalar>>
pub fn scalars_read_mut(&mut self) -> Option<Vec<&mut Scalar>>
Get a Vec of mutable references for each Scalar
read by this
Instruction
.
Trait Implementations§
source§impl Clone for Instruction
impl Clone for Instruction
source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Instruction
impl Debug for Instruction
source§impl Default for Instruction
impl Default for Instruction
source§fn default() -> Instruction
fn default() -> Instruction
source§impl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
source§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>,
source§impl Display for Instruction
impl Display for Instruction
source§impl Hash for Instruction
impl Hash for Instruction
source§impl Ord for Instruction
impl Ord for Instruction
source§fn cmp(&self, other: &Instruction) -> Ordering
fn cmp(&self, other: &Instruction) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<Instruction> for Instruction
impl PartialEq<Instruction> for Instruction
source§fn eq(&self, other: &Instruction) -> bool
fn eq(&self, other: &Instruction) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<Instruction> for Instruction
impl PartialOrd<Instruction> for Instruction
source§fn partial_cmp(&self, other: &Instruction) -> Option<Ordering>
fn partial_cmp(&self, other: &Instruction) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more