pub(super) trait MergeTuple: Sized {
    // Required method
    fn write_phis(
        self,
        ctx: &mut BlockContext<'_>,
        block: &mut Block,
        predecessors: &[(Self, Word)],
    ) -> Self;
}Expand description
A trait to help Selection manage any number of merged values.
Some selection constructs, like a ReadZeroSkipWrite bounds check on a
Load expression, produce a single merged value. Others produce no merged
value, like a bounds check on a Store statement.
To let Selection work nicely with both cases, we let the merge type
argument passed to Selection::start be any type that implements this
MergeTuple trait. MergeTuple is then implemented for (), Word,
(Word, Word), and so on.
A MergeTuple type can represent either a bunch of SPIR-V types or values;
the merge_types argument to Selection::start are type ids, whereas the
values arguments to the if_true and finish methods are value ids.
The set of merged value returned by finish is a tuple of value ids.
In fact, since Naga only uses zero- and single-valued selection constructs
at present, we only implement MergeTuple for () and Word. But if you
add more cases, feel free to add more implementations. Once const generics
are available, we could have a single implementation of MergeTuple for all
lengths of arrays, and be done with it.
Required Methods§
Sourcefn write_phis(
    self,
    ctx: &mut BlockContext<'_>,
    block: &mut Block,
    predecessors: &[(Self, Word)],
) -> Self
 
fn write_phis( self, ctx: &mut BlockContext<'_>, block: &mut Block, predecessors: &[(Self, Word)], ) -> Self
Write OpPhi instructions for the given set of predecessors.
The predecessors vector should be a vector of (LABEL, VALUES) pairs,
where each VALUES holds the values contributed by the branch from
LABEL, which should be one of the current block’s predecessors.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl MergeTuple for ()
Selections that produce no merged values.
 
impl MergeTuple for ()
Selections that produce no merged values.
For example, ImageStore under BoundsCheckPolicy::ReadZeroSkipWrite
either does the store or skips it, but in neither case does it produce a
value.
Source§fn write_phis(self, _: &mut BlockContext<'_>, _: &mut Block, _: &[((), Word)])
 
fn write_phis(self, _: &mut BlockContext<'_>, _: &mut Block, _: &[((), Word)])
No phis need to be generated.
Source§impl MergeTuple for Word
Selections that produce a single merged value.
 
impl MergeTuple for Word
Selections that produce a single merged value.
For example, ImageLoad with BoundsCheckPolicy::ReadZeroSkipWrite either
returns a texel value or zeros.