diff options
author | Dan Gohman <gohman@apple.com> | 2007-06-15 14:38:12 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2007-06-15 14:38:12 +0000 |
commit | d19534add90a2a894af61523b830887097bb780b (patch) | |
tree | 5b56c9525ef1b3afea45d0fcfa14855ce3678855 /include/llvm/Analysis/ScalarEvolutionExpressions.h | |
parent | 2c8c3a4a0df00eee39c28d827d43a1d5462b0671 (diff) | |
download | external_llvm-d19534add90a2a894af61523b830887097bb780b.zip external_llvm-d19534add90a2a894af61523b830887097bb780b.tar.gz external_llvm-d19534add90a2a894af61523b830887097bb780b.tar.bz2 |
Add a SCEV class and supporting code for sign-extend expressions.
This created an ambiguity for expandInTy to decide when to use
sign-extension or zero-extension, but it turns out that most of its callers
don't actually need a type conversion, now that LLVM types don't have
explicit signedness. Drop expandInTy in favor of plain expand, and change
the few places that actually need a type conversion to do it themselves.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37591 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis/ScalarEvolutionExpressions.h')
-rw-r--r-- | include/llvm/Analysis/ScalarEvolutionExpressions.h | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index af79537..dd6871f 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -24,8 +24,8 @@ namespace llvm { enum SCEVTypes { // These should be ordered in terms of increasing complexity to make the // folders simpler. - scConstant, scTruncate, scZeroExtend, scAddExpr, scMulExpr, scSDivExpr, - scAddRecExpr, scUnknown, scCouldNotCompute + scConstant, scTruncate, scZeroExtend, scSignExtend, scAddExpr, scMulExpr, + scSDivExpr, scAddRecExpr, scUnknown, scCouldNotCompute }; //===--------------------------------------------------------------------===// @@ -166,6 +166,53 @@ namespace llvm { } }; + //===--------------------------------------------------------------------===// + /// SCEVSignExtendExpr - This class represents a sign extension of a small + /// integer value to a larger integer value. + /// + class SCEVSignExtendExpr : public SCEV { + SCEVHandle Op; + const Type *Ty; + SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty); + virtual ~SCEVSignExtendExpr(); + public: + /// get method - This just gets and returns a new SCEVSignExtend object + /// + static SCEVHandle get(const SCEVHandle &Op, const Type *Ty); + + const SCEVHandle &getOperand() const { return Op; } + virtual const Type *getType() const { return Ty; } + + virtual bool isLoopInvariant(const Loop *L) const { + return Op->isLoopInvariant(L); + } + + virtual bool hasComputableLoopEvolution(const Loop *L) const { + return Op->hasComputableLoopEvolution(L); + } + + /// getValueRange - Return the tightest constant bounds that this value is + /// known to have. This method is only valid on integer SCEV objects. + virtual ConstantRange getValueRange() const; + + SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const { + SCEVHandle H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc); + if (H == Op) + return this; + return get(H, Ty); + } + + virtual void print(std::ostream &OS) const; + void print(std::ostream *OS) const { if (OS) print(*OS); } + + /// Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const SCEVSignExtendExpr *S) { return true; } + static inline bool classof(const SCEV *S) { + return S->getSCEVType() == scSignExtend; + } + }; + //===--------------------------------------------------------------------===// /// SCEVCommutativeExpr - This node is the base class for n'ary commutative @@ -503,6 +550,8 @@ namespace llvm { return ((SC*)this)->visitTruncateExpr((SCEVTruncateExpr*)S); case scZeroExtend: return ((SC*)this)->visitZeroExtendExpr((SCEVZeroExtendExpr*)S); + case scSignExtend: + return ((SC*)this)->visitSignExtendExpr((SCEVSignExtendExpr*)S); case scAddExpr: return ((SC*)this)->visitAddExpr((SCEVAddExpr*)S); case scMulExpr: |