diff options
| author | Chris Lattner <sabre@nondot.org> | 2003-03-06 21:02:43 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2003-03-06 21:02:43 +0000 |
| commit | 187c39b6d019620aa7a456667c6ce067ccdaf6c9 (patch) | |
| tree | d581f165d05400de98201d07041212aa085de66b | |
| parent | c33ae6723733877871e1dfc6ad65d7db5402217f (diff) | |
| download | bcm5719-llvm-187c39b6d019620aa7a456667c6ce067ccdaf6c9.tar.gz bcm5719-llvm-187c39b6d019620aa7a456667c6ce067ccdaf6c9.zip | |
Extend struct and array constants to support isNullValue
llvm-svn: 5719
| -rw-r--r-- | llvm/include/llvm/Constants.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/include/llvm/Constants.h b/llvm/include/llvm/Constants.h index ec6345846e3..6c1b8eb1e61 100644 --- a/llvm/include/llvm/Constants.h +++ b/llvm/include/llvm/Constants.h @@ -289,7 +289,14 @@ public: /// 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 @@ public: /// 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); |

