pub enum Float {
F16,
F32,
F64,
F80,
F128,
}Expand description
A floating point format, named by its width in bits.
The names are the widths because that is what the textual form uses, and a reader who sees
f80 should not have to know that it occupies sixteen bytes on the stack. That is a layout
question and it belongs to the target, not to the type.
Variants§
F16
IEEE binary16, which is _Float16 and __fp16.
F32
IEEE binary32, which is float everywhere we care about.
F64
IEEE binary64, which is double.
F80
The x87 80-bit extended format, which is long double on x86 SysV.
F128
IEEE binary128, which is _Float128, and long double on AArch64 Linux.
Implementations§
Source§impl Float
impl Float
Sourcepub const fn bits(self) -> u32
pub const fn bits(self) -> u32
The width of the format in bits.
This is the width of the format and not the size of the object. F80 is eighty bits of
format in a ten, twelve or sixteen byte object depending on the target.
Sourcepub const fn encoding(self) -> Format
pub const fn encoding(self) -> Format
The encoding this is, as rucc_base::float spells it.
The inverse of the map rucc-lower keeps in the other direction, and total where that one
is not. Every format the IR has a type for is an IEEE encoding, so the two that map to
nothing there, the brain float and the double-double, are not among these and there is no
case here to return nothing for.
It is on the type rather than in the crate that wants it because which encoding an f80 is
is a fact about f80 and not about whoever is asking. Anything that has to interpret the
bits of an fconst needs it, and a copy of the table in each of them is a table that can
disagree with itself.
use rucc_base::float::Format;
use rucc_ir::Float;
assert_eq!(Float::F64.encoding(), Format::Double);
assert_eq!(Float::F80.encoding(), Format::X87Extended);