Struct cranelift_codegen::ir::layout::Layout[][src]

pub struct Layout { /* fields omitted */ }

The Layout struct determines the layout of blocks and instructions in a function. It does not contain definitions of instructions or blocks, but depends on Inst and Block entity references being defined elsewhere.

This data structure determines:

  • The order of blocks in the function.
  • Which block contains a given instruction.
  • The order of instructions with a block.

While data dependencies are not recorded, instruction ordering does affect control dependencies, so part of the semantics of the program are determined by the layout.

Implementations

impl Layout[src]

pub fn new() -> Self[src]

Create a new empty Layout.

pub fn clear(&mut self)[src]

Clear the layout.

pub fn block_capacity(&self) -> usize[src]

Returns the capacity of the BlockData map.

impl Layout[src]

Methods for laying out blocks.

An unknown block starts out as not inserted in the block layout. The layout is a linear order of inserted blocks. Once a block has been inserted in the layout, instructions can be added. A block can only be removed from the layout when it is empty.

Since every block must end with a terminator instruction which cannot fall through, the layout of blocks do not affect the semantics of the program.

pub fn is_block_inserted(&self, block: Block) -> bool[src]

Is block currently part of the layout?

pub fn append_block(&mut self, block: Block)[src]

Insert block as the last block in the layout.

pub fn insert_block(&mut self, block: Block, before: Block)[src]

Insert block in the layout before the existing block before.

pub fn insert_block_after(&mut self, block: Block, after: Block)[src]

Insert block in the layout after the existing block after.

pub fn remove_block(&mut self, block: Block)[src]

Remove block from the layout.

pub fn blocks(&self) -> Blocks<'_>

Notable traits for Blocks<'f>

impl<'f> Iterator for Blocks<'f> type Item = Block;
[src]

Return an iterator over all blocks in layout order.

pub fn entry_block(&self) -> Option<Block>[src]

Get the function’s entry block. This is simply the first block in the layout order.

pub fn last_block(&self) -> Option<Block>[src]

Get the last block in the layout.

pub fn prev_block(&self, block: Block) -> Option<Block>[src]

Get the block preceding block in the layout order.

pub fn next_block(&self, block: Block) -> Option<Block>[src]

Get the block following block in the layout order.

impl Layout[src]

Methods for arranging instructions.

An instruction starts out as not inserted in the layout. An instruction can be inserted into a block at a given position.

pub fn inst_block(&self, inst: Inst) -> Option<Block>[src]

Get the block containing inst, or None if inst is not inserted in the layout.

pub fn pp_block<PP>(&self, pp: PP) -> Block where
    PP: Into<ExpandedProgramPoint>, 
[src]

Get the block containing the program point pp. Panic if pp is not in the layout.

pub fn append_inst(&mut self, inst: Inst, block: Block)[src]

Append inst to the end of block.

pub fn first_inst(&self, block: Block) -> Option<Inst>[src]

Fetch a block’s first instruction.

pub fn last_inst(&self, block: Block) -> Option<Inst>[src]

Fetch a block’s last instruction.

pub fn next_inst(&self, inst: Inst) -> Option<Inst>[src]

Fetch the instruction following inst.

pub fn prev_inst(&self, inst: Inst) -> Option<Inst>[src]

Fetch the instruction preceding inst.

pub fn canonical_branch_inst(
    &self,
    dfg: &DataFlowGraph,
    block: Block
) -> Option<Inst>
[src]

Fetch the first instruction in a block’s terminal branch group.

pub fn insert_inst(&mut self, inst: Inst, before: Inst)[src]

Insert inst before the instruction before in the same block.

pub fn remove_inst(&mut self, inst: Inst)[src]

Remove inst from the layout.

pub fn block_insts(&self, block: Block) -> Insts<'_>

Notable traits for Insts<'f>

impl<'f> Iterator for Insts<'f> type Item = Inst;
[src]

Iterate over the instructions in block in layout order.

pub fn block_likely_branches(&self, block: Block) -> Insts<'_>

Notable traits for Insts<'f>

impl<'f> Iterator for Insts<'f> type Item = Inst;
[src]

Iterate over a limited set of instruction which are likely the branches of block in layout order. Any instruction not visited by this iterator is not a branch, but an instruction visited by this may not be a branch.

pub fn split_block(&mut self, new_block: Block, before: Inst)[src]

Split the block containing before in two.

Insert new_block after the old block and move before and the following instructions to new_block:

old_block:
    i1
    i2
    i3 << before
    i4

becomes:

old_block:
    i1
    i2
new_block:
    i3 << before
    i4

Trait Implementations

impl Clone for Layout[src]

impl<'f> IntoIterator for &'f Layout[src]

Use a layout reference in a for loop.

type Item = Block

The type of the elements being iterated over.

type IntoIter = Blocks<'f>

Which kind of iterator are we turning this into?

impl ProgramOrder for Layout[src]

Auto Trait Implementations

impl RefUnwindSafe for Layout

impl Send for Layout

impl Sync for Layout

impl Unpin for Layout

impl UnwindSafe for Layout

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.