mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
Convert SCEV from FoldingSetNode to FastFoldingSetNode. This eliminates
a bunch of redundent code in Profile methods, and prepares for upcoming changes to do improved memoization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75494 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -42,7 +42,7 @@ namespace llvm {
|
|||||||
/// are opaque objects that the client is not allowed to do much with
|
/// are opaque objects that the client is not allowed to do much with
|
||||||
/// directly.
|
/// directly.
|
||||||
///
|
///
|
||||||
class SCEV : public FoldingSetNode {
|
class SCEV : public FastFoldingSetNode {
|
||||||
const unsigned SCEVType; // The SCEV baseclass this node corresponds to
|
const unsigned SCEVType; // The SCEV baseclass this node corresponds to
|
||||||
|
|
||||||
SCEV(const SCEV &); // DO NOT IMPLEMENT
|
SCEV(const SCEV &); // DO NOT IMPLEMENT
|
||||||
@ -50,10 +50,8 @@ namespace llvm {
|
|||||||
protected:
|
protected:
|
||||||
virtual ~SCEV();
|
virtual ~SCEV();
|
||||||
public:
|
public:
|
||||||
explicit SCEV(unsigned SCEVTy) :
|
explicit SCEV(const FoldingSetNodeID &ID, unsigned SCEVTy) :
|
||||||
SCEVType(SCEVTy) {}
|
FastFoldingSetNode(ID), SCEVType(SCEVTy) {}
|
||||||
|
|
||||||
virtual void Profile(FoldingSetNodeID &ID) const = 0;
|
|
||||||
|
|
||||||
unsigned getSCEVType() const { return SCEVType; }
|
unsigned getSCEVType() const { return SCEVType; }
|
||||||
|
|
||||||
@ -129,7 +127,6 @@ namespace llvm {
|
|||||||
SCEVCouldNotCompute();
|
SCEVCouldNotCompute();
|
||||||
|
|
||||||
// None of these methods are valid for this object.
|
// None of these methods are valid for this object.
|
||||||
virtual void Profile(FoldingSetNodeID &ID) const;
|
|
||||||
virtual bool isLoopInvariant(const Loop *L) const;
|
virtual bool isLoopInvariant(const Loop *L) const;
|
||||||
virtual const Type *getType() const;
|
virtual const Type *getType() const;
|
||||||
virtual bool hasComputableLoopEvolution(const Loop *L) const;
|
virtual bool hasComputableLoopEvolution(const Loop *L) const;
|
||||||
|
@ -37,11 +37,9 @@ namespace llvm {
|
|||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
ConstantInt *V;
|
ConstantInt *V;
|
||||||
explicit SCEVConstant(ConstantInt *v) :
|
SCEVConstant(const FoldingSetNodeID &ID, ConstantInt *v) :
|
||||||
SCEV(scConstant), V(v) {}
|
SCEV(ID, scConstant), V(v) {}
|
||||||
public:
|
public:
|
||||||
virtual void Profile(FoldingSetNodeID &ID) const;
|
|
||||||
|
|
||||||
ConstantInt *getValue() const { return V; }
|
ConstantInt *getValue() const { return V; }
|
||||||
|
|
||||||
virtual bool isLoopInvariant(const Loop *L) const {
|
virtual bool isLoopInvariant(const Loop *L) const {
|
||||||
@ -81,11 +79,10 @@ namespace llvm {
|
|||||||
const SCEV *Op;
|
const SCEV *Op;
|
||||||
const Type *Ty;
|
const Type *Ty;
|
||||||
|
|
||||||
SCEVCastExpr(unsigned SCEVTy, const SCEV *op, const Type *ty);
|
SCEVCastExpr(const FoldingSetNodeID &ID,
|
||||||
|
unsigned SCEVTy, const SCEV *op, const Type *ty);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void Profile(FoldingSetNodeID &ID) const;
|
|
||||||
|
|
||||||
const SCEV *getOperand() const { return Op; }
|
const SCEV *getOperand() const { return Op; }
|
||||||
virtual const Type *getType() const { return Ty; }
|
virtual const Type *getType() const { return Ty; }
|
||||||
|
|
||||||
@ -115,7 +112,8 @@ namespace llvm {
|
|||||||
class SCEVTruncateExpr : public SCEVCastExpr {
|
class SCEVTruncateExpr : public SCEVCastExpr {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
SCEVTruncateExpr(const SCEV *op, const Type *ty);
|
SCEVTruncateExpr(const FoldingSetNodeID &ID,
|
||||||
|
const SCEV *op, const Type *ty);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym,
|
const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym,
|
||||||
@ -143,7 +141,8 @@ namespace llvm {
|
|||||||
class SCEVZeroExtendExpr : public SCEVCastExpr {
|
class SCEVZeroExtendExpr : public SCEVCastExpr {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
SCEVZeroExtendExpr(const SCEV *op, const Type *ty);
|
SCEVZeroExtendExpr(const FoldingSetNodeID &ID,
|
||||||
|
const SCEV *op, const Type *ty);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym,
|
const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym,
|
||||||
@ -171,7 +170,8 @@ namespace llvm {
|
|||||||
class SCEVSignExtendExpr : public SCEVCastExpr {
|
class SCEVSignExtendExpr : public SCEVCastExpr {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
SCEVSignExtendExpr(const SCEV *op, const Type *ty);
|
SCEVSignExtendExpr(const FoldingSetNodeID &ID,
|
||||||
|
const SCEV *op, const Type *ty);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym,
|
const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym,
|
||||||
@ -201,12 +201,11 @@ namespace llvm {
|
|||||||
protected:
|
protected:
|
||||||
SmallVector<const SCEV *, 8> Operands;
|
SmallVector<const SCEV *, 8> Operands;
|
||||||
|
|
||||||
SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl<const SCEV *> &ops)
|
SCEVNAryExpr(const FoldingSetNodeID &ID,
|
||||||
: SCEV(T), Operands(ops.begin(), ops.end()) {}
|
enum SCEVTypes T, const SmallVectorImpl<const SCEV *> &ops)
|
||||||
|
: SCEV(ID, T), Operands(ops.begin(), ops.end()) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void Profile(FoldingSetNodeID &ID) const;
|
|
||||||
|
|
||||||
unsigned getNumOperands() const { return (unsigned)Operands.size(); }
|
unsigned getNumOperands() const { return (unsigned)Operands.size(); }
|
||||||
const SCEV *getOperand(unsigned i) const {
|
const SCEV *getOperand(unsigned i) const {
|
||||||
assert(i < Operands.size() && "Operand index out of range!");
|
assert(i < Operands.size() && "Operand index out of range!");
|
||||||
@ -262,9 +261,10 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
class SCEVCommutativeExpr : public SCEVNAryExpr {
|
class SCEVCommutativeExpr : public SCEVNAryExpr {
|
||||||
protected:
|
protected:
|
||||||
SCEVCommutativeExpr(enum SCEVTypes T,
|
SCEVCommutativeExpr(const FoldingSetNodeID &ID,
|
||||||
|
enum SCEVTypes T,
|
||||||
const SmallVectorImpl<const SCEV *> &ops)
|
const SmallVectorImpl<const SCEV *> &ops)
|
||||||
: SCEVNAryExpr(T, ops) {}
|
: SCEVNAryExpr(ID, T, ops) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym,
|
const SCEV *replaceSymbolicValuesWithConcrete(const SCEV *Sym,
|
||||||
@ -292,8 +292,9 @@ namespace llvm {
|
|||||||
class SCEVAddExpr : public SCEVCommutativeExpr {
|
class SCEVAddExpr : public SCEVCommutativeExpr {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
explicit SCEVAddExpr(const SmallVectorImpl<const SCEV *> &ops)
|
SCEVAddExpr(const FoldingSetNodeID &ID,
|
||||||
: SCEVCommutativeExpr(scAddExpr, ops) {
|
const SmallVectorImpl<const SCEV *> &ops)
|
||||||
|
: SCEVCommutativeExpr(ID, scAddExpr, ops) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -312,8 +313,9 @@ namespace llvm {
|
|||||||
class SCEVMulExpr : public SCEVCommutativeExpr {
|
class SCEVMulExpr : public SCEVCommutativeExpr {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
explicit SCEVMulExpr(const SmallVectorImpl<const SCEV *> &ops)
|
SCEVMulExpr(const FoldingSetNodeID &ID,
|
||||||
: SCEVCommutativeExpr(scMulExpr, ops) {
|
const SmallVectorImpl<const SCEV *> &ops)
|
||||||
|
: SCEVCommutativeExpr(ID, scMulExpr, ops) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -335,12 +337,10 @@ namespace llvm {
|
|||||||
|
|
||||||
const SCEV *LHS;
|
const SCEV *LHS;
|
||||||
const SCEV *RHS;
|
const SCEV *RHS;
|
||||||
SCEVUDivExpr(const SCEV *lhs, const SCEV *rhs)
|
SCEVUDivExpr(const FoldingSetNodeID &ID, const SCEV *lhs, const SCEV *rhs)
|
||||||
: SCEV(scUDivExpr), LHS(lhs), RHS(rhs) {}
|
: SCEV(ID, scUDivExpr), LHS(lhs), RHS(rhs) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void Profile(FoldingSetNodeID &ID) const;
|
|
||||||
|
|
||||||
const SCEV *getLHS() const { return LHS; }
|
const SCEV *getLHS() const { return LHS; }
|
||||||
const SCEV *getRHS() const { return RHS; }
|
const SCEV *getRHS() const { return RHS; }
|
||||||
|
|
||||||
@ -392,16 +392,15 @@ namespace llvm {
|
|||||||
|
|
||||||
const Loop *L;
|
const Loop *L;
|
||||||
|
|
||||||
SCEVAddRecExpr(const SmallVectorImpl<const SCEV *> &ops, const Loop *l)
|
SCEVAddRecExpr(const FoldingSetNodeID &ID,
|
||||||
: SCEVNAryExpr(scAddRecExpr, ops), L(l) {
|
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)
|
for (size_t i = 0, e = Operands.size(); i != e; ++i)
|
||||||
assert(Operands[i]->isLoopInvariant(l) &&
|
assert(Operands[i]->isLoopInvariant(l) &&
|
||||||
"Operands of AddRec must be loop-invariant!");
|
"Operands of AddRec must be loop-invariant!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void Profile(FoldingSetNodeID &ID) const;
|
|
||||||
|
|
||||||
const SCEV *getStart() const { return Operands[0]; }
|
const SCEV *getStart() const { return Operands[0]; }
|
||||||
const Loop *getLoop() const { return L; }
|
const Loop *getLoop() const { return L; }
|
||||||
|
|
||||||
@ -454,6 +453,12 @@ namespace llvm {
|
|||||||
const SCEV *Conc,
|
const SCEV *Conc,
|
||||||
ScalarEvolution &SE) const;
|
ScalarEvolution &SE) const;
|
||||||
|
|
||||||
|
/// getPostIncExpr - Return an expression representing the value of
|
||||||
|
/// this expression one iteration of the loop ahead.
|
||||||
|
const SCEV *getPostIncExpr(ScalarEvolution &SE) const {
|
||||||
|
return SE.getAddExpr(this, getStepRecurrence(SE));
|
||||||
|
}
|
||||||
|
|
||||||
virtual void print(raw_ostream &OS) const;
|
virtual void print(raw_ostream &OS) const;
|
||||||
|
|
||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
@ -470,8 +475,9 @@ namespace llvm {
|
|||||||
class SCEVSMaxExpr : public SCEVCommutativeExpr {
|
class SCEVSMaxExpr : public SCEVCommutativeExpr {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
explicit SCEVSMaxExpr(const SmallVectorImpl<const SCEV *> &ops)
|
SCEVSMaxExpr(const FoldingSetNodeID &ID,
|
||||||
: SCEVCommutativeExpr(scSMaxExpr, ops) {
|
const SmallVectorImpl<const SCEV *> &ops)
|
||||||
|
: SCEVCommutativeExpr(ID, scSMaxExpr, ops) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -491,8 +497,9 @@ namespace llvm {
|
|||||||
class SCEVUMaxExpr : public SCEVCommutativeExpr {
|
class SCEVUMaxExpr : public SCEVCommutativeExpr {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
explicit SCEVUMaxExpr(const SmallVectorImpl<const SCEV *> &ops)
|
SCEVUMaxExpr(const FoldingSetNodeID &ID,
|
||||||
: SCEVCommutativeExpr(scUMaxExpr, ops) {
|
const SmallVectorImpl<const SCEV *> &ops)
|
||||||
|
: SCEVCommutativeExpr(ID, scUMaxExpr, ops) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -515,12 +522,10 @@ namespace llvm {
|
|||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
Value *V;
|
Value *V;
|
||||||
explicit SCEVUnknown(Value *v) :
|
SCEVUnknown(const FoldingSetNodeID &ID, Value *v) :
|
||||||
SCEV(scUnknown), V(v) {}
|
SCEV(ID, scUnknown), V(v) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void Profile(FoldingSetNodeID &ID) const;
|
|
||||||
|
|
||||||
Value *getValue() const { return V; }
|
Value *getValue() const { return V; }
|
||||||
|
|
||||||
virtual bool isLoopInvariant(const Loop *L) const;
|
virtual bool isLoopInvariant(const Loop *L) const;
|
||||||
|
@ -145,11 +145,7 @@ bool SCEV::isAllOnesValue() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SCEVCouldNotCompute::SCEVCouldNotCompute() :
|
SCEVCouldNotCompute::SCEVCouldNotCompute() :
|
||||||
SCEV(scCouldNotCompute) {}
|
SCEV(FoldingSetNodeID(), scCouldNotCompute) {}
|
||||||
|
|
||||||
void SCEVCouldNotCompute::Profile(FoldingSetNodeID &ID) const {
|
|
||||||
LLVM_UNREACHABLE("Attempt to use a SCEVCouldNotCompute object!");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SCEVCouldNotCompute::isLoopInvariant(const Loop *L) const {
|
bool SCEVCouldNotCompute::isLoopInvariant(const Loop *L) const {
|
||||||
LLVM_UNREACHABLE("Attempt to use a SCEVCouldNotCompute object!");
|
LLVM_UNREACHABLE("Attempt to use a SCEVCouldNotCompute object!");
|
||||||
@ -189,7 +185,7 @@ const SCEV *ScalarEvolution::getConstant(ConstantInt *V) {
|
|||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVConstant>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVConstant>();
|
||||||
new (S) SCEVConstant(V);
|
new (S) SCEVConstant(ID, V);
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
@ -203,33 +199,23 @@ ScalarEvolution::getConstant(const Type *Ty, uint64_t V, bool isSigned) {
|
|||||||
return getConstant(ConstantInt::get(cast<IntegerType>(Ty), V, isSigned));
|
return getConstant(ConstantInt::get(cast<IntegerType>(Ty), V, isSigned));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCEVConstant::Profile(FoldingSetNodeID &ID) const {
|
|
||||||
ID.AddInteger(scConstant);
|
|
||||||
ID.AddPointer(V);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Type *SCEVConstant::getType() const { return V->getType(); }
|
const Type *SCEVConstant::getType() const { return V->getType(); }
|
||||||
|
|
||||||
void SCEVConstant::print(raw_ostream &OS) const {
|
void SCEVConstant::print(raw_ostream &OS) const {
|
||||||
WriteAsOperand(OS, V, false);
|
WriteAsOperand(OS, V, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCEVCastExpr::SCEVCastExpr(unsigned SCEVTy,
|
SCEVCastExpr::SCEVCastExpr(const FoldingSetNodeID &ID,
|
||||||
const SCEV *op, const Type *ty)
|
unsigned SCEVTy, const SCEV *op, const Type *ty)
|
||||||
: SCEV(SCEVTy), Op(op), Ty(ty) {}
|
: SCEV(ID, SCEVTy), Op(op), Ty(ty) {}
|
||||||
|
|
||||||
void SCEVCastExpr::Profile(FoldingSetNodeID &ID) const {
|
|
||||||
ID.AddInteger(getSCEVType());
|
|
||||||
ID.AddPointer(Op);
|
|
||||||
ID.AddPointer(Ty);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SCEVCastExpr::dominates(BasicBlock *BB, DominatorTree *DT) const {
|
bool SCEVCastExpr::dominates(BasicBlock *BB, DominatorTree *DT) const {
|
||||||
return Op->dominates(BB, DT);
|
return Op->dominates(BB, DT);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCEVTruncateExpr::SCEVTruncateExpr(const SCEV *op, const Type *ty)
|
SCEVTruncateExpr::SCEVTruncateExpr(const FoldingSetNodeID &ID,
|
||||||
: SCEVCastExpr(scTruncate, op, ty) {
|
const SCEV *op, const Type *ty)
|
||||||
|
: SCEVCastExpr(ID, scTruncate, op, ty) {
|
||||||
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
|
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
|
||||||
(Ty->isInteger() || isa<PointerType>(Ty)) &&
|
(Ty->isInteger() || isa<PointerType>(Ty)) &&
|
||||||
"Cannot truncate non-integer value!");
|
"Cannot truncate non-integer value!");
|
||||||
@ -239,8 +225,9 @@ void SCEVTruncateExpr::print(raw_ostream &OS) const {
|
|||||||
OS << "(trunc " << *Op->getType() << " " << *Op << " to " << *Ty << ")";
|
OS << "(trunc " << *Op->getType() << " " << *Op << " to " << *Ty << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEV *op, const Type *ty)
|
SCEVZeroExtendExpr::SCEVZeroExtendExpr(const FoldingSetNodeID &ID,
|
||||||
: SCEVCastExpr(scZeroExtend, op, ty) {
|
const SCEV *op, const Type *ty)
|
||||||
|
: SCEVCastExpr(ID, scZeroExtend, op, ty) {
|
||||||
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
|
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
|
||||||
(Ty->isInteger() || isa<PointerType>(Ty)) &&
|
(Ty->isInteger() || isa<PointerType>(Ty)) &&
|
||||||
"Cannot zero extend non-integer value!");
|
"Cannot zero extend non-integer value!");
|
||||||
@ -250,8 +237,9 @@ void SCEVZeroExtendExpr::print(raw_ostream &OS) const {
|
|||||||
OS << "(zext " << *Op->getType() << " " << *Op << " to " << *Ty << ")";
|
OS << "(zext " << *Op->getType() << " " << *Op << " to " << *Ty << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEV *op, const Type *ty)
|
SCEVSignExtendExpr::SCEVSignExtendExpr(const FoldingSetNodeID &ID,
|
||||||
: SCEVCastExpr(scSignExtend, op, ty) {
|
const SCEV *op, const Type *ty)
|
||||||
|
: SCEVCastExpr(ID, scSignExtend, op, ty) {
|
||||||
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
|
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
|
||||||
(Ty->isInteger() || isa<PointerType>(Ty)) &&
|
(Ty->isInteger() || isa<PointerType>(Ty)) &&
|
||||||
"Cannot sign extend non-integer value!");
|
"Cannot sign extend non-integer value!");
|
||||||
@ -303,13 +291,6 @@ SCEVCommutativeExpr::replaceSymbolicValuesWithConcrete(
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCEVNAryExpr::Profile(FoldingSetNodeID &ID) const {
|
|
||||||
ID.AddInteger(getSCEVType());
|
|
||||||
ID.AddInteger(Operands.size());
|
|
||||||
for (unsigned i = 0, e = Operands.size(); i != e; ++i)
|
|
||||||
ID.AddPointer(Operands[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SCEVNAryExpr::dominates(BasicBlock *BB, DominatorTree *DT) const {
|
bool SCEVNAryExpr::dominates(BasicBlock *BB, DominatorTree *DT) const {
|
||||||
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
|
||||||
if (!getOperand(i)->dominates(BB, DT))
|
if (!getOperand(i)->dominates(BB, DT))
|
||||||
@ -318,12 +299,6 @@ bool SCEVNAryExpr::dominates(BasicBlock *BB, DominatorTree *DT) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCEVUDivExpr::Profile(FoldingSetNodeID &ID) const {
|
|
||||||
ID.AddInteger(scUDivExpr);
|
|
||||||
ID.AddPointer(LHS);
|
|
||||||
ID.AddPointer(RHS);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SCEVUDivExpr::dominates(BasicBlock *BB, DominatorTree *DT) const {
|
bool SCEVUDivExpr::dominates(BasicBlock *BB, DominatorTree *DT) const {
|
||||||
return LHS->dominates(BB, DT) && RHS->dominates(BB, DT);
|
return LHS->dominates(BB, DT) && RHS->dominates(BB, DT);
|
||||||
}
|
}
|
||||||
@ -341,14 +316,6 @@ const Type *SCEVUDivExpr::getType() const {
|
|||||||
return RHS->getType();
|
return RHS->getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCEVAddRecExpr::Profile(FoldingSetNodeID &ID) const {
|
|
||||||
ID.AddInteger(scAddRecExpr);
|
|
||||||
ID.AddInteger(Operands.size());
|
|
||||||
for (unsigned i = 0, e = Operands.size(); i != e; ++i)
|
|
||||||
ID.AddPointer(Operands[i]);
|
|
||||||
ID.AddPointer(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
const SCEV *
|
const SCEV *
|
||||||
SCEVAddRecExpr::replaceSymbolicValuesWithConcrete(const SCEV *Sym,
|
SCEVAddRecExpr::replaceSymbolicValuesWithConcrete(const SCEV *Sym,
|
||||||
const SCEV *Conc,
|
const SCEV *Conc,
|
||||||
@ -399,11 +366,6 @@ void SCEVAddRecExpr::print(raw_ostream &OS) const {
|
|||||||
OS << "}<" << L->getHeader()->getName() + ">";
|
OS << "}<" << L->getHeader()->getName() + ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCEVUnknown::Profile(FoldingSetNodeID &ID) const {
|
|
||||||
ID.AddInteger(scUnknown);
|
|
||||||
ID.AddPointer(V);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SCEVUnknown::isLoopInvariant(const Loop *L) const {
|
bool SCEVUnknown::isLoopInvariant(const Loop *L) const {
|
||||||
// All non-instruction values are loop invariant. All instructions are loop
|
// All non-instruction values are loop invariant. All instructions are loop
|
||||||
// invariant if they are not contained in the specified loop.
|
// invariant if they are not contained in the specified loop.
|
||||||
@ -749,6 +711,13 @@ const SCEV *ScalarEvolution::getTruncateExpr(const SCEV *Op,
|
|||||||
"This is not a conversion to a SCEVable type!");
|
"This is not a conversion to a SCEVable type!");
|
||||||
Ty = getEffectiveSCEVType(Ty);
|
Ty = getEffectiveSCEVType(Ty);
|
||||||
|
|
||||||
|
FoldingSetNodeID ID;
|
||||||
|
ID.AddInteger(scTruncate);
|
||||||
|
ID.AddPointer(Op);
|
||||||
|
ID.AddPointer(Ty);
|
||||||
|
void *IP = 0;
|
||||||
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
|
|
||||||
// Fold if the operand is constant.
|
// Fold if the operand is constant.
|
||||||
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(Op))
|
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(Op))
|
||||||
return getConstant(
|
return getConstant(
|
||||||
@ -774,14 +743,11 @@ const SCEV *ScalarEvolution::getTruncateExpr(const SCEV *Op,
|
|||||||
return getAddRecExpr(Operands, AddRec->getLoop());
|
return getAddRecExpr(Operands, AddRec->getLoop());
|
||||||
}
|
}
|
||||||
|
|
||||||
FoldingSetNodeID ID;
|
// The cast wasn't folded; create an explicit cast node.
|
||||||
ID.AddInteger(scTruncate);
|
// Recompute the insert position, as it may have been invalidated.
|
||||||
ID.AddPointer(Op);
|
|
||||||
ID.AddPointer(Ty);
|
|
||||||
void *IP = 0;
|
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVTruncateExpr>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVTruncateExpr>();
|
||||||
new (S) SCEVTruncateExpr(Op, Ty);
|
new (S) SCEVTruncateExpr(ID, Op, Ty);
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
@ -877,7 +843,7 @@ const SCEV *ScalarEvolution::getZeroExtendExpr(const SCEV *Op,
|
|||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVZeroExtendExpr>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVZeroExtendExpr>();
|
||||||
new (S) SCEVZeroExtendExpr(Op, Ty);
|
new (S) SCEVZeroExtendExpr(ID, Op, Ty);
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
@ -957,7 +923,7 @@ const SCEV *ScalarEvolution::getSignExtendExpr(const SCEV *Op,
|
|||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVSignExtendExpr>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVSignExtendExpr>();
|
||||||
new (S) SCEVSignExtendExpr(Op, Ty);
|
new (S) SCEVSignExtendExpr(ID, Op, Ty);
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
@ -1426,7 +1392,7 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops) {
|
|||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVAddExpr>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVAddExpr>();
|
||||||
new (S) SCEVAddExpr(Ops);
|
new (S) SCEVAddExpr(ID, Ops);
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
@ -1597,7 +1563,7 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops) {
|
|||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVMulExpr>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVMulExpr>();
|
||||||
new (S) SCEVMulExpr(Ops);
|
new (S) SCEVMulExpr(ID, Ops);
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
@ -1696,7 +1662,7 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
|
|||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVUDivExpr>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVUDivExpr>();
|
||||||
new (S) SCEVUDivExpr(LHS, RHS);
|
new (S) SCEVUDivExpr(ID, LHS, RHS);
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
@ -1779,7 +1745,7 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
|
|||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVAddRecExpr>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVAddRecExpr>();
|
||||||
new (S) SCEVAddRecExpr(Operands, L);
|
new (S) SCEVAddRecExpr(ID, Operands, L);
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
@ -1876,7 +1842,7 @@ ScalarEvolution::getSMaxExpr(SmallVectorImpl<const SCEV *> &Ops) {
|
|||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVSMaxExpr>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVSMaxExpr>();
|
||||||
new (S) SCEVSMaxExpr(Ops);
|
new (S) SCEVSMaxExpr(ID, Ops);
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
@ -1973,7 +1939,7 @@ ScalarEvolution::getUMaxExpr(SmallVectorImpl<const SCEV *> &Ops) {
|
|||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVUMaxExpr>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVUMaxExpr>();
|
||||||
new (S) SCEVUMaxExpr(Ops);
|
new (S) SCEVUMaxExpr(ID, Ops);
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
@ -2002,7 +1968,7 @@ const SCEV *ScalarEvolution::getUnknown(Value *V) {
|
|||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVUnknown>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVUnknown>();
|
||||||
new (S) SCEVUnknown(V);
|
new (S) SCEVUnknown(ID, V);
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user