cranelift::prelude

Enum GlobalValueData

pub enum GlobalValueData {
    VMContext,
    Load {
        base: GlobalValue,
        offset: Offset32,
        global_type: Type,
        flags: MemFlags,
    },
    IAddImm {
        base: GlobalValue,
        offset: Imm64,
        global_type: Type,
    },
    Symbol {
        name: ExternalName,
        offset: Imm64,
        colocated: bool,
        tls: bool,
    },
    DynScaleTargetConst {
        vector_type: Type,
    },
}
Expand description

Information about a global value declaration.

Variants§

§

VMContext

Value is the address of the VM context struct.

§

Load

Value is pointed to by another global value.

The base global value is assumed to contain a pointer. This global value is computed by loading from memory at that pointer value. The memory must be accessible, and naturally aligned to hold a value of the type. The data at this address is assumed to never change while the current function is executing.

Fields

§base: GlobalValue

The base pointer global value.

§offset: Offset32

Offset added to the base pointer before doing the load.

§global_type: Type

Type of the loaded value.

§flags: MemFlags

Specifies the memory flags to be used by the load. Guaranteed to be notrap and aligned.

§

IAddImm

Value is an offset from another global value.

Fields

§base: GlobalValue

The base pointer global value.

§offset: Imm64

Byte offset to be added to the value.

§global_type: Type

Type of the iadd.

§

Symbol

Value is symbolic, meaning it’s a name which will be resolved to an actual value later (eg. by linking). Cranelift itself does not interpret this name; it’s used by embedders to link with other data structures.

For now, symbolic values always have pointer type, and represent addresses, however in the future they could be used to represent other things as well.

Fields

§name: ExternalName

The symbolic name.

§offset: Imm64

Offset from the symbol. This can be used instead of IAddImm to represent folding an offset into a symbol.

§colocated: bool

Will this symbol be defined nearby, such that it will always be a certain distance away, after linking? If so, references to it can avoid going through a GOT. Note that symbols meant to be preemptible cannot be colocated.

If true, some backends may use relocation forms that have limited range: for example, a +/- 2^27-byte range on AArch64. See the documentation for RelocDistance for more details.

§tls: bool

Does this symbol refer to a thread local storage value?

§

DynScaleTargetConst

Value is a multiple of how many instances of vector_type will fit in a target vector register.

Fields

§vector_type: Type

Base vector type.

Implementations§

§

impl GlobalValueData

pub fn symbol_name(&self) -> &ExternalName

Assume that self is an GlobalValueData::Symbol and return its name.

pub fn global_type(&self, isa: &dyn TargetIsa) -> Type

Return the type of this global.

Trait Implementations§

§

impl Clone for GlobalValueData

§

fn clone(&self) -> GlobalValueData

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
§

impl Debug for GlobalValueData

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for GlobalValueData

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<GlobalValueData, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Display for GlobalValueData

§

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

Formats the value using the given formatter. Read more
§

impl Hash for GlobalValueData

§

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

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
§

impl PartialEq for GlobalValueData

§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for GlobalValueData

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl StructuralPartialEq for GlobalValueData

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> Same for T

Source§

type Output = T

Should always be Self
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§

default 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,