Skip to main content

Arch

Enum Arch 

Source
pub enum Arch {
    X86_64,
    X86,
    Aarch64,
    Arm,
    Arm64Ec,
    Riscv64,
    Riscv32,
    LoongArch64,
    PowerPc64,
    S390x,
    Wasm32,
}
Expand description

An instruction set family.

Deliberately not #[non_exhaustive]. Adding a variant here has to break every match that needs to change, in this workspace and in anyone else’s code. That is the property spec/cross-compile/02-the-goal.md claim 3 is making when it says adding a target is a data change: the compiler tells you every place the data is read.

Variants§

§

X86_64

x86-64. The reference target, and the one everything is measured against first.

§

X86

32-bit x86, from i686 upwards. Not a narrower x86-64: eight registers, a PIC base register, and x87 as the floating point unit of the base ABI.

§

Aarch64

64-bit ARM.

§

Arm

32-bit ARM, including Thumb.

§

Arm64Ec

ARM64EC. A 64-bit ARM instruction set with the x86-64 calling convention, its own symbol namespace and thunks between the two. spec/cross-compile/06-abis.md section 6.8 declines to implement it and spec/cross-compile/04-target-matrix.md keeps it at tier 4, so this variant exists so that the tuple parses and --print-config answers, and nothing emits code for it.

§

Riscv64

64-bit RISC-V.

§

Riscv32

32-bit RISC-V.

§

LoongArch64

64-bit LoongArch.

§

PowerPc64

64-bit PowerPC. Only ELFv2 is in scope, which is what makes the little-endian spelling the common one.

§

S390x

IBM z/Architecture. The big-endian row, and the reason byte order is a field.

§

Wasm32

WebAssembly with 32-bit addresses. A stack machine with structured control flow, which spec/cross-compile/05-architectures.md section 5.9 explains is a second back end rather than a tenth architecture.

Implementations§

Source§

impl Arch

Source

pub const fn as_str(self) -> &'static str

The canonical name, which is the leading component of a tuple for every architecture whose baseline is not spelled in that component. ARM is the exception and crate::TargetTuple handles it.

Source

pub const fn register_width(self) -> u32

The width of a general purpose register, in bits.

This is a property of the instruction set and it is not the pointer width. A 64-bit machine running an ILP32 data model has 64-bit registers and 32-bit pointers, which is what x86_64-linux-gnux32 is for.

Source

pub const fn default_endian(self) -> Endian

The byte order this architecture uses unless the tuple says otherwise.

Every architecture here except s390x is little-endian by default, and five of them have a big-endian mode that a real target uses. That is why endianness is a tuple field and not a constant on this enum: the version of this function that returned true for everything was wrong for aarch64, arm, riscv, powerpc and mips at the same time.

Source

pub const fn has_both_endians(self) -> bool

Whether this architecture has a big-endian mode any target in the table uses.

x86 does not, so x86_64eb is a spelling error rather than a target, and saying so is better than emitting bytes for a machine that does not exist.

Source

pub const fn takes_subarch(self) -> bool

Whether a sub-architecture may be spelled for this family.

Source

pub const fn selects_float_abi(self) -> bool

Whether this family has more than one float calling convention to choose between.

False for x86-64, AArch64, s390x and PowerPC, which have exactly one, so naming a float ABI for them is a spelling error rather than a configuration. True for ARM, RISC-V and LoongArch, where it is a real choice that changes which registers arguments arrive in.

Trait Implementations§

Source§

impl Clone for Arch

Source§

fn clone(&self) -> Arch

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Arch

Source§

impl Debug for Arch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Arch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Arch

Source§

impl Hash for Arch

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Arch

Source§

fn cmp(&self, other: &Arch) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Arch

Source§

fn eq(&self, other: &Arch) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Arch

Source§

fn partial_cmp(&self, other: &Arch) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Arch

Auto Trait Implementations§

§

impl Freeze for Arch

§

impl RefUnwindSafe for Arch

§

impl Send for Arch

§

impl Sync for Arch

§

impl Unpin for Arch

§

impl UnsafeUnpin for Arch

§

impl UnwindSafe for Arch

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.