diff options
author | Chris Lattner <sabre@nondot.org> | 2007-04-27 20:35:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-04-27 20:35:56 +0000 |
commit | 2705829925b275ae8fb833218baec003ef8a4282 (patch) | |
tree | 5662a6162712846f0d2d4586b176d0ee0822bb48 /llvm/lib/VMCore/Instructions.cpp | |
parent | 99cb63029afa1523b8ddb7e3374dd78af0945526 (diff) | |
download | bcm5719-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.cpp | 11 |
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 |