diff options
author | Dan Gohman <gohman@apple.com> | 2010-02-01 18:27:38 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-02-01 18:27:38 +0000 |
commit | 4f8eea82d8967cffa85b9df6c9255717b059009e (patch) | |
tree | 30c0ce1f31994e690d1e06b942a93fd36103449a /include/llvm/Analysis | |
parent | d569561835b0fa4dbbb0fca1b1f0a8de6c01439a (diff) | |
download | external_llvm-4f8eea82d8967cffa85b9df6c9255717b059009e.zip external_llvm-4f8eea82d8967cffa85b9df6c9255717b059009e.tar.gz external_llvm-4f8eea82d8967cffa85b9df6c9255717b059009e.tar.bz2 |
Generalize target-independent folding rules for sizeof to handle more
cases, and implement target-independent folding rules for alignof and
offsetof. Also, reassociate reassociative operators when it leads to
more folding.
Generalize ScalarEvolution's isOffsetOf to recognize offsetof on
arrays. Rename getAllocSizeExpr to getSizeOfExpr, and getFieldOffsetExpr
to getOffsetOfExpr, for consistency with analagous ConstantExpr routines.
Make the target-dependent folder promote GEP array indices to
pointer-sized integers, to make implicit casting explicit and exposed
to subsequent folding.
And add a bunch of testcases for this new functionality, and a bunch
of related existing functionality.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94987 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis')
-rw-r--r-- | include/llvm/Analysis/ScalarEvolution.h | 18 | ||||
-rw-r--r-- | include/llvm/Analysis/ScalarEvolutionExpressions.h | 2 |
2 files changed, 17 insertions, 3 deletions
diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index e281971..315b782 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -452,11 +452,25 @@ namespace llvm { const SCEV *getUMaxExpr(SmallVectorImpl<const SCEV *> &Operands); const SCEV *getSMinExpr(const SCEV *LHS, const SCEV *RHS); const SCEV *getUMinExpr(const SCEV *LHS, const SCEV *RHS); - const SCEV *getFieldOffsetExpr(const StructType *STy, unsigned FieldNo); - const SCEV *getAllocSizeExpr(const Type *AllocTy); const SCEV *getUnknown(Value *V); const SCEV *getCouldNotCompute(); + /// getSizeOfExpr - Return an expression for sizeof on the given type. + /// + const SCEV *getSizeOfExpr(const Type *AllocTy); + + /// getSizeOfExpr - Return an expression for alignof on the given type. + /// + const SCEV *getAlignOfExpr(const Type *AllocTy); + + /// getSizeOfExpr - Return an expression for offsetof on the given field. + /// + const SCEV *getOffsetOfExpr(const StructType *STy, unsigned FieldNo); + + /// getSizeOfExpr - Return an expression for offsetof on the given field. + /// + const SCEV *getOffsetOfExpr(const Type *CTy, Constant *FieldNo); + /// getNegativeSCEV - Return the SCEV object corresponding to -V. /// const SCEV *getNegativeSCEV(const SCEV *V); diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index 5b93458..79d4c63 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -534,7 +534,7 @@ namespace llvm { /// where it isn't absolutely required for these to succeed. bool isSizeOf(const Type *&AllocTy) const; bool isAlignOf(const Type *&AllocTy) const; - bool isOffsetOf(const StructType *&STy, Constant *&FieldNo) const; + bool isOffsetOf(const Type *&STy, Constant *&FieldNo) const; virtual bool isLoopInvariant(const Loop *L) const; virtual bool hasComputableLoopEvolution(const Loop *QL) const { |