Skip to main content

Signature

Struct Signature 

Source
pub struct Signature {
Show 17 fields pub name: String, pub params: Vec<Parameter>, pub ret_ty: Option<MirType>, pub ret_signedness: Signedness, pub ret_aggregate: Option<Aggregate>, pub kernel: Option<KernelMetadata>, pub no_inline: bool, pub inline_hint: bool, pub noreturn: bool, pub pure: bool, pub visibility: Option<SymbolVisibility>, pub placement: Option<CodePlacement>, pub weak: bool, pub section: Option<String>, pub align: Option<u32>, pub naked: bool, pub variadic: bool,
}
Expand description

Function signature

Fields§

§name: String

Function name

§params: Vec<Parameter>

Parameters (in order)

§ret_ty: Option<MirType>

Return type (None for void)

§ret_signedness: Signedness

Signedness of an integer return value

§ret_aggregate: Option<Aggregate>

Set when the function returns an aggregate by value. ret_ty is then the pointer to it, and a call’s result register names the caller’s slot for the copy.

§kernel: Option<KernelMetadata>§no_inline: bool

Set by @noinline; the inliner must leave calls to this function alone.

§inline_hint: bool

Set by @inline; the inliner accepts a larger body than its default size limit.

§noreturn: bool

Set by @noreturn; no code after a call to this function is reachable.

§pure: bool

Set by @pure or @const; a call whose result is unused can be deleted.

§visibility: Option<SymbolVisibility>

Set by @internal, @private, @hidden or @protected.

§placement: Option<CodePlacement>

Set by @cold or @hot.

§weak: bool

Set by @weak; the symbol is emitted as a weak definition.

§section: Option<String>

Set by @section("name"); the function is emitted into that ELF section.

§align: Option<u32>

Set by @align(n); the function entry is aligned to n bytes.

§naked: bool

Set by @naked; the function is emitted with no prologue or epilogue.

§variadic: bool

Set by a trailing ... on an @extern declaration. A call to one follows the variadic side of the platform convention.

Implementations§

Source§

impl Signature

Source

pub fn new(name: impl Into<String>) -> Self

Creates a void, parameterless, non-kernel signature that the inliner may inline.

Source

pub fn with_kernel(self, metadata: KernelMetadata) -> Self

Marks the function as a GPU kernel, which GPU codegen requires to be void with a single block.

Source

pub fn with_params(self, params: Vec<Parameter>) -> Self

Source

pub fn with_return(self, ty: MirType) -> Self

Source

pub fn with_return_signedness(self, signedness: Signedness) -> Self

Source

pub fn with_return_aggregate(self, aggregate: Aggregate) -> Self

Source

pub fn param_count(&self) -> usize

Source

pub fn is_void(&self) -> bool

True when there is no return value. An aggregate return is not void, since ret_ty then holds the pointer.

Trait Implementations§

Source§

impl Clone for Signature

Source§

fn clone(&self) -> Self

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 Debug for Signature

Source§

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

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

impl PartialEq for Signature

Source§

fn eq(&self, other: &Self) -> 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 Signature

Auto Trait Implementations§

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.