Remove the parent pointer from SCEV, since it did not end up being needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73907 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2009-06-22 21:57:23 +00:00
parent 372b46cad9
commit 753ad615f9
3 changed files with 49 additions and 74 deletions

View File

@ -50,15 +50,13 @@ namespace llvm {
class SCEV {
const unsigned SCEVType; // The SCEV baseclass this node corresponds to
const ScalarEvolution* parent;
SCEV(const SCEV &); // DO NOT IMPLEMENT
void operator=(const SCEV &); // DO NOT IMPLEMENT
protected:
virtual ~SCEV();
public:
explicit SCEV(unsigned SCEVTy, const ScalarEvolution* p) :
SCEVType(SCEVTy), parent(p) {}
explicit SCEV(unsigned SCEVTy) :
SCEVType(SCEVTy) {}
unsigned getSCEVType() const { return SCEVType; }
@ -126,8 +124,7 @@ namespace llvm {
/// None of the standard SCEV operations are valid on this class, it is just a
/// marker.
struct SCEVCouldNotCompute : public SCEV {
SCEVCouldNotCompute(const ScalarEvolution* p);
~SCEVCouldNotCompute();
SCEVCouldNotCompute();
// None of these methods are valid for this object.
virtual bool isLoopInvariant(const Loop *L) const;

View File

@ -36,8 +36,8 @@ namespace llvm {
friend class ScalarEvolution;
ConstantInt *V;
explicit SCEVConstant(ConstantInt *v, const ScalarEvolution* p) :
SCEV(scConstant, p), V(v) {}
explicit SCEVConstant(ConstantInt *v) :
SCEV(scConstant), V(v) {}
public:
ConstantInt *getValue() const { return V; }
@ -78,9 +78,7 @@ namespace llvm {
const SCEV* Op;
const Type *Ty;
SCEVCastExpr(unsigned SCEVTy, const SCEV* op, const Type *ty,
const ScalarEvolution* p);
virtual ~SCEVCastExpr();
SCEVCastExpr(unsigned SCEVTy, const SCEV* op, const Type *ty);
public:
const SCEV* getOperand() const { return Op; }
@ -112,8 +110,7 @@ namespace llvm {
class SCEVTruncateExpr : public SCEVCastExpr {
friend class ScalarEvolution;
SCEVTruncateExpr(const SCEV* op, const Type *ty,
const ScalarEvolution* p);
SCEVTruncateExpr(const SCEV* op, const Type *ty);
public:
const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym,
@ -141,8 +138,7 @@ namespace llvm {
class SCEVZeroExtendExpr : public SCEVCastExpr {
friend class ScalarEvolution;
SCEVZeroExtendExpr(const SCEV* op, const Type *ty,
const ScalarEvolution* p);
SCEVZeroExtendExpr(const SCEV* op, const Type *ty);
public:
const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym,
@ -170,8 +166,7 @@ namespace llvm {
class SCEVSignExtendExpr : public SCEVCastExpr {
friend class ScalarEvolution;
SCEVSignExtendExpr(const SCEV* op, const Type *ty,
const ScalarEvolution* p);
SCEVSignExtendExpr(const SCEV* op, const Type *ty);
public:
const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym,
@ -201,10 +196,8 @@ namespace llvm {
protected:
SmallVector<const SCEV*, 8> Operands;
SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl<const SCEV*> &ops,
const ScalarEvolution* p)
: SCEV(T, p), Operands(ops.begin(), ops.end()) {}
virtual ~SCEVNAryExpr() {}
SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl<const SCEV*> &ops)
: SCEV(T), Operands(ops.begin(), ops.end()) {}
public:
unsigned getNumOperands() const { return (unsigned)Operands.size(); }
@ -261,9 +254,8 @@ namespace llvm {
class SCEVCommutativeExpr : public SCEVNAryExpr {
protected:
SCEVCommutativeExpr(enum SCEVTypes T,
const SmallVectorImpl<const SCEV*> &ops,
const ScalarEvolution* p)
: SCEVNAryExpr(T, ops, p) {}
const SmallVectorImpl<const SCEV*> &ops)
: SCEVNAryExpr(T, ops) {}
public:
const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym,
@ -291,9 +283,8 @@ namespace llvm {
class SCEVAddExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
explicit SCEVAddExpr(const SmallVectorImpl<const SCEV*> &ops,
const ScalarEvolution* p)
: SCEVCommutativeExpr(scAddExpr, ops, p) {
explicit SCEVAddExpr(const SmallVectorImpl<const SCEV*> &ops)
: SCEVCommutativeExpr(scAddExpr, ops) {
}
public:
@ -312,9 +303,8 @@ namespace llvm {
class SCEVMulExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
explicit SCEVMulExpr(const SmallVectorImpl<const SCEV*> &ops,
const ScalarEvolution* p)
: SCEVCommutativeExpr(scMulExpr, ops, p) {
explicit SCEVMulExpr(const SmallVectorImpl<const SCEV*> &ops)
: SCEVCommutativeExpr(scMulExpr, ops) {
}
public:
@ -336,9 +326,8 @@ namespace llvm {
const SCEV* LHS;
const SCEV* RHS;
SCEVUDivExpr(const SCEV* lhs, const SCEV* rhs,
const ScalarEvolution* p)
: SCEV(scUDivExpr, p), LHS(lhs), RHS(rhs) {}
SCEVUDivExpr(const SCEV* lhs, const SCEV* rhs)
: SCEV(scUDivExpr), LHS(lhs), RHS(rhs) {}
public:
const SCEV* getLHS() const { return LHS; }
@ -392,9 +381,8 @@ namespace llvm {
const Loop *L;
SCEVAddRecExpr(const SmallVectorImpl<const SCEV*> &ops, const Loop *l,
const ScalarEvolution* p)
: SCEVNAryExpr(scAddRecExpr, ops, p), L(l) {
SCEVAddRecExpr(const SmallVectorImpl<const SCEV*> &ops, const Loop *l)
: SCEVNAryExpr(scAddRecExpr, ops), L(l) {
for (size_t i = 0, e = Operands.size(); i != e; ++i)
assert(Operands[i]->isLoopInvariant(l) &&
"Operands of AddRec must be loop-invariant!");
@ -468,9 +456,8 @@ namespace llvm {
class SCEVSMaxExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
explicit SCEVSMaxExpr(const SmallVectorImpl<const SCEV*> &ops,
const ScalarEvolution* p)
: SCEVCommutativeExpr(scSMaxExpr, ops, p) {
explicit SCEVSMaxExpr(const SmallVectorImpl<const SCEV*> &ops)
: SCEVCommutativeExpr(scSMaxExpr, ops) {
}
public:
@ -490,9 +477,8 @@ namespace llvm {
class SCEVUMaxExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
explicit SCEVUMaxExpr(const SmallVectorImpl<const SCEV*> &ops,
const ScalarEvolution* p)
: SCEVCommutativeExpr(scUMaxExpr, ops, p) {
explicit SCEVUMaxExpr(const SmallVectorImpl<const SCEV*> &ops)
: SCEVCommutativeExpr(scUMaxExpr, ops) {
}
public:
@ -515,8 +501,8 @@ namespace llvm {
friend class ScalarEvolution;
Value *V;
explicit SCEVUnknown(Value *v, const ScalarEvolution* p) :
SCEV(scUnknown, p), V(v) {}
explicit SCEVUnknown(Value *v) :
SCEV(scUnknown), V(v) {}
public:
Value *getValue() const { return V; }

View File

@ -76,7 +76,6 @@
#include "llvm/Support/ConstantRange.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/InstIterator.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/Statistic.h"
@ -133,9 +132,8 @@ bool SCEV::isOne() const {
return false;
}
SCEVCouldNotCompute::SCEVCouldNotCompute(const ScalarEvolution* p) :
SCEV(scCouldNotCompute, p) {}
SCEVCouldNotCompute::~SCEVCouldNotCompute() {}
SCEVCouldNotCompute::SCEVCouldNotCompute() :
SCEV(scCouldNotCompute) {}
bool SCEVCouldNotCompute::isLoopInvariant(const Loop *L) const {
assert(0 && "Attempt to use a SCEVCouldNotCompute object!");
@ -174,7 +172,7 @@ bool SCEVCouldNotCompute::classof(const SCEV *S) {
const SCEV* ScalarEvolution::getConstant(ConstantInt *V) {
SCEVConstant *&R = SCEVConstants[V];
if (R == 0) R = new SCEVConstant(V, this);
if (R == 0) R = new SCEVConstant(V);
return R;
}
@ -194,11 +192,8 @@ void SCEVConstant::print(raw_ostream &OS) const {
}
SCEVCastExpr::SCEVCastExpr(unsigned SCEVTy,
const SCEV* op, const Type *ty,
const ScalarEvolution* p)
: SCEV(SCEVTy, p), Op(op), Ty(ty) {}
SCEVCastExpr::~SCEVCastExpr() {}
const SCEV* op, const Type *ty)
: SCEV(SCEVTy), Op(op), Ty(ty) {}
bool SCEVCastExpr::dominates(BasicBlock *BB, DominatorTree *DT) const {
return Op->dominates(BB, DT);
@ -208,9 +203,8 @@ bool SCEVCastExpr::dominates(BasicBlock *BB, DominatorTree *DT) const {
// particular input. Don't use a const SCEV* here, or else the object will
// never be deleted!
SCEVTruncateExpr::SCEVTruncateExpr(const SCEV* op, const Type *ty,
const ScalarEvolution* p)
: SCEVCastExpr(scTruncate, op, ty, p) {
SCEVTruncateExpr::SCEVTruncateExpr(const SCEV* op, const Type *ty)
: SCEVCastExpr(scTruncate, op, ty) {
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
(Ty->isInteger() || isa<PointerType>(Ty)) &&
"Cannot truncate non-integer value!");
@ -225,9 +219,8 @@ void SCEVTruncateExpr::print(raw_ostream &OS) const {
// particular input. Don't use a const SCEV* here, or else the object will never
// be deleted!
SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEV* op, const Type *ty,
const ScalarEvolution* p)
: SCEVCastExpr(scZeroExtend, op, ty, p) {
SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEV* op, const Type *ty)
: SCEVCastExpr(scZeroExtend, op, ty) {
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
(Ty->isInteger() || isa<PointerType>(Ty)) &&
"Cannot zero extend non-integer value!");
@ -241,9 +234,8 @@ void SCEVZeroExtendExpr::print(raw_ostream &OS) const {
// particular input. Don't use a const SCEV* here, or else the object will never
// be deleted!
SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEV* op, const Type *ty,
const ScalarEvolution* p)
: SCEVCastExpr(scSignExtend, op, ty, p) {
SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEV* op, const Type *ty)
: SCEVCastExpr(scSignExtend, op, ty) {
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
(Ty->isInteger() || isa<PointerType>(Ty)) &&
"Cannot sign extend non-integer value!");
@ -745,7 +737,7 @@ const SCEV* ScalarEvolution::getTruncateExpr(const SCEV* Op,
}
SCEVTruncateExpr *&Result = SCEVTruncates[std::make_pair(Op, Ty)];
if (Result == 0) Result = new SCEVTruncateExpr(Op, Ty, this);
if (Result == 0) Result = new SCEVTruncateExpr(Op, Ty);
return Result;
}
@ -833,7 +825,7 @@ const SCEV* ScalarEvolution::getZeroExtendExpr(const SCEV* Op,
}
SCEVZeroExtendExpr *&Result = SCEVZeroExtends[std::make_pair(Op, Ty)];
if (Result == 0) Result = new SCEVZeroExtendExpr(Op, Ty, this);
if (Result == 0) Result = new SCEVZeroExtendExpr(Op, Ty);
return Result;
}
@ -905,7 +897,7 @@ const SCEV* ScalarEvolution::getSignExtendExpr(const SCEV* Op,
}
SCEVSignExtendExpr *&Result = SCEVSignExtends[std::make_pair(Op, Ty)];
if (Result == 0) Result = new SCEVSignExtendExpr(Op, Ty, this);
if (Result == 0) Result = new SCEVSignExtendExpr(Op, Ty);
return Result;
}
@ -1367,7 +1359,7 @@ const SCEV* ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV*> &Ops) {
std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scAddExpr,
SCEVOps)];
if (Result == 0) Result = new SCEVAddExpr(Ops, this);
if (Result == 0) Result = new SCEVAddExpr(Ops);
return Result;
}
@ -1533,7 +1525,7 @@ const SCEV* ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV*> &Ops) {
SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scMulExpr,
SCEVOps)];
if (Result == 0)
Result = new SCEVMulExpr(Ops, this);
Result = new SCEVMulExpr(Ops);
return Result;
}
@ -1624,7 +1616,7 @@ const SCEV* ScalarEvolution::getUDivExpr(const SCEV* LHS,
}
SCEVUDivExpr *&Result = SCEVUDivs[std::make_pair(LHS, RHS)];
if (Result == 0) Result = new SCEVUDivExpr(LHS, RHS, this);
if (Result == 0) Result = new SCEVUDivExpr(LHS, RHS);
return Result;
}
@ -1677,7 +1669,7 @@ const SCEV* ScalarEvolution::getAddRecExpr(SmallVectorImpl<const SCEV*> &Operand
std::vector<const SCEV*> SCEVOps(Operands.begin(), Operands.end());
SCEVAddRecExpr *&Result = SCEVAddRecExprs[std::make_pair(L, SCEVOps)];
if (Result == 0) Result = new SCEVAddRecExpr(Operands, L, this);
if (Result == 0) Result = new SCEVAddRecExpr(Operands, L);
return Result;
}
@ -1764,7 +1756,7 @@ ScalarEvolution::getSMaxExpr(SmallVectorImpl<const SCEV*> &Ops) {
std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scSMaxExpr,
SCEVOps)];
if (Result == 0) Result = new SCEVSMaxExpr(Ops, this);
if (Result == 0) Result = new SCEVSMaxExpr(Ops);
return Result;
}
@ -1851,7 +1843,7 @@ ScalarEvolution::getUMaxExpr(SmallVectorImpl<const SCEV*> &Ops) {
std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scUMaxExpr,
SCEVOps)];
if (Result == 0) Result = new SCEVUMaxExpr(Ops, this);
if (Result == 0) Result = new SCEVUMaxExpr(Ops);
return Result;
}
@ -1873,7 +1865,7 @@ const SCEV* ScalarEvolution::getUnknown(Value *V) {
if (isa<ConstantPointerNull>(V))
return getIntegerSCEV(0, V->getType());
SCEVUnknown *&Result = SCEVUnknowns[V];
if (Result == 0) Result = new SCEVUnknown(V, this);
if (Result == 0) Result = new SCEVUnknown(V);
return Result;
}
@ -4261,7 +4253,7 @@ ScalarEvolution::SCEVCallbackVH::SCEVCallbackVH(Value *V, ScalarEvolution *se)
//===----------------------------------------------------------------------===//
ScalarEvolution::ScalarEvolution()
: FunctionPass(&ID), CouldNotCompute(new SCEVCouldNotCompute(0)) {
: FunctionPass(&ID), CouldNotCompute(new SCEVCouldNotCompute()) {
}
bool ScalarEvolution::runOnFunction(Function &F) {