Add new isNullValue method
authorChris Lattner <sabre@nondot.org>
Thu, 1 Nov 2001 05:53:56 +0000 (05:53 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 1 Nov 2001 05:53:56 +0000 (05:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1076 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ConstPoolVals.h

index 3142bbbe9c322af2e10dd6be746caa916f671b3b..b25ca3edc9eff300f0748758908a617b74d60b6d 100644 (file)
@@ -43,6 +43,10 @@ public:
   // Static constructor to get a '0' constant of arbitrary type...
   static ConstPoolVal *getNullConstant(const Type *Ty);
 
+  // isNullValue - Return true if this is the value that would be returned by
+  // getNullConstant.
+  virtual bool isNullValue() const = 0;
+
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstPoolVal *) { return true; }
   static inline bool classof(const Value *V) {
@@ -77,6 +81,10 @@ public:
   virtual string getStrValue() const;
   inline bool getValue() const { return Val; }
 
+  // isNullValue - Return true if this is the value that would be returned by
+  // getNullConstant.
+  virtual bool isNullValue() const { return this == False; }
+
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstPoolBool *) { return true; }
   static bool classof(const ConstPoolVal *CPV) {
@@ -117,6 +125,10 @@ public:
   //
   static ConstPoolInt *get(const Type *Ty, unsigned char V);
 
+  // isNullValue - Return true if this is the value that would be returned by
+  // getNullConstant.
+  virtual bool isNullValue() const { return Val.Unsigned == 0; }
+
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstPoolInt *) { return true; }
   static bool classof(const ConstPoolVal *CPV);  // defined in CPV.cpp
@@ -192,6 +204,10 @@ public:
   static bool isValueValidForType(const Type *Ty, double V);
   inline double getValue() const { return Val; }
 
+  // isNullValue - Return true if this is the value that would be returned by
+  // getNullConstant.
+  virtual bool isNullValue() const { return Val == 0; }
+
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstPoolFP *) { return true; }
   static bool classof(const ConstPoolVal *CPV);  // defined in CPV.cpp
@@ -219,6 +235,10 @@ public:
 
   inline const vector<Use> &getValues() const { return Operands; }
 
+  // isNullValue - Return true if this is the value that would be returned by
+  // getNullConstant.
+  virtual bool isNullValue() const { return false; }
+
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstPoolArray *) { return true; }
   static bool classof(const ConstPoolVal *CPV);  // defined in CPV.cpp
@@ -246,6 +266,10 @@ public:
 
   inline const vector<Use> &getValues() const { return Operands; }
 
+  // isNullValue - Return true if this is the value that would be returned by
+  // getNullConstant.
+  virtual bool isNullValue() const { return false; }
+
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstPoolStruct *) { return true; }
   static bool classof(const ConstPoolVal *CPV);  // defined in CPV.cpp
@@ -261,7 +285,6 @@ public:
 // a more specific/useful instance, a subclass of ConstPoolPointer should be
 // used.
 //
-class ConstPoolPointerNull;
 class ConstPoolPointer : public ConstPoolVal {
   ConstPoolPointer(const ConstPoolPointer &);      // DO NOT IMPLEMENT
 protected:
@@ -270,6 +293,10 @@ protected:
 public:
   virtual string getStrValue() const = 0;
 
+  // isNullValue - Return true if this is the value that would be returned by
+  // getNullConstant.
+  virtual bool isNullValue() const { return false; }
+
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstPoolPointer *) { return true; }
   static bool classof(const ConstPoolVal *CPV);  // defined in CPV.cpp
@@ -290,6 +317,10 @@ public:
 
   static ConstPoolPointerNull *get(const PointerType *T);
 
+  // isNullValue - Return true if this is the value that would be returned by
+  // getNullConstant.
+  virtual bool isNullValue() const { return true; }
+
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstPoolPointerNull *) { return true; }
   static inline bool classof(const ConstPoolPointer *P) {