[llvm-commits] CVS: llvm/include/llvm/Constants.h

Chris Lattner lattner at cs.uiuc.edu
Thu Mar 6 15:03:04 PST 2003


Changes in directory llvm/include/llvm:

Constants.h updated: 1.18 -> 1.19

---
Log message:

Extend struct and array constants to support isNullValue


---
Diffs of the changes:

Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.18 llvm/include/llvm/Constants.h:1.19
--- llvm/include/llvm/Constants.h:1.18	Sun Oct 13 22:30:13 2002
+++ llvm/include/llvm/Constants.h	Thu Mar  6 15:02:43 2003
@@ -289,7 +289,14 @@
 
   /// isNullValue - Return true if this is the value that would be returned by
   /// getNullValue.
-  virtual bool isNullValue() const { return false; }
+  virtual bool isNullValue() const {
+    // FIXME: This should be made to be MUCH faster.  Just check against well
+    // known null value!
+    for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
+      if (!cast<Constant>(getOperand(i))->isNullValue())
+        return false; 
+    return true;
+  }
 
   virtual void destroyConstant();
   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To);
@@ -328,7 +335,14 @@
 
   /// isNullValue - Return true if this is the value that would be returned by
   /// getNullValue.
-  virtual bool isNullValue() const { return false; }
+  virtual bool isNullValue() const {
+    // FIXME: This should be made to be MUCH faster.  Just check against well
+    // known null value!
+    for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
+      if (!cast<Constant>(getOperand(i))->isNullValue())
+        return false; 
+    return true;
+  }
 
   virtual void destroyConstant();
   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To);





More information about the llvm-commits mailing list