mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-13 17:38:39 +00:00
Add a new replaceSymbolicValuesWithConcrete method to the SCEV class,
adjust const'ness a bit to be more correct. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20145 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
39bcf5b8d0
commit
afc0dc7184
@ -38,11 +38,11 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
class SCEV {
|
class SCEV {
|
||||||
const unsigned SCEVType; // The SCEV baseclass this node corresponds to
|
const unsigned SCEVType; // The SCEV baseclass this node corresponds to
|
||||||
unsigned RefCount;
|
mutable unsigned RefCount;
|
||||||
|
|
||||||
friend class SCEVHandle;
|
friend class SCEVHandle;
|
||||||
void addRef() { ++RefCount; }
|
void addRef() const { ++RefCount; }
|
||||||
void dropRef() {
|
void dropRef() const {
|
||||||
if (--RefCount == 0)
|
if (--RefCount == 0)
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
@ -74,6 +74,15 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
virtual const Type *getType() const = 0;
|
virtual const Type *getType() const = 0;
|
||||||
|
|
||||||
|
/// replaceSymbolicValuesWithConcrete - If this SCEV internally references
|
||||||
|
/// the symbolic value "Sym", construct and return a new SCEV that produces
|
||||||
|
/// the same value, but which uses the concrete value Conc instead of the
|
||||||
|
/// symbolic value. If this SCEV does not use the symbolic value, it
|
||||||
|
/// returns itself.
|
||||||
|
virtual SCEVHandle
|
||||||
|
replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
|
||||||
|
const SCEVHandle &Conc) const = 0;
|
||||||
|
|
||||||
/// print - Print out the internal representation of this scalar to the
|
/// print - Print out the internal representation of this scalar to the
|
||||||
/// specified stream. This should really only be used for debugging
|
/// specified stream. This should really only be used for debugging
|
||||||
/// purposes.
|
/// purposes.
|
||||||
@ -102,7 +111,9 @@ namespace llvm {
|
|||||||
virtual const Type *getType() const;
|
virtual const Type *getType() const;
|
||||||
virtual bool hasComputableLoopEvolution(const Loop *L) const;
|
virtual bool hasComputableLoopEvolution(const Loop *L) const;
|
||||||
virtual void print(std::ostream &OS) const;
|
virtual void print(std::ostream &OS) const;
|
||||||
|
virtual SCEVHandle
|
||||||
|
replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
|
||||||
|
const SCEVHandle &Conc) const;
|
||||||
|
|
||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const SCEVCouldNotCompute *S) { return true; }
|
static inline bool classof(const SCEVCouldNotCompute *S) { return true; }
|
||||||
@ -115,7 +126,7 @@ namespace llvm {
|
|||||||
SCEV *S;
|
SCEV *S;
|
||||||
SCEVHandle(); // DO NOT IMPLEMENT
|
SCEVHandle(); // DO NOT IMPLEMENT
|
||||||
public:
|
public:
|
||||||
SCEVHandle(SCEV *s) : S(s) {
|
SCEVHandle(const SCEV *s) : S(const_cast<SCEV*>(s)) {
|
||||||
assert(S && "Cannot create a handle to a null SCEV!");
|
assert(S && "Cannot create a handle to a null SCEV!");
|
||||||
S->addRef();
|
S->addRef();
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,11 @@ namespace llvm {
|
|||||||
|
|
||||||
virtual const Type *getType() const;
|
virtual const Type *getType() const;
|
||||||
|
|
||||||
|
SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
|
||||||
|
const SCEVHandle &Conc) const {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void print(std::ostream &OS) const;
|
virtual void print(std::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:
|
||||||
@ -90,6 +95,14 @@ namespace llvm {
|
|||||||
return Op->hasComputableLoopEvolution(L);
|
return Op->hasComputableLoopEvolution(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
|
||||||
|
const SCEVHandle &Conc) const {
|
||||||
|
SCEVHandle H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc);
|
||||||
|
if (H == Op)
|
||||||
|
return this;
|
||||||
|
return get(H, Ty);
|
||||||
|
}
|
||||||
|
|
||||||
/// getValueRange - Return the tightest constant bounds that this value is
|
/// getValueRange - Return the tightest constant bounds that this value is
|
||||||
/// known to have. This method is only valid on integer SCEV objects.
|
/// known to have. This method is only valid on integer SCEV objects.
|
||||||
virtual ConstantRange getValueRange() const;
|
virtual ConstantRange getValueRange() const;
|
||||||
@ -132,6 +145,14 @@ namespace llvm {
|
|||||||
/// known to have. This method is only valid on integer SCEV objects.
|
/// known to have. This method is only valid on integer SCEV objects.
|
||||||
virtual ConstantRange getValueRange() const;
|
virtual ConstantRange getValueRange() const;
|
||||||
|
|
||||||
|
SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
|
||||||
|
const SCEVHandle &Conc) const {
|
||||||
|
SCEVHandle H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc);
|
||||||
|
if (H == Op)
|
||||||
|
return this;
|
||||||
|
return get(H, Ty);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void print(std::ostream &OS) const;
|
virtual void print(std::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:
|
||||||
@ -182,6 +203,9 @@ namespace llvm {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
|
||||||
|
const SCEVHandle &Conc) const;
|
||||||
|
|
||||||
virtual const char *getOperationStr() const = 0;
|
virtual const char *getOperationStr() const = 0;
|
||||||
|
|
||||||
virtual const Type *getType() const { return getOperand(0)->getType(); }
|
virtual const Type *getType() const { return getOperand(0)->getType(); }
|
||||||
@ -286,6 +310,17 @@ namespace llvm {
|
|||||||
RHS->hasComputableLoopEvolution(L);
|
RHS->hasComputableLoopEvolution(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
|
||||||
|
const SCEVHandle &Conc) const {
|
||||||
|
SCEVHandle L = LHS->replaceSymbolicValuesWithConcrete(Sym, Conc);
|
||||||
|
SCEVHandle R = RHS->replaceSymbolicValuesWithConcrete(Sym, Conc);
|
||||||
|
if (L == LHS && R == RHS)
|
||||||
|
return this;
|
||||||
|
else
|
||||||
|
return get(L, R);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual const Type *getType() const;
|
virtual const Type *getType() const;
|
||||||
|
|
||||||
void print(std::ostream &OS) const;
|
void print(std::ostream &OS) const;
|
||||||
@ -383,6 +418,8 @@ namespace llvm {
|
|||||||
/// returned.
|
/// returned.
|
||||||
SCEVHandle getNumIterationsInRange(ConstantRange Range) const;
|
SCEVHandle getNumIterationsInRange(ConstantRange Range) const;
|
||||||
|
|
||||||
|
SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
|
||||||
|
const SCEVHandle &Conc) const;
|
||||||
|
|
||||||
virtual void print(std::ostream &OS) const;
|
virtual void print(std::ostream &OS) const;
|
||||||
|
|
||||||
@ -420,6 +457,12 @@ namespace llvm {
|
|||||||
return false; // not computable
|
return false; // not computable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
|
||||||
|
const SCEVHandle &Conc) const {
|
||||||
|
if (&*Sym == this) return Conc;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
virtual const Type *getType() const;
|
virtual const Type *getType() const;
|
||||||
|
|
||||||
virtual void print(std::ostream &OS) const;
|
virtual void print(std::ostream &OS) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user