aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-06-18 19:26:04 +0000
committerDan Gohman <gohman@apple.com>2010-06-18 19:26:04 +0000
commit78db186d2dbaf4745f7e4beab4029db40856b54b (patch)
tree62518c4f9f58afe1407ad840269e1d2d5e09a5a0 /include
parentdd76f18f90f3d9934353d852e45271b3be747743 (diff)
downloadexternal_llvm-78db186d2dbaf4745f7e4beab4029db40856b54b.zip
external_llvm-78db186d2dbaf4745f7e4beab4029db40856b54b.tar.gz
external_llvm-78db186d2dbaf4745f7e4beab4029db40856b54b.tar.bz2
Reapply 105540, 105542, and 105548, and revert r105732.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106304 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/ScalarEvolution.h16
-rw-r--r--include/llvm/Analysis/ScalarEvolutionExpressions.h49
2 files changed, 39 insertions, 26 deletions
diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h
index 00b95c9..7bfd0ce 100644
--- a/include/llvm/Analysis/ScalarEvolution.h
+++ b/include/llvm/Analysis/ScalarEvolution.h
@@ -54,6 +54,10 @@ namespace llvm {
/// The ScalarEvolution's BumpPtrAllocator holds the data.
FoldingSetNodeIDRef FastID;
+ /// AllocationSequenceNumber - This is used as a deterministic tie
+ /// breaker when sorting SCEVs.
+ unsigned AllocationSequenceNumber;
+
// The SCEV baseclass this node corresponds to
const unsigned short SCEVType;
@@ -68,11 +72,18 @@ namespace llvm {
protected:
virtual ~SCEV();
public:
- explicit SCEV(const FoldingSetNodeIDRef ID, unsigned SCEVTy) :
- FastID(ID), SCEVType(SCEVTy), SubclassData(0) {}
+ explicit SCEV(const FoldingSetNodeIDRef ID, unsigned num, unsigned SCEVTy) :
+ FastID(ID), AllocationSequenceNumber(num),
+ SCEVType(SCEVTy), SubclassData(0) {}
unsigned getSCEVType() const { return SCEVType; }
+ /// getAllocationSequenceNumber - Return an arbitrary value which can be
+ /// used to deterministically order a sequence of SCEVs.
+ unsigned getAllocationSequenceNumber() const {
+ return AllocationSequenceNumber;
+ }
+
/// Profile - FoldingSet support.
void Profile(FoldingSetNodeID& ID) { ID = FastID; }
@@ -663,6 +674,7 @@ namespace llvm {
private:
FoldingSet<SCEV> UniqueSCEVs;
BumpPtrAllocator SCEVAllocator;
+ unsigned CurAllocationSequenceNumber;
};
}
diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h
index 7424203..2e4fd7e 100644
--- a/include/llvm/Analysis/ScalarEvolutionExpressions.h
+++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h
@@ -37,8 +37,8 @@ namespace llvm {
friend class ScalarEvolution;
ConstantInt *V;
- SCEVConstant(const FoldingSetNodeIDRef ID, ConstantInt *v) :
- SCEV(ID, scConstant), V(v) {}
+ SCEVConstant(const FoldingSetNodeIDRef ID, unsigned Num, ConstantInt *v)
+ : SCEV(ID, Num, scConstant), V(v) {}
public:
ConstantInt *getValue() const { return V; }
@@ -81,7 +81,7 @@ namespace llvm {
const SCEV *Op;
const Type *Ty;
- SCEVCastExpr(const FoldingSetNodeIDRef ID,
+ SCEVCastExpr(const FoldingSetNodeIDRef ID, unsigned Num,
unsigned SCEVTy, const SCEV *op, const Type *ty);
public:
@@ -120,7 +120,7 @@ namespace llvm {
class SCEVTruncateExpr : public SCEVCastExpr {
friend class ScalarEvolution;
- SCEVTruncateExpr(const FoldingSetNodeIDRef ID,
+ SCEVTruncateExpr(const FoldingSetNodeIDRef ID, unsigned Num,
const SCEV *op, const Type *ty);
public:
@@ -140,7 +140,7 @@ namespace llvm {
class SCEVZeroExtendExpr : public SCEVCastExpr {
friend class ScalarEvolution;
- SCEVZeroExtendExpr(const FoldingSetNodeIDRef ID,
+ SCEVZeroExtendExpr(const FoldingSetNodeIDRef ID, unsigned Num,
const SCEV *op, const Type *ty);
public:
@@ -160,7 +160,7 @@ namespace llvm {
class SCEVSignExtendExpr : public SCEVCastExpr {
friend class ScalarEvolution;
- SCEVSignExtendExpr(const FoldingSetNodeIDRef ID,
+ SCEVSignExtendExpr(const FoldingSetNodeIDRef ID, unsigned Num,
const SCEV *op, const Type *ty);
public:
@@ -187,9 +187,9 @@ namespace llvm {
const SCEV *const *Operands;
size_t NumOperands;
- SCEVNAryExpr(const FoldingSetNodeIDRef ID,
+ SCEVNAryExpr(const FoldingSetNodeIDRef ID, unsigned Num,
enum SCEVTypes T, const SCEV *const *O, size_t N)
- : SCEV(ID, T), Operands(O), NumOperands(N) {}
+ : SCEV(ID, Num, T), Operands(O), NumOperands(N) {}
public:
size_t getNumOperands() const { return NumOperands; }
@@ -262,9 +262,9 @@ namespace llvm {
///
class SCEVCommutativeExpr : public SCEVNAryExpr {
protected:
- SCEVCommutativeExpr(const FoldingSetNodeIDRef ID,
+ SCEVCommutativeExpr(const FoldingSetNodeIDRef ID, unsigned Num,
enum SCEVTypes T, const SCEV *const *O, size_t N)
- : SCEVNAryExpr(ID, T, O, N) {}
+ : SCEVNAryExpr(ID, Num, T, O, N) {}
public:
virtual const char *getOperationStr() const = 0;
@@ -288,9 +288,9 @@ namespace llvm {
class SCEVAddExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
- SCEVAddExpr(const FoldingSetNodeIDRef ID,
+ SCEVAddExpr(const FoldingSetNodeIDRef ID, unsigned Num,
const SCEV *const *O, size_t N)
- : SCEVCommutativeExpr(ID, scAddExpr, O, N) {
+ : SCEVCommutativeExpr(ID, Num, scAddExpr, O, N) {
}
public:
@@ -316,9 +316,9 @@ namespace llvm {
class SCEVMulExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
- SCEVMulExpr(const FoldingSetNodeIDRef ID,
+ SCEVMulExpr(const FoldingSetNodeIDRef ID, unsigned Num,
const SCEV *const *O, size_t N)
- : SCEVCommutativeExpr(ID, scMulExpr, O, N) {
+ : SCEVCommutativeExpr(ID, Num, scMulExpr, O, N) {
}
public:
@@ -340,8 +340,9 @@ namespace llvm {
const SCEV *LHS;
const SCEV *RHS;
- SCEVUDivExpr(const FoldingSetNodeIDRef ID, const SCEV *lhs, const SCEV *rhs)
- : SCEV(ID, scUDivExpr), LHS(lhs), RHS(rhs) {}
+ SCEVUDivExpr(const FoldingSetNodeIDRef ID, unsigned Num,
+ const SCEV *lhs, const SCEV *rhs)
+ : SCEV(ID, Num, scUDivExpr), LHS(lhs), RHS(rhs) {}
public:
const SCEV *getLHS() const { return LHS; }
@@ -390,9 +391,9 @@ namespace llvm {
const Loop *L;
- SCEVAddRecExpr(const FoldingSetNodeIDRef ID,
+ SCEVAddRecExpr(const FoldingSetNodeIDRef ID, unsigned Num,
const SCEV *const *O, size_t N, const Loop *l)
- : SCEVNAryExpr(ID, scAddRecExpr, O, N), L(l) {
+ : SCEVNAryExpr(ID, Num, scAddRecExpr, O, N), L(l) {
for (size_t i = 0, e = NumOperands; i != e; ++i)
assert(Operands[i]->isLoopInvariant(l) &&
"Operands of AddRec must be loop-invariant!");
@@ -472,9 +473,9 @@ namespace llvm {
class SCEVSMaxExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
- SCEVSMaxExpr(const FoldingSetNodeIDRef ID,
+ SCEVSMaxExpr(const FoldingSetNodeIDRef ID, unsigned Num,
const SCEV *const *O, size_t N)
- : SCEVCommutativeExpr(ID, scSMaxExpr, O, N) {
+ : SCEVCommutativeExpr(ID, Num, scSMaxExpr, O, N) {
// Max never overflows.
setHasNoUnsignedWrap(true);
setHasNoSignedWrap(true);
@@ -497,9 +498,9 @@ namespace llvm {
class SCEVUMaxExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
- SCEVUMaxExpr(const FoldingSetNodeIDRef ID,
+ SCEVUMaxExpr(const FoldingSetNodeIDRef ID, unsigned Num,
const SCEV *const *O, size_t N)
- : SCEVCommutativeExpr(ID, scUMaxExpr, O, N) {
+ : SCEVCommutativeExpr(ID, Num, scUMaxExpr, O, N) {
// Max never overflows.
setHasNoUnsignedWrap(true);
setHasNoSignedWrap(true);
@@ -524,8 +525,8 @@ namespace llvm {
friend class ScalarEvolution;
Value *V;
- SCEVUnknown(const FoldingSetNodeIDRef ID, Value *v) :
- SCEV(ID, scUnknown), V(v) {}
+ SCEVUnknown(const FoldingSetNodeIDRef ID, unsigned Num, Value *v)
+ : SCEV(ID, Num, scUnknown), V(v) {}
public:
Value *getValue() const { return V; }