Skip to main content

lower_float_inst

Function lower_float_inst 

Source
pub fn lower_float_inst(
    inst: Inst,
    func: &Function,
    value_map: &HashMap<Value, LoweredValueId>,
    next_value_id: &mut LoweredValueId,
) -> Option<LoweredOp>
Expand description

Try to lower one Cranelift instruction as a float-family op.

Returns Some(LoweredOp) if inst’s opcode is one of the seven this module handles (fadd/fsub/fmul/fdiv/fma/fneg/fabs) and its result type is f32 or f64. Returns None otherwise — the caller is expected to consult sibling lower_* modules in that case (vector float ops live in lower_vector; non-float ops live in lower_arith, lower_memory, etc.).

§Parameters

  • inst: the Cranelift instruction being lowered.
  • func: the enclosing function. Used read-only for opcode lookup, operand fetch (dfg.inst_args), and result-type inspection (dfg.value_type on the instruction’s first result).
  • value_map: caller-owned map from already-lowered Cranelift Values to their assigned LoweredValueIds. Every operand of inst must be present.
  • next_value_id: caller-owned monotonic counter for fresh result ids. On a successful lowering, the current value is consumed as the new op’s result field and then incremented by one.

§Panics

Panics if an operand Value is missing from value_map. This signals a walker bug (a use-before-def in the caller); the wave-1 design treats it as unrecoverable rather than threading a Result through every per-family lowering.