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
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.
Is block
currently part of the layout?
Insert block
as the last block in the layout.
Insert block
in the layout before the existing block before
.
Insert block
in the layout after the existing block after
.
Remove block
from the layout.
Return an iterator over all blocks in layout order.
Get the function’s entry block. This is simply the first block in the layout order.
Get the last block in the layout.
Get the block preceding block
in the layout order.
Get the block following block
in the layout order.
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.
Get the block containing inst
, or None
if inst
is not inserted in the layout.
Get the block containing the program point pp
. Panic if pp
is not in the layout.
Append inst
to the end of block
.
Fetch a block’s first instruction.
Fetch the first instruction in a block’s terminal branch group.
Insert inst
before the instruction before
in the same block.
Remove inst
from the layout.
Iterate over the instructions in block
in layout order.
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.
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
Use a layout reference in a for loop.
fn cmp<A, B>(&self, a: A, b: B) -> Ordering where
A: Into<ExpandedProgramPoint>,
B: Into<ExpandedProgramPoint>,
fn cmp<A, B>(&self, a: A, b: B) -> Ordering where
A: Into<ExpandedProgramPoint>,
B: Into<ExpandedProgramPoint>,
Compare the program points a
and b
relative to this program order. Read more
Auto Trait Implementations
impl RefUnwindSafe for Layout
impl UnwindSafe for Layout
Blanket Implementations
Mutably borrows from an owned value. Read more