Skip to main content

Module lower_float

Module lower_float 

Source
Expand description

Float-family Cranelift→LoweredOp lowering (wave 1, task L2).

This module covers the float rows of the Cranelift → dialect-mir mapping table:

Cranelift opProduces
faddLoweredOp::AddF
fsubLoweredOp::SubF
fmulLoweredOp::MulF
fdivLoweredOp::DivF
fmaLoweredOp::Fma (a*b + c, single rounding)
fnegLoweredOp::FNeg
fabsLoweredOp::FAbs

Only f32 / f64 scalars are accepted — f16, v128, or any other Cranelift type returns None so the caller can fall back to a different lowering family (lower_vector handles vector float ops in a sibling module). Per-row Pliron equivalents and PTX semantics are captured in the mapping table; this module purposely does not repeat those notes here so the single source of truth stays in [crate::pliron_dialect].

§Result-id allocation

Each successful lowering allocates a fresh LoweredValueId for the op’s SSA result by reading *next_value_id and post-incrementing it. Operand ids come from the caller-owned value_map which maps each Cranelift cranelift_codegen::ir::Value to the already-assigned LoweredValueId. Missing operands are a caller bug and panic — the lowering walker must populate the map for every block parameter and every prior instruction’s result before recursing into this family.

§Scope

  • Pure: no side effects beyond *next_value_id and reading func.dfg. Safe to call in any order; the caller controls block-walk ordering.
  • Stateless: no module-level statics; multiple lowerings can run concurrently (one &mut next_value_id per pass, as is the wave-1 convention shared with lower_arith etc.).

Functions§

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