pub struct MemLowerContext<'a> {
pub linear_memory_base: LoweredValueId,
pub value_map: &'a HashMap<Value, LoweredValueId>,
pub stack_slot_map: &'a mut HashMap<StackSlot, LoweredValueId>,
pub next_value_id: &'a mut LoweredValueId,
}Expand description
Context threaded through the memory-family lowering.
Carries the device-pointer base (kernel-arg 0 by convention), the
running value-id allocator, and the bookkeeping maps for translating
Cranelift ir::Value / ir::StackSlot into LoweredValueId.
The caller owns all four state pieces: this type is a borrow bundle,
not an owner. Lifetime 'a ties the borrows together so callers can
thread one context through a block walk without re-binding.
Fields§
§linear_memory_base: LoweredValueIdSSA value id of the kernel’s device-resident linear-memory base
pointer. By convention this is the lowered id of kernel arg 0.
Wave-1 lowering does not yet use this id (regular load/store
take their base directly from Self::value_map); it is plumbed
here so the wave-2 kernel-arg refinement can land without
changing the signature.
value_map: &'a HashMap<Value, LoweredValueId>Map from Cranelift ir::Value → LoweredValueId. Populated by
the caller before invoking this family. A miss on a base-pointer
lookup is a MemLowerError::UnmappedValue.
stack_slot_map: &'a mut HashMap<StackSlot, LoweredValueId>Map from Cranelift ir::StackSlot → LoweredValueId of the
alloca’s pointer. Populated lazily by this family the first time
a stack_load/stack_store references the slot.
next_value_id: &'a mut LoweredValueIdNext free LoweredValueId. Incremented by Self::fresh_id
each time a new id is handed out.
Implementations§
Source§impl<'a> MemLowerContext<'a>
impl<'a> MemLowerContext<'a>
Sourcepub fn fresh_id(&mut self) -> Result<LoweredValueId, MemLowerError>
pub fn fresh_id(&mut self) -> Result<LoweredValueId, MemLowerError>
Allocate and return the next fresh LoweredValueId, advancing
the caller’s counter.
jit LOW fix (finding 7): standardize on checked_add(1) (the
lower_arith idiom) and return a structured
MemLowerError::SsaOverflow on overflow rather than wrapping_add,
which silently aliased fresh ids onto already-used ones once the
counter wrapped.
Sourcepub fn lookup_value(&self, v: Value) -> Result<LoweredValueId, MemLowerError>
pub fn lookup_value(&self, v: Value) -> Result<LoweredValueId, MemLowerError>
Look up the LoweredValueId for a Cranelift value, returning
MemLowerError::UnmappedValue if the value has not been
lowered yet.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !UnwindSafe for MemLowerContext<'a>
impl<'a> Freeze for MemLowerContext<'a>
impl<'a> RefUnwindSafe for MemLowerContext<'a>
impl<'a> Send for MemLowerContext<'a>
impl<'a> Sync for MemLowerContext<'a>
impl<'a> Unpin for MemLowerContext<'a>
impl<'a> UnsafeUnpin for MemLowerContext<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more