diff options
author | Chris Lattner <sabre@nondot.org> | 2001-09-30 20:14:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-09-30 20:14:07 +0000 |
commit | 4cfb15331652f9a2f7e5f755485a2f6eb87a20c6 (patch) | |
tree | ccebc92215a1f26322a887cfbcca234139789b3e | |
parent | 7461bf5f8e1e9be67f4ce19f35a32a88668934c7 (diff) | |
download | external_llvm-4cfb15331652f9a2f7e5f755485a2f6eb87a20c6.zip external_llvm-4cfb15331652f9a2f7e5f755485a2f6eb87a20c6.tar.gz external_llvm-4cfb15331652f9a2f7e5f755485a2f6eb87a20c6.tar.bz2 |
Implement a constant pointer value
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@667 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/ConstPoolVals.h | 21 | ||||
-rw-r--r-- | lib/VMCore/ConstPoolVals.cpp | 9 |
2 files changed, 30 insertions, 0 deletions
diff --git a/include/llvm/ConstPoolVals.h b/include/llvm/ConstPoolVals.h index 71ca6a7..7ebe3f3 100644 --- a/include/llvm/ConstPoolVals.h +++ b/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/lib/VMCore/ConstPoolVals.cpp b/lib/VMCore/ConstPoolVals.cpp index d53130d..152209d 100644 --- a/lib/VMCore/ConstPoolVals.cpp +++ b/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 |