Program Rust
Dec2flt_modelNumImpDec2fltLemireU16
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
138 }139 140 #[cfg(target_has_reliable_f16)]141 impl Lemire for f16 {142 // These are the exact integer results of the upstream compile-time float143 // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and144 // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const145 // float arithmetic without changing either fast-path guard.146 const MAX_EXPONENT_FAST_PATH: i64 = 4;147 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;148 149 fn pow10_fast_path(exponent: usize) -> Self {150 // Each integer is the exact IEEE encoding of the corresponding151 // upstream table literal; the masked lookup and fallback zeros are152 // unchanged. Aeneas cannot translate arrays containing float values.153 match exponent & 7 {154 0 => f16::from_bits(0x3C00),155 1 => f16::from_bits(0x4900),156 2 => f16::from_bits(0x5640),157 3 => f16::from_bits(0x63D0),158 4 => f16::from_bits(0x70E2),159 _ => f16::from_bits(0),160 }161 }162 163 #[inline]164 // This method is exactly the upstream primitive `u64 as f16` conversion.165 // Charon extracts the cast, but Aeneas reports it unreachable; making only166 // this primitive boundary opaque preserves all guards and dispatcher logic.167 #[charon::opaque]168 fn from_u64(v: u64) -> Self {169 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);170 v as _171 }172 }173 174 impl Lemire for f32 {175 // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[reducible]
impl_def F16.Insts.Dec2flt_modelNumImpDec2fltLemireU16 : num.imp.dec2flt.Lemire
F16 Std.U16 := {
MAX_EXPONENT_FAST_PATH := ok
F16.Insts.Dec2flt_modelNumImpDec2fltLemireU16.MAX_EXPONENT_FAST_PATH
MIN_EXPONENT_FAST_PATH :=
num.imp.dec2flt.Lemire.MIN_EXPONENT_FAST_PATH.default
F16.Insts.Dec2flt_modelNumImpDec2fltLemireU16
MAX_EXPONENT_DISGUISED_FAST_PATH := ok
F16.Insts.Dec2flt_modelNumImpDec2fltLemireU16.MAX_EXPONENT_DISGUISED_FAST_PATH
MAX_MANTISSA_FAST_PATH :=
num.imp.dec2flt.Lemire.MAX_MANTISSA_FAST_PATH.default
F16.Insts.Dec2flt_modelNumImpDec2fltLemireU16
traitsFloatExtInst := F16.Insts.Dec2flt_modelNumImpTraitsFloatExtU16
pow10_fast_path :=
F16.Insts.Dec2flt_modelNumImpDec2fltLemireU16.pow10_fast_path
from_u64 := F16.Insts.Dec2flt_modelNumImpDec2fltLemireU16.from_u64
}Operations used here
Dec2flt_modelNumImpTraitsFloatExtU16 · Program Rust
pow10_fast_path · Program Rust
Source details
| Declaration | F16.Insts.Dec2flt_modelNumImpDec2fltLemireU16 |
|---|---|
| File | num/imp/../../dec2flt/mod.rs |
| Lines | 141:0–172:1 |
| Program version | Preparation 1 |