aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Constants.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Constants.h')
-rw-r--r--include/llvm/Constants.h42
1 files changed, 37 insertions, 5 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index c69a381..a55c19a 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -22,6 +22,7 @@
#include "llvm/Constant.h"
#include "llvm/Type.h"
+#include "llvm/OperandTraits.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/APFloat.h"
@@ -318,7 +319,6 @@ class ConstantArray : public Constant {
ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
protected:
ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
- ~ConstantArray();
public:
/// get() - Static factory methods - Return objects of the specified value
static Constant *get(const ArrayType *T, const std::vector<Constant*> &);
@@ -336,6 +336,9 @@ public:
/// null termination.
static Constant *get(const std::string &Initializer, bool AddNull = true);
+ /// Transparently provide more efficient getOperand methods.
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
+
/// getType - Specialize the getType() method to always return an ArrayType,
/// which reduces the amount of casting needed in parts of the compiler.
///
@@ -374,6 +377,11 @@ public:
}
};
+template <>
+struct OperandTraits<ConstantArray> : VariadicOperandTraits<> {
+};
+
+DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantArray, Constant)
//===----------------------------------------------------------------------===//
// ConstantStruct - Constant Struct Declarations
@@ -384,7 +392,6 @@ class ConstantStruct : public Constant {
ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
protected:
ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
- ~ConstantStruct();
public:
/// get() - Static factory methods - Return objects of the specified value
///
@@ -396,6 +403,9 @@ public:
return get(std::vector<Constant*>(Vals, Vals+NumVals), Packed);
}
+ /// Transparently provide more efficient getOperand methods.
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
+
/// getType() specialization - Reduce amount of casting...
///
inline const StructType *getType() const {
@@ -419,6 +429,12 @@ public:
}
};
+template <>
+struct OperandTraits<ConstantStruct> : VariadicOperandTraits<> {
+};
+
+DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantStruct, Constant)
+
//===----------------------------------------------------------------------===//
/// ConstantVector - Constant Vector Declarations
///
@@ -428,7 +444,6 @@ class ConstantVector : public Constant {
ConstantVector(const ConstantVector &); // DO NOT IMPLEMENT
protected:
ConstantVector(const VectorType *T, const std::vector<Constant*> &Val);
- ~ConstantVector();
public:
/// get() - Static factory methods - Return objects of the specified value
static Constant *get(const VectorType *T, const std::vector<Constant*> &);
@@ -438,6 +453,9 @@ public:
return get(std::vector<Constant*>(Vals, Vals+NumVals));
}
+ /// Transparently provide more efficient getOperand methods.
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
+
/// getType - Specialize the getType() method to always return a VectorType,
/// which reduces the amount of casting needed in parts of the compiler.
///
@@ -475,6 +493,12 @@ public:
}
};
+template <>
+struct OperandTraits<ConstantVector> : VariadicOperandTraits<> {
+};
+
+DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantVector, Constant)
+
//===----------------------------------------------------------------------===//
/// ConstantPointerNull - a constant pointer value that points to null
///
@@ -573,6 +597,9 @@ public:
static Constant *getIntToPtr(Constant *C, const Type *Ty);
static Constant *getBitCast (Constant *C, const Type *Ty);
+ /// Transparently provide more efficient getOperand methods.
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
+
// @brief Convenience function for getting one of the casting operations
// using a CastOps opcode.
static Constant *getCast(
@@ -709,13 +736,13 @@ public:
virtual void destroyConstant();
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
- /// Override methods to provide more type information...
+/* /// Override methods to provide more type information...
inline Constant *getOperand(unsigned i) {
return cast<Constant>(User::getOperand(i));
}
inline Constant *getOperand(unsigned i) const {
return const_cast<Constant*>(cast<Constant>(User::getOperand(i)));
- }
+ }*/
/// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -725,6 +752,11 @@ public:
}
};
+template <>
+struct OperandTraits<ConstantExpr> : VariadicOperandTraits<1> {
+};
+
+DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantExpr, Constant)
//===----------------------------------------------------------------------===//
/// UndefValue - 'undef' values are things that do not have specified contents.