Translator: an access refusal names the structure it met

Feature::Lowering(LowerFamily::Access) with Needs::NotImplemented covered
about 235 refusal sites behind one name, so a walk's log line could not say
which without the AIR. Unsupported gains `cause: Option<Cause>`; an access
refusal carries Cause::Access(AccessCause), one variant per structure the
sites refuse: the access's shape, the type it moves or the memory it
reaches. Sites that refuse the same structure share a variant, wherever
they are; none is named by a file, a line or a string of its own.

The five helpers that build the refusal (lower/access/mod.rs refuse() and
memory/{alloca,leaf,plan,provenance}.rs not_lowered()) take the cause, so
the compiler makes every site name one; the three direct constructions in
memory/handles.rs and lower/access/handle.rs do too, through
Unsupported::access. Feature stays Lowering(Access), so validation's
outcome key (feature_key, the Debug of the feature) and the census are
unchanged. Display prints the cause after the feature:
"Lowering(Access): PointerStore; needs NotImplemented at ...".

Storage: nothing stores the cause. Validation keys a refusal by
feature_key(&u.feature) (engine.rs); a FALLBACK repro bundle keeps the
failure as text (repro.rs, whose only serde record is the device); the
runtime's cache marks a refused translation with fixed bytes. No version
bump.

A buffer argument of a count other than one outside an argument table
names BufferArray, apart from an index or count the metadata does not fix
(UnfixedLocation).

Tests: the error module's Display test of an access refusal; the plan's
table gaps assert ArgumentTable, and its typed-depth, initializer and
buffer-array refusals PrivateType, Initializer and BufferArray.
runtime-sources.sha256 rewritten: memory/handles.rs's two refusals name
their cause, and no run behaves otherwise. api_signatures blessed (Cause,
AccessCause, Unsupported.cause), api_surface lists the two enums,
REFUSALS.md regenerated (the access refusals are built in error/mod.rs),
docs/API.md's error table names the field.

Consumer uses (consumer-uses.sh, read-only, plus git grep, over the
consumer's development 22cfe51a54 and its lane tips of the last day): no
struct literal or exhaustive destructuring of the translator's Unsupported
("Unsupported {" hits only its video crate's own Unsupported(String),
codec/encode.rs:494-502). Its rt platform builds refusals in tests with
Unsupported::not_implemented (rt_platform/diag.rs:3076, 3078, 3490;
rt_platform/unbuilt.rs:1203, 1293), whose cause is None, so their keys
("Translation-Lowering") hold. It reads u.feature where it names a refusal
(rt_platform/diag.rs:1082) and where it says one (rt_platform/unbuilt.rs:
507); each shows the cause once it reads u.cause too.
This commit is contained in:
Anees Iqbal committed 2026-12-02 14:24:11 -08:00
1 parent 8cbec0d80b
commit f124b1489f
27 files changed
+630 -277

No files matched your search

@@ -1 +1 @@
577c53655c6dececc9777f1581a7cc25ad988cae5767c2df599e8430eb8f1ae4
c246930c791ff0bd04df659e8cc485a1200da95bdab354f7a078a53a4c5b6937
+178
View File
@@ -194,6 +194,7 @@ impl From<crate::air::error::Unsupported> for Unsupported {
needs: Needs::NotImplemented,
location,
symbol,
cause: None,
}
}
}
@@ -316,6 +317,10 @@ pub struct Unsupported {
/// callee of a call that needs linking, the pixel format a refused texture, view or copy
/// holds. Opaque like every [`DiagName`].
pub symbol: Option<DiagName>,
/// Which of its causes refused, where the feature covers more than one: the structure the
/// translator met, named by its shape, type or address space, never by the input's names.
/// `None` for a feature of one cause.
pub cause: Option<Cause>,
}
impl Unsupported {
@@ -326,6 +331,7 @@ impl Unsupported {
needs: Needs::NotImplemented,
location: None,
symbol: None,
cause: None,
}
}
@@ -336,6 +342,7 @@ impl Unsupported {
needs: Needs::NotRepresentable,
location: None,
symbol: None,
cause: None,
}
}
@@ -346,6 +353,7 @@ impl Unsupported {
needs: Needs::AnyOf(alternatives),
location: None,
symbol: None,
cause: None,
}
}
@@ -396,6 +404,15 @@ impl Unsupported {
self.symbol = Some(symbol);
self
}
/// The access family's refusal of the structure `cause` names
/// (`Feature::Lowering(LowerFamily::Access)`, not implemented).
pub(crate) fn access(cause: AccessCause) -> Unsupported {
Unsupported {
cause: Some(Cause::Access(cause)),
..Unsupported::not_implemented(Feature::Lowering(LowerFamily::Access))
}
}
}
impl fmt::Display for Unsupported {
@@ -404,6 +421,9 @@ impl fmt::Display for Unsupported {
if let Some(symbol) = &self.symbol {
write!(f, " ({symbol})")?;
}
if let Some(cause) = &self.cause {
write!(f, ": {cause}")?;
}
write!(f, "; needs {:?}", self.needs)?;
if let Some(at) = &self.location {
write!(f, " at {at}")?;
@@ -997,6 +1017,164 @@ pub enum LowerFamily {
Mesh,
}
/// Which of its causes a refusal of a feature of several causes met ([`Unsupported::cause`]): the
/// structure the translator met, so a log line names the cause without the input.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Cause {
/// The access family's refusal (`Feature::Lowering(LowerFamily::Access)`).
Access(AccessCause),
}
impl fmt::Display for Cause {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Cause::Access(cause) => write!(f, "{cause:?}"),
}
}
}
/// The structure an access the translator does not lower yet met
/// (`Feature::Lowering(LowerFamily::Access)`, [`Needs::NotImplemented`]): the access's shape, the
/// type it moves, or the memory it reaches. Refusals that meet the same structure name the same
/// cause, wherever the translator meets it.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum AccessCause {
/// A load or store of a type the lowering holds no form for: a vector of `bool`s, of lanes
/// other than 8, 16, 32 or 64 bits, or whose lanes do not fill it; a scalar past 8 bytes; an
/// aggregate where one value is moved; a type that does not fit the typed private or
/// threadgroup object it reaches; or a copy (`memcpy`, `memmove`) whose unit is none of the
/// forms the copy moves.
AccessType,
/// An address computation (`getelementptr`) the lowering cannot place: a struct field index
/// that is not a constant or names no field, or an element type with no size.
AddressComputation,
/// An `alloca` whose count is not a constant integer.
AllocaCount,
/// An access to an argument table (a buffer argument of buffer pointers, `memory::plan`'s
/// buffer table) other than a load of one of its elements: a pointer into another table, a
/// wide (64-bit address) table pointer, a table pointer that escapes, merges with another or is
/// compared, a table in thread memory or of a count other than one, a load of a pointer of
/// another address space or from inside an element, an element of no size, or any other
/// instruction on a table pointer.
ArgumentTable,
/// An atomic of a type or an operation it has no form for: a vector, an element other than
/// a 32- or 64-bit integer or a 32-bit float, a compare-exchange of a float, or a
/// read-modify-write operation of no lowered form for its type.
AtomicForm,
/// An atomic on memory it has no atomic form for: a pointer of a form other than a buffer's,
/// threadgroup memory's or the private arena's; a 64-bit atomic on threadgroup memory, whose
/// arena is 32-bit words; or an atomic on a memory cell that holds a pointer.
AtomicMemory,
/// A buffer argument whose AIR metadata gives it a count other than one, an array of buffers
/// at consecutive indices that no argument table holds.
BufferArray,
/// A call whose effect on memory the lowering does not follow: a call to a function that is
/// neither an `air.*` nor an `llvm.*` intrinsic, as the memory model meets it.
Call,
/// A coherent access (`memory_coherence`) to memory other than device and constant memory.
CoherentMemory,
/// The address of constant data where the function reads one: a pointer into the constant
/// blob (the program-scope constants the translator places) stored, passed to a command,
/// compared, looked up as a handle or taken as a parameter's, where no Metal address names it.
ConstantAddress,
/// A `select` of pointers or handles whose condition is a constant.
ConstantCondition,
/// A constant operand the lowering does not materialize: a pointer constant other than null
/// or a constant global's address, a phi's incoming pointer constant, a constant handle of no
/// single candidate, a constant pointer held in a memory cell, an integer cast to a
/// threadgroup pointer that is not a literal, or another constant of no lowered form.
ConstantOperand,
/// A pointer whose displacement into its object is not one constant where the lowering needs
/// one: into the constant blob, a typed private or threadgroup object, or an arena.
DynamicOffset,
/// A program-scope variable the translator does not place: one in device or thread memory, a
/// constant one without an initializer, or one of a type with no size.
GlobalVariable,
/// A handle of a class the lowering does not take: one other than a texture or a sampler.
HandleClass,
/// A use of a handle or an array of handles it has no form for: an element of an array of
/// another class, a copy or `select` of arrays of different classes, a load of an array's
/// element that is neither a handle nor its word, a handle in memory other than device and
/// constant memory, a handle parameter of no slot, or another instruction on a handle.
HandleUse,
/// An index of a type other than an integer.
IndexType,
/// A constant initializer the translator does not write: one whose shape is not its type's,
/// one of a type with no layout, or one holding a constant of no lowered form, of a private
/// variable or of a program-scope constant.
Initializer,
/// A store an intrinsic makes into memory it has no form for: a typed threadgroup object, or
/// memory of no known home.
IntrinsicStore,
/// An offset, length, count or index below zero or past the 32 bits the lowering addresses
/// memory with: a constant's place in the constant blob, an arena offset, a copy's constant
/// length, a bound buffer's window, a slot or handle index, or the count of a function's typed
/// objects.
OffsetWidth,
/// An instruction routed to the access family that none of its forms takes.
Operation,
/// A parameter of a role the access family does not lower, or a buffer parameter of no slot.
Parameter,
/// A pointer held in a memory cell in a form the lowering does not hold: a handle of a
/// dynamic root, a typed private, threadgroup or constant pointer, a payload pointer, cells
/// whose stored pointers' encodings disagree, or a pointer cell outside an arena.
PointerCell,
/// A compare of pointers it has no form for: of two nulls, of pointers into different
/// memories, of a pointer that may be null with another pointer, a signed compare against
/// null, or of pointers of other forms.
PointerCompare,
/// A pointer of a form an operation does not take: a wide (64-bit address) pointer where a
/// slot's static pointer is needed, a pointer of no static slot, or a handle value with no
/// handle form.
PointerForm,
/// A pointer inside a vector or an aggregate value: a vector of pointers, or a pointer
/// inserted into a vector or an aggregate.
PointerInAggregate,
/// A cast between a pointer and an integer of a width it has no form for: an integer that is
/// not 64 bits cast to a pointer, or a pointer cast to a type that is not an integer of 1 to
/// 64 bits.
PointerInteger,
/// A `select` or phi of pointers whose sides the lowering cannot hold in one form: pointers
/// into different memories or of different shapes, constant data beside a buffer, or a wide
/// (64-bit address) pointer beside a static one.
PointerJoin,
/// A pointer into a typed private or threadgroup object whose shape walk meets a cycle,
/// passes its bound, or gathers more strides than it holds.
PointerShape,
/// A pointer stored in or loaded from memory whose size is not 8 bytes.
PointerSize,
/// A pointer that comes from an operation the memory model does not follow: a call other than
/// an intrinsic's result, an element of an aggregate or a vector, a cast between address
/// spaces, a constant expression other than an address computation or a cast, an argument's
/// aggregate, or a value that is not a pointer on a pointer's path.
PointerSource,
/// A store of a pointer, or of a value holding one, into memory: through a buffer pointer,
/// into private or threadgroup memory, or through a wide (64-bit address) pointer.
PointerStore,
/// A private variable (`alloca`) of a type the typed form does not hold: nested past the
/// depth bound, an array of no elements, a matrix with no fragment form, a type with no
/// size, or another type.
PrivateType,
/// A store, copy or intrinsic write into memory the function only reads: constant memory (the
/// constant blob, a program-scope constant), or a mesh function's payload.
ReadOnlyStore,
/// Memory the stage does not have: threadgroup memory in a vertex function, or a fragment
/// function's threadgroup memory without imageblock regions.
StageMemory,
/// An access at an alignment below its element's: an atomic below its natural alignment, or
/// a load of an argument table's or a handle array's element below the element's size, whose
/// index a division by that size would not give.
UnderAligned,
/// An argument whose place the AIR's metadata does not fix as a constant: a buffer's, an
/// argument table's or a threadgroup argument's index, or a table's count.
UnfixedLocation,
/// A volatile access of a form that has no volatile form: a payload word, a pointer or handle
/// lookup, or another of the access family's forms.
Volatile,
}
/// A pipeline input that the caller did not supply.
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+20
View File
@@ -223,6 +223,26 @@ fn refusals_name_their_symbol() {
);
}
/// An access refusal renders the structure it met after its feature, so a log line names the
/// cause without the input; a refusal of one cause renders none.
#[test]
fn an_access_refusal_names_its_cause() {
let at = Location::function(DiagName::new("k"), Some(3), Some(17));
let u = Unsupported::access(AccessCause::PointerStore).at(at);
assert_eq!(u.feature, Feature::Lowering(LowerFamily::Access));
assert_eq!(u.needs, Needs::NotImplemented);
assert_eq!(u.cause, Some(Cause::Access(AccessCause::PointerStore)));
assert_eq!(
u.to_string(),
"Lowering(Access): PointerStore; needs NotImplemented at function k, block 3, \
instruction 17"
);
assert_eq!(
Unsupported::not_implemented(Feature::Tessellation).cause,
None
);
}
#[test]
fn error_types_are_send_and_sync() {
fn send_sync<T: Send + Sync>() {}
+11 -9
View File
@@ -98,7 +98,7 @@ use crate::air::ir::{
use crate::budget::Meter;
use crate::device::profile::BufferAccess;
use crate::device::requirements::VkFeature;
use crate::error::{Capability, Error, Feature, Unsupported};
use crate::error::{AccessCause, Capability, Error, Feature, Unsupported};
use crate::lower::emit::EmitCx;
use crate::lower::select::SelectCx;
use crate::lower::sync::{barrier, memory_model};
@@ -340,7 +340,7 @@ fn air_kind(a: &AirAtomic) -> Result<AtomicKind, Error> {
AirOp::Sub if float => AtomicKind::Cas(CasOp::FSub),
AirOp::Min if float => AtomicKind::Cas(CasOp::FMin),
AirOp::Max if float => AtomicKind::Cas(CasOp::FMax),
op => AtomicKind::Rmw(int_op(op, a.sign).ok_or_else(refuse)?),
op => AtomicKind::Rmw(int_op(op, a.sign).ok_or_else(|| refuse(AccessCause::AtomicForm))?),
})
}
@@ -397,7 +397,7 @@ fn natural(align: Option<Align>, e: Elem) -> Result<Elem, Error> {
_ => 4,
};
match align {
Some(a) if a.bytes() < size => Err(refuse()),
Some(a) if a.bytes() < size => Err(refuse(AccessCause::UnderAligned)),
_ => Ok(e),
}
}
@@ -443,7 +443,9 @@ struct Request {
/// The request of `inst`, or `None` when it is no memory atomic.
fn request(cx: &SelectCx<'_>, inst: &Inst) -> Result<Option<Request>, Error> {
let elem = |cx: &SelectCx<'_>, ty: TypeId| elem_of(cx, ty).ok_or_else(refuse);
let elem = |cx: &SelectCx<'_>, ty: TypeId| {
elem_of(cx, ty).ok_or_else(|| refuse(AccessCause::AtomicForm))
};
let ty_of = |cx: &SelectCx<'_>, v: Value| {
cx.value_ty(v)
.ok_or_else(|| cx.invariant("an atomic operand without a type"))
@@ -458,7 +460,7 @@ fn request(cx: &SelectCx<'_>, inst: &Inst) -> Result<Option<Request>, Error> {
return Ok(None);
};
if a.ty.lanes != 1 || !matches!(a.ty.elem, Elem::I32 | Elem::I64 | Elem::F32) {
return Err(refuse());
return Err(refuse(AccessCause::AtomicForm));
}
let args: &[Value] = &call.args;
let arg = |i: usize| -> Result<Value, Error> {
@@ -498,7 +500,7 @@ fn request(cx: &SelectCx<'_>, inst: &Inst) -> Result<Option<Request>, Error> {
Request {
named: Named::Llvm,
ptr: *ptr,
kind: rmw_kind(*op, e).ok_or_else(refuse)?,
kind: rmw_kind(*op, e).ok_or_else(|| refuse(AccessCause::AtomicForm))?,
elem: e,
value: Some(*val),
compare: None,
@@ -518,7 +520,7 @@ fn request(cx: &SelectCx<'_>, inst: &Inst) -> Result<Option<Request>, Error> {
} => {
let e = natural(*align, elem(cx, ty_of(cx, *cmp)?)?)?;
if e == Elem::F32 {
return Err(refuse());
return Err(refuse(AccessCause::AtomicForm));
}
Request {
named: Named::Llvm,
@@ -587,7 +589,7 @@ pub fn select(
(Some(Repr::PrivPtr(PrivForm::Arena)), Named::Air(AtomicSpace::Private)) => {
return private(cx, inst, r).map(Some);
}
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::AtomicMemory)),
};
let addressed = cx.profile.fields().buffer_access == BufferAccess::Addressed;
let wide = r.elem == Elem::I64;
@@ -616,7 +618,7 @@ pub fn select(
}
if threadgroup {
// The arena is a `u32` word array; a `u64` view of it is not declared.
return Err(refuse());
return Err(refuse(AccessCause::AtomicMemory));
}
if !addressed {
// A buffer's `u64` word is reached through its device address only.
+11 -8
View File
@@ -17,7 +17,7 @@
use std::sync::Arc;
use crate::air::ir::{CastOp, Const, Inst, InstId, InstKind, Value, ValueId};
use crate::error::Error;
use crate::error::{AccessCause, Error};
use crate::lower::emit::EmitCx;
use crate::lower::select::SelectCx;
use crate::memory::blob::{BlobDecl, BlobHome, BlobUse};
@@ -131,14 +131,14 @@ pub fn lowered_pointer(cx: &SelectCx<'_>, v: Value) -> Result<Option<DemoteTy>,
// implemented.
return match cx.memory.repr(v) {
Some(Repr::BufPtr { wide: false, .. }) => Ok(None),
_ => Err(refuse()),
_ => Err(refuse(AccessCause::PointerJoin)),
};
}
if !is_blob(cx, v)? {
return Ok(None);
}
if super::phis::incoming(cx, v)?.is_some_and(|i| i.constant) {
return Err(refuse());
return Err(refuse(AccessCause::ConstantOperand));
}
Ok(Some(DemoteTy::ArenaOffset))
}
@@ -172,10 +172,13 @@ pub fn blob_ptr(cx: &SelectCx<'_>, v: Value) -> Result<LocalPtr, Error> {
};
match cx.entry.module.consts().get(c).map(|k| &k.value) {
Some(Const::GlobalAddr(g)) => {
let off = global_offset(cx.memory, *g).ok_or_else(refuse)?;
Ok(LocalPtr::Offset(u32::try_from(off).map_err(|_| refuse())?))
let off =
global_offset(cx.memory, *g).ok_or_else(|| refuse(AccessCause::ConstantOperand))?;
Ok(LocalPtr::Offset(
u32::try_from(off).map_err(|_| refuse(AccessCause::OffsetWidth))?,
))
}
_ => Err(refuse()),
_ => Err(refuse(AccessCause::ConstantOperand)),
}
}
@@ -207,7 +210,7 @@ pub fn select(
if is_blob(cx, v)? {
Ok(())
} else {
Err(refuse())
Err(refuse(AccessCause::PointerJoin))
}
};
Ok(Some(match &inst.kind {
@@ -270,7 +273,7 @@ pub fn select(
// The blob is constant: a store through it has no Metal meaning here.
InstKind::Store { ptr, .. } => {
return match is_blob(cx, *ptr)? {
true => Err(refuse()),
true => Err(refuse(AccessCause::ReadOnlyStore)),
false => Ok(None),
}
}
@@ -34,7 +34,7 @@
use crate::air::abi::{AbiInt, ParamBinding};
use crate::air::ir::{CastOp, Inst, InstId, InstKind, Value, ValueId};
use crate::error::Error;
use crate::error::{AccessCause, Error};
use crate::lower::emit::EmitCx;
use crate::lower::select::SelectCx;
use crate::memory::leaf::k32;
@@ -120,7 +120,7 @@ fn table_of(cx: &SelectCx<'_>, v: Value) -> Option<u32> {
/// The table pointer operand `v` of a pointer into table `param`.
fn table_operand(cx: &SelectCx<'_>, v: Value, param: u32) -> Result<ValueId, Error> {
if table_of(cx, v) != Some(param) {
return Err(refuse());
return Err(refuse(AccessCause::ArgumentTable));
}
operand(cx, v)
}
@@ -148,12 +148,16 @@ fn element(
param: u32,
align: Option<crate::air::ir::Align>,
) -> Result<Element, Error> {
let t = cx.memory.abi.buffer_table(param).ok_or_else(refuse)?;
let t = cx
.memory
.abi
.buffer_table(param)
.ok_or_else(|| refuse(AccessCause::ArgumentTable))?;
let AbiInt::Const(first) = t.first else {
return Err(refuse());
return Err(refuse(AccessCause::UnfixedLocation));
};
let Some(Repr::BufPtr { roots, wide: false }) = cx.memory.repr(Value::Inst(at)) else {
return Err(refuse());
return Err(refuse(AccessCause::ArgumentTable));
};
// The elements the set names, read once for the function (`root_sets`). A read wholly outside
// the table is the null pointer alone.
@@ -171,7 +175,12 @@ fn element(
} if p == param => (lo, hi, count),
_ => return Err(cx.invariant("a table load with a root outside its table")),
};
let root = |k: u32| first.checked_add(k).map(slot_root).ok_or_else(refuse);
let root = |k: u32| {
first
.checked_add(k)
.map(slot_root)
.ok_or_else(|| refuse(AccessCause::OffsetWidth))
};
match count {
1 => Ok(Element::Root(root(lo)?)),
_ => {
@@ -195,10 +204,10 @@ fn element(
.store_size(ty)
.and_then(|s| u32::try_from(s).ok())
.filter(|s| *s > 0)
.ok_or_else(refuse)?;
.ok_or_else(|| refuse(AccessCause::ArgumentTable))?;
// The division by the element size is exact only for an aligned load.
if align.map_or(1, |a| a.bytes()) < u64::from(size) {
return Err(refuse());
return Err(refuse(AccessCause::UnderAligned));
}
Ok(Element::Dynamic {
ptr: operand(cx, ptr)?,
@@ -274,7 +283,7 @@ pub fn select(
inst.kind
.for_each_value(|v| touches |= table_of(cx, v).is_some());
if touches || table_of(cx, here).is_some() {
return Err(refuse());
return Err(refuse(AccessCause::ArgumentTable));
}
return Ok(None);
}
+9 -9
View File
@@ -37,7 +37,7 @@ use std::collections::BTreeMap;
use crate::air::ir::{Align, CastOp, Const, Inst, InstId, InstKind, Value, ValueId};
use crate::budget::{tree_bytes, Meter};
use crate::error::Error;
use crate::error::{AccessCause, Error};
use crate::lower::arith::{Form, Held};
use crate::lower::emit::EmitCx;
use crate::lower::select::SelectCx;
@@ -186,7 +186,7 @@ fn encoding(cx: &SelectCx<'_>, v: Value) -> Result<Option<Encoding>, Error> {
Repr::Handle { cands, .. }
if cx.memory.roots(cands).binary_search(&Root::Dynamic).is_ok() =>
{
return Err(refuse())
return Err(refuse(AccessCause::PointerCell))
}
Repr::Handle { .. }
| Repr::TgPtr
@@ -199,7 +199,7 @@ fn encoding(cx: &SelectCx<'_>, v: Value) -> Result<Option<Encoding>, Error> {
Repr::PrivPtr(PrivForm::Typed(_))
| Repr::TgTyped(_)
| Repr::ConstPtr(_)
| Repr::PayloadPtr => return Err(refuse()),
| Repr::PayloadPtr => return Err(refuse(AccessCause::PointerCell)),
}))
}
@@ -259,14 +259,14 @@ fn constant(cx: &SelectCx<'_>, v: Value) -> Result<(Encoding, CellValue), Error>
_ if local::home_of(cx, v) == Some(Home::Arena(Arena::Threadgroup)) => {
match local::local_ptr(cx, v, Home::Arena(Arena::Threadgroup))? {
LocalPtr::Offset(o) => Ok((Encoding::Word, CellValue::Offset(o))),
LocalPtr::Value(_) => Err(refuse()),
LocalPtr::Value(_) => Err(refuse(AccessCause::ConstantOperand)),
}
}
Some(Const::GlobalAddr(_)) if blob::is_blob(cx, v)? => match blob::blob_ptr(cx, v)? {
LocalPtr::Offset(o) => Ok((Encoding::Word, CellValue::Offset(o))),
LocalPtr::Value(_) => Err(refuse()),
LocalPtr::Value(_) => Err(refuse(AccessCause::ConstantOperand)),
},
_ => Err(refuse()),
_ => Err(refuse(AccessCause::ConstantOperand)),
}
}
@@ -369,7 +369,7 @@ fn agree(
if enc == Encoding::Word && reads.only(Encoding::Pair) && blob::is_blob(cx, val)? {
return Ok((Encoding::Pair, CellValue::Blob(blob::blob_ptr(cx, val)?)));
}
Err(refuse())
Err(refuse(AccessCause::PointerCell))
}
/// Select the cell strategy of `inst`: a plain load or store of a pointer that provenance
@@ -456,7 +456,7 @@ pub fn select(
})
}
// An atomic cell access (a volatile one is selected as the plain one).
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::AtomicMemory)),
}))
}
@@ -518,7 +518,7 @@ mod tests {
let mut r = Reads::default();
assert!(r.add(Ok(Some(Encoding::Word))).is_ok());
assert!(r.only(Encoding::Word));
assert!(r.add(Err(refuse())).is_ok());
assert!(r.add(Err(refuse(AccessCause::PointerCell))).is_ok());
assert!(
!r.only(Encoding::Word),
"a refused load reads no cell encoding"
+4 -4
View File
@@ -63,7 +63,7 @@ use std::borrow::Cow;
use crate::air::intrinsics::LlvmIntrinsic;
use crate::air::ir::{Callee, CastOp, Const, Inst, InstId, InstKind, Value, ValueId};
use crate::budget::Meter;
use crate::error::{Error, LowerFamily};
use crate::error::{AccessCause, Error, LowerFamily};
use crate::lower::arith::{Form, Held};
use crate::lower::emit::EmitCx;
use crate::lower::select::SelectCx;
@@ -381,7 +381,7 @@ pub fn endpoint(
let leaf = unit_leaf(1);
if blob::is_blob(cx, v)? {
if write {
return Err(refuse());
return Err(refuse(AccessCause::ReadOnlyStore));
}
blob::use_blob(cx)?;
return Ok(Endpoint::Blob {
@@ -532,7 +532,7 @@ pub fn select(
// A constant length is split into units once the endpoints' alignment is known.
let span = match const_index(cx, n) {
// A constant length beyond the `u32` offset space reaches no Metal allocation's end.
Some(len) => Span::Bytes(u32::try_from(len).map_err(|_| refuse())?),
Some(len) => Span::Bytes(u32::try_from(len).map_err(|_| refuse(AccessCause::OffsetWidth))?),
None if matches!(n, Value::Const(_)) => return Err(not_lowered(LowerFamily::Arith)),
None => {
let ty = cx
@@ -546,7 +546,7 @@ pub fn select(
elem: ScalarTy::Int { bits: 32 },
len: 2,
} => true,
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::AccessType)),
};
Span::Dynamic(Length::Dynamic {
len: operand(cx, n)?,
+23 -16
View File
@@ -100,7 +100,7 @@ use crate::bind::status::{StatusBits, StatusWord};
use crate::budget::Meter;
use crate::device::profile::BufferAccess;
use crate::device::requirements::VkFeature;
use crate::error::{Capability, Error, Feature, LowerFamily, Unsupported};
use crate::error::{AccessCause, Capability, Error, Feature, LowerFamily, Unsupported};
use crate::lower::arith::{Form, Held};
use crate::lower::emit::EmitCx;
use crate::lower::select::SelectCx;
@@ -289,7 +289,7 @@ impl DynStrategy {
to: to.volatile(),
value,
},
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::Volatile)),
})
}
@@ -371,7 +371,7 @@ fn require_addresses(cx: &SelectCx<'_>) -> Result<(), Error> {
/// materialized).
fn wide_operand(cx: &SelectCx<'_>, v: Value) -> Result<ValueId, Error> {
if wide(cx, v).is_none() {
return Err(refuse());
return Err(refuse(AccessCause::ConstantOperand));
}
operand(cx, v)
}
@@ -405,11 +405,14 @@ fn plan_resolve(cx: &mut SelectCx<'_>) {
/// the pointer carries its address, and no entry is read ([`use_table`]).
pub(super) fn plan_entry(cx: &mut SelectCx<'_>, v: Value) -> Result<ValueId, Error> {
require_addresses(cx)?;
let roots = wide(cx, v).ok_or_else(refuse)?;
let roots = wide(cx, v).ok_or_else(|| refuse(AccessCause::PointerForm))?;
let Some(set) = cx.root_sets.get_mut(roots) else {
return Err(cx.invariant("a wide pointer's root set was not read"));
};
let slots = set.wide_slots.as_deref().ok_or_else(refuse)?;
let slots = set
.wide_slots
.as_deref()
.ok_or_else(|| refuse(AccessCause::PointerForm))?;
if !set.merged {
cx.families
.access
@@ -472,7 +475,7 @@ pub fn lowered_pointer(cx: &SelectCx<'_>, v: Value) -> Result<Option<DemoteTy>,
}
require_addresses(cx)?;
if super::phis::incoming(cx, v)?.is_some_and(|i| i.not_wide) {
return Err(refuse());
return Err(refuse(AccessCause::PointerJoin));
}
Ok(Some(match super::identity(cx.profile) {
true => DemoteTy::Address,
@@ -500,7 +503,7 @@ pub fn is_wide_param(cx: &SelectCx<'_>, b: &ParamBinding) -> bool {
pub fn select_param(cx: &mut SelectCx<'_>, b: &ParamBinding) -> Result<(), Error> {
require_addresses(cx)?;
if super::identity(cx.profile) {
let slot = param_slot(cx.entry, b).ok_or_else(refuse)?;
let slot = param_slot(cx.entry, b).ok_or_else(|| refuse(AccessCause::Parameter))?;
cx.push.insert(PushField::SlotGuestBase(slot));
}
cx.families.access.dynamic.params.insert(b.param);
@@ -591,9 +594,13 @@ fn pointer_leaf(
ty: crate::air::ir::TypeId,
align: Option<Align>,
) -> Result<Leaf, Error> {
let bytes = cx.memory.layouts.store_size(ty).ok_or_else(refuse)?;
let bytes = cx
.memory
.layouts
.store_size(ty)
.ok_or_else(|| refuse(AccessCause::PointerSize))?;
if bytes != 8 {
return Err(refuse());
return Err(refuse(AccessCause::PointerSize));
}
let align = align.map_or(1, |a| a.bytes());
Ok(Leaf {
@@ -707,7 +714,7 @@ pub fn select(
InstKind::Select { c, t, f, .. } if result_wide && is_ptr_ty(cx, inst.ty) => {
require_addresses(cx)?;
let c = match c {
Value::Const(_) => return Err(refuse()),
Value::Const(_) => return Err(refuse(AccessCause::ConstantCondition)),
c => operand(cx, *c)?,
};
let side = |v: Value| -> Result<Side, Error> {
@@ -731,7 +738,7 @@ pub fn select(
cx.value_ty(*v).and_then(|t| cx.entry.module.types().get(t)),
Some(Type::Int(64))
) {
return Err(refuse());
return Err(refuse(AccessCause::PointerInteger));
}
plan_resolve(cx);
DynStrategy::FromInt {
@@ -790,7 +797,7 @@ pub fn select(
} if is_buffer_ptr(cx, *v) => {
let bits = match cx.entry.module.types().get(inst.ty) {
Some(Type::Int(b @ 1..=64)) => *b,
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::PointerInteger)),
};
DynStrategy::ToInt {
of: stored(cx, *v)?,
@@ -831,7 +838,7 @@ pub fn select(
.value_ty(*val)
.ok_or_else(|| cx.invariant("a stored value without a type"))?;
if is_ptr_ty(cx, ty) {
return Err(refuse());
return Err(refuse(AccessCause::PointerStore));
}
let leaf = leaf::leaf_of(
cx.entry,
@@ -890,7 +897,7 @@ fn coherent(
return Ok(None);
}
if !matches!(c.space, AddrSpace::Device | AddrSpace::Constant) {
return Err(refuse());
return Err(refuse(AccessCause::CoherentMemory));
}
let ty = match value {
None => inst.ty,
@@ -998,7 +1005,7 @@ pub(super) fn store_destination(
/// its leaf holds a guest address.
fn cell(cx: &mut SelectCx<'_>, ptr: Value, leaf: Leaf, write: bool) -> Result<LocalAccess, Error> {
let Some(home @ Home::Arena(arena)) = local::home_of(cx, ptr) else {
return Err(refuse());
return Err(refuse(AccessCause::PointerCell));
};
local::use_arena(cx, arena)?;
local::composed(cx, arena);
@@ -1604,7 +1611,7 @@ pub(super) fn plan_word(
coherence: None,
volatile: false,
}),
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::PointerForm)),
})
}
+29 -27
View File
@@ -65,7 +65,7 @@ use std::collections::BTreeMap;
use crate::air::ir::{AddrSpace, CastOp, Inst, InstId, InstKind, Type, Value, ValueId};
use crate::budget::{tree_bytes, Meter};
use crate::error::{Error, Feature, LowerFamily, Unsupported};
use crate::error::{AccessCause, Error, Feature, LowerFamily, Unsupported};
use crate::lower::arith::{legal, Form, Held};
use crate::lower::emit::EmitCx;
use crate::lower::select::{DescriptorCounts, Plan, SelectCx};
@@ -335,7 +335,7 @@ fn null_constant(cx: &SelectCx<'_>, v: Value) -> bool {
/// static candidates are one, or a heap handle ([`domain_kind`]).
fn handle_domain(cx: &SelectCx<'_>, v: Value, class: HandleClass) -> Result<DomainKind, Error> {
if !lowered_class(class) {
return Err(refuse());
return Err(refuse(AccessCause::HandleClass));
}
domain_kind(cx, v, class)
}
@@ -361,7 +361,7 @@ pub(crate) fn domain_kind(
.handle(cx.entry, cx.memory, v, class, cands)
.cloned()
.unwrap_or_else(|| Err(cx.invariant("a handle's root set was not read"))),
_ => Err(Unsupported::not_implemented(Feature::Lowering(LowerFamily::Access)).into()),
_ => Err(Unsupported::access(AccessCause::PointerForm).into()),
}
}
@@ -374,7 +374,7 @@ fn static_candidates(
m: &mut Meter,
) -> Result<Vec<Candidate>, Error> {
if !lowered_class(class) {
return Err(refuse());
return Err(refuse(AccessCause::HandleClass));
}
handles::candidates(cx.entry, cx.memory, v, class, m)
}
@@ -387,17 +387,17 @@ fn handle_operand(cx: &SelectCx<'_>, v: Value, class: HandleClass) -> Result<Han
if matches!(v, Value::Const(_)) {
// A constexpr sampler's address.
if !lowered_class(class) {
return Err(refuse());
return Err(refuse(AccessCause::HandleClass));
}
let cands = handles::value_candidates(cx.entry, &cx.memory.abi, v, class)
.unwrap_or_else(|| Err(cx.invariant("a constant handle without a candidate")))?;
return match cands.as_slice() {
[c] => Ok(HandleOperand::Const(c.handle())),
_ => Err(refuse()),
_ => Err(refuse(AccessCause::ConstantOperand)),
};
}
if cx.param(v).is_none() && handle_class(cx, v) != Some(class) {
return Err(refuse());
return Err(refuse(AccessCause::HandleUse));
}
handle_domain(cx, v, class)?;
Ok(HandleOperand::Value(operand(cx, v)?))
@@ -416,7 +416,7 @@ pub fn lowered_pointer(cx: &SelectCx<'_>, v: Value) -> Result<Option<DemoteTy>,
// A phi's incoming constant would need a pointer constant's materialization, which the
// emitter's operands do not provide.
if super::phis::incoming(cx, v)?.is_some_and(|i| i.constant) {
return Err(refuse());
return Err(refuse(AccessCause::ConstantOperand));
}
if identity_sampler(cx, v) {
return Ok(Some(IDENTITY_SAMPLER_ID));
@@ -443,8 +443,8 @@ fn element(
}
return Ok(Element::Handle(handles::ABSENT_HANDLE));
}
let (pc, first, count) =
handles::param_slots(cx.entry, &cx.memory.abi, *p).ok_or_else(refuse)?;
let (pc, first, count) = handles::param_slots(cx.entry, &cx.memory.abi, *p)
.ok_or_else(|| refuse(AccessCause::HandleUse))?;
if pc != class {
return Err(Unsupported::not_implemented(Feature::HandleAsPointer).into());
}
@@ -454,17 +454,19 @@ fn element(
.store_size(ty)
.and_then(|s| u32::try_from(s).ok())
.filter(|s| *s > 0)
.ok_or_else(refuse)?;
.ok_or_else(|| refuse(AccessCause::HandleUse))?;
let range = cx.memory.offset(ptr).unwrap_or(OffsetRange::Top);
let Some((lo, hi)) = handles::array_elements(range, u64::from(size), count) else {
return Ok(Element::Handle(NULL_HANDLE));
};
let handle = |k: u32| -> Result<u32, Error> {
let n = first.checked_add(k).ok_or_else(refuse)?;
let n = first
.checked_add(k)
.ok_or_else(|| refuse(AccessCause::OffsetWidth))?;
let c = match class {
HandleClass::Texture => Candidate::Texture(n),
HandleClass::Sampler => Candidate::Sampler(n),
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::HandleClass)),
};
Ok(c.handle())
};
@@ -473,7 +475,7 @@ fn element(
}
// The division by the handle size is exact only for an aligned load.
if align.map_or(1, |a| a.bytes()) < u64::from(size) {
return Err(refuse());
return Err(refuse(AccessCause::UnderAligned));
}
Ok(Element::Dynamic {
ptr: operand(cx, ptr)?,
@@ -634,7 +636,7 @@ pub fn select(
..
} if array.is_some() => {
if array_class(cx, *base) != array {
return Err(refuse());
return Err(refuse(AccessCause::HandleUse));
}
let base = operand(cx, *base)?;
let (konst, terms) = super::gep_offset(cx, *src_ty, indices)?;
@@ -652,13 +654,13 @@ pub fn select(
(None, class) if array_class(cx, *v) == class => {
HandleOperand::Value(operand(cx, *v)?)
}
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::HandleUse)),
};
HandleStrategy::Copy { of }
}
InstKind::Select { c, t, f, .. } if result.is_some() || array.is_some() => {
let c = match c {
Value::Const(_) => return Err(refuse()),
Value::Const(_) => return Err(refuse(AccessCause::ConstantCondition)),
c => operand(cx, *c)?,
};
let (t, f) = match (result, array) {
@@ -667,7 +669,7 @@ pub fn select(
(Some(class), _) if identity_sampler(cx, here) => {
let id = |v: Value| match handle_operand(cx, v, class)? {
HandleOperand::Const(NULL_HANDLE) => Ok(HandleOperand::NullId),
HandleOperand::Const(_) => Err(refuse()),
HandleOperand::Const(_) => Err(refuse(AccessCause::ConstantOperand)),
op => Ok(op),
};
(id(*t)?, id(*f)?)
@@ -680,7 +682,7 @@ pub fn select(
HandleOperand::Value(operand(cx, *t)?),
HandleOperand::Value(operand(cx, *f)?),
),
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::HandleUse)),
};
HandleStrategy::Select { c, t, f }
}
@@ -691,10 +693,10 @@ pub fn select(
atomic: None,
..
} if array_class(cx, *ptr).is_some() => {
let class = array_class(cx, *ptr).ok_or_else(refuse)?;
let class = array_class(cx, *ptr).ok_or_else(|| refuse(AccessCause::HandleUse))?;
// A handle, or a handle word's integer.
if result != Some(class) && !is_word(&cx.families.access, here) {
return Err(refuse());
return Err(refuse(AccessCause::HandleUse));
}
HandleStrategy::Load(element(cx, *ptr, inst.ty, class, *align)?)
}
@@ -718,7 +720,7 @@ pub fn select(
Table::Samplers,
m,
)?)),
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::HandleUse)),
}
}
// The `inttoptr` of a handle word is its handle.
@@ -766,7 +768,7 @@ pub fn select(
Some(AddrSpace::Device | AddrSpace::Constant) => {
Unsupported::not_implemented(Feature::ArgumentBufferTextures).into()
}
_ => refuse(),
_ => refuse(AccessCause::HandleUse),
});
}
_ => {
@@ -776,7 +778,7 @@ pub fn select(
touches |= handle_class(cx, v).is_some() || array_class(cx, v).is_some()
});
if touches {
return Err(refuse());
return Err(refuse(AccessCause::HandleUse));
}
return Ok(None);
}
@@ -836,7 +838,7 @@ fn lookup(
_ => {
let (targets, null, in_blob) = super::buffer_roots(cx, ptr, m)?;
if in_blob {
return Err(refuse());
return Err(refuse(AccessCause::ConstantAddress));
}
IdLoad::Static(super::access_with_leaf(
cx, ptr, None, leaf, targets, null, false,
@@ -1135,7 +1137,7 @@ fn target(
) -> Result<HandleTarget, Error> {
if null_constant(cx, v) {
if !lowered_class(class) {
return Err(refuse());
return Err(refuse(AccessCause::HandleClass));
}
return Ok(HandleTarget::Null);
}
@@ -1146,7 +1148,7 @@ fn target(
if matches!(v, Value::Const(_)) {
// A constant that is neither null nor one candidate (a constexpr sampler's
// address takes `One` above).
return Err(refuse());
return Err(refuse(AccessCause::ConstantOperand));
}
let handle = operand(cx, v)?;
let cands: Vec<Candidate> = cands
+4 -4
View File
@@ -33,7 +33,7 @@ use crate::air::ir::{Callee, Inst, InstKind, Value, ValueId};
use crate::budget::Meter;
use crate::device::profile::BufferAccess;
use crate::error::{
Capability, DiagName, Error, Feature, InternalError, InternalKind, Unsupported,
AccessCause, Capability, DiagName, Error, Feature, InternalError, InternalKind, Unsupported,
};
use crate::lower::arith::LoweredConst;
use crate::lower::emit::EmitCx;
@@ -128,7 +128,7 @@ fn constant_bits(cx: &SelectCx<'_>, v: Value) -> Option<u64> {
/// materializes.
fn value(cx: &SelectCx<'_>, v: Value) -> Result<ValueId, Error> {
if matches!(v, Value::Const(_)) && cx.constant(v).is_none() {
return Err(refuse());
return Err(refuse(AccessCause::ConstantOperand));
}
cx.values
.id(v)
@@ -146,7 +146,7 @@ fn address(cx: &mut SelectCx<'_>, v: Value, m: &mut Meter) -> Result<Address, Er
let (targets, _, in_blob) = buffer_roots(cx, v, m)?;
// A pointer into the constant blob has no Metal address.
if in_blob {
return Err(refuse());
return Err(refuse(AccessCause::ConstantAddress));
}
dynamic::plan_static_guest(cx, &targets, Feature::GpuEncodedIndirectCommands)?;
Ok(Address::Static {
@@ -154,7 +154,7 @@ fn address(cx: &mut SelectCx<'_>, v: Value, m: &mut Meter) -> Result<Address, Er
targets,
})
}
_ => Err(refuse()),
_ => Err(refuse(AccessCause::PointerForm)),
}
}
+53 -43
View File
@@ -106,7 +106,7 @@ use crate::air::ir::{
};
use crate::budget::{tree_bytes, Meter, PRIVATE_ARENA_BYTES};
use crate::device::requirements::VkFeature;
use crate::error::{Capability, Error, Feature, Limit, LowerFamily, Unsupported};
use crate::error::{AccessCause, Capability, Error, Feature, Limit, LowerFamily, Unsupported};
use crate::lower::emit::EmitCx;
use crate::lower::select::{Plan, SelectCx};
use crate::memory::alloca::{self, Init, Shape, Step, Strides, TypedPath, TypedTy};
@@ -298,7 +298,7 @@ impl LocalStrategy {
Ok(match self {
// A payload word under the Vulkan model is an atomic, which carries no `Volatile`.
LocalStrategy::Load(a) | LocalStrategy::Store(a) if a.arena == Arena::Payload => {
return Err(refuse())
return Err(refuse(AccessCause::Volatile))
}
LocalStrategy::Load(a) => LocalStrategy::Load(LocalAccess {
volatile: true,
@@ -319,7 +319,7 @@ impl LocalStrategy {
volatile: true,
..a
}),
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::Volatile)),
})
}
@@ -594,7 +594,7 @@ fn use_home(cx: &mut SelectCx<'_>, home: Home, m: &mut Meter) -> Result<(), Erro
}
};
let local = &mut cx.families.access.local;
let at = u32::try_from(local.typed.len()).map_err(|_| refuse());
let at = u32::try_from(local.typed.len()).map_err(|_| refuse(AccessCause::OffsetWidth));
// The object and its position are charged while the plan holds them.
let charged = at.and_then(|at| {
m.grow(&mut local.typed, 1)?;
@@ -629,10 +629,12 @@ fn count_and_init(
let count = u32::try_from(count)
.ok()
.filter(|n| *n > 0)
.ok_or_else(refuse)?;
.ok_or_else(|| refuse(AccessCause::PrivateType))?;
let init = match home {
Home::Constant(i) => {
let c = const_global(cx, i)?.init.ok_or_else(refuse)?;
let c = const_global(cx, i)?
.init
.ok_or_else(|| refuse(AccessCause::GlobalVariable))?;
Some(alloca::init_of(cx.entry, c, tt, m)?)
}
_ => None,
@@ -696,7 +698,7 @@ pub(super) fn use_arena(cx: &mut SelectCx<'_>, arena: Arena) -> Result<(), Error
let fragment = match cx.stage {
Stage::Kernel | Stage::Object | Stage::Mesh => false,
Stage::Fragment => true,
Stage::Vertex => return Err(refuse()),
Stage::Vertex => return Err(refuse(AccessCause::StageMemory)),
};
// A tile function declares no threadgroup variables, as Metal refuses its pipeline
// whatever their size; Metal's compiler refuses a fragment function's.
@@ -713,7 +715,7 @@ pub(super) fn use_arena(cx: &mut SelectCx<'_>, arena: Arena) -> Result<(), Error
if fragment {
// Its arguments are its tile's memory in the pass's buffer, no workgroup array.
if shape.regions.is_empty() {
return Err(refuse());
return Err(refuse(AccessCause::StageMemory));
}
shape.fragment = Some(super::tile_memory::plan(cx));
} else {
@@ -806,14 +808,14 @@ pub(crate) fn choose_words(cx: &mut SelectCx<'_>, tier: crate::device::subgroup:
/// `MeshEXT` entry; Metal's mesh function takes it `const`).
pub(super) fn writable(cx: &SelectCx<'_>, arena: Arena) -> Result<(), Error> {
if arena == Arena::Payload && cx.stage != Stage::Object {
return Err(refuse());
return Err(refuse(AccessCause::ReadOnlyStore));
}
Ok(())
}
/// An arena offset as a `u32`; an offset past 2³² is not representable in the arena's pointer.
fn offset32(off: u64) -> Result<u32, Error> {
u32::try_from(off).map_err(|_| refuse())
u32::try_from(off).map_err(|_| refuse(AccessCause::OffsetWidth))
}
/// The most constant expressions [`addressed_global`] steps through (the constant graph is
@@ -928,7 +930,7 @@ fn threadgroup_constant_refusal(cx: &SelectCx<'_>, c: ConstId) -> Error {
if literal {
Unsupported::not_representable(Feature::DereferenceLoadedPointer).into()
} else {
refuse()
refuse(AccessCause::ConstantOperand)
}
}
@@ -940,7 +942,12 @@ pub(super) fn local_ptr(cx: &SelectCx<'_>, v: Value, home: Home) -> Result<Local
let Value::Const(c) = v else {
return Ok(LocalPtr::Value(operand(cx, v)?));
};
let k = cx.entry.module.consts().get(c).ok_or_else(refuse)?;
let k = cx
.entry
.module
.consts()
.get(c)
.ok_or_else(|| refuse(AccessCause::ConstantOperand))?;
match (&k.value, home) {
(Const::GlobalAddr(g), Home::Constant(i))
if cx
@@ -964,9 +971,9 @@ pub(super) fn local_ptr(cx: &SelectCx<'_>, v: Value, home: Home) -> Result<Local
.memory
.offset(v)
.and_then(OffsetRange::exact)
.ok_or_else(refuse)?;
.ok_or_else(|| refuse(AccessCause::DynamicOffset))?;
Ok(LocalPtr::Offset(offset32(
u64::try_from(displacement).map_err(|_| refuse())?,
u64::try_from(displacement).map_err(|_| refuse(AccessCause::OffsetWidth))?,
)?))
}
(Const::GlobalAddr(g), Home::Shared(i))
@@ -991,9 +998,9 @@ pub(super) fn local_ptr(cx: &SelectCx<'_>, v: Value, home: Home) -> Result<Local
.memory
.offset(v)
.and_then(OffsetRange::exact)
.ok_or_else(refuse)?;
.ok_or_else(|| refuse(AccessCause::DynamicOffset))?;
Ok(LocalPtr::Offset(offset32(
u64::try_from(displacement).map_err(|_| refuse())?,
u64::try_from(displacement).map_err(|_| refuse(AccessCause::OffsetWidth))?,
)?))
}
(Const::GlobalAddr(_) | Const::Expr(_), Home::Arena(Arena::Threadgroup)) => {
@@ -1002,7 +1009,7 @@ pub(super) fn local_ptr(cx: &SelectCx<'_>, v: Value, home: Home) -> Result<Local
.memory
.offset(v)
.and_then(OffsetRange::exact)
.ok_or_else(refuse)?;
.ok_or_else(|| refuse(AccessCause::DynamicOffset))?;
let e = cx
.memory
.tg_arena
@@ -1019,7 +1026,7 @@ pub(super) fn local_ptr(cx: &SelectCx<'_>, v: Value, home: Home) -> Result<Local
{
Ok(LocalPtr::Offset(0))
}
_ => Err(refuse()),
_ => Err(refuse(AccessCause::ConstantOperand)),
}
}
@@ -1045,7 +1052,7 @@ pub fn lowered_pointer(cx: &SelectCx<'_>, v: Value) -> Result<Option<DemoteTy>,
_ => false,
};
if i.constant && !null_only {
return Err(refuse());
return Err(refuse(AccessCause::ConstantOperand));
}
}
Ok(Some(DemoteTy::ArenaOffset))
@@ -1232,7 +1239,7 @@ fn join(a: Sh, b: Sh) -> Result<Sh, Error> {
match (a, b) {
(Sh::Empty, x) | (x, Sh::Empty) => Ok(x),
(x, y) if x == y => Ok(x),
_ => Err(refuse()),
_ => Err(refuse(AccessCause::PointerJoin)),
}
}
@@ -1306,8 +1313,8 @@ fn constant_shape(cx: &SelectCx<'_>, c: ConstId, v: Value) -> Result<Sh, Error>
.offset(v)
.and_then(OffsetRange::exact)
.map(|d| Sh::Is(Shape::Exact(d)))
.ok_or_else(refuse),
_ => Err(refuse()),
.ok_or_else(|| refuse(AccessCause::DynamicOffset)),
_ => Err(refuse(AccessCause::ConstantOperand)),
}
}
@@ -1329,7 +1336,7 @@ fn gep_shape(
None => Strides::one(u64::from(*s)),
Some(acc) => acc.with(u64::from(*s)),
}
.ok_or_else(refuse)?,
.ok_or_else(|| refuse(AccessCause::PointerShape))?,
);
}
Ok(match (base, added) {
@@ -1343,7 +1350,9 @@ fn gep_shape(
base: base.saturating_add(k),
strides: match more {
None => strides,
Some(more) => strides.union(more).ok_or_else(refuse)?,
Some(more) => strides
.union(more)
.ok_or_else(|| refuse(AccessCause::PointerShape))?,
},
}),
})
@@ -1370,14 +1379,14 @@ fn shape_of(cx: &mut SelectCx<'_>, v: Value, m: &mut Meter) -> Result<Sh, Error>
Some(r) => {
// Reading it again would open `height` more definitions on its deepest path.
if open.len().saturating_add(r.height) > SHAPE_WALK {
return Err(refuse());
return Err(refuse(AccessCause::PointerShape));
}
Some(*r)
}
None => {
// A pointer cycle is not implemented: its shape needs a fixpoint.
if open.iter().any(|o| o.at == i) || open.len() >= SHAPE_WALK {
return Err(refuse());
return Err(refuse(AccessCause::PointerShape));
}
let inst = body
.insts
@@ -1393,7 +1402,7 @@ fn shape_of(cx: &mut SelectCx<'_>, v: Value, m: &mut Meter) -> Result<Sh, Error>
| InstKind::Freeze(_)
| InstKind::Select { .. }
| InstKind::Phi { .. } => {}
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::PointerSource)),
}
open.push(Open {
at: i,
@@ -1405,7 +1414,7 @@ fn shape_of(cx: &mut SelectCx<'_>, v: Value, m: &mut Meter) -> Result<Sh, Error>
None
}
},
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::PointerSource)),
};
// Give the read shape to the definition that asked for it, and finish each definition
// whose operands are all read, until one has an operand left to read.
@@ -1549,13 +1558,13 @@ fn typed_access(
)
);
if !leaf {
return Err(refuse());
return Err(refuse(AccessCause::AccessType));
}
let held = crate::lower::arith::lowered_type(cx.entry, cx.profile, ty)?;
let (obj, count) = object(cx, home)?;
let shape = match shape_of(cx, ptr, m)? {
Sh::Is(s) => s,
Sh::Empty => return Err(refuse()),
Sh::Empty => return Err(refuse(AccessCause::PointerSource)),
};
// An access of a held matrix's elements 0 and 1, or of one of them, is the fragment's, or one
// lane of it: its held form must be the fragment's, or the lane's.
@@ -1576,13 +1585,13 @@ fn typed_access(
_ => false,
};
if !fits {
return Err(refuse());
return Err(refuse(AccessCause::AccessType));
}
(path, None, Some(part))
}
None => {
let path = alloca::path(cx.entry, &cx.memory.layouts, obj, count, shape, ty)
.ok_or_else(refuse)?;
.ok_or_else(|| refuse(AccessCause::AccessType))?;
// A typed object holds a simdgroup matrix only as its fragment, which is accessed
// whole or by its held elements: the memory plan typed no object whose matrices
// hold more (`memory::fragment`).
@@ -1664,7 +1673,8 @@ pub fn intrinsic_store(
ty,
m,
)?)),
Some(Home::Constant(_) | Home::Shared(_)) | None => Err(refuse()),
Some(Home::Constant(_)) => Err(refuse(AccessCause::ReadOnlyStore)),
Some(Home::Shared(_)) | None => Err(refuse(AccessCause::IntrinsicStore)),
}
}
@@ -1694,7 +1704,7 @@ pub fn select(
if home_of(cx, v) == Some(home) {
Ok(())
} else {
Err(refuse())
Err(refuse(AccessCause::PointerJoin))
}
};
Ok(Some(match &inst.kind {
@@ -1766,7 +1776,7 @@ pub fn select(
same(cx, *f, home)?;
use_home(cx, home, m)?;
let c = match c {
Value::Const(_) => return Err(refuse()),
Value::Const(_) => return Err(refuse(AccessCause::ConstantCondition)),
c => operand(cx, *c)?,
};
LocalStrategy::Select {
@@ -1811,14 +1821,14 @@ pub fn select(
.value_ty(*val)
.ok_or_else(|| cx.invariant("a stored value without a type"))?;
if is_ptr_ty(cx, ty) {
return Err(refuse());
return Err(refuse(AccessCause::PointerStore));
}
match home {
Home::Arena(arena) => {
LocalStrategy::Store(access(cx, arena, *ptr, Some(*val), ty, *align)?)
}
// A constant global in `Private` form is never written.
Home::Constant(_) => return Err(refuse()),
Home::Constant(_) => return Err(refuse(AccessCause::ReadOnlyStore)),
Home::Alloca(_) | Home::Shared(_) => LocalStrategy::TypedStore(typed_access(
cx,
home,
@@ -1862,10 +1872,10 @@ fn compare(
let (ptr, against_null) = match (null(cx, a), null(cx, b)) {
(false, true) => (a, Some(pred)),
(true, false) => (b, Some(swapped(pred))),
(true, true) => return Err(refuse()),
(true, true) => return Err(refuse(AccessCause::PointerCompare)),
(false, false) => (a, None),
};
let home = home_of(cx, ptr).ok_or_else(refuse)?;
let home = home_of(cx, ptr).ok_or_else(|| refuse(AccessCause::PointerCompare))?;
// In an arena that keeps its first word for null, a pointer that may be null is null at
// offset 0, below every object's address, as Metal's null is below every object's: its
// offset compares as its address does.
@@ -1879,7 +1889,7 @@ fn compare(
};
let Some(against_null) = against_null else {
if home_of(cx, b) != Some(home) || nullable(cx, a) || nullable(cx, b) {
return Err(refuse());
return Err(refuse(AccessCause::PointerCompare));
}
use_home(cx, home, m)?;
return Ok(Some(LocalStrategy::Compare {
@@ -1890,7 +1900,7 @@ fn compare(
}));
};
if nullable(cx, ptr) {
return Err(refuse());
return Err(refuse(AccessCause::PointerCompare));
}
let may_be_null = cx
.memory
@@ -1902,7 +1912,7 @@ fn compare(
against_null,
IntPredicate::Sgt | IntPredicate::Sge | IntPredicate::Slt | IntPredicate::Sle
) {
return Err(refuse());
return Err(refuse(AccessCause::PointerCompare));
}
use_home(cx, home, m)?;
return Ok(Some(LocalStrategy::Compare {
@@ -1917,7 +1927,7 @@ fn compare(
IntPredicate::Eq | IntPredicate::Ult | IntPredicate::Ule => false,
IntPredicate::Ne | IntPredicate::Ugt | IntPredicate::Uge => true,
IntPredicate::Sgt | IntPredicate::Sge | IntPredicate::Slt | IntPredicate::Sle => {
return Err(refuse())
return Err(refuse(AccessCause::PointerCompare))
}
};
Ok(Some(LocalStrategy::NullCompare { home, result }))
+26 -21
View File
@@ -121,7 +121,7 @@ use crate::budget::Meter;
use crate::device::profile::{BufferAccess, Limits};
use crate::device::requirements::VkLimit;
use crate::device::DeviceProfile;
use crate::error::{Capability, Error, Feature, LowerFamily, Unsupported};
use crate::error::{AccessCause, Capability, Error, Feature, LowerFamily, Unsupported};
use crate::lower::emit::EmitCx;
use crate::lower::select::{DescriptorCounts, FamilyPlans, Plan, SelectCx, SlotChoice};
use crate::lower::strategy::FamilyStrategy;
@@ -558,8 +558,9 @@ pub(crate) fn not_lowered(family: LowerFamily) -> Error {
Unsupported::not_implemented(Feature::Lowering(family)).into()
}
fn refuse() -> Error {
not_lowered(LowerFamily::Access)
/// The access family's refusal of the structure `cause` names.
fn refuse(cause: AccessCause) -> Error {
Unsupported::access(cause).into()
}
/// The candidate slots and null-ness of static-root buffer pointer `v`, or the refusal of any
@@ -567,7 +568,7 @@ fn refuse() -> Error {
fn static_roots(cx: &SelectCx<'_>, v: Value, m: &mut Meter) -> Result<(Vec<Target>, bool), Error> {
let s = statics(cx, v)?;
if s.in_blob {
return Err(refuse());
return Err(refuse(AccessCause::ConstantAddress));
}
Ok((held(s, m)?, s.null))
}
@@ -590,7 +591,7 @@ fn buffer_roots(
/// held, reads them here at no cost per root.
fn statics<'c>(cx: &'c SelectCx<'_>, v: Value) -> Result<&'c root_sets::Statics, Error> {
let Some(Repr::BufPtr { roots, wide: false }) = cx.memory.repr(v) else {
return Err(refuse());
return Err(refuse(AccessCause::PointerForm));
};
let set = cx
.root_sets
@@ -928,7 +929,7 @@ pub fn select_param(cx: &mut SelectCx<'_>, b: &ParamBinding) -> Result<(), Error
return Ok(());
}
match statics(cx, Value::Arg(crate::air::ir::ArgIdx::new(b.param)))? {
s if s.in_blob => Err(refuse()),
s if s.in_blob => Err(refuse(AccessCause::ConstantAddress)),
_ => Ok(()),
}
}
@@ -938,7 +939,7 @@ pub fn select_param(cx: &mut SelectCx<'_>, b: &ParamBinding) -> Result<(), Error
// The imageblock's value (a struct holding its opaque base) has no lowered form: a kernel
// reaches the imageblock only through its intrinsics.
ParamRole::Imageblock(_) => Err(Unsupported::not_implemented(Feature::Imageblocks).into()),
_ => Err(refuse()),
_ => Err(refuse(AccessCause::Parameter)),
}
}
@@ -1731,7 +1732,7 @@ fn psb_lowering(window: Window) -> Result<SlotLowering, Error> {
match window {
Window::Whole => Ok(SlotLowering::Psb { start: 0 }),
Window::Bounded { start, len } if len <= 1u64 << 32 => Ok(SlotLowering::Psb { start }),
Window::Bounded { .. } => Err(refuse()),
Window::Bounded { .. } => Err(refuse(AccessCause::OffsetWidth)),
}
}
@@ -1876,7 +1877,7 @@ fn const_index(cx: &SelectCx<'_>, v: Value) -> Option<i64> {
/// `pointer::null_operand`); any other constant is refused.
fn operand(cx: &SelectCx<'_>, v: Value) -> Result<ValueId, Error> {
if matches!(v, Value::Const(_)) && !pointer::null_constant(cx, v) {
return Err(refuse());
return Err(refuse(AccessCause::ConstantOperand));
}
cx.values
.id(v)
@@ -1893,7 +1894,7 @@ fn index_form(cx: &SelectCx<'_>, v: Value) -> Result<IndexForm, Error> {
Type::Int(bits @ 2..=31) => IndexForm::Narrow { bits: *bits },
Type::Int(32) => IndexForm::Word,
Type::Int(33..=64) => IndexForm::Wide,
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::IndexType)),
})
}
@@ -1989,14 +1990,18 @@ fn gep_offset_indexed(
} else {
match types.get(cur) {
Some(Type::Struct { fields, .. }) => {
let k = const_index(cx, i).ok_or_else(refuse)?;
let k = usize::try_from(k).map_err(|_| refuse())?;
let k = const_index(cx, i)
.ok_or_else(|| refuse(AccessCause::AddressComputation))?;
let k =
usize::try_from(k).map_err(|_| refuse(AccessCause::AddressComputation))?;
let off = layouts
.field_offsets(cur)
.and_then(|o| o.get(k).copied())
.ok_or_else(refuse)?;
.ok_or_else(|| refuse(AccessCause::AddressComputation))?;
konst = konst.wrapping_add(off);
cur = *fields.get(k).ok_or_else(refuse)?;
cur = *fields
.get(k)
.ok_or_else(|| refuse(AccessCause::AddressComputation))?;
continue;
}
Some(Type::Array { elem, len }) => {
@@ -2010,7 +2015,7 @@ fn gep_offset_indexed(
_ => (None, Indexed::Vector),
}
};
let scale = scale.ok_or_else(refuse)?;
let scale = scale.ok_or_else(|| refuse(AccessCause::AddressComputation))?;
match const_index(cx, i) {
Some(k) => konst = konst.wrapping_add((k as u64).wrapping_mul(scale)),
None if scale == 0 => {}
@@ -2061,7 +2066,7 @@ fn blob_roots(
) -> Result<(Vec<Target>, bool, bool), Error> {
let (targets, null, in_blob) = buffer_roots(cx, ptr, m)?;
if in_blob && write {
return Err(refuse());
return Err(refuse(AccessCause::ReadOnlyStore));
}
if in_blob {
blob::use_blob(cx)?;
@@ -2220,7 +2225,7 @@ fn select_coherent(
}
};
if !matches!(c.space, AddrSpace::Device | AddrSpace::Constant) {
return Err(refuse());
return Err(refuse(AccessCause::CoherentMemory));
}
// The intrinsic states no alignment: the value's natural (ABI) one.
let align = cx
@@ -2333,7 +2338,7 @@ pub fn select(
.value_ty(*val)
.ok_or_else(|| cx.invariant("a stored value without a type"))?;
if is_ptr_ty(cx, ty) {
return Err(refuse());
return Err(refuse(AccessCause::PointerStore));
}
Ok(AccessStrategy::Store(select_access(
cx,
@@ -2370,12 +2375,12 @@ pub fn select(
let t = select_side(cx, *t)?;
let f = select_side(cx, *f)?;
let c = match c {
Value::Const(_) => return Err(refuse()),
Value::Const(_) => return Err(refuse(AccessCause::ConstantCondition)),
c => operand(cx, *c)?,
};
Ok(AccessStrategy::Pointer(PtrOp::Select { c, t, f }))
}
_ => Err(refuse()),
_ => Err(refuse(AccessCause::Operation)),
}
}
@@ -2471,6 +2476,6 @@ fn volatile_form(s: AccessStrategy) -> Result<AccessStrategy, Error> {
AccessStrategy::Handle(handle::HandleStrategy::SamplerLookup(a)) => AccessStrategy::Handle(
handle::HandleStrategy::SamplerLookup(Box::new(a.volatile())),
),
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::Volatile)),
})
}
+2 -2
View File
@@ -16,7 +16,7 @@ use std::collections::BTreeMap;
use crate::air::ir::{InstId, InstKind, Type, Value};
use crate::budget::{tree_bytes, Meter};
use crate::error::Error;
use crate::error::{AccessCause, Error};
use crate::lower::select::SelectCx;
use super::{blob, dynamic, pointer};
@@ -150,7 +150,7 @@ pub(super) fn incoming<'c>(cx: &'c SelectCx<'_>, v: Value) -> Result<Option<&'c
pub(super) fn fat_refusal(cx: &SelectCx<'_>, i: &Incoming) -> Option<Error> {
match i.fat {
Fat::Plain => None,
Fat::Refused => Some(super::refuse()),
Fat::Refused => Some(super::refuse(AccessCause::PointerJoin)),
// `blob::is_blob`'s error for a set selection did not read.
Fat::Unread => Some(cx.invariant("a buffer pointer's root set was not read")),
}
@@ -61,7 +61,7 @@ use crate::air::ir::{
};
use crate::budget::Meter;
use crate::device::profile::BufferAccess;
use crate::error::{Error, Feature, Unsupported};
use crate::error::{AccessCause, Error, Feature, Unsupported};
use crate::lower::arith::wide::{self, Pair};
use crate::lower::arith::{Form, Held};
use crate::lower::emit::{EmitCx, SlotMemo};
@@ -175,7 +175,7 @@ impl PointerValue {
value,
words,
}),
_ => Err(refuse()),
_ => Err(refuse(AccessCause::Volatile)),
}
}
@@ -315,7 +315,7 @@ fn kind(cx: &SelectCx<'_>, v: Value) -> Result<Kind, Error> {
},
_ => match local::home_of(cx, v) {
Some(Home::Constant(k)) => Ok(Kind::Constant(k)),
_ => Err(refuse()),
_ => Err(refuse(AccessCause::PointerForm)),
},
}
}
@@ -347,7 +347,7 @@ fn address(cx: &mut SelectCx<'_>, v: Value, k: &Kind, m: &mut Meter) -> Result<A
let (targets, null, in_blob) = buffer_roots(cx, v, m)?;
// The blob has no Metal address the function can read.
if in_blob {
return Err(refuse());
return Err(refuse(AccessCause::ConstantAddress));
}
let mut out = Vec::with_capacity(targets.len());
for t in &targets {
@@ -368,7 +368,7 @@ fn address(cx: &mut SelectCx<'_>, v: Value, k: &Kind, m: &mut Meter) -> Result<A
start: range_start(cx, v),
}))
}
Kind::Blob | Kind::Constant(_) => Err(refuse()),
Kind::Blob | Kind::Constant(_) => Err(refuse(AccessCause::ConstantAddress)),
}
}
@@ -433,7 +433,7 @@ fn compare(
words,
}
}
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::PointerCompare)),
}))
}
@@ -457,7 +457,7 @@ fn static_escape(cx: &SelectCx<'_>, v: Value) -> Result<Option<Kind>, Error> {
/// without `shaderInt64`).
fn address_leaf(cx: &SelectCx<'_>, ty: TypeId, align: Option<Align>) -> Result<Leaf, Error> {
if cx.memory.layouts.store_size(ty) != Some(8) {
return Err(refuse());
return Err(refuse(AccessCause::PointerSize));
}
let held = if cx.profile.fields().leaf.int64 {
Held::Int {
@@ -498,7 +498,7 @@ fn store_pointer(
Some(Repr::BufPtr { wide: false, .. }) => {
let (targets, null, in_blob) = buffer_roots(cx, ptr, m)?;
if in_blob {
return Err(refuse());
return Err(refuse(AccessCause::ConstantAddress));
}
Source::Static(super::access_with_leaf(
cx, ptr, None, leaf, targets, null, false,
@@ -542,7 +542,7 @@ pub fn select(
};
let bits = match cx.entry.module.types().get(inst.ty) {
Some(Type::Int(b @ 1..=64)) => *b,
_ => return Err(refuse()),
_ => return Err(refuse(AccessCause::PointerInteger)),
};
let words = !cx.profile.fields().leaf.int64;
Ok(Some(PointerValue::ToInt {
@@ -22,7 +22,7 @@ use std::collections::BTreeMap;
use crate::air::ir::Value;
use crate::air::Entry;
use crate::budget::{tree_bytes, Meter};
use crate::error::Error;
use crate::error::{AccessCause, Error};
use crate::lower::select::SelectCx;
use crate::memory::handles::{self, DomainKind};
use crate::memory::plan::MemoryPlan;
@@ -114,7 +114,7 @@ impl StaticRefusal {
/// The error a selection that needs the set's candidates returns.
pub(super) fn error(self, cx: &SelectCx<'_>) -> Error {
match self {
StaticRefusal::NotLowered => refuse(),
StaticRefusal::NotLowered => refuse(AccessCause::PointerForm),
StaticRefusal::MissingSlot => cx.invariant("a buffer root names a missing slot"),
StaticRefusal::PrimitiveData => crate::lower::raytracing::primitive_data_read(),
}
+32 -21
View File
@@ -50,15 +50,16 @@ use crate::air::ir::{Const, ConstId as AirConstId, Type, TypeId as AirTypeId, Ty
use crate::air::Entry;
use crate::budget::{tree_bytes, Meter};
use crate::device::DeviceProfile;
use crate::error::{Error, Feature, LowerFamily, Unsupported};
use crate::error::{AccessCause, Error, Unsupported};
use crate::lower::arith::{self, LoweredConst};
use crate::spirv::builder::ModuleBuilder;
use crate::spirv::error::{BResult, BuildError, Dangling};
use crate::spirv::ids::{ConstId, DemoteTy, ScalarTy, TypeId};
use crate::spirv::ir::{ConstBits, Constant, Type as SType};
fn not_lowered() -> Error {
Unsupported::not_implemented(Feature::Lowering(LowerFamily::Access)).into()
/// The access family's refusal of the structure `cause` names.
fn not_lowered(cause: AccessCause) -> Error {
Unsupported::access(cause).into()
}
/// The deepest type nesting a typed object may have.
@@ -285,23 +286,23 @@ impl Shaper<'_> {
) -> Result<Result<Built, Error>, Error> {
m.tick(1)?;
if depth > MAX_DEPTH {
return Ok(Err(not_lowered()));
return Ok(Err(not_lowered(AccessCause::PrivateType)));
}
if let Some(b) = self.built.get(&ty) {
// Its deepest member is `height - 1` types below it.
return Ok(if depth + (b.height - 1) > MAX_DEPTH {
Err(not_lowered())
Err(not_lowered(AccessCause::PrivateType))
} else {
Ok(*b)
});
}
let Some(t) = self.e.module.types().get(ty) else {
return Ok(Err(not_lowered()));
return Ok(Err(not_lowered(AccessCause::PrivateType)));
};
let (node, height, size) = match t {
Type::Array { elem, len } => {
let Some(len) = u32::try_from(*len).ok().filter(|n| *n > 0) else {
return Ok(Err(not_lowered()));
return Ok(Err(not_lowered(AccessCause::PrivateType)));
};
let elem = match self.at(*elem, depth + 1, m)? {
Ok(b) => b,
@@ -349,16 +350,16 @@ impl Shaper<'_> {
Ok(d) if self.fragments && fragment::is_matrix(self.e.module.types(), ty) => {
match fragment::fragment_form(&d) {
Some(f) => (TypedNode::Fragment(f), 1, 1),
None => return Ok(Err(not_lowered())),
None => return Ok(Err(not_lowered(AccessCause::PrivateType))),
}
}
Ok(_) => return Ok(Err(not_lowered())),
Ok(_) => return Ok(Err(not_lowered(AccessCause::PrivateType))),
Err(refusal) => return Ok(Err(refusal)),
},
_ => return Ok(Err(not_lowered())),
_ => return Ok(Err(not_lowered(AccessCause::PrivateType))),
};
let Ok(index) = u32::try_from(self.nodes.len()) else {
return Ok(Err(not_lowered()));
return Ok(Err(not_lowered(AccessCause::OffsetWidth)));
};
let before = m.ledger();
m.grow(&mut self.nodes, 1)?;
@@ -475,7 +476,9 @@ struct InitReader<'a> {
/// one work unit. The parts stay on the ledger while the plan holds them; the record of read parts
/// is released on return, and everything on a refusal.
pub fn init_of(e: &Entry, c: AirConstId, t: &TypedTy, m: &mut Meter) -> Result<Init, Error> {
let root = t.root().ok_or_else(not_lowered)?;
let root = t
.root()
.ok_or_else(|| not_lowered(AccessCause::PrivateType))?;
let mut r = InitReader {
e,
t,
@@ -502,11 +505,18 @@ impl InitReader<'_> {
return Ok(i);
}
let (e, t) = (self.e, self.t);
let k = e.module.consts().get(c).ok_or_else(not_lowered)?;
let shape = t.nodes.get(node as usize).ok_or_else(not_lowered)?;
let k = e
.module
.consts()
.get(c)
.ok_or_else(|| not_lowered(AccessCause::Initializer))?;
let shape = t
.nodes
.get(node as usize)
.ok_or_else(|| not_lowered(AccessCause::Initializer))?;
let part = match (&k.value, shape) {
// Only an alloca holds fragments, and an alloca has no initializer.
(_, TypedNode::Fragment(_)) => return Err(not_lowered()),
(_, TypedNode::Fragment(_)) => return Err(not_lowered(AccessCause::Initializer)),
(Const::Null | Const::Undef | Const::Poison, _) => InitNode::Zero,
(_, TypedNode::Leaf(d)) => {
// A vector's lanes are held while the part lives, charged before they are built.
@@ -523,24 +533,25 @@ impl InitReader<'_> {
Some(l @ (LoweredConst::Scalar { .. } | LoweredConst::Vector { .. })) => {
InitNode::Leaf(l)
}
_ => return Err(not_lowered()),
_ => return Err(not_lowered(AccessCause::Initializer)),
}
}
(Const::Aggregate(elems), TypedNode::Array { elem, len }) => {
if elems.len() != *len as usize {
return Err(not_lowered());
return Err(not_lowered(AccessCause::Initializer));
}
InitNode::Parts(self.parts(elems, |_| Some(*elem), m)?)
}
(Const::Aggregate(elems), TypedNode::Struct(members)) => {
if elems.len() != members.len() {
return Err(not_lowered());
return Err(not_lowered(AccessCause::Initializer));
}
InitNode::Parts(self.parts(elems, |i| members.get(i).copied(), m)?)
}
_ => return Err(not_lowered()),
_ => return Err(not_lowered(AccessCause::Initializer)),
};
let index = u32::try_from(self.nodes.len()).map_err(|_| not_lowered())?;
let index =
u32::try_from(self.nodes.len()).map_err(|_| not_lowered(AccessCause::OffsetWidth))?;
let before = m.ledger();
m.grow(&mut self.nodes, 1)?;
let grown = usize::try_from(m.ledger().saturating_sub(before)).unwrap_or(usize::MAX);
@@ -563,7 +574,7 @@ impl InitReader<'_> {
self.bytes = self.bytes.saturating_add(held);
let mut parts = Vec::with_capacity(elems.len());
for (i, x) in elems.iter().enumerate() {
let node = member(i).ok_or_else(not_lowered)?;
let node = member(i).ok_or_else(|| not_lowered(AccessCause::Initializer))?;
parts.push(self.at(*x, node, m)?);
}
Ok(parts.into_boxed_slice())
+5 -3
View File
@@ -76,7 +76,9 @@ use std::collections::{BTreeMap, BTreeSet};
use crate::air::abi::{AbiHandle, AbiInt, Access as AbiAccess, ParamBinding, ParamRole};
use crate::air::ir::{AddrSpace, Body, GlobalId, InstId, InstKind, Type, Value};
use crate::air::Entry;
use crate::error::{Error, Feature, InternalError, InternalKind, LowerFamily, Unsupported};
use crate::error::{
AccessCause, Error, Feature, InternalError, InternalKind, LowerFamily, Unsupported,
};
use crate::memory::leaf::k32;
use crate::memory::views::{self, View};
use crate::pipeline::sym::ImageAccess;
@@ -237,7 +239,7 @@ pub fn candidates(
return r;
}
let Some(Repr::Handle { class: c, cands }) = mp.repr(v) else {
return Err(not_implemented(Feature::Lowering(LowerFamily::Access)));
return Err(Unsupported::access(AccessCause::PointerForm).into());
};
if c != class {
return Err(not_implemented(Feature::HandleAsPointer));
@@ -677,7 +679,7 @@ fn loaded_member(
_ => None,
});
if !matches!(space, Some(AddrSpace::Device | AddrSpace::Constant)) {
return Err(not_implemented(Feature::Lowering(LowerFamily::Access)));
return Err(Unsupported::access(AccessCause::HandleUse).into());
}
let at = located(e, mp, body, ptr, align, 0)?;
Ok(LoadedMember {
+13 -10
View File
@@ -122,7 +122,7 @@
use crate::air::ir::{Type, TypeId as AirTypeId, TypeLayouts};
use crate::air::Entry;
use crate::device::DeviceProfile;
use crate::error::{Error, Feature, LowerFamily, Unsupported};
use crate::error::{AccessCause, Error, Unsupported};
use crate::lower::arith::legal::{self, wide_form_on};
use crate::lower::arith::narrow;
use crate::lower::arith::ops;
@@ -221,8 +221,9 @@ impl WordOps {
}
}
fn not_lowered() -> Error {
Unsupported::not_implemented(Feature::Lowering(LowerFamily::Access)).into()
/// The access family's refusal of the structure `cause` names.
fn not_lowered(cause: AccessCause) -> Error {
Unsupported::access(cause).into()
}
/// How a leaf is composed from words.
@@ -346,22 +347,24 @@ pub fn leaf_of(
lanes: u8::try_from(lanes)
.ok()
.filter(|l| *l > 4)
.ok_or_else(not_lowered)?,
.ok_or_else(|| not_lowered(AccessCause::AccessType))?,
},
None => wide_form_on(e, p, ty)?,
};
let bytes = layouts.store_size(ty).ok_or_else(not_lowered)?;
let bytes = u32::try_from(bytes).map_err(|_| not_lowered())?;
let bytes = layouts
.store_size(ty)
.ok_or_else(|| not_lowered(AccessCause::AccessType))?;
let bytes = u32::try_from(bytes).map_err(|_| not_lowered(AccessCause::AccessType))?;
if form.lanes > 1 {
let lane_bits = match form.held {
Held::Int { bits, .. } | Held::Wide { bits } => bits,
Held::Float(f) => f.bits(),
Held::Bool => return Err(not_lowered()),
Held::Bool => return Err(not_lowered(AccessCause::AccessType)),
};
if !matches!(lane_bits, 8 | 16 | 32 | 64)
|| u32::from(lane_bits / 8) * u32::from(form.lanes) != bytes
{
return Err(not_lowered());
return Err(not_lowered(AccessCause::AccessType));
}
} else {
let bits = form.bits();
@@ -369,7 +372,7 @@ pub fn leaf_of(
|| bytes > 8
|| (form.held != Held::Bool && u32::from(bits).div_ceil(8) != bytes)
{
return Err(not_lowered());
return Err(not_lowered(AccessCause::AccessType));
}
}
// Refuse a non-scalar AIR type that `form_on` accepted (it only accepts scalars and vectors).
@@ -384,7 +387,7 @@ pub fn leaf_of(
| Type::Vector { .. }
)
) {
return Err(not_lowered());
return Err(not_lowered(AccessCause::AccessType));
}
let path = if bytes == 16 && align >= 16 && proven >= 16 {
Path::Vec4
+76 -37
View File
@@ -62,7 +62,7 @@ use crate::air::Entry;
use crate::budget::{tree_bytes, vec_bytes, Meter};
use crate::device::profile::{BufferAccess, PointerDomain};
use crate::device::DeviceProfile;
use crate::error::{Error, Feature, InternalError, InternalKind, Limit, LowerFamily, Unsupported};
use crate::error::{AccessCause, Error, Feature, InternalError, InternalKind, Limit, Unsupported};
use crate::pipeline::interface::{AccessSet, Window};
use crate::pipeline::sym::{SlotClass, SlotRef};
@@ -579,8 +579,9 @@ fn invariant(detail: &str) -> Error {
Error::Internal(InternalError::new(InternalKind::Invariant, detail))
}
fn not_lowered() -> Error {
Unsupported::not_implemented(Feature::Lowering(LowerFamily::Access)).into()
/// The access family's refusal of the structure `cause` names.
fn not_lowered(cause: AccessCause) -> Error {
Unsupported::access(cause).into()
}
fn too_large() -> Error {
@@ -877,7 +878,7 @@ impl Planner<'_> {
} else {
self.layouts.alloc_size(a.ty)
};
let size = size.ok_or_else(not_lowered)?;
let size = size.ok_or_else(|| not_lowered(AccessCause::PrivateType))?;
bytes = bytes.saturating_add(size.saturating_mul(a.count));
}
let private = |c: &&ConstGlobalPlan| c.form == ConstGlobalForm::Private;
@@ -891,7 +892,7 @@ impl Planner<'_> {
let size = self
.layouts
.alloc_size(global.value_ty)
.ok_or_else(not_lowered)?;
.ok_or_else(|| not_lowered(AccessCause::GlobalVariable))?;
bytes = bytes.saturating_add(size);
}
// A blob offset only the run knows: an index, or a pointer that merges with another
@@ -1017,7 +1018,7 @@ impl Planner<'_> {
let (AbiInt::Const(first), AbiInt::Const(_)) =
(arg.location.index, arg.location.count)
else {
return Err(not_lowered());
return Err(not_lowered(AccessCause::UnfixedLocation));
};
let range = Root::BufferElement {
param: b.param,
@@ -1033,7 +1034,9 @@ impl Planner<'_> {
if !eu.referenced {
continue;
}
let index = first.checked_add(element).ok_or_else(not_lowered)?;
let index = first
.checked_add(element)
.ok_or_else(|| not_lowered(AccessCause::OffsetWidth))?;
grow(&mut slots, 1, m)?;
slots.push(SlotPlan {
slot: slot(index),
@@ -1057,10 +1060,14 @@ impl Planner<'_> {
}
continue;
}
let (AbiInt::Const(index), AbiInt::Const(1)) = (arg.location.index, arg.location.count)
let (AbiInt::Const(index), AbiInt::Const(count)) =
(arg.location.index, arg.location.count)
else {
return Err(not_lowered());
return Err(not_lowered(AccessCause::UnfixedLocation));
};
if count != 1 {
return Err(not_lowered(AccessCause::BufferArray));
}
grow(&mut slots, 1, m)?;
slots.push(SlotPlan {
slot: slot(index),
@@ -1098,7 +1105,7 @@ impl Planner<'_> {
if self.prov.abi.buffer_table(b.param).is_some()
&& (u.escapes || u.merged || u.cross_compare)
{
return Err(not_lowered());
return Err(not_lowered(AccessCause::ArgumentTable));
}
if let ParamRole::Threadgroup(arg) = &b.role {
let space = self
@@ -1111,7 +1118,7 @@ impl Planner<'_> {
})
.and_then(|&t| self.e.module.types().ptr_space(t));
if space == Some(AddrSpace::Thread) || arg.location.count != AbiInt::Const(1) {
return Err(not_lowered());
return Err(not_lowered(AccessCause::ArgumentTable));
}
}
}
@@ -1190,10 +1197,10 @@ impl Planner<'_> {
AddrSpace::Constant if self.is_static_sampler(g) => continue,
AddrSpace::Constant => {}
// No corpus row has device or thread-space globals; memory has no model.
_ => return Err(not_lowered()),
_ => return Err(not_lowered(AccessCause::GlobalVariable)),
}
let Some(init) = global.init else {
return Err(not_lowered());
return Err(not_lowered(AccessCause::GlobalVariable));
};
// A pointer stored into a pointer cell is read back without its definitions,
// which the typed form's access chains are read from.
@@ -1208,14 +1215,19 @@ impl Planner<'_> {
let size = self
.layouts
.alloc_size(global.value_ty)
.ok_or_else(not_lowered)?;
let offset = round_up(*len as u64, align).ok_or_else(not_lowered)?;
let end = offset.checked_add(size).ok_or_else(not_lowered)?;
let end = usize::try_from(end).map_err(|_| not_lowered())?;
.ok_or_else(|| not_lowered(AccessCause::GlobalVariable))?;
let offset = round_up(*len as u64, align)
.ok_or_else(|| not_lowered(AccessCause::OffsetWidth))?;
let end = offset
.checked_add(size)
.ok_or_else(|| not_lowered(AccessCause::OffsetWidth))?;
let end = usize::try_from(end)
.map_err(|_| not_lowered(AccessCause::OffsetWidth))?;
// The initializer's refusals; its bytes and its writing's work are charged
// once every initializer is checked.
let nodes = self.blob_nodes(init, global.value_ty, m)?;
let at = usize::try_from(offset).map_err(|_| not_lowered())?;
let at = usize::try_from(offset)
.map_err(|_| not_lowered(AccessCause::OffsetWidth))?;
grow(placed, 1, m)?;
placed.push((init, global.value_ty, at));
provenance::push_working(&mut costs, (end, nodes), &mut working, m)?;
@@ -1244,7 +1256,10 @@ impl Planner<'_> {
.module
.global(g)
.ok_or_else(|| invariant("a global out of range"))?;
let abi = self.layouts.abi_align(ty).ok_or_else(not_lowered)?;
let abi = self
.layouts
.abi_align(ty)
.ok_or_else(|| not_lowered(AccessCause::Initializer))?;
Ok(global.align.map_or(abi, |a| a.bytes().max(abi)))
}
@@ -1285,8 +1300,12 @@ impl Planner<'_> {
let parts: Box<[(ConstId, TypeId)]> = match &k.value {
Const::Null | Const::Undef | Const::Poison => Box::new([]),
Const::Int(_) | Const::Float(_) => {
let n = self.layouts.store_size(ty).ok_or_else(not_lowered)?;
usize::try_from(n).map_err(|_| not_lowered())?;
let n = self
.layouts
.store_size(ty)
.ok_or_else(|| not_lowered(AccessCause::Initializer))?;
usize::try_from(n)
.map_err(|_| not_lowered(AccessCause::OffsetWidth))?;
Box::new([])
}
Const::Aggregate(elems) => {
@@ -1346,33 +1365,45 @@ impl Planner<'_> {
let types = self.e.module.types();
let (at, count) = match types.get(ty) {
Some(Type::Struct { fields, .. }) => {
let offs = self.layouts.field_offsets(ty).ok_or_else(not_lowered)?;
let offs = self
.layouts
.field_offsets(ty)
.ok_or_else(|| not_lowered(AccessCause::Initializer))?;
(PartsAt::Fields(fields, offs), fields.len().min(offs.len()))
}
Some(Type::Array { elem, len }) => {
let stride = self.layouts.alloc_size(*elem).ok_or_else(not_lowered)?;
let stride = self
.layouts
.alloc_size(*elem)
.ok_or_else(|| not_lowered(AccessCause::Initializer))?;
let count = usize::try_from(*len).unwrap_or(usize::MAX);
(PartsAt::Strided(*elem, stride), count)
}
Some(Type::Vector { elem, len }) => {
let lane = self.layouts.store_size(*elem).ok_or_else(not_lowered)?;
let lane = self
.layouts
.store_size(*elem)
.ok_or_else(|| not_lowered(AccessCause::Initializer))?;
let bits = match types.get(*elem) {
Some(Type::Int(w)) => u64::from(*w),
_ => lane.saturating_mul(8),
};
if lane.checked_mul(8) != Some(bits) {
return Err(not_lowered());
return Err(not_lowered(AccessCause::Initializer));
}
(PartsAt::Strided(*elem, lane), *len as usize)
}
_ => return Err(not_lowered()),
_ => return Err(not_lowered(AccessCause::Initializer)),
};
if count != n {
return Err(invariant("an aggregate constant of the wrong arity"));
}
// Each part within the aggregate's bytes; a part of no known size refuses where it is
// written, as before.
let total = self.layouts.store_size(ty).ok_or_else(not_lowered)?;
let total = self
.layouts
.store_size(ty)
.ok_or_else(|| not_lowered(AccessCause::Initializer))?;
let last = match at {
PartsAt::Fields(..) => 0..n,
PartsAt::Strided(..) => n.saturating_sub(1)..n,
@@ -1412,7 +1443,7 @@ impl Planner<'_> {
.store_size(ty)
.and_then(|n| usize::try_from(n).ok())
.and_then(|n| at.checked_add(n))
.ok_or_else(not_lowered)?;
.ok_or_else(|| not_lowered(AccessCause::Initializer))?;
let mut stack = vec![(c, ty, at)];
while let Some((c, ty, at)) = stack.pop() {
let k = consts
@@ -1421,8 +1452,12 @@ impl Planner<'_> {
match &k.value {
Const::Null | Const::Undef | Const::Poison => {}
Const::Int(v) | Const::Float(v) => {
let n = self.layouts.store_size(ty).ok_or_else(not_lowered)?;
let n = usize::try_from(n).map_err(|_| not_lowered())?;
let n = self
.layouts
.store_size(ty)
.ok_or_else(|| not_lowered(AccessCause::Initializer))?;
let n =
usize::try_from(n).map_err(|_| not_lowered(AccessCause::OffsetWidth))?;
let bytes = v.to_le_bytes();
let to = at
.checked_add(n)
@@ -1447,7 +1482,8 @@ impl Planner<'_> {
.ok_or_else(|| invariant("a constant's part out of range"))?;
grow(&mut stack, elems.len(), m)?;
for (&e, (t, off)) in elems.iter().zip(placed) {
let off = usize::try_from(off).map_err(|_| not_lowered())?;
let off = usize::try_from(off)
.map_err(|_| not_lowered(AccessCause::OffsetWidth))?;
stack.push((e, t, at.saturating_add(off)));
}
m.release(placed_bytes);
@@ -1486,7 +1522,7 @@ impl Planner<'_> {
let size = self
.layouts
.alloc_size(global.value_ty)
.ok_or_else(not_lowered)?;
.ok_or_else(|| not_lowered(AccessCause::GlobalVariable))?;
let align = self.global_align(g, global.value_ty)?.max(METAL_TG_ALIGN);
objects.push((ArenaObject::Global(g), size, align));
}
@@ -1497,7 +1533,7 @@ impl Planner<'_> {
continue;
};
let AbiInt::Const(index) = arg.location.index else {
return Err(not_lowered());
return Err(not_lowered(AccessCause::UnfixedLocation));
};
// Metal threadgroup lengths are multiples of 16 bytes; every region starts on one.
grow(&mut arena.dynamic, 1, m)?;
@@ -2017,9 +2053,9 @@ impl Planner<'_> {
let count = match count {
Value::Const(c) => match self.e.module.consts().get(*c).map(|k| &k.value) {
Some(Const::Int(n)) => *n,
_ => return Err(not_lowered()),
_ => return Err(not_lowered(AccessCause::AllocaCount)),
},
_ => return Err(not_lowered()),
_ => return Err(not_lowered(AccessCause::AllocaCount)),
};
// A type with a member no typed object holds (a chunked vector) has a place in the
// arena, whose leaves hold every such member; so does a simdgroup matrix's `<64 x
@@ -2053,10 +2089,13 @@ impl Planner<'_> {
let size = self
.layouts
.alloc_size(*ty)
.ok_or_else(not_lowered)?
.ok_or_else(|| not_lowered(AccessCause::PrivateType))?
.checked_mul(count)
.ok_or(Error::LimitExceeded(Limit::PrivateArenaBytes))?;
let abi = self.layouts.abi_align(*ty).ok_or_else(not_lowered)?;
let abi = self
.layouts
.abi_align(*ty)
.ok_or_else(|| not_lowered(AccessCause::PrivateType))?;
let align = align.map_or(abi, |a| a.bytes().max(abi));
arena
.place(ArenaObject::Alloca(id), size, align, m)
+4 -4
View File
@@ -13,7 +13,7 @@ use crate::air::ir::{
};
use crate::device::requirements::VkFeature;
use crate::device::DevicePolicy;
use crate::error::{Capability, DiagName, Needs};
use crate::error::{AccessCause, Capability, Cause, DiagName, LowerFamily, Needs};
use crate::graph::{Cfg, DomTree};
use crate::memory::provenance::{Class, PrivForm, Repr, Root};
use crate::pipeline::testing::{meter, profile};
@@ -1080,7 +1080,7 @@ fn the_typed_depth_bound_is_unchanged_by_building_each_type_once() {
alloca::typed_ty(&e, &addressed(), top, false, &mut meter()).expect("no budget stop")
};
assert!(shaped(4).is_ok(), "{:?}", shaped(4));
assert_eq!(shaped(5).err(), Some(not_lowered()));
assert_eq!(shaped(5).err(), Some(not_lowered(AccessCause::PrivateType)));
}
/// A typed constant's vector lanes are held with its initializer and charged, 8 bytes a lane,
@@ -1128,7 +1128,7 @@ fn a_typed_constant_s_vector_lanes_are_charged() {
"{v} bytes for the vector's initializer, {s} for the scalar's"
);
let (refused, r) = init_bytes(v4, bad);
assert_eq!(refused, Err(not_lowered()));
assert_eq!(refused, Err(not_lowered(AccessCause::Initializer)));
assert_eq!(r, 0, "a refused initializer left {r} bytes on the ledger");
}
@@ -1417,7 +1417,7 @@ fn the_ledger_holds_the_plan_after_success_and_nothing_after_a_refusal() {
let mut m = meter();
assert_eq!(
analyze_memory(&arrayed, &addressed(), &mut m).err(),
Some(not_lowered())
Some(not_lowered(AccessCause::BufferArray))
);
assert_eq!(m.ledger(), 0);
}
@@ -187,9 +187,15 @@ fn other_uses_of_a_table_are_not_implemented() {
body(fb);
fb.ret(None);
});
refused_feature(plan(&e, &addressed()))
match plan(&e, &addressed()) {
Err(Error::Unsupported(u)) => (u.feature, u.cause),
other => panic!("expected a refusal, got {other:?}"),
}
};
let access = Feature::Lowering(LowerFamily::Access);
let access = (
Feature::Lowering(LowerFamily::Access),
Some(Cause::Access(AccessCause::ArgumentTable)),
);
// A store of a pointer into the table.
assert_eq!(
refused(&|fb| {
+44 -33
View File
@@ -30,7 +30,7 @@ use crate::air::ir::{
};
use crate::air::Entry;
use crate::budget::Meter;
use crate::error::{Error, Feature, InternalError, InternalKind, LowerFamily, Unsupported};
use crate::error::{AccessCause, Error, Feature, InternalError, InternalKind, Unsupported};
use crate::memory::abi_index::AbiIndex;
use crate::memory::alloca::{self, Strides};
use crate::memory::union_find::UnionFind;
@@ -693,8 +693,9 @@ fn root_use<'u>(
Ok(uses.entry(r).or_default())
}
fn not_lowered() -> Error {
Unsupported::not_implemented(Feature::Lowering(LowerFamily::Access)).into()
/// The access family's refusal of the structure `cause` names.
fn not_lowered(cause: AccessCause) -> Error {
Unsupported::access(cause).into()
}
/// Constant integer index `v` of `e`'s module, sign-extended from its width; `None` when not
@@ -734,14 +735,18 @@ pub(crate) fn gep_displacement(
} else {
match e.module.types().get(cur) {
Some(Type::Struct { fields, .. }) => {
let k = const_index(e, i).ok_or_else(not_lowered)?;
let k = usize::try_from(k).map_err(|_| not_lowered())?;
let k = const_index(e, i)
.ok_or_else(|| not_lowered(AccessCause::AddressComputation))?;
let k = usize::try_from(k)
.map_err(|_| not_lowered(AccessCause::AddressComputation))?;
let off = layouts
.field_offsets(cur)
.and_then(|o| o.get(k).copied())
.ok_or_else(not_lowered)?;
.ok_or_else(|| not_lowered(AccessCause::AddressComputation))?;
konst = konst.and_then(|c| c.checked_add(i128::from(off)));
cur = *fields.get(k).ok_or_else(not_lowered)?;
cur = *fields
.get(k)
.ok_or_else(|| not_lowered(AccessCause::AddressComputation))?;
continue;
}
Some(Type::Array { elem, .. } | Type::Vector { elem, .. }) => {
@@ -751,7 +756,7 @@ pub(crate) fn gep_displacement(
_ => None,
}
}
.ok_or_else(not_lowered)?;
.ok_or_else(|| not_lowered(AccessCause::AddressComputation))?;
match const_index(e, i) {
Some(k) => {
konst = konst.and_then(|c| {
@@ -1051,7 +1056,7 @@ impl Chains {
break;
}
if hit.is_none_or(|(d, _, _)| depth < d) {
return Err(not_lowered());
return Err(not_lowered(AccessCause::PointerSource));
}
}
Ok(match hit {
@@ -1106,7 +1111,7 @@ fn resolve_walk(
ty.and_then(|t| e.module.types().get(t)),
Some(Type::Ptr { .. })
) {
return Err(not_lowered());
return Err(not_lowered(AccessCause::PointerSource));
}
if let Value::Const(c) = v {
if matches!(
@@ -1124,13 +1129,17 @@ fn resolve_walk(
Value::Const(c) => match e.module.consts().get(c).map(|k| &k.value) {
Some(Const::Undef | Const::Poison | Const::Null) => out.null = true,
Some(Const::Aggregate(elems)) => {
let (&first, rest) = path.split_first().ok_or_else(not_lowered)?;
let elem = *elems.get(first as usize).ok_or_else(not_lowered)?;
let (&first, rest) = path
.split_first()
.ok_or_else(|| not_lowered(AccessCause::PointerSource))?;
let elem = *elems
.get(first as usize)
.ok_or_else(|| not_lowered(AccessCause::PointerSource))?;
work.push((Value::Const(elem), rest.into()));
}
_ => return Err(not_lowered()),
_ => return Err(not_lowered(AccessCause::PointerSource)),
},
Value::Arg(_) => return Err(not_lowered()),
Value::Arg(_) => return Err(not_lowered(AccessCause::PointerSource)),
Value::Inst(id) => {
let inst = body
.insts
@@ -1171,9 +1180,9 @@ fn resolve_walk(
{
out.intersections.push(id);
}
_ => return Err(not_lowered()),
_ => return Err(not_lowered(AccessCause::PointerSource)),
},
_ => return Err(not_lowered()),
_ => return Err(not_lowered(AccessCause::PointerSource)),
}
}
}
@@ -1201,7 +1210,7 @@ impl<'a> Cx<'a> {
fn check_ty(&self, t: TypeId) -> Result<(), Error> {
match self.ty(t) {
Some(Type::Vector { elem, .. }) if matches!(self.ty(*elem), Some(Type::Ptr { .. })) => {
Err(not_lowered())
Err(not_lowered(AccessCause::PointerInAggregate))
}
_ => Ok(()),
}
@@ -1300,12 +1309,14 @@ impl<'a> Cx<'a> {
|| self.space_of(k.ty)
!= self.e.module.consts().ty(*o).and_then(|t| self.space_of(t))
{
return Err(not_lowered());
return Err(not_lowered(AccessCause::PointerSource));
}
self.const_facts.get(o).copied().unwrap_or(PtrFact::BOTTOM)
}
Const::Expr(ConstExpr::Gep { src_ty, ops, .. }) => {
let (base, idx) = ops.split_first().ok_or_else(not_lowered)?;
let (base, idx) = ops
.split_first()
.ok_or_else(|| not_lowered(AccessCause::PointerSource))?;
let base = self
.const_facts
.get(base)
@@ -1314,7 +1325,7 @@ impl<'a> Cx<'a> {
let idx: Vec<Value> = idx.iter().map(|&i| Value::Const(i)).collect();
self.gep(base, *src_ty, &idx)?
}
_ => return Err(not_lowered()),
_ => return Err(not_lowered(AccessCause::PointerSource)),
};
m.charge(map_entry_bytes::<ConstId, PtrFact>())?;
self.const_facts.insert(top, fact);
@@ -1548,12 +1559,12 @@ impl<'a> Cx<'a> {
let s = self.sets.single(Root::Call(id), m)?;
PtrFact::unknown(s)
}
None => return Err(not_lowered()),
None => return Err(not_lowered(AccessCause::PointerSource)),
}
}
// A pointer out of an aggregate or vector, a cast between spaces, or any other
// producer has no model.
_ => return Err(not_lowered()),
_ => return Err(not_lowered(AccessCause::PointerSource)),
})
}
@@ -1572,25 +1583,25 @@ impl<'a> Cx<'a> {
m: &mut Meter,
) -> Result<PtrFact, Error> {
let AbiInt::Const(count) = t.count else {
return Err(not_lowered());
return Err(not_lowered(AccessCause::UnfixedLocation));
};
// The element is a pointer of the table's space; any other load reads its bytes.
if self.space_of(ty) != Some(t.space) {
return Err(not_lowered());
return Err(not_lowered(AccessCause::ArgumentTable));
}
let size = self
.layouts
.store_size(ty)
.and_then(|s| i64::try_from(s).ok())
.filter(|&s| s > 0)
.ok_or_else(not_lowered)?;
.ok_or_else(|| not_lowered(AccessCause::ArgumentTable))?;
let last = i64::from(count) - 1;
let (lo, hi) = match f.range {
OffsetRange::Empty => return Ok(PtrFact::BOTTOM),
OffsetRange::Span { lo, hi } => {
// A constant offset inside an element reads parts of two pointers.
if lo == hi && lo.rem_euclid(size) != 0 {
return Err(not_lowered());
return Err(not_lowered(AccessCause::ArgumentTable));
}
(lo.div_euclid(size).max(0), hi.div_euclid(size).min(last))
}
@@ -1600,7 +1611,7 @@ impl<'a> Cx<'a> {
let s = self.sets.single(Root::Null, m)?;
return Ok(PtrFact::at(s, 0));
}
let n = usize::try_from(hi - lo + 1).map_err(|_| not_lowered())?;
let n = usize::try_from(hi - lo + 1).map_err(|_| not_lowered(AccessCause::OffsetWidth))?;
let mut roots = Vec::new();
grow(&mut roots, n, m)?;
for k in lo..=hi {
@@ -2733,7 +2744,7 @@ impl Walk<'_, '_> {
if let Some(t) = self.cx.abi.buffer_table(p) {
let element = plain.and_then(|a| self.cx.space_of(a)) == Some(t.space);
if touch != Touch::Read || !element {
return Err(not_lowered());
return Err(not_lowered(AccessCause::ArgumentTable));
}
}
}
@@ -3053,7 +3064,7 @@ impl Walk<'_, '_> {
.value_ty(*val)
.is_some_and(|t| self.cx.e.module.types().holds_pointer(t)) =>
{
return Err(not_lowered());
return Err(not_lowered(AccessCause::PointerStore));
}
InstKind::Store { val, ptr, .. } => {
let n = size(self.cx, *val);
@@ -3157,7 +3168,7 @@ impl Walk<'_, '_> {
InstKind::Alloca { count, .. } => {
self.seed(this, Class::Byte, m)?;
if self.cx.const_index(*count).is_none() {
return Err(not_lowered());
return Err(not_lowered(AccessCause::AllocaCount));
}
}
InstKind::Call(call) => self.call((b, id), call, m)?,
@@ -3170,7 +3181,7 @@ impl Walk<'_, '_> {
}
}
InstKind::InsertElement { elt: val, .. } if self.is_ptr(*val) => {
return Err(not_lowered());
return Err(not_lowered(AccessCause::PointerInAggregate));
}
InstKind::Ret(Some(v))
if self.is_ptr(*v)
@@ -3179,7 +3190,7 @@ impl Walk<'_, '_> {
.value_ty(*v)
.is_some_and(|t| self.cx.e.module.types().holds_pointer(t)) =>
{
return Err(not_lowered())
return Err(not_lowered(AccessCause::PointerInAggregate))
}
_ => {}
}
@@ -3238,7 +3249,7 @@ impl Walk<'_, '_> {
{
return Err(crate::lower::simd::agx::unmodeled());
}
return Err(not_lowered());
return Err(not_lowered(AccessCause::Call));
}
return Ok(());
};
@@ -658,12 +658,14 @@ enum metal2vulkan::device::VkFeature #[cfg_attr(feature = "serde", derive(serde:
enum metal2vulkan::device::VkLimit #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum VkLimit
enum metal2vulkan::device::VkProperty #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum VkProperty
enum metal2vulkan::error::AbiError #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum AbiError
enum metal2vulkan::error::AccessCause #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum AccessCause
enum metal2vulkan::error::Attachment #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Attachment
enum metal2vulkan::error::BitcodeError #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum BitcodeError
enum metal2vulkan::error::BitstreamError #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum BitstreamError
enum metal2vulkan::error::BudgetExceeded #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum BudgetExceeded
enum metal2vulkan::error::CanonError #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum CanonError
enum metal2vulkan::error::Capability #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum Capability
enum metal2vulkan::error::Cause #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Cause
enum metal2vulkan::error::ComputePipelineProblem #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum ComputePipelineProblem
enum metal2vulkan::error::ConstantRecord #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum ConstantRecord
enum metal2vulkan::error::ContainerError #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum ContainerError
@@ -2258,6 +2260,7 @@ field metal2vulkan::error::InputError.at pub at: Location
field metal2vulkan::error::InputError.kind pub kind: InputErrorKind
field metal2vulkan::error::InternalError.detail pub detail: String
field metal2vulkan::error::InternalError.kind pub kind: InternalKind
field metal2vulkan::error::Unsupported.cause pub cause: Option<Cause>
field metal2vulkan::error::Unsupported.feature pub feature: Feature
field metal2vulkan::error::Unsupported.location pub location: Option<Location>
field metal2vulkan::error::Unsupported.needs pub needs: Needs
@@ -7238,6 +7241,7 @@ trait-impl metal2vulkan::device::DevicePolicy impl Default impl Default for Devi
trait-impl metal2vulkan::device::SpirvCapability impl Codec impl Codec for SpirvCapability
trait-impl metal2vulkan::device::SpirvCapability impl fmt::Debug impl fmt::Debug for SpirvCapability
trait-impl metal2vulkan::error::Attachment impl fmt::Display impl fmt::Display for Attachment
trait-impl metal2vulkan::error::Cause impl fmt::Display impl fmt::Display for Cause
trait-impl metal2vulkan::error::DescriptorError impl From<RequestError> impl From<RequestError> for DescriptorError
trait-impl metal2vulkan::error::DiagName impl fmt::Debug impl fmt::Debug for DiagName
trait-impl metal2vulkan::error::DiagName impl fmt::Display impl fmt::Display for DiagName
@@ -9375,6 +9379,44 @@ variant metal2vulkan::error::AbiError::StructInfoMismatch StructInfoMismatch
variant metal2vulkan::error::AbiError::TypeSizeMismatch TypeSizeMismatch
variant metal2vulkan::error::AbiError::UnknownKey UnknownKey
variant metal2vulkan::error::AbiError::UnknownStageAttribute UnknownStageAttribute(DiagName)
variant metal2vulkan::error::AccessCause::AccessType AccessType
variant metal2vulkan::error::AccessCause::AddressComputation AddressComputation
variant metal2vulkan::error::AccessCause::AllocaCount AllocaCount
variant metal2vulkan::error::AccessCause::ArgumentTable ArgumentTable
variant metal2vulkan::error::AccessCause::AtomicForm AtomicForm
variant metal2vulkan::error::AccessCause::AtomicMemory AtomicMemory
variant metal2vulkan::error::AccessCause::BufferArray BufferArray
variant metal2vulkan::error::AccessCause::Call Call
variant metal2vulkan::error::AccessCause::CoherentMemory CoherentMemory
variant metal2vulkan::error::AccessCause::ConstantAddress ConstantAddress
variant metal2vulkan::error::AccessCause::ConstantCondition ConstantCondition
variant metal2vulkan::error::AccessCause::ConstantOperand ConstantOperand
variant metal2vulkan::error::AccessCause::DynamicOffset DynamicOffset
variant metal2vulkan::error::AccessCause::GlobalVariable GlobalVariable
variant metal2vulkan::error::AccessCause::HandleClass HandleClass
variant metal2vulkan::error::AccessCause::HandleUse HandleUse
variant metal2vulkan::error::AccessCause::IndexType IndexType
variant metal2vulkan::error::AccessCause::Initializer Initializer
variant metal2vulkan::error::AccessCause::IntrinsicStore IntrinsicStore
variant metal2vulkan::error::AccessCause::OffsetWidth OffsetWidth
variant metal2vulkan::error::AccessCause::Operation Operation
variant metal2vulkan::error::AccessCause::Parameter Parameter
variant metal2vulkan::error::AccessCause::PointerCell PointerCell
variant metal2vulkan::error::AccessCause::PointerCompare PointerCompare
variant metal2vulkan::error::AccessCause::PointerForm PointerForm
variant metal2vulkan::error::AccessCause::PointerInAggregate PointerInAggregate
variant metal2vulkan::error::AccessCause::PointerInteger PointerInteger
variant metal2vulkan::error::AccessCause::PointerJoin PointerJoin
variant metal2vulkan::error::AccessCause::PointerShape PointerShape
variant metal2vulkan::error::AccessCause::PointerSize PointerSize
variant metal2vulkan::error::AccessCause::PointerSource PointerSource
variant metal2vulkan::error::AccessCause::PointerStore PointerStore
variant metal2vulkan::error::AccessCause::PrivateType PrivateType
variant metal2vulkan::error::AccessCause::ReadOnlyStore ReadOnlyStore
variant metal2vulkan::error::AccessCause::StageMemory StageMemory
variant metal2vulkan::error::AccessCause::UnderAligned UnderAligned
variant metal2vulkan::error::AccessCause::UnfixedLocation UnfixedLocation
variant metal2vulkan::error::AccessCause::Volatile Volatile
variant metal2vulkan::error::Attachment::Color Color(u32)
variant metal2vulkan::error::Attachment::Depth Depth
variant metal2vulkan::error::Attachment::Stencil Stencil
@@ -9407,6 +9449,7 @@ variant metal2vulkan::error::Capability::Feature Feature(VkFeature)
variant metal2vulkan::error::Capability::Format Format { format: vk::Format, usage: FormatUsage }
variant metal2vulkan::error::Capability::Limit Limit { limit: VkLimit, required: u64, available: u64 }
variant metal2vulkan::error::Capability::Property Property(VkProperty)
variant metal2vulkan::error::Cause::Access Access(AccessCause)
variant metal2vulkan::error::ComputePipelineProblem::MaxThreadsDiffer MaxThreadsDiffer { specified: u32, max: u32 }
variant metal2vulkan::error::ComputePipelineProblem::MaxThreadsOverLimit MaxThreadsOverLimit { max: u32, limit: u32 }
variant metal2vulkan::error::ConstantRecord::BlockAddress BlockAddress
Can't render this file because it is too large.
+2
View File
@@ -193,6 +193,8 @@ surface! {
enum Capability N;
enum Feature N;
enum LowerFamily N;
enum Cause N;
enum AccessCause N;
enum PrivateRenderField N;
enum RuntimeInput N;
enum DescriptorError N;
+1 -1
View File
@@ -1502,7 +1502,7 @@ match floor.compile_function(&min_lod, &LoweringInputs::new(), &Budget::standard
| Variant | Means | Retry |
|---|---|---|
| `Unsupported` | The device cannot run this exactly. `feature` names the Metal feature, `needs` what would change it | No |
| `Unsupported` | The device cannot run this exactly. `feature` names the Metal feature, `needs` what would change it, and `cause`, where the feature covers more than one cause, the structure the translator met (`Cause::Access` names an access's: `AccessCause::PointerStore`, `AccessCause::UnderAligned`, ...); its `Display` prints the cause after the feature | No |
| `NeedsInput` | The compile needs a pipeline input you did not supply | After supplying it |
| `InvalidInput` | The AIR or container is malformed | No |
| `InvalidDescriptor` | The descriptor is invalid as Metal would refuse it, or names a missing entry | No |
+2 -2
View File
@@ -144,7 +144,7 @@ Columns:
| `SubgroupOperations` | Simdgroup operations of a class the stage's subgroups do not support (the stage is not in `subgroupSupportedStages`, or an operation class is... | devices without VkFeature::ShaderQuadControl; devices without VkFeature::ShaderSubgroupExtendedTypes | `device` | 2: `crates/metal2vulkan/src/lower/simd/mod.rs (full_quads)`, `crates/metal2vulkan/src/lower/simd/mod.rs (select_group)` | `app`: simdgroup functions in a stage a device's subgroups do not support |
| `DirectCall` | A call to a defined function the inliner cannot take | every device (not implemented) | `ours` | 1: `crates/metal2vulkan-air/src/canon/mod.rs (post_check)` | `rare`: variadic or byval calls the inliner cannot take |
| `WideSwitchLiteral` | A switch case literal wider than 32 bits | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/structurize/emit.rs (check_tree)` | `rare`: 64-bit switch literals |
| `Lowering` | An instruction, intrinsic, or interface element of a lowering family whose lowering has not landed yet (each family narrows its refusals as it lands) | devices without VkFeature::ShaderDemoteToHelperInvocation; every device (not implemented) | `ours` | 35: `crates/metal2vulkan/src/lower/access/handle.rs (domain_kind)`, `crates/metal2vulkan/src/lower/access/handle.rs (sampler_target)` (+32) | `system`: the catch-all of lowering families not landed: any shader can meet one |
| `Lowering` | An instruction, intrinsic, or interface element of a lowering family whose lowering has not landed yet (each family narrows its refusals as it lands) | devices without VkFeature::ShaderDemoteToHelperInvocation; every device (not implemented) | `ours` | 31: `crates/metal2vulkan/src/error/mod.rs (access)`, `crates/metal2vulkan/src/lower/access/handle.rs (sampler_target)` (+28) | `system`: the catch-all of lowering families not landed: any shader can meet one |
| `SamplerAddressMode` | A sampler address mode the device lacks (`MirrorClampToEdge`) | devices without VkFeature::SamplerMirrorClampToEdge; every device (not implemented) | `ours` | 2: `crates/metal2vulkan/src/lower/sampler/constexpr.rs`, `crates/metal2vulkan/src/metal/sampler.rs (check_sampler)` | `app`: mirror-clamp-to-edge on a device without it |
| `AlphaToOne` | `alphaToOneEnabled` on a device without Vulkan's `alphaToOne` feature, the exact counterpart... | devices without VkFeature::AlphaToOne | `device` | 1: `crates/metal2vulkan/src/pipeline/link/graphics.rs (graphics_state)` | `rare`: alphaToOneEnabled on a device without alphaToOne |
| `StageStoresAndAtomics` | Buffer or image stores or atomics in a vertex or fragment function without the stage's store feature (`vertexPipelineStoresAndAtomics`,... | devices without VkFeature::FragmentStoresAndAtomics | `device` | 1: `crates/metal2vulkan/src/lower/access/tile_memory.rs (written)` | `app`: stores or atomics in vertex or fragment functions on a device without the feature |
@@ -472,7 +472,7 @@ Each refusal's sites, with the function that builds it.
- `feature::SubgroupOperations`: `crates/metal2vulkan/src/lower/simd/mod.rs (full_quads)`; `crates/metal2vulkan/src/lower/simd/mod.rs (select_group)`
- `feature::DirectCall`: `crates/metal2vulkan-air/src/canon/mod.rs (post_check)`
- `feature::WideSwitchLiteral`: `crates/metal2vulkan/src/structurize/emit.rs (check_tree)`
- `feature::Lowering`: `crates/metal2vulkan/src/lower/access/handle.rs (domain_kind)`; `crates/metal2vulkan/src/lower/access/handle.rs (sampler_target)`; `crates/metal2vulkan/src/lower/access/handle.rs (texture_target)`; `crates/metal2vulkan/src/lower/access/imageblock.rs (operand)`; `crates/metal2vulkan/src/lower/access/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/access/pulled.rs (share)`; `crates/metal2vulkan/src/lower/arith/legal.rs (not_lowered)`; `crates/metal2vulkan/src/lower/dispatch.rs (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs (plan)`; `crates/metal2vulkan/src/lower/fragment/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/mesh/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/sampler/mod.rs (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs (refuse)`; `crates/metal2vulkan/src/lower/select.rs (not_lowered)`; `crates/metal2vulkan/src/lower/select.rs (route_air, 2 sites)`; `crates/metal2vulkan/src/lower/simd/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/simd/mod.rs (select_param)`; `crates/metal2vulkan/src/lower/simd/workgroup.rs (check)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs (not_lowered)`; `crates/metal2vulkan/src/lower/stage_io/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/sync/barrier.rs (not_lowered)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs (not_implemented)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs (select)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/texture/mod.rs (refuse)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_through)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_write)`; `crates/metal2vulkan/src/memory/alloca.rs (not_lowered)`; `crates/metal2vulkan/src/memory/leaf.rs (not_lowered)`; `crates/metal2vulkan/src/memory/plan.rs (not_lowered)`; `crates/metal2vulkan/src/memory/provenance.rs (not_lowered)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs (patch_fetch_projection)`
- `feature::Lowering`: `crates/metal2vulkan/src/error/mod.rs (access)`; `crates/metal2vulkan/src/lower/access/handle.rs (sampler_target)`; `crates/metal2vulkan/src/lower/access/handle.rs (texture_target)`; `crates/metal2vulkan/src/lower/access/imageblock.rs (operand)`; `crates/metal2vulkan/src/lower/access/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/access/pulled.rs (share)`; `crates/metal2vulkan/src/lower/arith/legal.rs (not_lowered)`; `crates/metal2vulkan/src/lower/dispatch.rs (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs (plan)`; `crates/metal2vulkan/src/lower/fragment/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/mesh/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/sampler/mod.rs (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs (refuse)`; `crates/metal2vulkan/src/lower/select.rs (not_lowered)`; `crates/metal2vulkan/src/lower/select.rs (route_air, 2 sites)`; `crates/metal2vulkan/src/lower/simd/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/simd/mod.rs (select_param)`; `crates/metal2vulkan/src/lower/simd/workgroup.rs (check)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs (not_lowered)`; `crates/metal2vulkan/src/lower/stage_io/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/sync/barrier.rs (not_lowered)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs (not_implemented)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs (select)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs (not_lowered)`; `crates/metal2vulkan/src/lower/texture/mod.rs (refuse)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_through)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_write)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs (patch_fetch_projection)`
- `feature::SamplerAddressMode`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs`; `crates/metal2vulkan/src/metal/sampler.rs (check_sampler)`
- `feature::AlphaToOne`: `crates/metal2vulkan/src/pipeline/link/graphics.rs (graphics_state)`
- `feature::StageStoresAndAtomics`: `crates/metal2vulkan/src/lower/access/tile_memory.rs (written)`