aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Analysis/ScalarEvolutionExpressions.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Analysis/ScalarEvolutionExpressions.h')
-rw-r--r--include/llvm/Analysis/ScalarEvolutionExpressions.h50
1 files changed, 26 insertions, 24 deletions
diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h
index 0ab3b3f4a5..27539a3753 100644
--- a/include/llvm/Analysis/ScalarEvolutionExpressions.h
+++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h
@@ -180,25 +180,27 @@ namespace llvm {
///
class SCEVNAryExpr : public SCEV {
protected:
- SmallVector<const SCEV *, 8> Operands;
+ // Since SCEVs are immutable, ScalarEvolution allocates operand
+ // arrays with its SCEVAllocator, so this class just needs a simple
+ // pointer rather than a more elaborate vector-like data structure.
+ // This also avoids the need for a non-trivial destructor.
+ const SCEV *const *Operands;
+ size_t NumOperands;
SCEVNAryExpr(const FoldingSetNodeID &ID,
- enum SCEVTypes T, const SmallVectorImpl<const SCEV *> &ops)
- : SCEV(ID, T), Operands(ops.begin(), ops.end()) {}
+ enum SCEVTypes T, const SCEV *const *O, size_t N)
+ : SCEV(ID, T), Operands(O), NumOperands(N) {}
public:
- unsigned getNumOperands() const { return (unsigned)Operands.size(); }
+ size_t getNumOperands() const { return NumOperands; }
const SCEV *getOperand(unsigned i) const {
- assert(i < Operands.size() && "Operand index out of range!");
+ assert(i < NumOperands && "Operand index out of range!");
return Operands[i];
}
- const SmallVectorImpl<const SCEV *> &getOperands() const {
- return Operands;
- }
- typedef SmallVectorImpl<const SCEV *>::const_iterator op_iterator;
- op_iterator op_begin() const { return Operands.begin(); }
- op_iterator op_end() const { return Operands.end(); }
+ typedef const SCEV *const *op_iterator;
+ op_iterator op_begin() const { return Operands; }
+ op_iterator op_end() const { return Operands + NumOperands; }
virtual bool isLoopInvariant(const Loop *L) const {
for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
@@ -262,8 +264,8 @@ namespace llvm {
protected:
SCEVCommutativeExpr(const FoldingSetNodeID &ID,
enum SCEVTypes T,
- const SmallVectorImpl<const SCEV *> &ops)
- : SCEVNAryExpr(ID, T, ops) {}
+ const SCEV *const *O, size_t N)
+ : SCEVNAryExpr(ID, T, O, N) {}
public:
virtual const char *getOperationStr() const = 0;
@@ -288,8 +290,8 @@ namespace llvm {
friend class ScalarEvolution;
SCEVAddExpr(const FoldingSetNodeID &ID,
- const SmallVectorImpl<const SCEV *> &ops)
- : SCEVCommutativeExpr(ID, scAddExpr, ops) {
+ const SCEV *const *O, size_t N)
+ : SCEVCommutativeExpr(ID, scAddExpr, O, N) {
}
public:
@@ -316,8 +318,8 @@ namespace llvm {
friend class ScalarEvolution;
SCEVMulExpr(const FoldingSetNodeID &ID,
- const SmallVectorImpl<const SCEV *> &ops)
- : SCEVCommutativeExpr(ID, scMulExpr, ops) {
+ const SCEV *const *O, size_t N)
+ : SCEVCommutativeExpr(ID, scMulExpr, O, N) {
}
public:
@@ -390,9 +392,9 @@ namespace llvm {
const Loop *L;
SCEVAddRecExpr(const FoldingSetNodeID &ID,
- const SmallVectorImpl<const SCEV *> &ops, const Loop *l)
- : SCEVNAryExpr(ID, scAddRecExpr, ops), L(l) {
- for (size_t i = 0, e = Operands.size(); i != e; ++i)
+ const SCEV *const *O, size_t N, const Loop *l)
+ : SCEVNAryExpr(ID, 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,8 +474,8 @@ namespace llvm {
friend class ScalarEvolution;
SCEVSMaxExpr(const FoldingSetNodeID &ID,
- const SmallVectorImpl<const SCEV *> &ops)
- : SCEVCommutativeExpr(ID, scSMaxExpr, ops) {
+ const SCEV *const *O, size_t N)
+ : SCEVCommutativeExpr(ID, scSMaxExpr, O, N) {
// Max never overflows.
setHasNoUnsignedWrap(true);
setHasNoSignedWrap(true);
@@ -497,8 +499,8 @@ namespace llvm {
friend class ScalarEvolution;
SCEVUMaxExpr(const FoldingSetNodeID &ID,
- const SmallVectorImpl<const SCEV *> &ops)
- : SCEVCommutativeExpr(ID, scUMaxExpr, ops) {
+ const SCEV *const *O, size_t N)
+ : SCEVCommutativeExpr(ID, scUMaxExpr, O, N) {
// Max never overflows.
setHasNoUnsignedWrap(true);
setHasNoSignedWrap(true);