Trait cranelift_codegen::machinst::lower::LowerCtx [−][src]
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
Loading content...Required methods
fn abi(&mut self) -> &dyn ABIBody<I = Self::I>
[src]
Get the ABIBody
.
fn retval(&self, idx: usize) -> Writable<Reg>
[src]
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.)
fn data(&self, ir_inst: Inst) -> &InstructionData
[src]
Get the instdata for a given IR instruction.
fn ty(&self, ir_inst: Inst) -> Type
[src]
Get the controlling type for a polymorphic IR instruction.
fn call_target<'b>(
&'b self,
ir_inst: Inst
) -> Option<(&'b ExternalName, RelocDistance)>
[src]
&'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.)
fn call_sig<'b>(&'b self, ir_inst: Inst) -> Option<&'b Signature>
[src]
Get the signature for a call or call-indirect instruction.
fn symbol_value<'b>(
&'b self,
ir_inst: Inst
) -> Option<(&'b ExternalName, RelocDistance, i64)>
[src]
&'b self,
ir_inst: Inst
) -> Option<(&'b ExternalName, RelocDistance, i64)>
Get the symbol name, relocation distance estimate, and offset for a symbol_value instruction.
fn memflags(&self, ir_inst: Inst) -> Option<MemFlags>
[src]
Returns the memory flags of a given memory access.
fn srcloc(&self, ir_inst: Inst) -> SourceLoc
[src]
Get the source location for a given instruction.
fn inst_color(&self, ir_inst: Inst) -> InstColor
[src]
Get the side-effect color of the given instruction (specifically, at the program point just prior to the instruction). The “color” changes at every side-effecting op; the backend should not try to merge across side-effect colors unless the op being merged is known to be pure.
fn num_inputs(&self, ir_inst: Inst) -> usize
[src]
Get the number of inputs to the given IR instruction.
fn num_outputs(&self, ir_inst: Inst) -> usize
[src]
Get the number of outputs to the given IR instruction.
fn input_ty(&self, ir_inst: Inst, idx: usize) -> Type
[src]
Get the type for an instruction’s input.
fn output_ty(&self, ir_inst: Inst, idx: usize) -> Type
[src]
Get the type for an instruction’s output.
fn get_constant(&self, ir_inst: Inst) -> Option<u64>
[src]
Get the value of a constant instruction (iconst
, etc.) as a 64-bit
value, if possible.
fn get_input(&self, ir_inst: Inst, idx: usize) -> LowerInput
[src]
Get the input in any combination of three forms:
- An instruction, if the same color as this instruction or if the producing instruction has no side effects (thus in both cases mergeable);
- A constant, if the value is a constant;
- A register.
The instruction input may be available in some or all of these forms. More than one is possible: e.g., it may be produced by an instruction in the same block, but may also have been forced into a register already by an earlier op. It will always be available in a register, at least.
If the backend uses the register, rather than one of the other
forms (constant or merging of the producing op), it must call
use_input_reg()
to ensure the producing inst is actually lowered
as well. Failing to do so may result in the instruction that generates
this value never being generated, thus resulting in incorrect execution.
For correctness, backends should thus wrap get_input()
and
use_input_regs()
with helpers that return a register only after
ensuring it is marked as used.
fn get_output(&self, ir_inst: Inst, idx: usize) -> Writable<Reg>
[src]
Get the idx
th output register 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.
fn alloc_tmp(&mut self, rc: RegClass, ty: Type) -> Writable<Reg>
[src]
Get a new temp.
fn emit(&mut self, mach_inst: Self::I)
[src]
Emit a machine instruction.
fn emit_safepoint(&mut self, mach_inst: Self::I)
[src]
Emit a machine instruction that is a safepoint.
fn use_input_reg(&mut self, input: LowerInput)
[src]
Indicate that the given input uses the register returned by
get_input()
. Codegen may not happen otherwise for the producing
instruction if it has no side effects and no uses.
fn is_reg_needed(&self, ir_inst: Inst, reg: Reg) -> bool
[src]
Is the given register output needed after the given instruction? Allows instructions with multiple outputs to make fine-grained decisions on which outputs to actually generate.
fn get_constant_data(&self, constant_handle: Constant) -> &ConstantData
[src]
Retrieve constant data given a handle.
Implementors
impl<'func, I: VCodeInst> LowerCtx for Lower<'func, I>
[src]
type I = I
fn abi(&mut self) -> &dyn ABIBody<I = I>
[src]
fn retval(&self, idx: usize) -> Writable<Reg>
[src]
fn data(&self, ir_inst: Inst) -> &InstructionData
[src]
fn ty(&self, ir_inst: Inst) -> Type
[src]
fn call_target<'b>(
&'b self,
ir_inst: Inst
) -> Option<(&'b ExternalName, RelocDistance)>
[src]
&'b self,
ir_inst: Inst
) -> Option<(&'b ExternalName, RelocDistance)>
fn call_sig<'b>(&'b self, ir_inst: Inst) -> Option<&'b Signature>
[src]
fn symbol_value<'b>(
&'b self,
ir_inst: Inst
) -> Option<(&'b ExternalName, RelocDistance, i64)>
[src]
&'b self,
ir_inst: Inst
) -> Option<(&'b ExternalName, RelocDistance, i64)>