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_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
.
pub fn new_local_index(&self) -> u32
pub fn take_variables(&self) -> Vec<Variable>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Allocator
impl<'de> Deserialize<'de> for Allocator
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Allocator
Auto Trait Implementations§
impl Freeze for Allocator
impl !RefUnwindSafe for Allocator
impl !Send for Allocator
impl !Sync for Allocator
impl Unpin for Allocator
impl !UnwindSafe for Allocator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.