Convert several parts of the ScalarEvolution framework to use

SmallVector instead of std::vector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73357 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-06-14 22:47:23 +00:00
parent ea73f3c2e1
commit a82752c9eb
5 changed files with 80 additions and 74 deletions

View File

@@ -394,24 +394,24 @@ namespace llvm {
SCEVHandle getZeroExtendExpr(const SCEVHandle &Op, const Type *Ty);
SCEVHandle getSignExtendExpr(const SCEVHandle &Op, const Type *Ty);
SCEVHandle getAnyExtendExpr(const SCEVHandle &Op, const Type *Ty);
SCEVHandle getAddExpr(std::vector<SCEVHandle> &Ops);
SCEVHandle getAddExpr(SmallVectorImpl<SCEVHandle> &Ops);
SCEVHandle getAddExpr(const SCEVHandle &LHS, const SCEVHandle &RHS) {
std::vector<SCEVHandle> Ops;
SmallVector<SCEVHandle, 2> Ops;
Ops.push_back(LHS);
Ops.push_back(RHS);
return getAddExpr(Ops);
}
SCEVHandle getAddExpr(const SCEVHandle &Op0, const SCEVHandle &Op1,
const SCEVHandle &Op2) {
std::vector<SCEVHandle> Ops;
SmallVector<SCEVHandle, 3> Ops;
Ops.push_back(Op0);
Ops.push_back(Op1);
Ops.push_back(Op2);
return getAddExpr(Ops);
}
SCEVHandle getMulExpr(std::vector<SCEVHandle> &Ops);
SCEVHandle getMulExpr(SmallVectorImpl<SCEVHandle> &Ops);
SCEVHandle getMulExpr(const SCEVHandle &LHS, const SCEVHandle &RHS) {
std::vector<SCEVHandle> Ops;
SmallVector<SCEVHandle, 2> Ops;
Ops.push_back(LHS);
Ops.push_back(RHS);
return getMulExpr(Ops);
@@ -419,17 +419,17 @@ namespace llvm {
SCEVHandle getUDivExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
SCEVHandle getAddRecExpr(const SCEVHandle &Start, const SCEVHandle &Step,
const Loop *L);
SCEVHandle getAddRecExpr(std::vector<SCEVHandle> &Operands,
SCEVHandle getAddRecExpr(SmallVectorImpl<SCEVHandle> &Operands,
const Loop *L);
SCEVHandle getAddRecExpr(const std::vector<SCEVHandle> &Operands,
SCEVHandle getAddRecExpr(const SmallVectorImpl<SCEVHandle> &Operands,
const Loop *L) {
std::vector<SCEVHandle> NewOp(Operands);
SmallVector<SCEVHandle, 4> NewOp(Operands.begin(), Operands.end());
return getAddRecExpr(NewOp, L);
}
SCEVHandle getSMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
SCEVHandle getSMaxExpr(std::vector<SCEVHandle> Operands);
SCEVHandle getSMaxExpr(SmallVectorImpl<SCEVHandle> &Operands);
SCEVHandle getUMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
SCEVHandle getUMaxExpr(std::vector<SCEVHandle> Operands);
SCEVHandle getUMaxExpr(SmallVectorImpl<SCEVHandle> &Operands);
SCEVHandle getUnknown(Value *V);
SCEVHandle getCouldNotCompute();

View File

@@ -199,10 +199,10 @@ namespace llvm {
///
class SCEVNAryExpr : public SCEV {
protected:
std::vector<SCEVHandle> Operands;
SmallVector<SCEVHandle, 8> Operands;
SCEVNAryExpr(enum SCEVTypes T, const std::vector<SCEVHandle> &ops)
: SCEV(T), Operands(ops) {}
SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl<SCEVHandle> &ops)
: SCEV(T), Operands(ops.begin(), ops.end()) {}
virtual ~SCEVNAryExpr() {}
public:
@@ -212,8 +212,8 @@ namespace llvm {
return Operands[i];
}
const std::vector<SCEVHandle> &getOperands() const { return Operands; }
typedef std::vector<SCEVHandle>::const_iterator op_iterator;
const SmallVectorImpl<SCEVHandle> &getOperands() const { return Operands; }
typedef SmallVectorImpl<SCEVHandle>::const_iterator op_iterator;
op_iterator op_begin() const { return Operands.begin(); }
op_iterator op_end() const { return Operands.end(); }
@@ -259,7 +259,7 @@ namespace llvm {
///
class SCEVCommutativeExpr : public SCEVNAryExpr {
protected:
SCEVCommutativeExpr(enum SCEVTypes T, const std::vector<SCEVHandle> &ops)
SCEVCommutativeExpr(enum SCEVTypes T, const SmallVectorImpl<SCEVHandle> &ops)
: SCEVNAryExpr(T, ops) {}
~SCEVCommutativeExpr();
@@ -289,7 +289,7 @@ namespace llvm {
class SCEVAddExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
explicit SCEVAddExpr(const std::vector<SCEVHandle> &ops)
explicit SCEVAddExpr(const SmallVectorImpl<SCEVHandle> &ops)
: SCEVCommutativeExpr(scAddExpr, ops) {
}
@@ -309,7 +309,7 @@ namespace llvm {
class SCEVMulExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
explicit SCEVMulExpr(const std::vector<SCEVHandle> &ops)
explicit SCEVMulExpr(const SmallVectorImpl<SCEVHandle> &ops)
: SCEVCommutativeExpr(scMulExpr, ops) {
}
@@ -387,7 +387,7 @@ namespace llvm {
const Loop *L;
SCEVAddRecExpr(const std::vector<SCEVHandle> &ops, const Loop *l)
SCEVAddRecExpr(const SmallVectorImpl<SCEVHandle> &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) &&
@@ -404,7 +404,7 @@ namespace llvm {
/// of degree N, it returns a chrec of degree N-1.
SCEVHandle getStepRecurrence(ScalarEvolution &SE) const {
if (isAffine()) return getOperand(1);
return SE.getAddRecExpr(std::vector<SCEVHandle>(op_begin()+1,op_end()),
return SE.getAddRecExpr(SmallVector<SCEVHandle, 3>(op_begin()+1,op_end()),
getLoop());
}
@@ -463,7 +463,7 @@ namespace llvm {
class SCEVSMaxExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
explicit SCEVSMaxExpr(const std::vector<SCEVHandle> &ops)
explicit SCEVSMaxExpr(const SmallVectorImpl<SCEVHandle> &ops)
: SCEVCommutativeExpr(scSMaxExpr, ops) {
}
@@ -484,7 +484,7 @@ namespace llvm {
class SCEVUMaxExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
explicit SCEVUMaxExpr(const std::vector<SCEVHandle> &ops)
explicit SCEVUMaxExpr(const SmallVectorImpl<SCEVHandle> &ops)
: SCEVCommutativeExpr(scUMaxExpr, ops) {
}