pub struct Operand { /* private fields */ }
Expand description

An Operand encodes everything about a mention of a register in an instruction: virtual register number, and any constraint that applies to the register at this program point.

An Operand may be a use or def (this corresponds to LUse and LAllocation in Ion).

Generally, regalloc2 considers operands to have their effects at one of two points that exist in an instruction: “Early” or “Late”. All operands at a given program-point are assigned non-conflicting locations based on their constraints. Each operand has a “kind”, one of use/def/mod, corresponding to read/write/read-write, respectively.

Usually, an instruction’s inputs will be “early uses” and outputs will be “late defs”, though there are valid use-cases for other combinations too. For example, a single “instruction” seen by the regalloc that lowers into multiple machine instructions and reads some of its inputs after it starts to write outputs must either make those input(s) “late uses” or those output(s) “early defs” so that the conflict (overlap) is properly accounted for. See comments on the constructors below for more.

Implementations

Construct a new operand.

Create an Operand that designates a use of a VReg that must be in a register, and that is used at the “before” point, i.e., can be overwritten by a result.

Create an Operand that designates a use of a VReg that must be in a register, and that is used up until the “after” point, i.e., must not conflict with any results.

Create an Operand that designates a definition of a VReg that must be in a register, and that occurs at the “after” point, i.e. may reuse a register that carried a use into this instruction.

Create an Operand that designates a definition of a VReg that must be in a register, and that occurs early at the “before” point, i.e., must not conflict with any input to the instruction.

Note that the register allocator will ensure that such an early-def operand is live throughout the instruction, i.e., also at the after-point. Hence it will also avoid conflicts with all outputs to the instruction. As such, early defs are appropriate for use as “temporary registers” that an instruction can use throughout its execution separately from the inputs and outputs.

Create an Operand that designates a def (and use) of a temporary within the instruction. This register is assumed to be written by the instruction, and will not conflict with any input or output, but should not be used after the instruction completes.

Note that within a single instruction, the dedicated scratch register (as specified in the MachineEnv) is also always available for use. The register allocator may use the register between instructions in order to implement certain sequences of moves, but will never hold a value live in the scratch register across an instruction.

Create an Operand that designates a def of a vreg that must reuse the register assigned to an input to the instruction. The input is identified by idx (is the idxth Operand for the instruction) and must be constraint to a register, i.e., be the result of Operand::reg_use(vreg).

Create an Operand that designates a use of a vreg and ensures that it is placed in the given, fixed PReg at the use. It is guaranteed that the Allocation resulting for this operand will be preg.

Create an Operand that designates a def of a vreg and ensures that it is placed in the given, fixed PReg at the def. It is guaranteed that the Allocation resulting for this operand will be preg.

Create an Operand that designates a use of a vreg and places no constraints on its location (i.e., it can be allocated into either a register or on the stack).

Create an Operand that designates a def of a vreg and places no constraints on its location (i.e., it can be allocated into either a register or on the stack).

Get the virtual register designated by an operand. Every operand must name some virtual register, even if it constrains the operand to a fixed physical register as well; the vregs are used to track dataflow.

Get the register class used by this operand.

Get the “kind” of this operand: a definition (write), a use (read), or a “mod” / modify (a read followed by a write).

Get the “position” of this operand, i.e., where its read and/or write occurs: either before the instruction executes, or after it does. Ordinarily, uses occur at “before” and defs at “after”, though there are cases where this is not true.

Get the “constraint” of this operand, i.e., what requirements its allocation must fulfill.

Get the raw 32-bit encoding of this operand’s fields.

Construct an Operand from the raw 32-bit encoding returned from bits().

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. 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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. 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.