pub struct Allocator { /* private fields */ }
Expand description
An allocator for local variables of a kernel.
A local variable is unique to a unit. That is, each unit have their own copy of a local variable. There are three types of local variables based on their capabilities. - An immutable local variable is obtained by calling Allocator::create_local. - A mutable local variable is obtained by calling Allocator::create_local_mut. The allocator will reuse previously defined mutable variables if possible. - A restricted mutable local variable is obtained by calling Allocator::create_local_restricted. This a is mutable variable that cannot be reused. This is mostly used for loop indices.
§Performance tips
In order, prefer immutable local variables, then mutable, then restricted.
To enable many compiler optimizations, it is preferred to use the [static single-assignment] strategy for immutable variables. That is, each variable must be declared and used exactly once.
Implementations§
Source§impl Allocator
impl Allocator
Sourcepub fn create_local(&self, item: Item) -> ExpandElement
pub fn create_local(&self, item: Item) -> ExpandElement
Create a new immutable local variable of type specified by item
.
Sourcepub fn create_local_mut(&self, item: Item) -> ExpandElement
pub fn create_local_mut(&self, item: Item) -> ExpandElement
Create a new mutable local variable of type specified by item
.
Try to reuse a previously defined but unused mutable variable if possible.
Else, this define a new variable.
Sourcepub fn create_local_restricted(&self, item: Item) -> ExpandElement
pub fn create_local_restricted(&self, item: Item) -> ExpandElement
Create a new mutable restricted local variable of type specified by item
.
pub fn create_local_array(&self, item: Item, array_size: u32) -> ExpandElement
Sourcepub fn create_slice(&self, item: Item) -> ExpandElement
pub fn create_slice(&self, item: Item) -> ExpandElement
Create a slice variable
Sourcepub fn create_matrix(&self, matrix: Matrix) -> ExpandElement
pub fn create_matrix(&self, matrix: Matrix) -> ExpandElement
Create a matrix variable
pub fn create_pipeline(&self, item: Item, num_stages: u8) -> ExpandElement
pub fn create_barrier(&self, item: Item, level: BarrierLevel) -> ExpandElement
pub fn reuse_local_mut(&self, item: Item) -> Option<ExpandElement>
Sourcepub fn add_local_mut(&self, item: Item) -> Rc<Variable>
pub fn add_local_mut(&self, item: Item) -> Rc<Variable>
Add a new variable to the pool with type specified by item
for the given scope
.