Module cranelift_codegen::machinst::vcode
source · [−]Expand description
This implements the VCode container: a CFG of Insts that have been lowered.
VCode is virtual-register code. An instruction in VCode is almost a machine instruction; however, its register slots can refer to virtual registers in addition to real machine registers.
VCode is structured with traditional basic blocks, and each block must be terminated by an unconditional branch (one target), a conditional branch (two targets), or a return (no targets). Note that this slightly differs from the machine code of most ISAs: in most ISAs, a conditional branch has one target (and the not-taken case falls through). However, we expect that machine backends will elide branches to the following block (i.e., zero-offset jumps), and will be able to codegen a branch-cond / branch-uncond pair if both targets are not fallthrough. This allows us to play with layout prior to final binary emission, as well, if we want.
See the main module comment in mod.rs
for more details on the VCode-based
backend pipeline.
Structs
A function in “VCode” (virtualized-register code) form, after lowering. This is essentially a standard CFG of basic blocks, where each basic block consists of lowered instructions produced by the machine-specific backend.
A builder for a VCode function body. This builder is designed for the lowering approach that we take: we traverse basic blocks in forward (original IR) order, but within each basic block, we generate code from bottom to top; and within each IR instruction that we visit in this reverse order, we emit machine instructions in forward order again.
A use of a constant by one or more VCode instructions; see VCodeConstants.
This structure tracks the large constants used in VCode that will be emitted separately by the MachBuffer.
Enums
Identify the different types of constant that can be inserted into VCodeConstants. Tracking these separately instead of as raw byte buffers allows us to avoid some duplication.
Traits
VCodeInst wraps all requirements for a MachInst to be in VCode: it must be
a MachInst
and it must be able to emit itself at least to a SizeCodeSink
.
Type Definitions
Index referring to a basic block in VCode.
Index referring to an instruction in VCode.
Range of an instructions in VCode.