Reads the register as an f32, applying NaN-boxing validation. If bits [63:32] are not all 1s the stored value is not a valid NaN-boxed f32, so the canonical NaN is returned (RISC-V spec 11.3).
(&self, reg: usize)
| 60 | pub fn read_f32(&self, reg: usize) -> f32 { |
| 61 | let bits = self.f[reg]; |
| 62 | if bits & NAN_BOX_UPPER != NAN_BOX_UPPER { |
| 63 | return f32::NAN; |
| 64 | } |
| 65 | f32::from_bits(bits as u32) |
| 66 | } |
| 67 | |
| 68 | /// Writes an f32, NaN-boxing it by setting bits `63:32` to all 1s. |
| 69 | pub fn write_f32(&mut self, reg: usize, val: f32) { |
| 70 | self.f[reg] = NAN_BOX_UPPER | u64::from(val.to_bits()); |
| 71 | } |
no outgoing calls