summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-09-30 20:14:07 +0000
committerChris Lattner <sabre@nondot.org>2001-09-30 20:14:07 +0000
commit436248f236b13fa4816e0cb22bbaf37198433f2a (patch)
tree744fe59af11352eac3f55deb16275262fc07d7eb
parent409bbecbcd4cb798a6be4bfc063f1753ffe40895 (diff)
downloadbcm5719-llvm-436248f236b13fa4816e0cb22bbaf37198433f2a.tar.gz
bcm5719-llvm-436248f236b13fa4816e0cb22bbaf37198433f2a.zip
Implement a constant pointer value
llvm-svn: 667
-rw-r--r--llvm/include/llvm/ConstPoolVals.h21
-rw-r--r--llvm/lib/VMCore/ConstPoolVals.cpp9
2 files changed, 30 insertions, 0 deletions
diff --git a/llvm/include/llvm/ConstPoolVals.h b/llvm/include/llvm/ConstPoolVals.h
index 71ca6a7a96d..7ebe3f3ce28 100644
--- a/llvm/include/llvm/ConstPoolVals.h
+++ b/llvm/include/llvm/ConstPoolVals.h
@@ -13,6 +13,7 @@
class ArrayType;
class StructType;
+class PointerType;
//===----------------------------------------------------------------------===//
// ConstPoolVal Class
@@ -182,4 +183,24 @@ public:
inline const vector<Use> &getValues() const { return Operands; }
};
+//===---------------------------------------------------------------------------
+// ConstPoolPointer - Constant Pointer Declarations
+//
+// The ConstPoolPointer class represents a null pointer of a specific type. For
+// a more specific/useful instance, a subclass of ConstPoolPointer should be
+// used.
+//
+class ConstPoolPointer : public ConstPoolVal {
+ ConstPoolPointer(const ConstPoolPointer &); // DO NOT IMPLEMENT
+protected:
+ ConstPoolPointer(const PointerType *T);
+ ~ConstPoolPointer() {}
+public:
+ static ConstPoolPointer *getNullPointer(const PointerType *T) {
+ return new ConstPoolPointer(T);
+ }
+
+ virtual string getStrValue() const;
+};
+
#endif
diff --git a/llvm/lib/VMCore/ConstPoolVals.cpp b/llvm/lib/VMCore/ConstPoolVals.cpp
index d53130d6012..152209dcc7d 100644
--- a/llvm/lib/VMCore/ConstPoolVals.cpp
+++ b/llvm/lib/VMCore/ConstPoolVals.cpp
@@ -43,6 +43,9 @@ ConstPoolVal *ConstPoolVal::getNullConstant(const Type *Ty) {
case Type::FloatTyID:
case Type::DoubleTyID: return ConstPoolFP::get(Ty, 0);
+
+ case Type::PointerTyID:
+ return ConstPoolPointer::getNullPointer(Ty->castPointerType());
default:
return 0;
}
@@ -98,6 +101,8 @@ ConstPoolStruct::ConstPoolStruct(const StructType *T,
}
}
+ConstPoolPointer::ConstPoolPointer(const PointerType *T) : ConstPoolVal(T) {}
+
//===----------------------------------------------------------------------===//
// getStrValue implementations
@@ -144,6 +149,10 @@ string ConstPoolStruct::getStrValue() const {
return Result + " }";
}
+string ConstPoolPointer::getStrValue() const {
+ return "null";
+}
+
//===----------------------------------------------------------------------===//
// isValueValidForType implementations
OpenPOWER on IntegriCloud