Skip to main content

Abi

Enum Abi 

Source
pub enum Abi {
    Plain,
    Sext,
    Zext,
    ByVal {
        size: u64,
        align: u32,
    },
    Sret {
        size: u64,
        align: u32,
    },
}
Expand description

How one parameter or one return value travels, beyond what its type says.

The IR’s types are the machine’s and not C’s, so a ptr parameter says nothing about whether the pointer is the argument or whether the object it points at is, and an i8 says nothing about which half of the register above it the callee may read. Both are the ABI’s answer rather than the type’s, which is why they are here and not on Type.

A signature carrying one of these has already had the ABI applied to it. What the walk to the IR builds first is the C-level form, where every parameter is Abi::Plain, and the classification in rucc-target is what turns one into the other.

Variants§

§

Plain

The value itself, in the type it is written as.

§

Sext

An integer narrower than a register, with the bits above it its own sign.

Which of these an ABI asks for is not a property of the value: unsigned char is Abi::Sext on the Darwin ABIs and Abi::Zext elsewhere, and on SysV neither the caller nor the callee may assume anything about those bits at all.

§

Zext

An integer narrower than a register, with zeroes above it.

§

ByVal

The bytes of the object the pointer points at, in the argument area, with no address travelling anywhere.

The caller makes the copy the callee is free to write to, which is what makes this a C call by value rather than a pointer the callee must not keep.

Fields

§size: u64

How many bytes travel.

§align: u32

What the copy is aligned to, which is the C alignment of the type and not the pointer’s.

§

Sret

Somewhere for the return value to go, whose address the caller passes as the first argument because the value does not fit in the registers a return comes back in.

Fields

§size: u64

How many bytes the callee writes.

§align: u32

What the space is aligned to.

Implementations§

Source§

impl Abi

Source

pub const fn indirect(self) -> bool

Whether this describes an object behind a pointer rather than the value in hand.

Source

pub const fn object(self) -> Option<(u64, u32)>

The size and alignment of that object, for the two that have one.

Trait Implementations§

Source§

impl Clone for Abi

Source§

fn clone(&self) -> Abi

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 Abi

Source§

impl Debug for Abi

Source§

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

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

impl Default for Abi

Source§

fn default() -> Abi

Returns the “default value” for a type. Read more
Source§

impl Eq for Abi

Source§

impl PartialEq for Abi

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Abi

Auto Trait Implementations§

§

impl Freeze for Abi

§

impl RefUnwindSafe for Abi

§

impl Send for Abi

§

impl Sync for Abi

§

impl Unpin for Abi

§

impl UnsafeUnpin for Abi

§

impl UnwindSafe for Abi

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, 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.