summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Instructions.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-04-27 20:35:56 +0000
committerChris Lattner <sabre@nondot.org>2007-04-27 20:35:56 +0000
commit2705829925b275ae8fb833218baec003ef8a4282 (patch)
tree5662a6162712846f0d2d4586b176d0ee0822bb48 /llvm/lib/VMCore/Instructions.cpp
parent99cb63029afa1523b8ddb7e3374dd78af0945526 (diff)
downloadbcm5719-llvm-2705829925b275ae8fb833218baec003ef8a4282.tar.gz
bcm5719-llvm-2705829925b275ae8fb833218baec003ef8a4282.zip
add a GEP helper function
llvm-svn: 36515
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r--llvm/lib/VMCore/Instructions.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index 2bd350080e3..4c792a56afb 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -1043,6 +1043,17 @@ bool GetElementPtrInst::hasAllZeroIndices() const {
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 GetElementPtrInst::hasAllConstantIndices() const {
+ for (unsigned i = 1, e = getNumOperands(); i != e; ++i) {
+ if (!isa<ConstantInt>(getOperand(i)))
+ return false;
+ }
+ return true;
+}
+
//===----------------------------------------------------------------------===//
// ExtractElementInst Implementation
OpenPOWER on IntegriCloud