pub struct OperandRef<'tcx, V> {
pub val: OperandValue<V>,
pub layout: TyAndLayout<'tcx>,
pub move_annotation: Option<Instance<'tcx>>,
}Expand description
An OperandRef is an “SSA” reference to a Rust value, along with
its type.
NOTE: unless you know a value’s type exactly, you should not
generate LLVM opcodes acting on it and instead act via methods,
to avoid nasty edge cases. In particular, using Builder::store
directly is sure to cause problems – use OperandRef::store
instead.
Fields§
§val: OperandValue<V>The value.
layout: TyAndLayout<'tcx>The layout of value, based on its Rust type.
move_annotation: Option<Instance<'tcx>>Annotation for profiler visibility of move/copy operations. When set, the store operation should appear as an inlined call to this function.
Implementations§
Source§impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V>
impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V>
pub fn zero_sized(layout: TyAndLayout<'tcx>) -> OperandRef<'tcx, V>
pub(crate) fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>( bx: &mut Bx, val: ConstValue, ty: Ty<'tcx>, ) -> Self
fn from_const_alloc<Bx: BuilderMethods<'a, 'tcx, Value = V>>( bx: &mut Bx, layout: TyAndLayout<'tcx>, alloc: ConstAllocation<'tcx>, offset: Size, ) -> Self
Sourcepub fn immediate(self) -> V
pub fn immediate(self) -> V
Asserts that this operand refers to a scalar and returns a reference to its value.
Sourcepub fn deref<Cx: CodegenMethods<'tcx>>(self, cx: &Cx) -> PlaceRef<'tcx, V>
pub fn deref<Cx: CodegenMethods<'tcx>>(self, cx: &Cx) -> PlaceRef<'tcx, V>
Asserts that this operand is a pointer (or reference) and returns the place to which it points. (This requires no code to be emitted as we represent places using the pointer to the place.)
This uses [Ty::builtin_deref] to include the type of the place and
assumes the place is aligned to the pointee’s usual ABI alignment.
If you don’t need the type, see OperandValue::pointer_parts
or OperandValue::deref.
Sourcepub fn store_with_annotation<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
self,
bx: &mut Bx,
dest: PlaceRef<'tcx, V>,
)
pub fn store_with_annotation<Bx: BuilderMethods<'a, 'tcx, Value = V>>( self, bx: &mut Bx, dest: PlaceRef<'tcx, V>, )
Store this operand into a place, applying move/copy annotation if present.
This is the preferred method for storing operands, as it automatically applies profiler annotations for tracked move/copy operations.
Sourcepub fn store_with_annotation_and_flags<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
self,
bx: &mut Bx,
dest: PlaceRef<'tcx, V>,
flags: MemFlags,
)
pub fn store_with_annotation_and_flags<Bx: BuilderMethods<'a, 'tcx, Value = V>>( self, bx: &mut Bx, dest: PlaceRef<'tcx, V>, flags: MemFlags, )
Same as store_with_annotation(), but also specify flags for the store.
Sourcepub fn immediate_or_packed_pair<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
self,
bx: &mut Bx,
) -> V
pub fn immediate_or_packed_pair<Bx: BuilderMethods<'a, 'tcx, Value = V>>( self, bx: &mut Bx, ) -> V
If this operand is a Pair, we return an aggregate with the two values.
For other cases, see immediate.
Note: The use of this is discouraged outside cg_llvm, as some other backends don’t natively support packing multiple things into one like this.
Sourcepub fn from_immediate_or_packed_pair<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
bx: &mut Bx,
llval: V,
layout: TyAndLayout<'tcx>,
) -> Self
pub fn from_immediate_or_packed_pair<Bx: BuilderMethods<'a, 'tcx, Value = V>>( bx: &mut Bx, llval: V, layout: TyAndLayout<'tcx>, ) -> Self
If the type is a pair, we return a Pair, otherwise, an Immediate.
Note: The use of this is discouraged outside cg_llvm, as some other backends don’t natively support packing multiple things into one like this.
pub(crate) fn extract_field<Bx: BuilderMethods<'a, 'tcx, Value = V>>( &self, fx: &mut FunctionCx<'a, 'tcx, Bx>, bx: &mut Bx, i: usize, ) -> Self
Sourcepub fn codegen_get_discr<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
self,
fx: &mut FunctionCx<'a, 'tcx, Bx>,
bx: &mut Bx,
cast_to: Ty<'tcx>,
) -> V
pub fn codegen_get_discr<Bx: BuilderMethods<'a, 'tcx, Value = V>>( self, fx: &mut FunctionCx<'a, 'tcx, Bx>, bx: &mut Bx, cast_to: Ty<'tcx>, ) -> V
Obtain the actual discriminant of a value.
Trait Implementations§
Source§impl<'tcx, V: Clone> Clone for OperandRef<'tcx, V>
impl<'tcx, V: Clone> Clone for OperandRef<'tcx, V>
Source§fn clone(&self) -> OperandRef<'tcx, V>
fn clone(&self) -> OperandRef<'tcx, V>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'tcx, V: Copy> Copy for OperandRef<'tcx, V>
Auto Trait Implementations§
impl<'tcx, V> !RefUnwindSafe for OperandRef<'tcx, V>
impl<'tcx, V> !UnwindSafe for OperandRef<'tcx, V>
impl<'tcx, V> DynSend for OperandRef<'tcx, V>where
V: DynSend,
impl<'tcx, V> DynSync for OperandRef<'tcx, V>where
V: DynSync,
impl<'tcx, V> Freeze for OperandRef<'tcx, V>where
V: Freeze,
impl<'tcx, V> Send for OperandRef<'tcx, V>where
V: Send,
impl<'tcx, V> Sync for OperandRef<'tcx, V>where
V: Sync,
impl<'tcx, V> Unpin for OperandRef<'tcx, V>where
V: Unpin,
impl<'tcx, V> UnsafeUnpin for OperandRef<'tcx, V>where
V: UnsafeUnpin,
Blanket Implementations§
Source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]
§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
impl<T> ErasedDestructor for Twhere
T: 'static,
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§impl<K> IntoQueryKey<K> for K
impl<K> IntoQueryKey<K> for K
§fn into_query_key(self) -> K
fn into_query_key(self) -> K
Self to K.
This should always be a very cheap conversion, e.g. LocalDefId::to_def_id.§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
Source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.