pub struct Lower<'func, I: VCodeInst> { /* private fields */ }
Expand description
Machine-independent lowering driver / machine-instruction container. Maintains a correspondence from original Inst to MachInsts.
Implementations
sourceimpl<'func, I: VCodeInst> Lower<'func, I>
impl<'func, I: VCodeInst> Lower<'func, I>
sourcepub fn new(
f: &'func Function,
abi: Box<dyn ABICallee<I = I>>,
emit_info: I::Info,
block_order: BlockLoweringOrder
) -> CodegenResult<Lower<'func, I>>
pub fn new(
f: &'func Function,
abi: Box<dyn ABICallee<I = I>>,
emit_info: I::Info,
block_order: BlockLoweringOrder
) -> CodegenResult<Lower<'func, I>>
Prepare a new lowering context for the given IR function.
sourcepub fn lower<B: LowerBackend<MInst = I>>(
self,
backend: &B
) -> CodegenResult<(VCode<I>, StackmapRequestInfo)>
pub fn lower<B: LowerBackend<MInst = I>>(
self,
backend: &B
) -> CodegenResult<(VCode<I>, StackmapRequestInfo)>
Lower the function.
Trait Implementations
sourceimpl<'func, I: VCodeInst> LowerCtx for Lower<'func, I>
impl<'func, I: VCodeInst> LowerCtx for Lower<'func, I>
type I = I
type I = I
The instruction type for which this lowering framework is instantiated.
sourcefn retval(&self, idx: usize) -> ValueRegs<Writable<Reg>>
fn retval(&self, idx: usize) -> ValueRegs<Writable<Reg>>
Get the (virtual) register that receives the return value. A return instruction should lower into a sequence that fills this register. (Why not allow the backend to specify its own result register for the return? Because there may be multiple return points.) Read more
sourcefn get_vm_context(&self) -> Option<Reg>
fn get_vm_context(&self) -> Option<Reg>
Returns the vreg containing the VmContext parameter, if there’s one.
sourcefn data(&self, ir_inst: Inst) -> &InstructionData
fn data(&self, ir_inst: Inst) -> &InstructionData
Get the instdata for a given IR instruction.
sourcefn call_target<'b>(
&'b self,
ir_inst: Inst
) -> Option<(&'b ExternalName, RelocDistance)>
fn call_target<'b>(
&'b self,
ir_inst: Inst
) -> Option<(&'b ExternalName, RelocDistance)>
Get the target for a call instruction, as an ExternalName
. Returns a tuple
providing this name and the “relocation distance”, i.e., whether the backend
can assume the target will be “nearby” (within some small offset) or an
arbitrary address. (This comes from the colocated
bit in the CLIF.) Read more
sourcefn call_sig<'b>(&'b self, ir_inst: Inst) -> Option<&'b Signature>
fn call_sig<'b>(&'b self, ir_inst: Inst) -> Option<&'b Signature>
Get the signature for a call or call-indirect instruction.
sourcefn symbol_value<'b>(
&'b self,
ir_inst: Inst
) -> Option<(&'b ExternalName, RelocDistance, i64)>
fn symbol_value<'b>(
&'b self,
ir_inst: Inst
) -> Option<(&'b ExternalName, RelocDistance, i64)>
Get the symbol name, relocation distance estimate, and offset for a symbol_value instruction. Read more
sourcefn memflags(&self, ir_inst: Inst) -> Option<MemFlags>
fn memflags(&self, ir_inst: Inst) -> Option<MemFlags>
Returns the memory flags of a given memory access.
sourcefn num_inputs(&self, ir_inst: Inst) -> usize
fn num_inputs(&self, ir_inst: Inst) -> usize
Get the number of inputs to the given IR instruction.
sourcefn num_outputs(&self, ir_inst: Inst) -> usize
fn num_outputs(&self, ir_inst: Inst) -> usize
Get the number of outputs to the given IR instruction.
sourcefn output_ty(&self, ir_inst: Inst, idx: usize) -> Type
fn output_ty(&self, ir_inst: Inst, idx: usize) -> Type
Get the type for an instruction’s output.
sourcefn get_constant(&self, ir_inst: Inst) -> Option<u64>
fn get_constant(&self, ir_inst: Inst) -> Option<u64>
Get the value of a constant instruction (iconst
, etc.) as a 64-bit
value, if possible. Read more
sourcefn get_input_as_source_or_const(&self, ir_inst: Inst, idx: usize) -> NonRegInput
fn get_input_as_source_or_const(&self, ir_inst: Inst, idx: usize) -> NonRegInput
Get the input as one of two options other than a direct register: Read more
sourcefn put_input_in_regs(&mut self, ir_inst: Inst, idx: usize) -> ValueRegs<Reg>
fn put_input_in_regs(&mut self, ir_inst: Inst, idx: usize) -> ValueRegs<Reg>
Put the idx
th input into register(s) and return the assigned register.
sourcefn get_output(&self, ir_inst: Inst, idx: usize) -> ValueRegs<Writable<Reg>>
fn get_output(&self, ir_inst: Inst, idx: usize) -> ValueRegs<Writable<Reg>>
Get the idx
th output register(s) of the given IR instruction. When
backend.lower_inst_to_regs(ctx, inst)
is called, it is expected that
the backend will write results to these output register(s). This
register will always be “fresh”; it is guaranteed not to overlap with
any of the inputs, and can be freely used as a scratch register within
the lowered instruction sequence, as long as its final value is the
result of the computation. Read more
sourcefn emit_safepoint(&mut self, mach_inst: I)
fn emit_safepoint(&mut self, mach_inst: I)
Emit a machine instruction that is a safepoint.
sourcefn sink_inst(&mut self, ir_inst: Inst)
fn sink_inst(&mut self, ir_inst: Inst)
Indicate that the side-effect of an instruction has been sunk to the
current scan location. This should only be done with the instruction’s
original results are not used (i.e., put_input_in_regs
is not invoked
for the input produced by the sunk instruction), otherwise the
side-effect will occur twice. Read more
sourcefn get_constant_data(&self, constant_handle: Constant) -> &ConstantData
fn get_constant_data(&self, constant_handle: Constant) -> &ConstantData
Retrieve constant data given a handle.
sourcefn use_constant(&mut self, constant: VCodeConstantData) -> VCodeConstant
fn use_constant(&mut self, constant: VCodeConstantData) -> VCodeConstant
Indicate that a constant should be emitted.
Auto Trait Implementations
impl<'func, I> !RefUnwindSafe for Lower<'func, I>
impl<'func, I> !Send for Lower<'func, I>
impl<'func, I> !Sync for Lower<'func, I>
impl<'func, I> Unpin for Lower<'func, I> where
I: Unpin,
<I as MachInstEmit>::Info: Unpin,
impl<'func, I> !UnwindSafe for Lower<'func, 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