Struct BodyOrder

Source
pub struct BodyOrder { /* private fields */ }
Expand description

Represents basic block order and instruction order.

Implementations§

Source§

impl BodyOrder

Source

pub fn new(entry_block: BasicBlockId) -> Self

Source

pub fn entry(&self) -> BasicBlockId

Returns an entry block of a function body.

Source

pub fn last_block(&self) -> BasicBlockId

Returns a last block of a function body.

Source

pub fn is_block_empty(&self, block: BasicBlockId) -> bool

Returns true if a block doesn’t contain any block.

Source

pub fn is_block_inserted(&self, block: BasicBlockId) -> bool

Returns true if a function body contains a given block.

Source

pub fn block_num(&self) -> usize

Returns a number of block in a function.

Source

pub fn prev_block(&self, block: BasicBlockId) -> Option<BasicBlockId>

Returns a previous block of a given block.

§Panics

Panics if block is not inserted yet.

Source

pub fn next_block(&self, block: BasicBlockId) -> Option<BasicBlockId>

Returns a next block of a given block.

§Panics

Panics if block is not inserted yet.

Source

pub fn is_inst_inserted(&self, inst: InstId) -> bool

Returns true is a given inst is inserted.

Source

pub fn first_inst(&self, block: BasicBlockId) -> Option<InstId>

Returns first instruction of a block if exists.

§Panics

Panics if block is not inserted yet.

Source

pub fn terminator( &self, store: &BodyDataStore, block: BasicBlockId, ) -> Option<InstId>

Returns a terminator instruction of a block.

§Panics

Panics if

  1. block is not inserted yet.
Source

pub fn is_terminated(&self, store: &BodyDataStore, block: BasicBlockId) -> bool

Returns true if a block is terminated.

Source

pub fn last_inst(&self, block: BasicBlockId) -> Option<InstId>

Returns a last instruction of a block.

§Panics

Panics if block is not inserted yet.

Source

pub fn prev_inst(&self, inst: InstId) -> Option<InstId>

Returns a previous instruction of a given inst.

§Panics

Panics if inst is not inserted yet.

Source

pub fn next_inst(&self, inst: InstId) -> Option<InstId>

Returns a next instruction of a given inst.

§Panics

Panics if inst is not inserted yet.

Source

pub fn inst_block(&self, inst: InstId) -> BasicBlockId

Returns a block to which a given inst belongs.

§Panics

Panics if inst is not inserted yet.

Source

pub fn iter_block(&self) -> impl Iterator<Item = BasicBlockId> + '_

Returns an iterator which iterates all basic blocks in a function body in pre-order.

Source

pub fn iter_inst( &self, block: BasicBlockId, ) -> impl Iterator<Item = InstId> + '_

Returns an iterator which iterates all instruction in a given block in pre-order.

§Panics

Panics if block is not inserted yet.

Source

pub fn append_block(&mut self, block: BasicBlockId)

Appends a given block to a function body.

§Panics

Panics if a given block is already inserted to a function.

Source

pub fn insert_block_before_block( &mut self, block: BasicBlockId, before: BasicBlockId, )

Inserts a given block before a before block.

§Panics

Panics if

  1. a given block is already inserted.
  2. a given before block is NOTE inserted yet.
Source

pub fn insert_block_after_block( &mut self, block: BasicBlockId, after: BasicBlockId, )

Inserts a given block after a after block.

§Panics

Panics if

  1. a given block is already inserted.
  2. a given after block is NOTE inserted yet.
Source

pub fn remove_block(&mut self, block: BasicBlockId)

Remove a given block from a function. All instructions in a block are also removed.

§Panics

Panics if

  1. a given block is NOT inserted.
  2. a block is the last one block in a function.
Source

pub fn append_inst(&mut self, inst: InstId, block: BasicBlockId)

Appends inst to the end of a block

§Panics

Panics if

  1. a given block is NOT inserted.
  2. a given inst is already inserted.
Source

pub fn prepend_inst(&mut self, inst: InstId, block: BasicBlockId)

Prepends inst to the beginning of a block

§Panics

Panics if

  1. a given block is NOT inserted.
  2. a given inst is already inserted.
Source

pub fn insert_inst_before_inst(&mut self, inst: InstId, before: InstId)

Insert inst before before inst.

§Panics

Panics if

  1. a given before is NOT inserted.
  2. a given inst is already inserted.
Source

pub fn insert_inst_after(&mut self, inst: InstId, after: InstId)

Insert inst after after inst.

§Panics

Panics if

  1. a given after is NOT inserted.
  2. a given inst is already inserted.
Source

pub fn remove_inst(&mut self, inst: InstId)

Remove instruction from the function body.

§Panics

Panics if a given inst is not inserted.

Trait Implementations§

Source§

impl Clone for BodyOrder

Source§

fn clone(&self) -> BodyOrder

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 BodyOrder

Source§

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

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

impl PartialEq for BodyOrder

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for BodyOrder

Source§

impl StructuralPartialEq for BodyOrder

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

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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,

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

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.