mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Implement a constant pointer value
llvm-svn: 667
This commit is contained in:
parent
a8f5e13f7a
commit
94ef0a1a2c
@ -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