Struct cranelift_codegen::cursor::EncCursor
source · [−]pub struct EncCursor<'f> {
pub func: &'f mut Function,
pub isa: &'f dyn TargetIsa,
/* private fields */
}
Expand description
Encoding cursor.
An EncCursor
can be used to insert instructions that are immediately assigned an encoding.
The cursor holds a mutable reference to the whole function which can be re-borrowed from the
public pos.func
member.
Fields
func: &'f mut Function
The referenced function.
isa: &'f dyn TargetIsa
The target ISA that will be used to encode instructions.
Implementations
sourceimpl<'f> EncCursor<'f>
impl<'f> EncCursor<'f>
sourcepub fn new(func: &'f mut Function, isa: &'f dyn TargetIsa) -> Self
pub fn new(func: &'f mut Function, isa: &'f dyn TargetIsa) -> Self
Create a new EncCursor
pointing nowhere.
sourcepub fn use_srcloc(&mut self, inst: Inst)
pub fn use_srcloc(&mut self, inst: Inst)
Use the source location of inst
for future instructions.
sourcepub fn ins(&mut self) -> InsertBuilder<'_, &mut EncCursor<'f>>
pub fn ins(&mut self) -> InsertBuilder<'_, &mut EncCursor<'f>>
Create an instruction builder that will insert an encoded instruction at the current position.
The builder will panic if it is used to insert an instruction that can’t be encoded for
self.isa
.
sourcepub fn built_inst(&self) -> Inst
pub fn built_inst(&self) -> Inst
Get the last built instruction.
This returns the last instruction that was built using the ins()
method on this cursor.
Panics if no instruction was built.
sourcepub fn display_inst(&self, inst: Inst) -> DisplayInst<'_>
pub fn display_inst(&self, inst: Inst) -> DisplayInst<'_>
Return an object that can display inst
.
This is a convenience wrapper for the DFG equivalent.
Trait Implementations
sourceimpl<'f> Cursor for EncCursor<'f>
impl<'f> Cursor for EncCursor<'f>
sourcefn position(&self) -> CursorPosition
fn position(&self) -> CursorPosition
Get the current cursor position.
sourcefn set_position(&mut self, pos: CursorPosition)
fn set_position(&mut self, pos: CursorPosition)
Set the current position.
sourcefn srcloc(&self) -> SourceLoc
fn srcloc(&self) -> SourceLoc
Get the source location that should be assigned to new instructions.
sourcefn set_srcloc(&mut self, srcloc: SourceLoc)
fn set_srcloc(&mut self, srcloc: SourceLoc)
Set the source location that should be assigned to new instructions.
sourcefn layout(&self) -> &Layout
fn layout(&self) -> &Layout
Borrow a reference to the function layout that this cursor is navigating.
sourcefn layout_mut(&mut self) -> &mut Layout
fn layout_mut(&mut self) -> &mut Layout
Borrow a mutable reference to the function layout that this cursor is navigating.
sourcefn with_srcloc(self, srcloc: SourceLoc) -> Self where
Self: Sized,
fn with_srcloc(self, srcloc: SourceLoc) -> Self where
Self: Sized,
Exchange this cursor for one with a set source location. Read more
sourcefn at_position(self, pos: CursorPosition) -> Self where
Self: Sized,
fn at_position(self, pos: CursorPosition) -> Self where
Self: Sized,
Rebuild this cursor positioned at pos
.
sourcefn at_inst(self, inst: Inst) -> Self where
Self: Sized,
fn at_inst(self, inst: Inst) -> Self where
Self: Sized,
Rebuild this cursor positioned at inst
. Read more
sourcefn at_first_insertion_point(self, block: Block) -> Self where
Self: Sized,
fn at_first_insertion_point(self, block: Block) -> Self where
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
sourcefn at_first_inst(self, block: Block) -> Self where
Self: Sized,
fn at_first_inst(self, block: Block) -> Self where
Self: Sized,
Rebuild this cursor positioned at the first instruction in block
. Read more
sourcefn at_last_inst(self, block: Block) -> Self where
Self: Sized,
fn at_last_inst(self, block: Block) -> Self where
Self: Sized,
Rebuild this cursor positioned at the last instruction in block
. Read more
sourcefn after_inst(self, inst: Inst) -> Self where
Self: Sized,
fn after_inst(self, inst: Inst) -> Self where
Self: Sized,
Rebuild this cursor positioned after inst
. Read more
sourcefn at_top(self, block: Block) -> Self where
Self: Sized,
fn at_top(self, block: Block) -> Self where
Self: Sized,
Rebuild this cursor positioned at the top of block
. Read more
sourcefn at_bottom(self, block: Block) -> Self where
Self: Sized,
fn at_bottom(self, block: Block) -> Self where
Self: Sized,
Rebuild this cursor positioned at the bottom of block
. Read more
sourcefn current_block(&self) -> Option<Block>
fn current_block(&self) -> Option<Block>
Get the block corresponding to the current position.
sourcefn current_inst(&self) -> Option<Inst>
fn current_inst(&self) -> Option<Inst>
Get the instruction corresponding to the current position, if any.
sourcefn goto_after_inst(&mut self, inst: Inst)
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
. Read more
sourcefn goto_inst(&mut self, inst: Inst)
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
. Read more
sourcefn goto_first_insertion_point(&mut self, block: Block)
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. Read more
sourcefn goto_first_inst(&mut self, block: Block)
fn goto_first_inst(&mut self, block: Block)
Go to the first instruction in block
.
sourcefn goto_last_inst(&mut self, block: Block)
fn goto_last_inst(&mut self, block: Block)
Go to the last instruction in block
.
sourcefn goto_top(&mut self, block: Block)
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
. Read more
sourcefn goto_bottom(&mut self, block: Block)
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
. Read more
sourcefn next_block(&mut self) -> Option<Block>
fn next_block(&mut self) -> Option<Block>
Go to the top of the next block in layout order and return it. Read more
sourcefn prev_block(&mut self) -> Option<Block>
fn prev_block(&mut self) -> Option<Block>
Go to the bottom of the previous block in layout order and return it. Read more
sourcefn next_inst(&mut self) -> Option<Inst>
fn next_inst(&mut self) -> Option<Inst>
Move to the next instruction in the same block and return it. Read more
sourcefn prev_inst(&mut self) -> Option<Inst>
fn prev_inst(&mut self) -> Option<Inst>
Move to the previous instruction in the same block and return it. Read more
sourcefn insert_inst(&mut self, inst: Inst)
fn insert_inst(&mut self, inst: Inst)
Insert an instruction at the current position. Read more
sourcefn remove_inst(&mut self) -> Inst
fn remove_inst(&mut self) -> Inst
Remove the instruction under the cursor. Read more
sourcefn remove_inst_and_step_back(&mut self) -> Inst
fn remove_inst_and_step_back(&mut self) -> Inst
Remove the instruction under the cursor. Read more
sourcefn insert_block(&mut self, new_block: Block)
fn insert_block(&mut self, new_block: Block)
Insert a block at the current position and switch to it. Read more
sourceimpl<'c, 'f> InstInserterBase<'c> for &'c mut EncCursor<'f>
impl<'c, 'f> InstInserterBase<'c> for &'c mut EncCursor<'f>
sourcefn data_flow_graph(&self) -> &DataFlowGraph
fn data_flow_graph(&self) -> &DataFlowGraph
Get an immutable reference to the data flow graph.
sourcefn data_flow_graph_mut(&mut self) -> &mut DataFlowGraph
fn data_flow_graph_mut(&mut self) -> &mut DataFlowGraph
Get a mutable reference to the data flow graph.
sourcefn insert_built_inst(
self,
inst: Inst,
ctrl_typevar: Type
) -> &'c mut DataFlowGraph
fn insert_built_inst(
self,
inst: Inst,
ctrl_typevar: Type
) -> &'c mut DataFlowGraph
Insert a new instruction which belongs to the DFG.
Auto Trait Implementations
impl<'f> !RefUnwindSafe for EncCursor<'f>
impl<'f> Send for EncCursor<'f>
impl<'f> Sync for EncCursor<'f>
impl<'f> Unpin for EncCursor<'f>
impl<'f> !UnwindSafe for EncCursor<'f>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more