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§

Create a new empty Layout.

Clear the 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.

Is ebb currently part of the layout?

Insert ebb as the last EBB in the layout.

Insert ebb in the layout before the existing EBB before.

Insert ebb in the layout after the existing EBB after.

Remove ebb from the layout.

Return an iterator over all EBBs in layout order.

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

Get the last EBB in the layout.

Get the block preceding ebb in the layout order.

Get the block following ebb in the layout order.

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.

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

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

Append inst to the end of ebb.

Fetch an ebb’s first instruction.

Fetch an ebb’s last instruction.

Fetch the instruction following inst.

Fetch the instruction preceding inst.

Insert inst before the instruction before in the same EBB.

Remove inst from the layout.

Iterate over the instructions in ebb in layout order.

Split the EBB containing before in two.

Insert new_ebb after the old EBB and move before and the following instructions to new_ebb:

old_ebb:
    i1
    i2
    i3 << before
    i4

becomes:

old_ebb:
    i1
    i2
new_ebb:
    i3 << before
    i4

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Use a layout reference in a for loop.

The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
Compare the program points a and b relative to this program order. Read more
Is the range from inst to ebb just the gap between consecutive EBBs? Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.