Struct cranelift_codegen::ir::layout::Layout
source · pub struct Layout { /* private fields */ }
Expand description
The Layout
struct determines the layout of EBBs and instructions in a function. It does not
contain definitions of instructions or EBBs, but depends on Inst
and Ebb
entity references
being defined elsewhere.
This data structure determines:
- The order of EBBs in the function.
- Which EBB contains a given instruction.
- The order of instructions with an EBB.
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§
source§impl Layout
impl Layout
Methods for laying out EBBs.
An unknown EBB starts out as not inserted in the EBB layout. The layout is a linear order of inserted EBBs. Once an EBB has been inserted in the layout, instructions can be added. An EBB can only be removed from the layout when it is empty.
Since every EBB must end with a terminator instruction which cannot fall through, the layout of EBBs do not affect the semantics of the program.
sourcepub fn is_ebb_inserted(&self, ebb: Ebb) -> bool
pub fn is_ebb_inserted(&self, ebb: Ebb) -> bool
Is ebb
currently part of the layout?
sourcepub fn append_ebb(&mut self, ebb: Ebb)
pub fn append_ebb(&mut self, ebb: Ebb)
Insert ebb
as the last EBB in the layout.
sourcepub fn insert_ebb(&mut self, ebb: Ebb, before: Ebb)
pub fn insert_ebb(&mut self, ebb: Ebb, before: Ebb)
Insert ebb
in the layout before the existing EBB before
.
sourcepub fn insert_ebb_after(&mut self, ebb: Ebb, after: Ebb)
pub fn insert_ebb_after(&mut self, ebb: Ebb, after: Ebb)
Insert ebb
in the layout after the existing EBB after
.
sourcepub fn remove_ebb(&mut self, ebb: Ebb)
pub fn remove_ebb(&mut self, ebb: Ebb)
Remove ebb
from the layout.
sourcepub fn entry_block(&self) -> Option<Ebb>
pub fn entry_block(&self) -> Option<Ebb>
Get the function’s entry block. This is simply the first EBB in the layout order.
source§impl Layout
impl Layout
Methods for arranging instructions.
An instruction starts out as not inserted in the layout. An instruction can be inserted into an EBB at a given position.
sourcepub fn inst_ebb(&self, inst: Inst) -> Option<Ebb>
pub fn inst_ebb(&self, inst: Inst) -> Option<Ebb>
Get the EBB containing inst
, or None
if inst
is not inserted in the layout.
sourcepub fn pp_ebb<PP>(&self, pp: PP) -> Ebbwhere
PP: Into<ExpandedProgramPoint>,
pub fn pp_ebb<PP>(&self, pp: PP) -> Ebbwhere
PP: Into<ExpandedProgramPoint>,
Get the EBB containing the program point pp
. Panic if pp
is not in the layout.
sourcepub fn append_inst(&mut self, inst: Inst, ebb: Ebb)
pub fn append_inst(&mut self, inst: Inst, ebb: Ebb)
Append inst
to the end of ebb
.
sourcepub fn first_inst(&self, ebb: Ebb) -> Option<Inst>
pub fn first_inst(&self, ebb: Ebb) -> Option<Inst>
Fetch an ebb’s first instruction.
sourcepub fn insert_inst(&mut self, inst: Inst, before: Inst)
pub fn insert_inst(&mut self, inst: Inst, before: Inst)
Insert inst
before the instruction before
in the same EBB.
sourcepub fn remove_inst(&mut self, inst: Inst)
pub fn remove_inst(&mut self, inst: Inst)
Remove inst
from the layout.
Trait Implementations§
source§impl<'f> IntoIterator for &'f Layout
impl<'f> IntoIterator for &'f Layout
Use a layout reference in a for loop.