aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-12-11 10:29:10 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-12-11 10:29:10 +0000
commit4ced4ee94b59a2b239a59a2ae5fd373579868f20 (patch)
tree8c6d5c19405cf5c036c2d75bd35379cc6c1537bc /include
parent05749cff9b045505f08313b4c2d1bd9a4fb84970 (diff)
downloadexternal_llvm-4ced4ee94b59a2b239a59a2ae5fd373579868f20.tar.gz
external_llvm-4ced4ee94b59a2b239a59a2ae5fd373579868f20.tar.bz2
external_llvm-4ced4ee94b59a2b239a59a2ae5fd373579868f20.zip
Hoist the GEP constant address offset computation to a common home on
the GEP instruction class. This is part of the continued refactoring and cleaning of the infrastructure used by SROA. This particular operation is also done in a few other places which I'll try to refactor to share this implementation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169852 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/PtrUseVisitor.h1
-rw-r--r--include/llvm/Instructions.h13
2 files changed, 12 insertions, 2 deletions
diff --git a/include/llvm/Analysis/PtrUseVisitor.h b/include/llvm/Analysis/PtrUseVisitor.h
index e15f2b45a8..f5daf2c63e 100644
--- a/include/llvm/Analysis/PtrUseVisitor.h
+++ b/include/llvm/Analysis/PtrUseVisitor.h
@@ -29,7 +29,6 @@
#include "llvm/InstVisitor.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Support/Compiler.h"
-#include "llvm/Support/GetElementPtrTypeIterator.h"
namespace llvm {
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 9c5a2db2fe..b5c75e3782 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -29,9 +29,10 @@
namespace llvm {
+class APInt;
class ConstantInt;
class ConstantRange;
-class APInt;
+class DataLayout;
class LLVMContext;
enum AtomicOrdering {
@@ -850,6 +851,16 @@ public:
/// isInBounds - Determine whether the GEP has the inbounds flag.
bool isInBounds() const;
+ /// \brief Accumulate the constant address offset of this GEP if possible.
+ ///
+ /// This routine accepts an APInt into which it will accumulate the constant
+ /// offset of this GEP if the GEP is in fact constant. If the GEP is not
+ /// all-constant, it returns false and the value of the offset APInt is
+ /// undefined (it is *not* preserved!). The APInt passed into this routine
+ /// must be at least as wide as the IntPtr type for the address space of
+ /// the base GEP pointer.
+ bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const;
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Instruction *I) {
return (I->getOpcode() == Instruction::GetElementPtr);