cranelift_codegen::ir::function

Struct FunctionStencil

Source
pub struct FunctionStencil {
    pub version_marker: VersionMarker,
    pub signature: Signature,
    pub sized_stack_slots: StackSlots,
    pub dynamic_stack_slots: DynamicStackSlots,
    pub global_values: PrimaryMap<GlobalValue, GlobalValueData>,
    pub global_value_facts: SecondaryMap<GlobalValue, Option<Fact>>,
    pub memory_types: PrimaryMap<MemoryType, MemoryTypeData>,
    pub dfg: DataFlowGraph,
    pub layout: Layout,
    pub srclocs: SecondaryMap<Inst, RelSourceLoc>,
    pub stack_limit: Option<GlobalValue>,
}
Expand description

Function fields needed when compiling a function.

Additionally, these fields can be the same for two functions that would be compiled the same way, and finalized by applying FunctionParameters onto their CompiledCodeStencil.

Fields§

§version_marker: VersionMarker

A version marker used to ensure that serialized clif ir is never deserialized with a different version of Cranelift.

§signature: Signature

Signature of this function.

§sized_stack_slots: StackSlots

Sized stack slots allocated in this function.

§dynamic_stack_slots: DynamicStackSlots

Dynamic stack slots allocated in this function.

§global_values: PrimaryMap<GlobalValue, GlobalValueData>

Global values referenced.

§global_value_facts: SecondaryMap<GlobalValue, Option<Fact>>

Global value proof-carrying-code facts.

§memory_types: PrimaryMap<MemoryType, MemoryTypeData>

Memory types for proof-carrying code.

§dfg: DataFlowGraph

Data flow graph containing the primary definition of all instructions, blocks and values.

§layout: Layout

Layout of blocks and instructions in the function body.

§srclocs: SecondaryMap<Inst, RelSourceLoc>

Source locations.

Track the original source location for each instruction. The source locations are not interpreted by Cranelift, only preserved.

§stack_limit: Option<GlobalValue>

An optional global value which represents an expression evaluating to the stack limit for this function. This GlobalValue will be interpreted in the prologue, if necessary, to insert a stack check to ensure that a trap happens if the stack pointer goes below the threshold specified here.

Implementations§

Source§

impl FunctionStencil

Source

pub fn create_jump_table(&mut self, data: JumpTableData) -> JumpTable

Creates a jump table in the function, to be used by br_table instructions.

Source

pub fn create_sized_stack_slot(&mut self, data: StackSlotData) -> StackSlot

Creates a sized stack slot in the function, to be used by stack_load, stack_store and stack_addr instructions.

Source

pub fn create_dynamic_stack_slot( &mut self, data: DynamicStackSlotData, ) -> DynamicStackSlot

Creates a dynamic stack slot in the function, to be used by dynamic_stack_load, dynamic_stack_store and dynamic_stack_addr instructions.

Source

pub fn import_signature(&mut self, signature: Signature) -> SigRef

Adds a signature which can later be used to declare an external function import.

Source

pub fn create_global_value(&mut self, data: GlobalValueData) -> GlobalValue

Declares a global value accessible to the function.

Source

pub fn create_memory_type(&mut self, data: MemoryTypeData) -> MemoryType

Declares a memory type for use by the function.

Source

pub fn get_dyn_scale(&self, ty: DynamicType) -> GlobalValue

Find the global dyn_scale value associated with given DynamicType.

Source

pub fn get_dynamic_slot_scale(&self, dss: DynamicStackSlot) -> GlobalValue

Find the global dyn_scale for the given stack slot.

Source

pub fn get_concrete_dynamic_ty(&self, ty: DynamicType) -> Option<Type>

Get a concrete Type from a user defined DynamicType.

Source

pub fn special_param(&self, purpose: ArgumentPurpose) -> Option<Value>

Find a presumed unique special-purpose function parameter value.

Returns the value of the last purpose parameter, or None if no such parameter exists.

Source

pub fn collect_debug_info(&mut self)

Starts collection of debug information.

Source

pub fn rewrite_branch_destination( &mut self, inst: Inst, old_dest: Block, new_dest: Block, )

Rewrite the branch destination to new_dest if the destination matches old_dest. Does nothing if called with a non-jump or non-branch instruction.

Source

pub fn is_block_basic(&self, block: Block) -> Result<(), (Inst, &'static str)>

Checks that the specified block can be encoded as a basic block.

On error, returns the first invalid instruction and an error message.

Source

pub fn block_successors( &self, block: Block, ) -> impl DoubleEndedIterator<Item = Block> + '_

Returns an iterator over the blocks succeeding the given block.

Source

pub fn is_leaf(&self) -> bool

Returns true if the function is function that doesn’t call any other functions. This is not to be confused with a “leaf function” in Windows terminology.

Source

pub fn transplant_inst(&mut self, dst: Inst, src: Inst)

Replace the dst instruction’s data with the src instruction’s data and then remove src.

src and its result values should not be used at all, as any uses would be left dangling after calling this method.

src and dst must have the same number of resulting values, and src’s i^th value must have the same type as dst’s i^th value.

Source

pub fn fixed_stack_size(&self) -> u32

Size occupied by all stack slots associated with this function.

Does not include any padding necessary due to offsets

Trait Implementations§

Source§

impl Clone for FunctionStencil

Source§

fn clone(&self) -> FunctionStencil

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

impl<'de> Deserialize<'de> for FunctionStencil

Source§

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

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

impl Hash for FunctionStencil

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 PartialEq for FunctionStencil

Source§

fn eq(&self, other: &FunctionStencil) -> 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.
Source§

impl Serialize for FunctionStencil

Source§

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

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

impl StructuralPartialEq for FunctionStencil

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