13#ifndef LLVM_IR_VALUEHANDLE_H
14#define LLVM_IR_VALUEHANDLE_H
47 AddToExistingUseList(
RHS.getPrevPtr());
53 AddToExistingUseList(
RHS.getPrevPtr());
54 RHS.RemoveFromUseList();
64 void setValPtr(
Value *V) { Val = V; }
68 : PrevPair(nullptr, Kind) {}
70 : PrevPair(nullptr, Kind), Val(V) {
93 return RHS.getValPtr();
96 setValPtr(
RHS.getValPtr());
98 AddToExistingUseList(
RHS.getPrevPtr());
106 RHS.RemoveFromUseList();
113 setValPtr(
RHS.getValPtr());
115 AddToExistingUseList(
RHS.getPrevPtr());
116 RHS.RemoveFromUseList();
125 assert(V &&
"Dereferencing deleted ValueHandle");
290template <
typename ValueTy>
292#
if LLVM_ENABLE_ABI_BREAKING_CHECKS
298#if LLVM_ENABLE_ABI_BREAKING_CHECKS
303 Value *getRawValPtr()
const {
return ThePtr; }
304 void setRawValPtr(
Value *
P) { ThePtr =
P; }
307 static Value *GetAsValue(
Value *V) {
return V; }
308 static Value *GetAsValue(
const Value *V) {
return const_cast<Value*
>(V); }
310 ValueTy *getValPtr()
const {
return static_cast<ValueTy *
>(getRawValPtr()); }
311 void setValPtr(ValueTy *
P) { setRawValPtr(GetAsValue(
P)); }
314#if LLVM_ENABLE_ABI_BREAKING_CHECKS
326 operator ValueTy*()
const {
335 setValPtr(
RHS.getValPtr());
338#if LLVM_ENABLE_ABI_BREAKING_CHECKS
345 ThePtr = std::exchange(
RHS.ThePtr,
nullptr);
380 assert(InnerHandle.pointsToAliveValue() &&
381 "TrackingVH must be non-null and valid on dereference!");
388 "Tracked Value was replaced by one with an invalid type!");
407 operator ValueTy*()
const {
428 virtual void anchor();
488template <
typename ValueTy>
490#
if LLVM_ENABLE_ABI_BREAKING_CHECKS
497 static Value *GetAsValue(
Value *V) {
return V; }
498 static Value *GetAsValue(
const Value *V) {
return const_cast<Value *
>(V); }
500#if LLVM_ENABLE_ABI_BREAKING_CHECKS
507 bool Poisoned =
false;
513 void deleted()
override {
514 assert(!Poisoned &&
"Tried to delete an already poisoned handle!");
520 void allUsesReplacedWith(
Value *)
override {
521 assert(!Poisoned &&
"Tried to RAUW an already poisoned handle!");
526 Value *ThePtr =
nullptr;
528 Value *getRawValPtr()
const {
return ThePtr; }
529 void setRawValPtr(
Value *
P) { ThePtr =
P; }
532 ValueTy *getValPtr()
const {
533#if LLVM_ENABLE_ABI_BREAKING_CHECKS
534 assert(!Poisoned &&
"Accessed a poisoned value handle!");
536 return static_cast<ValueTy *
>(getRawValPtr());
538 void setValPtr(ValueTy *
P) { setRawValPtr(GetAsValue(
P)); }
542#if LLVM_ENABLE_ABI_BREAKING_CHECKS
549 ValueHandleBase::setValPtr(
RHS.getRawValPtr());
551 setRawValPtr(
RHS.getRawValPtr());
566 ValueHandleBase::setValPtr(
RHS.getRawValPtr());
570 Poisoned =
RHS.Poisoned;
577 operator ValueTy *()
const {
return getValPtr(); }
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines DenseMapInfo traits for DenseMap.
This file defines the PointerIntPair class.
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
Value handle that asserts if the Value is deleted.
ValueTy * operator=(ValueTy *RHS)
ValueTy & operator*() const
ValueTy * operator=(const AssertingVH< ValueTy > &RHS)
ValueTy * operator->() const
AssertingVH(const AssertingVH &)=default
ValueTy * operator=(AssertingVH< ValueTy > &&RHS)
AssertingVH(AssertingVH &&RHS)
Value handle with callbacks on RAUW and destruction.
virtual void allUsesReplacedWith(Value *)
Callback for Value RAUW.
CallbackVH(const Value *P)
CallbackVH & operator=(const CallbackVH &)=default
CallbackVH(const CallbackVH &)=default
virtual void deleted()
Callback for Value destruction.
PointerIntPair - This class implements a pair of a pointer and small integer.
PointerTy getPointer() const
Value handle that poisons itself if the Value is deleted.
ValueTy & operator*() const
ValueTy * operator->() const
ValueTy * operator->() const
ValueTy * getValPtr() const
static Value * GetAsValue(const Value *V)
static Value * GetAsValue(Value *V)
ValueTy & operator*() const
void setValPtr(ValueTy *P)
ValueTy * operator=(ValueTy *RHS)
This is the common base class of value handles.
Value & operator*() const
ValueHandleBase(HandleBaseKind Kind, Value *V)
static bool isValid(Value *V)
LLVM_ABI void RemoveFromUseList()
Remove this ValueHandle from its current use list.
ValueHandleBase(HandleBaseKind Kind, ValueHandleBase &&RHS)
Value * operator->() const
Value * operator=(Value *RHS)
Value * operator=(const ValueHandleBase &RHS)
Value * getValPtr() const
Value * operator=(ValueHandleBase &&RHS)
static LLVM_ABI void ValueIsDeleted(Value *V)
void clearValPtr()
Clear the underlying pointer without clearing the use list.
ValueHandleBase(HandleBaseKind Kind)
static LLVM_ABI void ValueIsRAUWd(Value *Old, Value *New)
HandleBaseKind
This indicates what sub class the handle actually is.
ValueHandleBase(HandleBaseKind Kind, const ValueHandleBase &RHS)
ValueHandleBase(const ValueHandleBase &RHS)
LLVM Value Representation.
Value handle that is nullable, but tries to track the Value.
WeakTrackingVH(const WeakTrackingVH &RHS)
Value * operator=(const ValueHandleBase &RHS)
Value * operator=(Value *RHS)
WeakTrackingVH & operator=(const WeakTrackingVH &RHS)=default
bool pointsToAliveValue() const
A nullable Value handle that is nullable.
WeakVH(const WeakVH &RHS)
WeakVH & operator=(const WeakVH &RHS)=default
Value * operator=(const ValueHandleBase &RHS)
Value * operator=(Value *RHS)
This is an optimization pass for GlobalISel generic memory operations.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
FunctionAddr VTableAddr Next
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Implement std::hash so that hash_code can be used in STL containers.
static bool isEqual(const T *LHS, const PoisoningVH< T > &RHS)
static PoisoningVH< T > getTombstoneKey()
static unsigned getHashValue(const T *Val)
static unsigned getHashValue(const PoisoningVH< T > &Val)
static bool isEqual(const PoisoningVH< T > &LHS, const PoisoningVH< T > &RHS)
static PoisoningVH< T > getEmptyKey()
static bool isEqual(const WeakVH &LHS, const WeakVH &RHS)
static unsigned getHashValue(const WeakVH &Val)
static WeakVH getEmptyKey()
static WeakVH getTombstoneKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
static SimpleType getSimplifiedValue(WeakTrackingVH &WVH)
static SimpleType getSimplifiedValue(WeakVH &WVH)
static SimpleType getSimplifiedValue(const WeakVH &WVH)
Define a template that can be specialized by smart pointers to reflect the fact that they are automat...
static SimpleType & getSimplifiedValue(From &Val)