Skip to main content

Function

Struct Function 

Source
pub struct Function {
    pub explicit_params: Vec<Value>,
    pub implicit_params: Vec<Value>,
    pub memories: HashMap<Id, MemoryBlock>,
    pub graph: StableDiGraph<BasicBlock, u32>,
    pub root: NodeIndex,
    pub ret: NodeIndex,
    pub return_value: Option<Value>,
    /* private fields */
}

Fields§

§explicit_params: Vec<Value>

Explicit parameters passed to the function, i.e. the inputs to a closure

§implicit_params: Vec<Value>

Implicit parameters passed to the function, i.e. kernel args, closure captures

§memories: HashMap<Id, MemoryBlock>§graph: StableDiGraph<BasicBlock, u32>§root: NodeIndex§ret: NodeIndex

The single return block

§return_value: Option<Value>

The return value, if any

Implementations§

Source§

impl Function

Source

pub fn analysis<A: Analysis + Any>(&mut self, state: &GlobalState) -> Rc<A>

Fetch an analysis if cached, or run it if not.

Source

pub fn invalidate_analysis<A: Analysis + Any>(&self)

Invalidate an analysis by removing it from the cache. The analysis is rerun when requested again.

Source

pub fn invalidate_structure(&self)

Invalidate all analyses that rely on the structure of the control flow graph.

Source§

impl Function

Source

pub fn local_variable_id(&self, value: &Value) -> Option<Id>

Gets the id of the variable if it’s a destructurable Local and not atomic, None otherwise.

Source

pub fn local_memory_id(&self, value: &Value) -> Option<Id>

Gets the id of the variable if it’s a Local memory and not atomic, None otherwise.

Unlike Function::local_variable_id, this includes non-destructurable locals such as arrays, so it can be used by backends that allocate and free those memories.

Source§

impl Function

Source

pub fn visit_all( &mut self, state: &GlobalState, visit_read: impl FnMut(&mut Self, &mut Value) + Clone, visit_write: impl FnMut(&mut Self, &mut Value) + Clone, )

Visit all operations in the program with the specified read and write visitors.

Source§

impl Function

Source

pub fn dot_viz(&self) -> String

Source§

impl Function

Source

pub fn visit_out( &mut self, val: &mut Option<Value>, visit_write: impl FnMut(&mut Self, &mut Value), )

Source

pub fn visit_instruction_memory_writes( &mut self, state: &GlobalState, inst: &Instruction, visit_write: impl FnMut(&mut Self, &MemoryBlock), )

Visit an instruction with only a write visitor. Visits both out and any pointer writes.

Source

pub fn visit_instruction_memory_reads( &mut self, state: &GlobalState, inst: &Instruction, visit_read: impl FnMut(&mut Self, &MemoryBlock), )

Source

pub fn visit_instruction( &mut self, state: &GlobalState, inst: &mut Instruction, visit_read: impl FnMut(&mut Self, &mut Value), visit_write: impl FnMut(&mut Self, &mut Value), )

Visit an operation with a set of read and write visitors. Each visitor will be called with each read or written to variable.

Source

pub fn visit_operation( &mut self, state: &GlobalState, op: &mut Operation, visit_read: impl FnMut(&mut Self, &mut Value), )

Visit an operation with a set of read and write visitors. Each visitor will be called with each read or written to variable.

Source

pub fn visit_control_flow( &mut self, op: &mut ControlFlow, visit_read: impl FnMut(&mut Self, &mut Value), )

Visit a control flow finisher with a set of read and write visitors. Each visitor will be called with each read or written to variable.

Source§

impl Function

Source

pub fn place_phi_nodes(&mut self, state: &GlobalState)

Places a phi node for each live variable at each frontier

Source

pub fn insert_phi(&mut self, block: NodeIndex, id: Id, item: Type)

Insert a phi node for variable id at block

Source

pub fn destructurable_local_memories(&self) -> HashMap<Id, MemoryBlock>

Returns all pointers to local stack space that are destructurable

Source§

impl Function

Source

pub fn parse_scope(&mut self, state: &GlobalState, scope: Scope) -> bool

Recursively parse a scope into the graph

Source

pub fn predecessors(&self, block: NodeIndex) -> Vec<NodeIndex>

List of predecessor IDs of the block

Source

pub fn successors(&self, block: NodeIndex) -> Vec<NodeIndex>

List of successor IDs of the block

Source

pub fn breadth_first_dominators(&self) -> Vec<NodeIndex>

Return the breadth-first list of nodes along the dominator tree. This is useful for generating the blocks in a human-readable-ish order that follows the Vulkan spec (dominators before dominated).

Source

pub fn block(&self, block: NodeIndex) -> &BasicBlock

Reference to the BasicBlock with ID block

Source

pub fn block_mut(&mut self, block: NodeIndex) -> &mut BasicBlock

Reference to the BasicBlock with ID block

Source

pub fn is_unreachable(&self, block: NodeIndex) -> bool

Source

pub fn node_ids(&self) -> Vec<NodeIndex>

A set of node indices for all blocks in the program

Source

pub fn all_params(&self) -> impl Iterator<Item = Value>

Source

pub fn create_local_mut(&mut self, state: &GlobalState, value_ty: Type) -> Value

Trait Implementations§

Source§

impl Clone for Function

Source§

fn clone(&self) -> Function

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 Function

Source§

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

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

impl Default for Function

Source§

fn default() -> Function

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

impl Deref for Function

Source§

type Target = StableGraph<BasicBlock, u32>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Function

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Display for Function

Debug display for the program state.

Source§

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

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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> IntoComptime for T

Source§

fn comptime(self) -> Self

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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 = 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.