#[non_exhaustive]pub enum ShapePredicate {
AtLeast(u32),
AtMost(u32),
Exactly(u32),
MultipleOf(u32),
ModEquals {
modulus: u32,
remainder: u32,
},
AffineRange {
scale: i64,
offset: i64,
min: i64,
max: i64,
},
And(Box<ShapePredicate>, Box<ShapePredicate>),
Or(Box<ShapePredicate>, Box<ShapePredicate>),
Not(Box<ShapePredicate>),
}Expand description
Refinement predicate over a buffer’s element count (P-1.0-V3.1).
Represents a small grammar of constraints a BufferDecl author
can attach. The validator (P-1.0-V3.2) checks each predicate
against the program’s static count and the optimizer (P-1.0-V3.3)
uses verified predicates to prove loop-bound and alignment
invariants for vectorization.
None (the default) is “unconstrained”; existing programs keep
their current behavior.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
AtLeast(u32)
count >= n. Holds when the runtime element count is at
least n. Used to prove non-empty workgroup buffers and
minimum vectorization tile sizes.
AtMost(u32)
count <= n. Holds when the count never exceeds n. Used
to bound dispatch sizes and prevent oversized allocations.
Exactly(u32)
count == n. The strongest constraint; the count is fixed.
MultipleOf(u32)
count % n == 0. Used for alignment proofs (e.g. SIMD lanes).
ModEquals
count % modulus == remainder. Invalid modular forms evaluate
false, so static validation catches impossible declarations.
Fields
AffineRange
min <= count * scale + offset <= max, evaluated with wide
arithmetic for frontend-derived affine constraints.
Fields
And(Box<ShapePredicate>, Box<ShapePredicate>)
Conjunction of two predicates (p1 && p2). Both must hold.
Or(Box<ShapePredicate>, Box<ShapePredicate>)
Disjunction of two predicates (p1 || p2). Either may hold.
Not(Box<ShapePredicate>)
Negation of a predicate.
Implementations§
Source§impl ShapePredicate
impl ShapePredicate
Sourcepub fn holds(&self, count: u32) -> bool
pub fn holds(&self, count: u32) -> bool
Evaluate the predicate against a concrete count. Returns
true when the predicate holds. P-1.0-V3.2 uses this from
the validate() pass; P-1.0-V3.3 calls it from optimizer
passes that need a yes/no proof.
Sourcepub fn proves_non_empty(&self) -> bool
pub fn proves_non_empty(&self) -> bool
Whether this predicate proves that the count cannot be zero.
Trait Implementations§
Source§impl Clone for ShapePredicate
impl Clone for ShapePredicate
Source§fn clone(&self) -> ShapePredicate
fn clone(&self) -> ShapePredicate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ShapePredicate
impl Debug for ShapePredicate
impl Eq for ShapePredicate
Source§impl Hash for ShapePredicate
impl Hash for ShapePredicate
Source§impl PartialEq for ShapePredicate
impl PartialEq for ShapePredicate
impl StructuralPartialEq for ShapePredicate
Auto Trait Implementations§
impl Freeze for ShapePredicate
impl RefUnwindSafe for ShapePredicate
impl Send for ShapePredicate
impl Sync for ShapePredicate
impl Unpin for ShapePredicate
impl UnsafeUnpin for ShapePredicate
impl UnwindSafe for ShapePredicate
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§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.