From 450fd6ffbbeef7536401b6bf8b60fa9dc6ded42c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 21 Sep 2009 05:52:45 +0000 Subject: add a helper method. llvm-svn: 82438 --- llvm/include/llvm/Operator.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'llvm') diff --git a/llvm/include/llvm/Operator.h b/llvm/include/llvm/Operator.h index 06eb243418e..2b5cc57e75d 100644 --- a/llvm/include/llvm/Operator.h +++ b/llvm/include/llvm/Operator.h @@ -274,6 +274,18 @@ public: return true; } + /// hasAllConstantIndices - Return true if all of the indices of this GEP are + /// constant integers. If so, the result pointer and the first operand have + /// a constant offset between them. + bool hasAllConstantIndices() const { + for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) { + if (!isa(I)) + return false; + } + return true; + } + + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const GEPOperator *) { return true; } static inline bool classof(const GetElementPtrInst *) { return true; } -- cgit v1.2.3