Expand description

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

An opaque reference to a basic block in a Function.

An opaque reference to a constant.

An opaque reference to a dynamic stack slot.

An opaque reference to a dynamic type.

An opaque reference to another Function.

An opaque reference to a global value.

An opaque reference to a heap.

An opaque reference to an immediate.

An opaque reference to an instruction in a Function.

An opaque reference to a jump table.

An opaque reference to a function Signature.

An opaque reference to a stack slot.

An opaque reference to a WebAssembly table.

A reference to an UserExternalName, declared with Function::declare_imported_user_function.

An opaque reference to an SSA value.

Enums

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