diff options
author | Chris Lattner <sabre@nondot.org> | 2004-04-23 21:28:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-04-23 21:28:25 +0000 |
commit | 2cdf0a7a32f08674562b0cf6b071b96b36421f87 (patch) | |
tree | e5a971e0b12fd061200df1768a34ae39db047570 /include/llvm/Analysis/ScalarEvolutionExpressions.h | |
parent | f4789e6d04c1fddb40092a1193c4a5eb67387acc (diff) | |
download | external_llvm-2cdf0a7a32f08674562b0cf6b071b96b36421f87.tar.gz external_llvm-2cdf0a7a32f08674562b0cf6b071b96b36421f87.tar.bz2 external_llvm-2cdf0a7a32f08674562b0cf6b071b96b36421f87.zip |
Remove the SCEV::expandCodeFor method, add a new SCEVVisitor class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13133 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis/ScalarEvolutionExpressions.h')
-rw-r--r-- | include/llvm/Analysis/ScalarEvolutionExpressions.h | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index fdca8b36a2..f2ed4238ef 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -56,11 +56,6 @@ namespace llvm { virtual const Type *getType() const; - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) { - return (Value*)getValue(); - } - virtual void print(std::ostream &OS) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -99,9 +94,6 @@ namespace llvm { /// known to have. This method is only valid on integer SCEV objects. virtual ConstantRange getValueRange() const; - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - virtual void print(std::ostream &OS) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -140,9 +132,6 @@ namespace llvm { /// known to have. This method is only valid on integer SCEV objects. virtual ConstantRange getValueRange() const; - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - virtual void print(std::ostream &OS) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -236,9 +225,6 @@ namespace llvm { virtual const char *getOperationStr() const { return " + "; } - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const SCEVAddExpr *S) { return true; } static inline bool classof(const SCEV *S) { @@ -266,9 +252,6 @@ namespace llvm { virtual const char *getOperationStr() const { return " * "; } - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const SCEVMulExpr *S) { return true; } static inline bool classof(const SCEV *S) { @@ -305,9 +288,6 @@ namespace llvm { virtual const Type *getType() const; - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - void print(std::ostream &OS) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -376,10 +356,6 @@ namespace llvm { virtual const Type *getType() const { return Operands[0]->getType(); } - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - - /// isAffine - Return true if this is an affine AddRec (i.e., it represents /// an expressions A+B*x where A and B are loop invariant values. bool isAffine() const { @@ -433,12 +409,11 @@ namespace llvm { /// SCEVUnknown. static SCEVHandle get(Value *V); - Value *getValue() const { return V; } + /// getIntegerSCEV - Given an integer or FP type, create a constant for the + /// specified signed integer value and return a SCEV for the constant. + static SCEVHandle getIntegerSCEV(int Val, const Type *Ty); - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) { - return V; - } + Value *getValue() const { return V; } virtual bool isLoopInvariant(const Loop *L) const; virtual bool hasComputableLoopEvolution(const Loop *QL) const { @@ -455,6 +430,42 @@ namespace llvm { return S->getSCEVType() == scUnknown; } }; + + /// SCEVVisitor - This class defines a simple visitor class that may be used + /// for various SCEV analysis purposes. + template<typename SC, typename RetVal=void> + struct SCEVVisitor { + RetVal visit(SCEV *S) { + switch (S->getSCEVType()) { + case scConstant: + return ((SC*)this)->visitConstant((SCEVConstant*)S); + case scTruncate: + return ((SC*)this)->visitTruncateExpr((SCEVTruncateExpr*)S); + case scZeroExtend: + return ((SC*)this)->visitZeroExtendExpr((SCEVZeroExtendExpr*)S); + case scAddExpr: + return ((SC*)this)->visitAddExpr((SCEVAddExpr*)S); + case scMulExpr: + return ((SC*)this)->visitMulExpr((SCEVMulExpr*)S); + case scUDivExpr: + return ((SC*)this)->visitUDivExpr((SCEVUDivExpr*)S); + case scAddRecExpr: + return ((SC*)this)->visitAddRecExpr((SCEVAddRecExpr*)S); + case scUnknown: + return ((SC*)this)->visitUnknown((SCEVUnknown*)S); + case scCouldNotCompute: + return ((SC*)this)->visitCouldNotCompute((SCEVCouldNotCompute*)S); + default: + assert(0 && "Unknown SCEV type!"); + } + } + + RetVal visitCouldNotCompute(SCEVCouldNotCompute *S) { + assert(0 && "Invalid use of SCEVCouldNotCompute!"); + abort(); + return RetVal(); + } + }; } #endif |