#[non_exhaustive]pub enum PointerWidth {
P32,
P64,
}Expand description
The width of addresses (ptr and ref) in a module.
§Examples
use ir_lang::PointerWidth;
assert_eq!(PointerWidth::P64.bytes(), 8);
assert_eq!(PointerWidth::P32.bits(), 32);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
P32
32-bit addresses (wasm32, 32-bit targets).
P64
64-bit addresses (x86-64, AArch64, riscv64). The default.
Implementations§
Source§impl PointerWidth
impl PointerWidth
Sourcepub const fn bytes(self) -> u32
pub const fn bytes(self) -> u32
The address width in bytes.
§Examples
use ir_lang::PointerWidth;
assert_eq!(PointerWidth::P32.bytes(), 4);Sourcepub const fn bits(self) -> u32
pub const fn bits(self) -> u32
The address width in bits.
§Examples
use ir_lang::PointerWidth;
assert_eq!(PointerWidth::P64.bits(), 64);Sourcepub const fn is_address_int(self, ty: Type) -> bool
pub const fn is_address_int(self, ty: Type) -> bool
Whether ty is an integer exactly as wide as an address (the integer side
of ptr_to_int / int_to_ptr).
§Examples
use ir_lang::{PointerWidth, Type};
assert!(PointerWidth::P64.is_address_int(Type::U64));
assert!(!PointerWidth::P64.is_address_int(Type::U32));Trait Implementations§
Source§impl Clone for PointerWidth
impl Clone for PointerWidth
impl Copy for PointerWidth
Source§impl Debug for PointerWidth
impl Debug for PointerWidth
Source§impl Default for PointerWidth
impl Default for PointerWidth
impl Eq for PointerWidth
Source§impl Hash for PointerWidth
impl Hash for PointerWidth
Source§impl Ord for PointerWidth
impl Ord for PointerWidth
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for PointerWidth
impl PartialEq for PointerWidth
Source§impl PartialOrd for PointerWidth
impl PartialOrd for PointerWidth
impl StructuralPartialEq for PointerWidth
Auto Trait Implementations§
impl Freeze for PointerWidth
impl RefUnwindSafe for PointerWidth
impl Send for PointerWidth
impl Sync for PointerWidth
impl Unpin for PointerWidth
impl UnsafeUnpin for PointerWidth
impl UnwindSafe for PointerWidth
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more