Translator: a slot pointer stored through a loaded pointer or into an open cell is its Metal address
L288. Under the identity domains (and on Profile F) an escaping slot root stays static, so a
stored slot pointer is access::pointer's: its Metal address, the slot's SlotGuestBase plus its
displacement, as an 8-byte leaf. That leaf went only through a static-root destination; a store
through a pointer loaded from memory, or into a pointer cell whose bytes are read at an offset only
the run knows (an open cell), was Unsupported{Lowering(Access), NotImplemented}. Metal stores the
pointer's 64-bit address wherever it is stored.
Now the stored address goes through any destination dynamic stores a wide pointer's through: a
static-root pointer (unchanged), the address a wide pointer holds (an 8-byte store there), or an
arena's pointer cell. dynamic::store_destination and dynamic::emit_store_word are the one form
both share; dynamic's own StorePointer selects and emits through them as before. A destination in
the blob, a typed object or a constant global stays refused. Census names:
access.pointer.store_pointer.wide and .arena, as dynamic names its own.
Existing inputs keep their modules (the static-root path is unchanged); a refusal becomes a
module, so SEMANTICS_VERSION 2312. No refusal site was added or removed: docs/REFUSALS.md
regenerates unchanged.
Verified (job m3-max-78337, msi, at this tree before its rebase onto f1dfed1138): the interpreter
test passes on every identity profile and compiles and passes L3 on the bound ones (1 passed);
on lavapipe the runtime test passes, both dispatches at their addresses ("32 slot pointers stored
as their Metal addresses", M2V-FORM 0 bound, 2 at their addresses).
This commit is contained in:
1 parent
37a5bc7f0c
commit
f29613d057
3 files changed
+92
-47
No files matched your search
Vendored
+1
-1
@@ -60,7 +60,7 @@ mod tests;
|
||||
/// unchanged version, and its bless records the version. Independent of the crate's version and of
|
||||
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
|
||||
/// history.
|
||||
pub const SEMANTICS_VERSION: u32 = 2311;
|
||||
pub const SEMANTICS_VERSION: u32 = 2312;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
|
||||
@@ -185,7 +185,7 @@ impl Source {
|
||||
}
|
||||
|
||||
/// The same access, volatile.
|
||||
fn volatile(self) -> Source {
|
||||
pub(super) fn volatile(self) -> Source {
|
||||
match self {
|
||||
Source::Static(a) => Source::Static(Access {
|
||||
volatile: true,
|
||||
@@ -780,14 +780,7 @@ pub fn select(
|
||||
Some(Repr::BufPtr { wide: false, .. }) => {
|
||||
Source::Static(static_access(cx, *ptr, leaf, true, m)?)
|
||||
}
|
||||
Some(Repr::BufPtr { wide: true, .. }) => Source::Wide(WideAccess {
|
||||
ptr: plan_deref(cx, *ptr)?,
|
||||
value: None,
|
||||
leaf,
|
||||
coherence: None,
|
||||
volatile: false,
|
||||
}),
|
||||
_ => Source::Arena(cell(cx, *ptr, leaf, true)?),
|
||||
_ => store_destination(cx, *ptr, leaf)?,
|
||||
};
|
||||
DynStrategy::StorePointer { to, value }
|
||||
}
|
||||
@@ -978,6 +971,29 @@ fn stored(cx: &mut SelectCx<'_>, v: Value) -> Result<Side, Error> {
|
||||
plan_entry(cx, v).map(Side::Ptr)
|
||||
}
|
||||
|
||||
/// Where a stored pointer's 8-byte `leaf` is written through `ptr` when `ptr` is no static-root
|
||||
/// buffer pointer: the address a wide pointer holds, or a pointer cell in an arena. Any other
|
||||
/// destination (a typed object, a constant global) is refused.
|
||||
pub(super) fn store_destination(
|
||||
cx: &mut SelectCx<'_>,
|
||||
ptr: Value,
|
||||
leaf: Leaf,
|
||||
) -> Result<Source, Error> {
|
||||
Ok(match cx.memory.repr(ptr) {
|
||||
Some(Repr::BufPtr { wide: false, .. }) => {
|
||||
return Err(cx.invariant("a static-root destination of a stored pointer"))
|
||||
}
|
||||
Some(Repr::BufPtr { wide: true, .. }) => Source::Wide(WideAccess {
|
||||
ptr: plan_deref(cx, ptr)?,
|
||||
value: None,
|
||||
leaf,
|
||||
coherence: None,
|
||||
volatile: false,
|
||||
}),
|
||||
_ => Source::Arena(cell(cx, ptr, leaf, true)?),
|
||||
})
|
||||
}
|
||||
|
||||
/// The 8-byte access of pointer cell `ptr` (a pointer into an arena), a store of one where `write`:
|
||||
/// its leaf holds a guest address.
|
||||
fn cell(cx: &mut SelectCx<'_>, ptr: Value, leaf: Leaf, write: bool) -> Result<LocalAccess, Error> {
|
||||
@@ -1525,20 +1541,7 @@ pub fn emit(
|
||||
}
|
||||
DynStrategy::StorePointer { to, value } => {
|
||||
let guest = metal_address(cx, fb, *value)?;
|
||||
match to {
|
||||
Source::Static(a) => {
|
||||
let p = cx.operand(fb, a.ptr)?;
|
||||
let m = fb.composite_extract(p, &[1])?;
|
||||
super::emit::access_at(cx, fb, a, p, m, Some(guest))?;
|
||||
}
|
||||
Source::Wide(a) => {
|
||||
wide_access(cx, fb, a, Some(guest))?;
|
||||
}
|
||||
Source::Arena(a) => {
|
||||
local::emit_access(cx, fb, a, Some(guest))?;
|
||||
}
|
||||
}
|
||||
return Ok(());
|
||||
return emit_store_word(cx, fb, to, guest);
|
||||
}
|
||||
DynStrategy::ToInt { of, bits } => {
|
||||
let a = metal_address(cx, fb, *of)?;
|
||||
@@ -1605,6 +1608,29 @@ pub(super) fn plan_word(
|
||||
})
|
||||
}
|
||||
|
||||
/// Store `word`, a stored pointer's 8-byte leaf value, where `s` writes it.
|
||||
pub(super) fn emit_store_word(
|
||||
cx: &mut EmitCx<'_>,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
s: &Source,
|
||||
word: SValue,
|
||||
) -> BResult<()> {
|
||||
match s {
|
||||
Source::Static(a) => {
|
||||
let p = cx.operand(fb, a.ptr)?;
|
||||
let m = fb.composite_extract(p, &[1])?;
|
||||
super::emit::access_at(cx, fb, a, p, m, Some(word))?;
|
||||
}
|
||||
Source::Wide(a) => {
|
||||
wide_access(cx, fb, a, Some(word))?;
|
||||
}
|
||||
Source::Arena(a) => {
|
||||
local::emit_access(cx, fb, a, Some(word))?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The 8-byte word `s` reads ([`plan_word`]), a `u64`.
|
||||
pub(super) fn emit_word(
|
||||
cx: &mut EmitCx<'_>,
|
||||
|
||||
@@ -43,8 +43,11 @@
|
||||
//! ([`PointerValue::ToInt`], [`PointerValue::StorePointer`]). Without root entries an escaping
|
||||
//! slot root stays static (`memory::plan`), so `ptrtoint` of a static fat pointer (or of the null
|
||||
//! constant) is its Metal address as above, truncated to the integer's width (a `bool` its low
|
||||
//! bit), and a stored one is that address as an 8-byte leaf through a static-root destination
|
||||
//! (stored pointers are guest addresses). On Profile A's resident table such a pointer is wide.
|
||||
//! bit), and a stored one is that address as an 8-byte leaf (stored pointers are guest addresses)
|
||||
//! through its destination, as `dynamic` stores a wide pointer's: a static-root pointer, a wide
|
||||
//! pointer (a pointer loaded from memory or made from an integer, at the address it holds), or a
|
||||
//! pointer cell in an arena (an open cell, whose bytes are read at an offset only the run knows).
|
||||
//! On Profile A's resident table such a pointer is wide.
|
||||
//!
|
||||
//! **Handles of the other families.** A command buffer, pipeline state, acceleration structure, or
|
||||
//! function table loaded from an argument buffer, or any access-family instruction on one, is
|
||||
@@ -73,9 +76,10 @@ use crate::spirv::error::BResult;
|
||||
use crate::spirv::ids::{DemoteTy, Value as SValue};
|
||||
use crate::spirv::ir::{BinOp, ConstBits, Constant, ConvOp, Type as SType};
|
||||
|
||||
use super::dynamic::Source;
|
||||
use super::emit::fat_part;
|
||||
use super::local::{self, Home, LocalPtr};
|
||||
use super::{blob, buffer_roots, dynamic, operand, psb, refuse, statics, Access, AccessPlan};
|
||||
use super::{blob, buffer_roots, dynamic, operand, psb, refuse, statics, AccessPlan};
|
||||
|
||||
/// Bytes a `u32` offset tells apart.
|
||||
const SPAN: i128 = 1 << 32;
|
||||
@@ -135,9 +139,10 @@ pub enum PointerValue {
|
||||
/// `ptrtoint` of a static fat pointer or the null constant to `i<bits>` (Profile F).
|
||||
ToInt { of: Addr, bits: u8, words: bool },
|
||||
/// A static fat pointer or the null constant stored as its 8-byte Metal address through a
|
||||
/// static-root destination (Profile F).
|
||||
/// static-root pointer, a wide pointer, or an arena's pointer cell (Profile F and the identity
|
||||
/// domains).
|
||||
StorePointer {
|
||||
to: Box<Access>,
|
||||
to: Box<Source>,
|
||||
value: Addr,
|
||||
words: bool,
|
||||
},
|
||||
@@ -166,10 +171,7 @@ impl PointerValue {
|
||||
pub(super) fn volatile(self) -> Result<PointerValue, Error> {
|
||||
match self {
|
||||
PointerValue::StorePointer { to, value, words } => Ok(PointerValue::StorePointer {
|
||||
to: Box::new(Access {
|
||||
volatile: true,
|
||||
..*to
|
||||
}),
|
||||
to: Box::new((*to).volatile()),
|
||||
value,
|
||||
words,
|
||||
}),
|
||||
@@ -178,7 +180,9 @@ impl PointerValue {
|
||||
}
|
||||
|
||||
/// The census name (`access.pointer.<op>`) in the finished plan `slots`: a pointer store
|
||||
/// qualified by the reach of its destination ([`BufferReach`](super::BufferReach)).
|
||||
/// through a static-root pointer qualified by the reach of its destination
|
||||
/// ([`BufferReach`](super::BufferReach)); through a wide pointer or an arena cell it is named
|
||||
/// apart.
|
||||
pub fn name(&self, slots: &AccessPlan) -> Cow<'static, str> {
|
||||
match self {
|
||||
PointerValue::CompareOffsets { .. } => "access.pointer.compare_offsets".into(),
|
||||
@@ -189,9 +193,11 @@ impl PointerValue {
|
||||
"access.pointer.compare_addresses.words".into()
|
||||
}
|
||||
PointerValue::ToInt { .. } => "access.pointer.ptrtoint".into(),
|
||||
PointerValue::StorePointer { to, .. } => {
|
||||
to.reach(slots).qualify("access.pointer.store_pointer")
|
||||
}
|
||||
PointerValue::StorePointer { to, .. } => match &**to {
|
||||
Source::Static(a) => a.reach(slots).qualify("access.pointer.store_pointer"),
|
||||
Source::Wide(_) => "access.pointer.store_pointer.wide".into(),
|
||||
Source::Arena(_) => "access.pointer.store_pointer.arena".into(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,8 +479,9 @@ fn address_leaf(cx: &SelectCx<'_>, ty: TypeId, align: Option<Align>) -> Result<L
|
||||
}
|
||||
|
||||
/// A store of pointer `val` (taking the static form) through `ptr`: a leaf store of its
|
||||
/// address through a static-root destination. A destination in the blob, an arena, or behind a
|
||||
/// wide pointer is refused (on Profile A's resident table a wide one makes `val` wide too).
|
||||
/// address through a static-root destination, at the address a wide one holds, or into an arena's
|
||||
/// pointer cell (`dynamic::store_destination`). A destination in the blob, a typed object or a
|
||||
/// constant global is refused (on Profile A's resident table a wide one makes `val` wide too).
|
||||
fn store_pointer(
|
||||
cx: &mut SelectCx<'_>,
|
||||
val: Value,
|
||||
@@ -487,11 +494,18 @@ fn store_pointer(
|
||||
.value_ty(val)
|
||||
.ok_or_else(|| cx.invariant("a stored pointer without a type"))?;
|
||||
let leaf = address_leaf(cx, ty, align)?;
|
||||
let (targets, null, in_blob) = buffer_roots(cx, ptr, m)?;
|
||||
if in_blob {
|
||||
return Err(refuse());
|
||||
}
|
||||
let to = super::access_with_leaf(cx, ptr, None, leaf, targets, null, false)?;
|
||||
let to = match cx.memory.repr(ptr) {
|
||||
Some(Repr::BufPtr { wide: false, .. }) => {
|
||||
let (targets, null, in_blob) = buffer_roots(cx, ptr, m)?;
|
||||
if in_blob {
|
||||
return Err(refuse());
|
||||
}
|
||||
Source::Static(super::access_with_leaf(
|
||||
cx, ptr, None, leaf, targets, null, false,
|
||||
)?)
|
||||
}
|
||||
_ => dynamic::store_destination(cx, ptr, leaf)?,
|
||||
};
|
||||
let words = !cx.profile.fields().leaf.int64;
|
||||
Ok(PointerValue::StorePointer {
|
||||
to: Box::new(to),
|
||||
@@ -1050,9 +1064,14 @@ pub fn emit(
|
||||
PointerValue::StorePointer { to, value, words } => {
|
||||
let a = emit_address(cx, fb, value, *words)?;
|
||||
let v = address_value(fb, a)?;
|
||||
let p = cx.operand(fb, to.ptr)?;
|
||||
let m = fat_part(fb, p, 1)?;
|
||||
super::emit::access_at(cx, fb, to, p, m, Some(v))?;
|
||||
match &**to {
|
||||
Source::Static(to) => {
|
||||
let p = cx.operand(fb, to.ptr)?;
|
||||
let m = fat_part(fb, p, 1)?;
|
||||
super::emit::access_at(cx, fb, to, p, m, Some(v))?;
|
||||
}
|
||||
to => dynamic::emit_store_word(cx, fb, to, v)?,
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user