- /// SCEVHandle - This class is used to maintain the SCEV object's refcounts,
- /// freeing the objects when the last reference is dropped.
- class SCEVHandle {
- const SCEV *S;
- SCEVHandle(); // DO NOT IMPLEMENT
- public:
- SCEVHandle(const SCEV *s) : S(s) {
- assert(S && "Cannot create a handle to a null SCEV!");
- S->addRef();
- }
- SCEVHandle(const SCEVHandle &RHS) : S(RHS.S) {
- S->addRef();
- }
- ~SCEVHandle() { S->dropRef(); }
-
- operator const SCEV*() const { return S; }
-
- const SCEV &operator*() const { return *S; }
- const SCEV *operator->() const { return S; }
-
- bool operator==(const SCEV *RHS) const { return S == RHS; }
- bool operator!=(const SCEV *RHS) const { return S != RHS; }
-
- const SCEVHandle &operator=(SCEV *RHS) {
- if (S != RHS) {
- S->dropRef();
- S = RHS;
- S->addRef();
- }
- return *this;
- }
-
- const SCEVHandle &operator=(const SCEVHandle &RHS) {
- if (S != RHS.S) {
- S->dropRef();
- S = RHS.S;
- S->addRef();
- }
- return *this;
- }
- };
-
- template<typename From> struct simplify_type;
- template<> struct simplify_type<const SCEVHandle> {
- typedef const SCEV* SimpleType;
- static SimpleType getSimplifiedValue(const SCEVHandle &Node) {
- return Node;
- }
- };
- template<> struct simplify_type<SCEVHandle>
- : public simplify_type<const SCEVHandle> {};
-