pub trait LowerCtx {
    type I: VCodeInst;
Show 26 methods fn abi(&mut self) -> &mut dyn ABICallee<I = Self::I>;
fn retval(&self, idx: usize) -> ValueRegs<Writable<Reg>>;
fn get_vm_context(&self) -> Option<Reg>;
fn data(&self, ir_inst: Inst) -> &InstructionData;
fn ty(&self, ir_inst: Inst) -> Type;
fn call_target<'b>(
        &'b self,
        ir_inst: Inst
    ) -> Option<(&'b ExternalName, RelocDistance)>;
fn call_sig<'b>(&'b self, ir_inst: Inst) -> Option<&'b Signature>;
fn symbol_value<'b>(
        &'b self,
        ir_inst: Inst
    ) -> Option<(&'b ExternalName, RelocDistance, i64)>;
fn memflags(&self, ir_inst: Inst) -> Option<MemFlags>;
fn srcloc(&self, ir_inst: Inst) -> SourceLoc;
fn num_inputs(&self, ir_inst: Inst) -> usize;
fn num_outputs(&self, ir_inst: Inst) -> usize;
fn input_ty(&self, ir_inst: Inst, idx: usize) -> Type;
fn output_ty(&self, ir_inst: Inst, idx: usize) -> Type;
fn get_constant(&self, ir_inst: Inst) -> Option<u64>;
fn get_input_as_source_or_const(
        &self,
        ir_inst: Inst,
        idx: usize
    ) -> NonRegInput;
fn put_input_in_regs(&mut self, ir_inst: Inst, idx: usize) -> ValueRegs<Reg>;
fn get_output(&self, ir_inst: Inst, idx: usize) -> ValueRegs<Writable<Reg>>;
fn alloc_tmp(&mut self, ty: Type) -> ValueRegs<Writable<Reg>>;
fn emit(&mut self, mach_inst: Self::I);
fn emit_safepoint(&mut self, mach_inst: Self::I);
fn sink_inst(&mut self, ir_inst: Inst);
fn get_constant_data(&self, constant_handle: Constant) -> &ConstantData;
fn use_constant(&mut self, constant: VCodeConstantData) -> VCodeConstant;
fn get_immediate(&self, ir_inst: Inst) -> Option<DataValue>;
fn ensure_in_vreg(&mut self, reg: Reg, ty: Type) -> Reg;
}
Expand description

A context that machine-specific lowering code can use to emit lowered instructions. This is the view of the machine-independent per-function lowering context that is seen by the machine backend.

Associated Types

The instruction type for which this lowering framework is instantiated.

Required methods

Get the ABICallee.

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.)

Returns the vreg containing the VmContext parameter, if there’s one.

Get the instdata for a given IR instruction.

Get the controlling type for a polymorphic IR instruction.

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.)

Get the signature for a call or call-indirect instruction.

Get the symbol name, relocation distance estimate, and offset for a symbol_value instruction.

Returns the memory flags of a given memory access.

Get the source location for a given instruction.

Get the number of inputs to the given IR instruction.

Get the number of outputs to the given IR instruction.

Get the type for an instruction’s input.

Get the type for an instruction’s output.

Get the value of a constant instruction (iconst, etc.) as a 64-bit value, if possible.

Get the input as one of two options other than a direct register:

  • An instruction, given that it is effect-free or able to sink its effect to the current instruction being lowered, and given it has only one output, and if effect-ful, given that this is the only use;
  • A constant, if the value is a constant.

The instruction input may be available in either of these forms. It may be available in neither form, if the conditions are not met; if so, use put_input_in_regs() instead to get it in a register.

If the backend merges the effect of a side-effecting instruction, it must call sink_inst(). When this is called, it indicates that the effect has been sunk to the current scan location. The sunk instruction’s result(s) must have no uses remaining, because it will not be codegen’d (it has been integrated into the current instruction).

Put the idxth input into register(s) and return the assigned register.

Get the idxth 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.

Get a new temp.

Emit a machine instruction.

Emit a machine instruction that is a safepoint.

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.

Retrieve constant data given a handle.

Indicate that a constant should be emitted.

Retrieve the value immediate from an instruction. This will perform necessary lookups on the DataFlowGraph to retrieve even large immediates.

Cause the value in reg to be in a virtual reg, by copying it into a new virtual reg if reg is a real reg. ty describes the type of the value in reg.

Implementors