summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/include/llvm/IR/Value.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/include/llvm/IR/Value.h')
-rw-r--r--contrib/llvm/include/llvm/IR/Value.h63
1 files changed, 31 insertions, 32 deletions
diff --git a/contrib/llvm/include/llvm/IR/Value.h b/contrib/llvm/include/llvm/IR/Value.h
index f3a342d..bdafbbf 100644
--- a/contrib/llvm/include/llvm/IR/Value.h
+++ b/contrib/llvm/include/llvm/IR/Value.h
@@ -18,12 +18,14 @@
#include "llvm/IR/Use.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/Casting.h"
+#include "llvm-c/Types.h"
+#include <cassert>
+#include <iterator>
namespace llvm {
class APInt;
class Argument;
-class AssemblyAnnotationWriter;
class BasicBlock;
class Constant;
class ConstantData;
@@ -41,12 +43,10 @@ class Instruction;
class LLVMContext;
class Module;
class ModuleSlotTracker;
+class raw_ostream;
class StringRef;
class Twine;
class Type;
-class ValueHandleBase;
-class ValueSymbolTable;
-class raw_ostream;
template<typename ValueTy> class StringMapEntry;
typedef StringMapEntry<Value*> ValueName;
@@ -77,6 +77,7 @@ class Value {
const unsigned char SubclassID; // Subclass identifier (for isa/dyn_cast)
unsigned char HasValueHandle : 1; // Has a ValueHandle pointing to this?
+
protected:
/// \brief Hold subclass data that can be dropped.
///
@@ -134,6 +135,7 @@ private:
U = U->getNext();
return *this;
}
+
use_iterator_impl operator++(int) { // Postincrement
auto tmp = *this;
++*this;
@@ -160,7 +162,7 @@ private:
friend class Value;
public:
- user_iterator_impl() {}
+ user_iterator_impl() = default;
bool operator==(const user_iterator_impl &x) const { return UI == x.UI; }
bool operator!=(const user_iterator_impl &x) const { return !operator==(x); }
@@ -172,6 +174,7 @@ private:
++UI;
return *this;
}
+
user_iterator_impl operator++(int) { // Postincrement
auto tmp = *this;
++*this;
@@ -192,12 +195,12 @@ private:
Use &getUse() const { return *UI; }
};
- void operator=(const Value &) = delete;
- Value(const Value &) = delete;
-
protected:
Value(Type *Ty, unsigned scid);
+
public:
+ Value(const Value &) = delete;
+ void operator=(const Value &) = delete;
virtual ~Value();
/// \brief Support for debugging, callable in GDB: V->dump()
@@ -236,13 +239,15 @@ public:
private:
void destroyValueName();
+ void doRAUW(Value *New, bool NoMetadata);
void setNameImpl(const Twine &Name);
public:
/// \brief Return a constant reference to the value's name.
///
- /// This is cheap and guaranteed to return the same reference as long as the
- /// value is not modified.
+ /// This guaranteed to return the same reference as long as the value is not
+ /// modified. If the value has a name, this does a hashtable lookup, so it's
+ /// not free.
StringRef getName() const;
/// \brief Change the name of the value.
@@ -252,7 +257,6 @@ public:
/// \param Name The new name; or "" if the value's name should be removed.
void setName(const Twine &Name);
-
/// \brief Transfer the name from V to this value.
///
/// After taking V's name, sets V's name to empty.
@@ -267,6 +271,12 @@ public:
/// guaranteed to be empty.
void replaceAllUsesWith(Value *V);
+ /// \brief Change non-metadata uses of this to point to a new Value.
+ ///
+ /// Go through the uses list for this definition and make each use point to
+ /// "V" instead of "this". This function skips metadata entries in the list.
+ void replaceNonMetadataUsesWith(Value *V);
+
/// replaceUsesOutsideBlock - Go through the uses list for this definition and
/// make each use point to "V" instead of "this" when the use is outside the
/// block. 'This's use list is expected to have at least one element.
@@ -442,17 +452,18 @@ public:
return SubclassOptionalData == V->SubclassOptionalData;
}
- /// \brief Clear any optional flags not set in the given Value.
- void intersectOptionalDataWith(const Value *V) {
- SubclassOptionalData &= V->SubclassOptionalData;
- }
-
/// \brief Return true if there is a value handle associated with this value.
bool hasValueHandle() const { return HasValueHandle; }
/// \brief Return true if there is metadata referencing this value.
bool isUsedByMetadata() const { return IsUsedByMD; }
+ /// \brief Return true if this value is a swifterror value.
+ ///
+ /// swifterror values can be either a function argument or an alloca with a
+ /// swifterror attribute.
+ bool isSwiftError() const;
+
/// \brief Strip off pointer casts, all-zero GEPs, and aliases.
///
/// Returns the original uncasted value. If this is called on a non-pointer
@@ -783,18 +794,6 @@ template <> struct isa_impl<GlobalObject, Value> {
}
};
-// Value* is only 4-byte aligned.
-template<>
-class PointerLikeTypeTraits<Value*> {
- typedef Value* PT;
-public:
- static inline void *getAsVoidPointer(PT P) { return P; }
- static inline PT getFromVoidPointer(void *P) {
- return static_cast<PT>(P);
- }
- enum { NumLowBitsAvailable = 2 };
-};
-
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_ISA_CONVERSION_FUNCTIONS(Value, LLVMValueRef)
@@ -805,9 +804,9 @@ inline Value **unwrap(LLVMValueRef *Vals) {
template<typename T>
inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
-#ifdef DEBUG
+#ifndef NDEBUG
for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I)
- cast<T>(*I);
+ unwrap<T>(*I); // For side effect of calling assert on invalid usage.
#endif
(void)Length;
return reinterpret_cast<T**>(Vals);
@@ -817,6 +816,6 @@ inline LLVMValueRef *wrap(const Value **Vals) {
return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
}
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_VALUE_H
OpenPOWER on IntegriCloud