pub enum DataModel {
Ilp32,
Lp64,
Llp64,
Ilp32On64,
}Expand description
The widths of int, long and a pointer, as one choice rather than three.
Only a handful of combinations exist and every other combination is a bug, so this is an enumeration and not three independent numbers. The individual widths are still readable, because that is what the type layout wants, but they are read from here rather than guessed from the architecture.
Variants§
Ilp32
32-bit int, 32-bit long, 32-bit pointer, on a 32-bit machine. i686 and armv7.
Lp64
32-bit int, 64-bit long, 64-bit pointer. Every 64-bit Unix.
Llp64
32-bit int, 32-bit long, 64-bit pointer. Windows, and only Windows.
Ilp32On64
32-bit int, 32-bit long, 32-bit pointer, on a machine with 64-bit registers.
x86_64-linux-gnux32 and the ILP32 modes of AArch64 and RISC-V.
This exists in the enumeration mostly to prove the field is real. A model that is derived from the architecture cannot express it, and the version of this code that derived it silently produced 64-bit pointers for a target whose pointers are 32 bits.
Implementations§
Source§impl DataModel
impl DataModel
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
The name used in diagnostics and in the print queries.
Sourcepub const fn int_width(self) -> u32
pub const fn int_width(self) -> u32
The width of int in bits, which is 32 on every target in the table.
Sourcepub const fn long_width(self) -> u32
pub const fn long_width(self) -> u32
The width of long in bits. This is the field that separates the LP64 world from
Windows.
Sourcepub const fn long_long_width(self) -> u32
pub const fn long_long_width(self) -> u32
The width of long long in bits, which is 64 everywhere.
Sourcepub const fn pointer_width(self) -> u32
pub const fn pointer_width(self) -> u32
The width of a pointer in bits.
Sourcepub const fn address_width(self) -> u32
pub const fn address_width(self) -> u32
The number of bits of a pointer that are an address.
Equal to DataModel::pointer_width for every target in the table, and separate from
it because on CHERI it is not: a purecap pointer is 128 bits carrying a 64-bit address
plus bounds, permissions and a tag. spec/cross-compile/03-target-model.md section 3.9 puts CHERI out
of scope and keeps this accessor, because adding the distinction later is an audit of
every use of the pointer width and adding it now costs one function.