Skip to main content

lower_vector_inst

Function lower_vector_inst 

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

Lower a single vector-family Cranelift instruction to a LoweredOp.

Returns None if inst is not one of the opcodes handled by this family (see the module-level table) or if it is one of those opcodes but applied to a scalar type (e.g. scalar fmin). In both cases the caller is expected to route the instruction to the appropriate sibling family.

The function:

  1. Inspects func.dfg.insts[inst] to read the opcode and operands.
  2. Maps each Cranelift Value operand through value_map to its pre-assigned LoweredValueId.
  3. Allocates a fresh result id from next_value_id and constructs the matching LoweredOp variant.

value_map is not mutated here — the caller is responsible for inserting the new instruction’s result after the returned op is pushed into a block (the caller has the Cranelift Value for the result; we only see the id we allocated).