[][src]Module cranelift_codegen::ir::entities

Cranelift IR entity references.

Instructions in Cranelift IR need to reference other entities in the function. This can be other parts of the function like basic blocks or stack slots, or it can be external entities that are declared in the function preamble in the text format.

These entity references in instruction operands are not implemented as Rust references both because Rust's ownership and mutability rules make it difficult, and because 64-bit pointers take up a lot of space, and we want a compact in-memory representation. Instead, entity references are structs wrapping a u32 index into a table in the Function main data structure. There is a separate index type for each entity type, so we don't lose type safety.

The entities module defines public types for the entity references along with constants representing an invalid reference. We prefer to use Option<EntityRef> whenever possible, but unfortunately that type is twice as large as the 32-bit index type on its own. Thus, compact data structures use the PackedOption<EntityRef> representation, while function arguments and return values prefer the more Rust-like Option<EntityRef> variant.

The entity references all implement the Display trait in a way that matches the textual IR format.

Structs

Block

An opaque reference to a basic block in a Function.

Constant

An opaque reference to a constant.

FuncRef

An opaque reference to another Function.

GlobalValue

An opaque reference to a global value.

Heap

An opaque reference to a heap.

Immediate

An opaque reference to an immediate.

Inst

An opaque reference to an instruction in a Function.

JumpTable

An opaque reference to a jump table.

SigRef

An opaque reference to a function Signature.

StackSlot

An opaque reference to a stack slot.

Table

An opaque reference to a WebAssembly table.

Value

An opaque reference to an SSA value.

Enums

AnyEntity

An opaque reference to any of the entities defined in this module that can appear in CLIF IR.