Struct cranelift_codegen::machinst::vcode::VCodeBuilder
source · [−]pub struct VCodeBuilder<I: VCodeInst> { /* private fields */ }
Expand description
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.
Hence, to produce the final instructions in proper order, we perform two
swaps. First, the machine instructions (I
instances) are produced in
forward order for an individual IR instruction. Then these are reversed
and concatenated to bb_insns
at the end of the IR instruction lowering.
The bb_insns
vec will thus contain all machine instructions for a basic
block, in reverse order. Finally, when we’re done with a basic block, we
reverse the whole block’s vec of instructions again, and concatenate onto
the VCode’s insts.
Implementations
sourceimpl<I: VCodeInst> VCodeBuilder<I>
impl<I: VCodeInst> VCodeBuilder<I>
sourcepub fn new(
abi: Box<dyn ABICallee<I = I>>,
emit_info: I::Info,
block_order: BlockLoweringOrder,
constants: VCodeConstants
) -> VCodeBuilder<I>
pub fn new(
abi: Box<dyn ABICallee<I = I>>,
emit_info: I::Info,
block_order: BlockLoweringOrder,
constants: VCodeConstants
) -> VCodeBuilder<I>
Create a new VCodeBuilder.
sourcepub fn block_order(&self) -> &BlockLoweringOrder
pub fn block_order(&self) -> &BlockLoweringOrder
Access to the BlockLoweringOrder object.
sourcepub fn set_vreg_type(&mut self, vreg: VirtualReg, ty: Type)
pub fn set_vreg_type(&mut self, vreg: VirtualReg, ty: Type)
Set the type of a VReg.
sourcepub fn have_ref_values(&self) -> bool
pub fn have_ref_values(&self) -> bool
Are there any reference-typed values at all among the vregs?
sourcepub fn set_entry(&mut self, block: BlockIndex)
pub fn set_entry(&mut self, block: BlockIndex)
Set the current block as the entry block.
sourcepub fn end_bb(&mut self)
pub fn end_bb(&mut self)
End the current basic block. Must be called after emitting vcode insts for IR insts and prior to ending the function (building the VCode).
sourcepub fn push(&mut self, insn: I, is_safepoint: bool)
pub fn push(&mut self, insn: I, is_safepoint: bool)
Push an instruction for the current BB and current IR inst within the BB.
sourcepub fn get_srcloc(&self) -> SourceLoc
pub fn get_srcloc(&self) -> SourceLoc
Get the current source location.
sourcepub fn set_srcloc(&mut self, srcloc: SourceLoc)
pub fn set_srcloc(&mut self, srcloc: SourceLoc)
Set the current source location.
sourcepub fn constants(&mut self) -> &mut VCodeConstants
pub fn constants(&mut self) -> &mut VCodeConstants
Access the constants.
Auto Trait Implementations
impl<I> !RefUnwindSafe for VCodeBuilder<I>
impl<I> !Send for VCodeBuilder<I>
impl<I> !Sync for VCodeBuilder<I>
impl<I> Unpin for VCodeBuilder<I> where
I: Unpin,
<I as MachInstEmit>::Info: Unpin,
impl<I> !UnwindSafe for VCodeBuilder<I>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more