Struct cranelift_codegen::ir::layout::Layout [−][src]
pub struct Layout { /* fields omitted */ }
Expand description
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]
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]
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]
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]
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]
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]
pub fn remove_block(&mut self, block: Block)
[src]Remove block
from the layout.
pub fn entry_block(&self) -> Option<Block>
[src]
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]
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]
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]
pub fn next_block(&self, block: Block) -> Option<Block>
[src]Get the block following block
in the layout order.
impl Layout
[src]
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]
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]
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]
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]
pub fn first_inst(&self, block: Block) -> Option<Inst>
[src]Fetch a block’s first instruction.
pub fn canonical_branch_inst(
&self,
dfg: &DataFlowGraph,
block: Block
) -> Option<Inst>
[src]
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]
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]
pub fn remove_inst(&mut self, inst: Inst)
[src]Remove inst
from the layout.
pub fn block_insts(&self, block: Block) -> Insts<'_>ⓘ
[src]
pub fn block_insts(&self, block: Block) -> Insts<'_>ⓘ
[src]Iterate over the instructions in block
in layout order.
pub fn block_likely_branches(&self, block: Block) -> Insts<'_>ⓘ
[src]
pub fn block_likely_branches(&self, block: Block) -> Insts<'_>ⓘ
[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]
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<'f> IntoIterator for &'f Layout
[src]
impl<'f> IntoIterator for &'f Layout
[src]Use a layout reference in a for loop.
impl ProgramOrder for Layout
[src]
impl ProgramOrder for Layout
[src]fn cmp<A, B>(&self, a: A, b: B) -> Ordering where
A: Into<ExpandedProgramPoint>,
B: Into<ExpandedProgramPoint>,
[src]
fn cmp<A, B>(&self, a: A, b: B) -> Ordering where
A: Into<ExpandedProgramPoint>,
B: Into<ExpandedProgramPoint>,
[src]Compare the program points a
and b
relative to this program order. Read more
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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more