pub struct FuncCursor<'f> {
    pub func: &'f mut Function,
    /* private fields */
}
Expand description

Function cursor.

A FuncCursor holds a mutable reference to a whole ir::Function while keeping a position too. The function can be re-borrowed by accessing the public cur.func member.

This cursor is for use before legalization. The inserted instructions are not given an encoding.

Fields§

§func: &'f mut Function

The referenced function.

Implementations§

source§

impl<'f> FuncCursor<'f>

source

pub fn new(func: &'f mut Function) -> Self

Create a new FuncCursor pointing nowhere.

source

pub fn use_srcloc(&mut self, inst: Inst)

Use the source location of inst for future instructions.

source

pub fn ins(&mut self) -> InsertBuilder<'_, &mut FuncCursor<'f>>

Create an instruction builder that inserts an instruction at the current position.

Trait Implementations§

source§

impl<'f> Cursor for FuncCursor<'f>

source§

fn position(&self) -> CursorPosition

Get the current cursor position.
source§

fn set_position(&mut self, pos: CursorPosition)

Set the current position.
source§

fn srcloc(&self) -> SourceLoc

Get the source location that should be assigned to new instructions.
source§

fn set_srcloc(&mut self, srcloc: SourceLoc)

Set the source location that should be assigned to new instructions.
source§

fn layout(&self) -> &Layout

Borrow a reference to the function layout that this cursor is navigating.
source§

fn layout_mut(&mut self) -> &mut Layout

Borrow a mutable reference to the function layout that this cursor is navigating.
source§

fn with_srcloc(self, srcloc: SourceLoc) -> Selfwhere Self: Sized,

Exchange this cursor for one with a set source location. Read more
source§

fn at_position(self, pos: CursorPosition) -> Selfwhere Self: Sized,

Rebuild this cursor positioned at pos.
source§

fn at_inst(self, inst: Inst) -> Selfwhere Self: Sized,

Rebuild this cursor positioned at inst. Read more
source§

fn at_first_insertion_point(self, block: Block) -> Selfwhere Self: Sized,

Rebuild this cursor positioned at the first insertion point for block. This differs from at_first_inst in that it doesn’t assume that any instructions have been inserted into block yet. Read more
source§

fn at_first_inst(self, block: Block) -> Selfwhere Self: Sized,

Rebuild this cursor positioned at the first instruction in block. Read more
source§

fn at_last_inst(self, block: Block) -> Selfwhere Self: Sized,

Rebuild this cursor positioned at the last instruction in block. Read more
source§

fn after_inst(self, inst: Inst) -> Selfwhere Self: Sized,

Rebuild this cursor positioned after inst. Read more
source§

fn at_top(self, block: Block) -> Selfwhere Self: Sized,

Rebuild this cursor positioned at the top of block. Read more
source§

fn at_bottom(self, block: Block) -> Selfwhere Self: Sized,

Rebuild this cursor positioned at the bottom of block. Read more
source§

fn current_block(&self) -> Option<Block>

Get the block corresponding to the current position.
source§

fn current_inst(&self) -> Option<Inst>

Get the instruction corresponding to the current position, if any.
source§

fn goto_after_inst(&mut self, inst: Inst)

Go to the position after a specific instruction, which must be inserted in the layout. New instructions will be inserted after inst.
source§

fn goto_inst(&mut self, inst: Inst)

Go to a specific instruction which must be inserted in the layout. New instructions will be inserted before inst.
source§

fn goto_first_insertion_point(&mut self, block: Block)

Go to the position for inserting instructions at the beginning of block, which unlike goto_first_inst doesn’t assume that any instructions have been inserted into block yet.
source§

fn goto_first_inst(&mut self, block: Block)

Go to the first instruction in block.
source§

fn goto_last_inst(&mut self, block: Block)

Go to the last instruction in block.
source§

fn goto_top(&mut self, block: Block)

Go to the top of block which must be inserted into the layout. At this position, instructions cannot be inserted, but next_inst() will move to the first instruction in block.
source§

fn goto_bottom(&mut self, block: Block)

Go to the bottom of block which must be inserted into the layout. At this position, inserted instructions will be appended to block.
source§

fn next_block(&mut self) -> Option<Block>

Go to the top of the next block in layout order and return it. Read more
source§

fn prev_block(&mut self) -> Option<Block>

Go to the bottom of the previous block in layout order and return it. Read more
source§

fn next_inst(&mut self) -> Option<Inst>

Move to the next instruction in the same block and return it. Read more
source§

fn prev_inst(&mut self) -> Option<Inst>

Move to the previous instruction in the same block and return it. Read more
source§

fn insert_inst(&mut self, inst: Inst)

Insert an instruction at the current position. Read more
source§

fn remove_inst(&mut self) -> Inst

Remove the instruction under the cursor. Read more
source§

fn remove_inst_and_step_back(&mut self) -> Inst

Remove the instruction under the cursor. Read more
source§

fn insert_block(&mut self, new_block: Block)

Insert a block at the current position and switch to it. Read more
source§

impl<'c, 'f> InstInserterBase<'c> for &'c mut FuncCursor<'f>

source§

fn data_flow_graph(&self) -> &DataFlowGraph

Get an immutable reference to the data flow graph.
source§

fn data_flow_graph_mut(&mut self) -> &mut DataFlowGraph

Get a mutable reference to the data flow graph.
source§

fn insert_built_inst(self, inst: Inst) -> &'c mut DataFlowGraph

Insert a new instruction which belongs to the DFG.

Auto Trait Implementations§

§

impl<'f> RefUnwindSafe for FuncCursor<'f>

§

impl<'f> Send for FuncCursor<'f>

§

impl<'f> Sync for FuncCursor<'f>

§

impl<'f> Unpin for FuncCursor<'f>

§

impl<'f> !UnwindSafe for FuncCursor<'f>

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