Implement a constant pointer value

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@667 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2001-09-30 20:14:07 +00:00
parent 7461bf5f8e
commit 4cfb153316
2 changed files with 30 additions and 0 deletions

View File

@ -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

View File

@ -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