0179: f64 in the IR and a libm-free runtime
Status: Proposed (pending maintainer)
Context
Integer arithmetic flows through Rvalue::Arith,
Neg and Convert, which the range prover
(ADR-0066), byte-class lowering and map fusion read with integer
assumptions. Generated programs link no libraries (no
-lm).
Decision
- IR gains
Ty::F64andConst::F64(bits)(bit pattern, so IR staysEqand printing is exact).emit-irprints constants asf64 0x<bits>. - Float arithmetic, negation, conversions and methods use one
new
Rvalue::Float { op, lhs, rhs, pos }; integer passes see it as an opaque scalar. Comparisons reuseRvalue::Cmp, which the prover already limits to integers.i64(x)is the only float value check (overflow kind). parse_f64lowers to one typed intrinsic. Both backends parse the receiver once and return itsoption<f64>value.- C:
double, constants as exact hex-float literals,+ - * /native.runtime/hrt_f64.his included only when a program uses f64 (feature bit), so existing emitted C is unchanged.abs floor ceil round trunc min maxare bit/compare helpers andsqrtis a correctly rounded integer square root, so no libm is needed and results match Rust exactly. - Determinism: compilation uses
-std=c11(gcc then disables FP contraction) and every IR operation is its own C statement, so no FMA fusion; x86-64 and arm64 use binary64 registers.
Consequences
The interpreter stores Value::F64(bits). Backends
agree on every operation because each is correctly rounded IEEE or
exact. A future Ty::F32 would reuse
Rvalue::Float with a width.
Alternatives
- Reuse
Arith/Neg/Convert: every integer pass would need a float guard; a missed one silently proves or mis-folds a float. - Link
-lm: changes the C command for every program, and libmround/fminbehaviour differs across platforms on edge cases.