mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-26 13:10:34 +00:00
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:
parent
7461bf5f8e
commit
4cfb153316
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user