pub enum Value<D: Dialect> {
Constant(ConstantValue, Item<D>),
Value {
id: Id,
item: Item<D>,
},
Tmp {
id: Id,
item: Item<D>,
is_declared: bool,
is_ptr: bool,
is_const: bool,
},
}Variants§
Implementations§
Source§impl<D: Dialect> Value<D>
impl<D: Dialect> Value<D>
pub fn is_optimized(&self) -> bool
Sourcepub fn tmp(item: Item<D>) -> Self
pub fn tmp(item: Item<D>) -> Self
Create a temporary variable.
Also see Self::tmp_declared for a version that needs custom declaration.
pub fn to_const(&mut self)
Sourcepub fn reinterpret_ptr(&self, f: &mut Formatter<'_>, item: Item<D>) -> Self
pub fn reinterpret_ptr(&self, f: &mut Formatter<'_>, item: Item<D>) -> Self
Create a temporary variable with a reinterpret_cast.
Sourcepub fn tmp_ptr(item: Item<D>) -> Self
pub fn tmp_ptr(item: Item<D>) -> Self
Create a temporary pointer variable.
Also see Self::tmp_declared for a version that needs custom declaration.
Sourcepub fn tmp_declared(item: Item<D>) -> Self
pub fn tmp_declared(item: Item<D>) -> Self
Create a temporary variable with a custom declaration.
§Notes
Calling val.fmt_left() will assume the variable already exist.
pub fn optimized_args<const N: usize>(args: [Self; N]) -> OptimizedArgs<N, D>
pub fn optimized(&self) -> Self
pub fn index(&self, index: usize) -> IndexedValue<D>
pub fn const_qualifier(&self) -> &str
pub fn id(&self) -> Option<Id>
Sourcepub fn declare_local_ptr_backing(
&self,
f: &mut Formatter<'_>,
) -> Result<bool, Error>
pub fn declare_local_ptr_backing( &self, f: &mut Formatter<'_>, ) -> Result<bool, Error>
A value-producing op (e.g. Dot/VectorSum, or any arithmetic) whose
output was allocated as a fresh mutable local ends up typed as a local
pointer. Such an output can’t be declared inline via FmtLeft::fmt_left
— that yields T* out = <scalar value>;, which is a type error. Instead it
needs backing storage, exactly like super::Instruction::DeclareVariable.
When self is such a local pointer, this emits the backing declaration
(T out_store; T* out = &out_store;) and returns true, so the caller
writes the result through the pointer (*out = value;). Otherwise it emits
nothing and returns false, and the caller declares the output inline.
This is only reached for freshly-created outputs (the op defines out),
so it never double-declares an already-declared local.
Sourcepub fn fmt_ptr(&self) -> String
pub fn fmt_ptr(&self) -> String
Format variable for a pointer argument. Slices and buffers are already pointers, so we just leave them as is to avoid accidental double pointers
Sourcepub fn fmt_ref(&self) -> String
pub fn fmt_ref(&self) -> String
Format variable for a reference argument. Dereferences pointers while keeping locals as is.
Sourcepub fn fmt_cast_to(&self, item: Item<D>) -> String
pub fn fmt_cast_to(&self, item: Item<D>) -> String
Format an item with a specific type, casting if necessary
Trait Implementations§
impl<D: Copy + Dialect> Copy for Value<D>
impl<D: Eq + Dialect> Eq for Value<D>
impl<D: PartialEq + Dialect> StructuralPartialEq for Value<D>
Auto Trait Implementations§
impl<D> Freeze for Value<D>
impl<D> RefUnwindSafe for Value<D>where
D: RefUnwindSafe,
impl<D> Send for Value<D>
impl<D> Sync for Value<D>
impl<D> Unpin for Value<D>where
D: Unpin,
impl<D> UnsafeUnpin for Value<D>
impl<D> UnwindSafe for Value<D>where
D: UnwindSafe + RefUnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneExpand for Twhere
T: Clone,
impl<T> CloneExpand for Twhere
T: Clone,
fn __expand_clone_method(&self, _: &Scope) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CompilationArg for T
impl<T> CompilationArg for T
Source§fn dynamic_cast<Arg>(&self) -> Argwhere
Arg: CompilationArg,
fn dynamic_cast<Arg>(&self) -> Argwhere
Arg: CompilationArg,
impl<T> CubeComptime for T
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.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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