summaryrefslogtreecommitdiff
path: root/lib/VMCore/ConstantsContext.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore/ConstantsContext.h')
-rw-r--r--lib/VMCore/ConstantsContext.h31
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/VMCore/ConstantsContext.h b/lib/VMCore/ConstantsContext.h
index 718470aff4..f4a2cde5d0 100644
--- a/lib/VMCore/ConstantsContext.h
+++ b/lib/VMCore/ConstantsContext.h
@@ -16,6 +16,7 @@
#define LLVM_CONSTANTSCONTEXT_H
#include "llvm/Instructions.h"
+#include "llvm/Metadata.h"
#include "llvm/Operator.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
@@ -340,7 +341,7 @@ struct ConstantCreator {
};
template<class ConstantClass, class TypeClass>
-struct ConvertConstantType {
+struct ConvertConstant {
static void convert(ConstantClass *OldC, const TypeClass *NewTy) {
llvm_unreachable("This type cannot be converted!");
}
@@ -391,7 +392,7 @@ struct ConstantCreator<ConstantExpr, Type, ExprMapKeyType> {
};
template<>
-struct ConvertConstantType<ConstantExpr, Type> {
+struct ConvertConstant<ConstantExpr, Type> {
static void convert(ConstantExpr *OldC, const Type *NewTy) {
Constant *New;
switch (OldC->getOpcode()) {
@@ -444,7 +445,14 @@ struct ConstantCreator<ConstantAggregateZero, Type, ValType> {
};
template<>
-struct ConvertConstantType<ConstantVector, VectorType> {
+struct ConstantCreator<MDNode, Type, std::vector<Value*> > {
+ static MDNode *create(const Type* Ty, const std::vector<Value*> &V) {
+ return new MDNode(Ty->getContext(), &V[0], V.size());
+ }
+};
+
+template<>
+struct ConvertConstant<ConstantVector, VectorType> {
static void convert(ConstantVector *OldC, const VectorType *NewTy) {
// Make everyone now use a constant of the new type...
std::vector<Constant*> C;
@@ -458,7 +466,7 @@ struct ConvertConstantType<ConstantVector, VectorType> {
};
template<>
-struct ConvertConstantType<ConstantAggregateZero, Type> {
+struct ConvertConstant<ConstantAggregateZero, Type> {
static void convert(ConstantAggregateZero *OldC, const Type *NewTy) {
// Make everyone now use a constant of the new type...
Constant *New = ConstantAggregateZero::get(NewTy);
@@ -469,7 +477,7 @@ struct ConvertConstantType<ConstantAggregateZero, Type> {
};
template<>
-struct ConvertConstantType<ConstantArray, ArrayType> {
+struct ConvertConstant<ConstantArray, ArrayType> {
static void convert(ConstantArray *OldC, const ArrayType *NewTy) {
// Make everyone now use a constant of the new type...
std::vector<Constant*> C;
@@ -483,7 +491,7 @@ struct ConvertConstantType<ConstantArray, ArrayType> {
};
template<>
-struct ConvertConstantType<ConstantStruct, StructType> {
+struct ConvertConstant<ConstantStruct, StructType> {
static void convert(ConstantStruct *OldC, const StructType *NewTy) {
// Make everyone now use a constant of the new type...
std::vector<Constant*> C;
@@ -506,7 +514,7 @@ struct ConstantCreator<ConstantPointerNull, PointerType, ValType> {
};
template<>
-struct ConvertConstantType<ConstantPointerNull, PointerType> {
+struct ConvertConstant<ConstantPointerNull, PointerType> {
static void convert(ConstantPointerNull *OldC, const PointerType *NewTy) {
// Make everyone now use a constant of the new type...
Constant *New = ConstantPointerNull::get(NewTy);
@@ -525,7 +533,7 @@ struct ConstantCreator<UndefValue, Type, ValType> {
};
template<>
-struct ConvertConstantType<UndefValue, Type> {
+struct ConvertConstant<UndefValue, Type> {
static void convert(UndefValue *OldC, const Type *NewTy) {
// Make everyone now use a constant of the new type.
Constant *New = UndefValue::get(NewTy);
@@ -540,8 +548,8 @@ template<class ValType, class TypeClass, class ConstantClass,
class ValueMap : public AbstractTypeUser {
public:
typedef std::pair<const Type*, ValType> MapKey;
- typedef std::map<MapKey, Constant *> MapTy;
- typedef std::map<Constant*, typename MapTy::iterator> InverseMapTy;
+ typedef std::map<MapKey, Value *> MapTy;
+ typedef std::map<Value*, typename MapTy::iterator> InverseMapTy;
typedef std::map<const Type*, typename MapTy::iterator> AbstractTypeMapTy;
private:
/// Map - This is the main map from the element descriptor to the Constants.
@@ -759,8 +767,7 @@ public:
// leaving will remove() itself, causing the AbstractTypeMapEntry to be
// eliminated eventually.
do {
- ConvertConstantType<ConstantClass,
- TypeClass>::convert(
+ ConvertConstant<ConstantClass, TypeClass>::convert(
static_cast<ConstantClass *>(I->second->second),
cast<TypeClass>(NewTy));