#define LLVM_IR_CONSTANT_H
#include "llvm/IR/User.h"
+#include "llvm/IR/Value.h"
+#include "llvm/Support/Casting.h"
namespace llvm {
- class APInt;
- template<typename T> class SmallVectorImpl;
+class APInt;
/// This is an important base class in LLVM. It provides the common facilities
/// of all constant values in an LLVM program. A constant is a value that is
/// don't have to worry about the lifetime of the objects.
/// @brief LLVM Constant Representation
class Constant : public User {
- void operator=(const Constant &) = delete;
- Constant(const Constant &) = delete;
void anchor() override;
protected:
: User(ty, vty, Ops, NumOps) {}
public:
+ void operator=(const Constant &) = delete;
+ Constant(const Constant &) = delete;
+
/// Return true if this is the value that would be returned by getNullValue.
bool isNullValue() const;
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_CONSTANT_H
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/OperandTraits.h"
+#include "llvm/IR/User.h"
+#include "llvm/IR/Value.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
namespace llvm {
class ArrayType;
class IntegerType;
-class StructType;
class PointerType;
-class VectorType;
class SequentialType;
-
-struct ConstantExprKeyType;
+class StructType;
+class VectorType;
template <class ConstantClass> struct ConstantAggrKeyType;
/// Base class for constants with no operands.
/// Since they can be in use by unrelated modules (and are never based on
/// GlobalValues), it never makes sense to RAUW them.
class ConstantData : public Constant {
+ friend class Constant;
+
void anchor() override;
- void *operator new(size_t, unsigned) = delete;
- ConstantData() = delete;
- ConstantData(const ConstantData &) = delete;
- friend class Constant;
Value *handleOperandChangeImpl(Value *From, Value *To) {
llvm_unreachable("Constant data does not have operands!");
}
protected:
explicit ConstantData(Type *Ty, ValueTy VT) : Constant(Ty, VT, nullptr, 0) {}
+
void *operator new(size_t s) { return User::operator new(s, 0); }
public:
+ ConstantData() = delete;
+ ConstantData(const ConstantData &) = delete;
+
+ void *operator new(size_t, unsigned) = delete;
+
/// Methods to support type inquiry through isa, cast, and dyn_cast.
static bool classof(const Value *V) {
return V->getValueID() >= ConstantDataFirstVal &&
/// represents both boolean and integral constants.
/// @brief Class for constant integers.
class ConstantInt final : public ConstantData {
- void anchor() override;
- ConstantInt(const ConstantInt &) = delete;
- ConstantInt(IntegerType *Ty, const APInt& V);
+ friend class Constant;
+
APInt Val;
- friend class Constant;
+ ConstantInt(IntegerType *Ty, const APInt& V);
+
+ void anchor() override;
void destroyConstantImpl();
public:
+ ConstantInt(const ConstantInt &) = delete;
+
static ConstantInt *getTrue(LLVMContext &Context);
static ConstantInt *getFalse(LLVMContext &Context);
static Constant *getTrue(Type *Ty);
}
};
-
//===----------------------------------------------------------------------===//
/// ConstantFP - Floating Point Values [float, double]
///
class ConstantFP final : public ConstantData {
- APFloat Val;
- void anchor() override;
- ConstantFP(const ConstantFP &) = delete;
-
friend class Constant;
- void destroyConstantImpl();
+
+ APFloat Val;
ConstantFP(Type *Ty, const APFloat& V);
+ void anchor() override;
+ void destroyConstantImpl();
+
public:
+ ConstantFP(const ConstantFP &) = delete;
+
/// Floating point negation must be implemented with f(x) = -0.0 - x. This
/// method returns the negative zero constant for floating point or vector
/// floating point types; for all other types, it returns the null value.
FV.convert(Val.getSemantics(), APFloat::rmNearestTiesToEven, &ignored);
return isExactlyValue(FV);
}
+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V) {
return V->getValueID() == ConstantFPVal;
/// All zero aggregate value
///
class ConstantAggregateZero final : public ConstantData {
- ConstantAggregateZero(const ConstantAggregateZero &) = delete;
-
friend class Constant;
- void destroyConstantImpl();
explicit ConstantAggregateZero(Type *Ty)
: ConstantData(Ty, ConstantAggregateZeroVal) {}
+ void destroyConstantImpl();
+
public:
+ ConstantAggregateZero(const ConstantAggregateZero &) = delete;
+
static ConstantAggregateZero *get(Type *Ty);
/// If this CAZ has array or vector type, return a zero with the right element
class ConstantArray final : public ConstantAggregate {
friend struct ConstantAggrKeyType<ConstantArray>;
friend class Constant;
- void destroyConstantImpl();
- Value *handleOperandChangeImpl(Value *From, Value *To);
ConstantArray(ArrayType *T, ArrayRef<Constant *> Val);
+ void destroyConstantImpl();
+ Value *handleOperandChangeImpl(Value *From, Value *To);
+
public:
// ConstantArray accessors
static Constant *get(ArrayType *T, ArrayRef<Constant*> V);
class ConstantStruct final : public ConstantAggregate {
friend struct ConstantAggrKeyType<ConstantStruct>;
friend class Constant;
- void destroyConstantImpl();
- Value *handleOperandChangeImpl(Value *From, Value *To);
ConstantStruct(StructType *T, ArrayRef<Constant *> Val);
+ void destroyConstantImpl();
+ Value *handleOperandChangeImpl(Value *From, Value *To);
+
public:
// ConstantStruct accessors
static Constant *get(StructType *T, ArrayRef<Constant*> V);
}
};
-
//===----------------------------------------------------------------------===//
/// Constant Vector Declarations
///
class ConstantVector final : public ConstantAggregate {
friend struct ConstantAggrKeyType<ConstantVector>;
friend class Constant;
- void destroyConstantImpl();
- Value *handleOperandChangeImpl(Value *From, Value *To);
ConstantVector(VectorType *T, ArrayRef<Constant *> Val);
+ void destroyConstantImpl();
+ Value *handleOperandChangeImpl(Value *From, Value *To);
+
public:
// ConstantVector accessors
static Constant *get(ArrayRef<Constant*> V);
/// A constant pointer value that points to null
///
class ConstantPointerNull final : public ConstantData {
- ConstantPointerNull(const ConstantPointerNull &) = delete;
-
friend class Constant;
- void destroyConstantImpl();
explicit ConstantPointerNull(PointerType *T)
: ConstantData(T, Value::ConstantPointerNullVal) {}
+ void destroyConstantImpl();
+
public:
+ ConstantPointerNull(const ConstantPointerNull &) = delete;
+
/// Static factory methods - Return objects of the specified value
static ConstantPointerNull *get(PointerType *T);
///
class ConstantDataSequential : public ConstantData {
friend class LLVMContextImpl;
+ friend class Constant;
+
/// A pointer to the bytes underlying this constant (which is owned by the
/// uniquing StringMap).
const char *DataElements;
/// element array of i8, or a 1-element array of i32. They'll both end up in
/// the same StringMap bucket, linked up.
ConstantDataSequential *Next;
- ConstantDataSequential(const ConstantDataSequential &) = delete;
- friend class Constant;
void destroyConstantImpl();
protected:
static Constant *getImpl(StringRef Bytes, Type *Ty);
public:
+ ConstantDataSequential(const ConstantDataSequential &) = delete;
+
/// Return true if a ConstantDataSequential can be formed with a vector or
/// array of the specified element type.
/// ConstantDataArray only works with normal float and int types that are
return V->getValueID() == ConstantDataArrayVal ||
V->getValueID() == ConstantDataVectorVal;
}
+
private:
const char *getElementPointer(unsigned Elt) const;
};
/// stores all of the elements of the constant as densely packed data, instead
/// of as Value*'s.
class ConstantDataArray final : public ConstantDataSequential {
- void *operator new(size_t, unsigned) = delete;
- ConstantDataArray(const ConstantDataArray &) = delete;
- void anchor() override;
friend class ConstantDataSequential;
+
explicit ConstantDataArray(Type *ty, const char *Data)
: ConstantDataSequential(ty, ConstantDataArrayVal, Data) {}
+
/// Allocate space for exactly zero operands.
void *operator new(size_t s) {
return User::operator new(s, 0);
}
+ void anchor() override;
+
public:
+ ConstantDataArray(const ConstantDataArray &) = delete;
+
+ void *operator new(size_t, unsigned) = delete;
+
/// get() constructors - Return a constant with array type with an element
/// count and element type matching the ArrayRef passed in. Note that this
/// can return a ConstantAggregateZero object.
/// stores all of the elements of the constant as densely packed data, instead
/// of as Value*'s.
class ConstantDataVector final : public ConstantDataSequential {
- void *operator new(size_t, unsigned) = delete;
- ConstantDataVector(const ConstantDataVector &) = delete;
- void anchor() override;
friend class ConstantDataSequential;
+
explicit ConstantDataVector(Type *ty, const char *Data)
: ConstantDataSequential(ty, ConstantDataVectorVal, Data) {}
+
// allocate space for exactly zero operands.
void *operator new(size_t s) {
return User::operator new(s, 0);
}
+ void anchor() override;
+
public:
+ ConstantDataVector(const ConstantDataVector &) = delete;
+
+ void *operator new(size_t, unsigned) = delete;
+
/// get() constructors - Return a constant with vector type with an element
/// count and element type matching the ArrayRef passed in. Note that this
/// can return a ConstantAggregateZero object.
/// A constant token which is empty
///
class ConstantTokenNone final : public ConstantData {
- ConstantTokenNone(const ConstantTokenNone &) = delete;
-
friend class Constant;
- void destroyConstantImpl();
explicit ConstantTokenNone(LLVMContext &Context)
: ConstantData(Type::getTokenTy(Context), ConstantTokenNoneVal) {}
+ void destroyConstantImpl();
+
public:
+ ConstantTokenNone(const ConstantTokenNone &) = delete;
+
/// Return the ConstantTokenNone.
static ConstantTokenNone *get(LLVMContext &Context);
/// The address of a basic block.
///
class BlockAddress final : public Constant {
- void *operator new(size_t, unsigned) = delete;
- void *operator new(size_t s) { return User::operator new(s, 2); }
+ friend class Constant;
+
BlockAddress(Function *F, BasicBlock *BB);
- friend class Constant;
+ void *operator new(size_t s) { return User::operator new(s, 2); }
+
void destroyConstantImpl();
Value *handleOperandChangeImpl(Value *From, Value *To);
public:
+ void *operator new(size_t, unsigned) = delete;
+
/// Return a BlockAddress for the specified function and basic block.
static BlockAddress *get(Function *F, BasicBlock *BB);
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BlockAddress, Value)
-
//===----------------------------------------------------------------------===//
/// A constant value that is initialized with an expression using
/// other constant values.
/// maintained in the Value::SubclassData field.
class ConstantExpr : public Constant {
friend struct ConstantExprKeyType;
-
friend class Constant;
+
void destroyConstantImpl();
Value *handleOperandChangeImpl(Value *From, Value *To);
static Constant *getNSWNeg(Constant *C) { return getNeg(C, false, true); }
static Constant *getNUWNeg(Constant *C) { return getNeg(C, true, false); }
+
static Constant *getNSWAdd(Constant *C1, Constant *C2) {
return getAdd(C1, C2, false, true);
}
+
static Constant *getNUWAdd(Constant *C1, Constant *C2) {
return getAdd(C1, C2, true, false);
}
+
static Constant *getNSWSub(Constant *C1, Constant *C2) {
return getSub(C1, C2, false, true);
}
+
static Constant *getNUWSub(Constant *C1, Constant *C2) {
return getSub(C1, C2, true, false);
}
+
static Constant *getNSWMul(Constant *C1, Constant *C2) {
return getMul(C1, C2, false, true);
}
+
static Constant *getNUWMul(Constant *C1, Constant *C2) {
return getMul(C1, C2, true, false);
}
+
static Constant *getNSWShl(Constant *C1, Constant *C2) {
return getShl(C1, C2, false, true);
}
+
static Constant *getNUWShl(Constant *C1, Constant *C2) {
return getShl(C1, C2, true, false);
}
+
static Constant *getExactSDiv(Constant *C1, Constant *C2) {
return getSDiv(C1, C2, true);
}
+
static Constant *getExactUDiv(Constant *C1, Constant *C2) {
return getUDiv(C1, C2, true);
}
+
static Constant *getExactAShr(Constant *C1, Constant *C2) {
return getAShr(C1, C2, true);
}
+
static Constant *getExactLShr(Constant *C1, Constant *C2) {
return getLShr(C1, C2, true);
}
/// LangRef.html#undefvalues for details.
///
class UndefValue final : public ConstantData {
- UndefValue(const UndefValue &) = delete;
-
friend class Constant;
- void destroyConstantImpl();
explicit UndefValue(Type *T) : ConstantData(T, UndefValueVal) {}
+ void destroyConstantImpl();
+
public:
+ UndefValue(const UndefValue &) = delete;
+
/// Static factory methods - Return an 'undef' object of the specified type.
static UndefValue *get(Type *T);
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_CONSTANTS_H
#ifndef LLVM_IR_FUNCTION_H
#define LLVM_IR_FUNCTION_H
+#include "llvm/ADT/ilist_node.h"
#include "llvm/ADT/iterator_range.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/GlobalObject.h"
+#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/OperandTraits.h"
+#include "llvm/IR/SymbolTableListTraits.h"
+#include "llvm/IR/Value.h"
#include "llvm/Support/Compiler.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <string>
namespace llvm {
template <typename T> class Optional;
+class AssemblyAnnotationWriter;
class FunctionType;
class LLVMContext;
class DISubprogram;
if (hasLazyArguments())
BuildLazyArguments();
}
- void BuildLazyArguments() const;
- Function(const Function&) = delete;
- void operator=(const Function&) = delete;
+ void BuildLazyArguments() const;
/// Function ctor - If the (optional) Module argument is specified, the
/// function is automatically inserted into the end of the function list for
const Twine &N = "", Module *M = nullptr);
public:
+ Function(const Function&) = delete;
+ void operator=(const Function&) = delete;
+ ~Function() override;
+
static Function *Create(FunctionType *Ty, LinkageTypes Linkage,
const Twine &N = "", Module *M = nullptr) {
return new Function(Ty, Linkage, N, M);
}
- ~Function() override;
-
// Provide fast operand accessors.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
/// Returns the type of the ret val.
CheckLazyArguments();
return ArgumentList;
}
+
static ArgumentListType Function::*getSublistAccess(Argument*) {
return &Function::ArgumentList;
}
const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
BasicBlockListType &getBasicBlockList() { return BasicBlocks; }
+
static BasicBlockListType Function::*getSublistAccess(BasicBlock*) {
return &Function::BasicBlocks;
}
CheckLazyArguments();
return ArgumentList.begin();
}
+
arg_iterator arg_end() {
CheckLazyArguments();
return ArgumentList.end();
iterator_range<arg_iterator> args() {
return make_range(arg_begin(), arg_end());
}
-
iterator_range<const_arg_iterator> args() const {
return make_range(arg_begin(), arg_end());
}
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(Function, Value)
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_FUNCTION_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/PointerUnion.h"
-#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/ilist_node.h"
#include "llvm/ADT/iterator_range.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Value.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <iterator>
+#include <memory>
+#include <string>
#include <type_traits>
+#include <utility>
namespace llvm {
-class LLVMContext;
class Module;
class ModuleSlotTracker;
: SubclassID(ID), Storage(Storage), SubclassData16(0), SubclassData32(0) {
static_assert(sizeof(*this) == 8, "Metdata fields poorly packed");
}
+
~Metadata() = default;
/// \brief Default handling of a changed operand, which asserts.
public:
ReplaceableMetadataImpl(LLVMContext &Context)
: Context(Context), NextIndex(0) {}
+
~ReplaceableMetadataImpl() {
assert(UseMap.empty() && "Cannot destroy in-use replaceable metadata");
}
: Metadata(ID, Uniqued), ReplaceableMetadataImpl(V->getContext()), V(V) {
assert(V && "Expected valid value");
}
+
~ValueAsMetadata() = default;
public:
static ConstantAsMetadata *get(Constant *C) {
return ValueAsMetadata::getConstant(C);
}
+
static ConstantAsMetadata *getIfExists(Constant *C) {
return ValueAsMetadata::getConstantIfExists(C);
}
static LocalAsMetadata *get(Value *Local) {
return ValueAsMetadata::getLocal(Local);
}
+
static LocalAsMetadata *getIfExists(Value *Local) {
return ValueAsMetadata::getLocalIfExists(Local);
}
namespace mdconst {
namespace detail {
+
template <class T> T &make();
template <class T, class Result> struct HasDereference {
typedef char Yes[1];
static const bool value = std::is_base_of<Constant, V>::value &&
std::is_convertible<M, const Metadata &>::value;
};
+
} // end namespace detail
/// \brief Check whether Metadata has a Value.
class MDString : public Metadata {
friend class StringMapEntry<MDString>;
- MDString(const MDString &) = delete;
- MDString &operator=(MDString &&) = delete;
- MDString &operator=(const MDString &) = delete;
-
StringMapEntry<MDString> *Entry;
MDString() : Metadata(MDStringKind, Uniqued), Entry(nullptr) {}
public:
+ MDString(const MDString &) = delete;
+ MDString &operator=(MDString &&) = delete;
+ MDString &operator=(const MDString &) = delete;
+
static MDString *get(LLVMContext &Context, StringRef Str);
static MDString *get(LLVMContext &Context, const char *Str) {
return get(Context, Str ? StringRef(Str) : StringRef());
return AAMDNodes(DenseMapInfo<MDNode *>::getEmptyKey(),
nullptr, nullptr);
}
+
static inline AAMDNodes getTombstoneKey() {
return AAMDNodes(DenseMapInfo<MDNode *>::getTombstoneKey(),
nullptr, nullptr);
}
+
static unsigned getHashValue(const AAMDNodes &Val) {
return DenseMapInfo<MDNode *>::getHashValue(Val.TBAA) ^
DenseMapInfo<MDNode *>::getHashValue(Val.Scope) ^
DenseMapInfo<MDNode *>::getHashValue(Val.NoAlias);
}
+
static bool isEqual(const AAMDNodes &LHS, const AAMDNodes &RHS) {
return LHS == RHS;
}
///
/// In particular, this is used by \a MDNode.
class MDOperand {
+ Metadata *MD = nullptr;
+
+public:
+ MDOperand() = default;
MDOperand(MDOperand &&) = delete;
MDOperand(const MDOperand &) = delete;
MDOperand &operator=(MDOperand &&) = delete;
MDOperand &operator=(const MDOperand &) = delete;
-
- Metadata *MD;
-
-public:
- MDOperand() : MD(nullptr) {}
~MDOperand() { untrack(); }
Metadata *get() const { return MD; }
MetadataTracking::track(MD);
}
}
+
void untrack() {
assert(static_cast<void *>(this) == &MD && "Expected same address");
if (MD)
class ContextAndReplaceableUses {
PointerUnion<LLVMContext *, ReplaceableMetadataImpl *> Ptr;
- ContextAndReplaceableUses() = delete;
- ContextAndReplaceableUses(ContextAndReplaceableUses &&) = delete;
- ContextAndReplaceableUses(const ContextAndReplaceableUses &) = delete;
- ContextAndReplaceableUses &operator=(ContextAndReplaceableUses &&) = delete;
- ContextAndReplaceableUses &
- operator=(const ContextAndReplaceableUses &) = delete;
-
public:
ContextAndReplaceableUses(LLVMContext &Context) : Ptr(&Context) {}
ContextAndReplaceableUses(
: Ptr(ReplaceableUses.release()) {
assert(getReplaceableUses() && "Expected non-null replaceable uses");
}
+ ContextAndReplaceableUses() = delete;
+ ContextAndReplaceableUses(ContextAndReplaceableUses &&) = delete;
+ ContextAndReplaceableUses(const ContextAndReplaceableUses &) = delete;
+ ContextAndReplaceableUses &operator=(ContextAndReplaceableUses &&) = delete;
+ ContextAndReplaceableUses &
+ operator=(const ContextAndReplaceableUses &) = delete;
~ContextAndReplaceableUses() { delete getReplaceableUses(); }
operator LLVMContext &() { return getContext(); }
bool hasReplaceableUses() const {
return Ptr.is<ReplaceableMetadataImpl *>();
}
+
LLVMContext &getContext() const {
if (hasReplaceableUses())
return getReplaceableUses()->getContext();
return *Ptr.get<LLVMContext *>();
}
+
ReplaceableMetadataImpl *getReplaceableUses() const {
if (hasReplaceableUses())
return Ptr.get<ReplaceableMetadataImpl *>();
friend class ReplaceableMetadataImpl;
friend class LLVMContextImpl;
- MDNode(const MDNode &) = delete;
- void operator=(const MDNode &) = delete;
- void *operator new(size_t) = delete;
-
unsigned NumOperands;
unsigned NumUnresolved;
}
public:
+ MDNode(const MDNode &) = delete;
+ void operator=(const MDNode &) = delete;
+ void *operator new(size_t) = delete;
+
static inline MDTuple *get(LLVMContext &Context, ArrayRef<Metadata *> MDs);
static inline MDTuple *getIfExists(LLVMContext &Context,
ArrayRef<Metadata *> MDs);
op_iterator op_begin() const {
return const_cast<MDNode *>(this)->mutable_begin();
}
+
op_iterator op_end() const {
return const_cast<MDNode *>(this)->mutable_end();
}
+
op_range operands() const { return op_range(op_begin(), op_end()); }
const MDOperand &getOperand(unsigned I) const {
: MDNode(C, MDTupleKind, Storage, Vals) {
setHash(Hash);
}
+
~MDTuple() { dropAllReferences(); }
void setHash(unsigned Hash) { SubclassData32 = Hash; }
static MDTuple *get(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
return getImpl(Context, MDs, Uniqued);
}
+
static MDTuple *getIfExists(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
return getImpl(Context, MDs, Uniqued, /* ShouldCreate */ false);
}
MDTuple *MDNode::get(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
return MDTuple::get(Context, MDs);
}
+
MDTuple *MDNode::getIfExists(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
return MDTuple::getIfExists(Context, MDs);
}
+
MDTuple *MDNode::getDistinct(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
return MDTuple::getDistinct(Context, MDs);
}
+
TempMDTuple MDNode::getTemporary(LLVMContext &Context,
ArrayRef<Metadata *> MDs) {
return MDTuple::getTemporary(Context, MDs);
public:
TypedMDOperandIterator() = default;
explicit TypedMDOperandIterator(MDNode::op_iterator I) : I(I) {}
+
T *operator*() const { return cast_or_null<T>(*I); }
+
TypedMDOperandIterator &operator++() {
++I;
return *this;
}
+
TypedMDOperandIterator operator++(int) {
TypedMDOperandIterator Temp(*this);
++I;
return Temp;
}
+
bool operator==(const TypedMDOperandIterator &X) const { return I == X.I; }
bool operator!=(const TypedMDOperandIterator &X) const { return I != X.I; }
};
Metadata **Use = nullptr;
- DistinctMDOperandPlaceholder() = delete;
- DistinctMDOperandPlaceholder(DistinctMDOperandPlaceholder &&) = delete;
- DistinctMDOperandPlaceholder(const DistinctMDOperandPlaceholder &) = delete;
-
public:
explicit DistinctMDOperandPlaceholder(unsigned ID)
: Metadata(DistinctMDOperandPlaceholderKind, Distinct) {
SubclassData32 = ID;
}
+ DistinctMDOperandPlaceholder() = delete;
+ DistinctMDOperandPlaceholder(DistinctMDOperandPlaceholder &&) = delete;
+ DistinctMDOperandPlaceholder(const DistinctMDOperandPlaceholder &) = delete;
+
~DistinctMDOperandPlaceholder() {
if (Use)
*Use = nullptr;
class NamedMDNode : public ilist_node<NamedMDNode> {
friend class LLVMContextImpl;
friend class Module;
- NamedMDNode(const NamedMDNode &) = delete;
std::string Name;
Module *Parent;
template<class T1, class T2>
class op_iterator_impl :
public std::iterator<std::bidirectional_iterator_tag, T2> {
- const NamedMDNode *Node;
- unsigned Idx;
+ const NamedMDNode *Node = nullptr;
+ unsigned Idx = 0;
+
op_iterator_impl(const NamedMDNode *N, unsigned i) : Node(N), Idx(i) { }
friend class NamedMDNode;
public:
- op_iterator_impl() : Node(nullptr), Idx(0) { }
+ op_iterator_impl() = default;
bool operator==(const op_iterator_impl &o) const { return Idx == o.Idx; }
bool operator!=(const op_iterator_impl &o) const { return Idx != o.Idx; }
+
op_iterator_impl &operator++() {
++Idx;
return *this;
}
+
op_iterator_impl operator++(int) {
op_iterator_impl tmp(*this);
operator++();
return tmp;
}
+
op_iterator_impl &operator--() {
--Idx;
return *this;
}
+
op_iterator_impl operator--(int) {
op_iterator_impl tmp(*this);
operator--();
};
public:
+ NamedMDNode(const NamedMDNode &) = delete;
+ ~NamedMDNode();
+
/// \brief Drop all references and remove the node from parent module.
void eraseFromParent();
/// Drop all references to this node's operands.
void clearOperands();
- ~NamedMDNode();
-
/// \brief Get the module that holds this named metadata collection.
inline Module *getParent() { return Parent; }
inline const Module *getParent() const { return Parent; }
}
};
-} // end llvm namespace
+} // end namespace llvm
#endif // LLVM_IR_METADATA_H
#include "llvm/ADT/iterator.h"
#include "llvm/ADT/iterator_range.h"
+#include "llvm/IR/Use.h"
#include "llvm/IR/Value.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <iterator>
namespace llvm {
struct OperandTraits;
class User : public Value {
- User(const User &) = delete;
template <unsigned>
friend struct HungoffOperandTraits;
+
virtual void anchor();
LLVM_ATTRIBUTE_ALWAYS_INLINE inline static void *
void growHungoffUses(unsigned N, bool IsPhi = false);
public:
- ~User() override {
- }
+ User(const User &) = delete;
+ ~User() override = default;
+
/// \brief Free memory allocated for User and Use objects.
void operator delete(void *Usr);
/// \brief Placement delete - required by std, but never called.
void operator delete(void*, unsigned, bool) {
llvm_unreachable("Constructor throws?");
}
+
protected:
template <int Idx, typename U> static Use &OpFrom(const U *that) {
return Idx < 0
template <int Idx> const Use &Op() const {
return OpFrom<Idx>(this);
}
+
private:
Use *&getHungOffOperands() { return *(reinterpret_cast<Use **>(this) - 1); }
"Setting operand list only required for hung off uses");
getHungOffOperands() = NewList;
}
+
public:
Use *getOperandList() {
return HasHungOffUses ? getHungOffOperands() : getIntrusiveOperands();
const Use *getOperandList() const {
return const_cast<User *>(this)->getOperandList();
}
+
Value *getOperand(unsigned i) const {
assert(i < NumUserOperands && "getOperand() out of range!");
return getOperandList()[i];
}
+
void setOperand(unsigned i, Value *Val) {
assert(i < NumUserOperands && "setOperand() out of range!");
assert((!isa<Constant>((const Value*)this) ||
"Cannot mutate a constant with setOperand!");
getOperandList()[i] = Val;
}
+
const Use &getOperandUse(unsigned i) const {
assert(i < NumUserOperands && "getOperandUse() out of range!");
return getOperandList()[i];
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_USER_H
#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;
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;
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.
///
U = U->getNext();
return *this;
}
+
use_iterator_impl operator++(int) { // Postincrement
auto tmp = *this;
++*this;
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); }
++UI;
return *this;
}
+
user_iterator_impl operator++(int) { // Postincrement
auto tmp = *this;
++*this;
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()
/// \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.
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 };
};
return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
}
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_VALUE_H