summaryrefslogtreecommitdiffstats
path: root/include/llvm/Use.h
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2008-09-19 15:13:20 +0000
committerGabor Greif <ggreif@gmail.com>2008-09-19 15:13:20 +0000
commit6f4266506bca785828bacda55bd5db9172f990c6 (patch)
tree55a17319586a5d0b4c6c2a2596b594e0eed5a35c /include/llvm/Use.h
parent6c2c95d0acd867add034d93d4b909ddd75d61b14 (diff)
downloadexternal_llvm-6f4266506bca785828bacda55bd5db9172f990c6.zip
external_llvm-6f4266506bca785828bacda55bd5db9172f990c6.tar.gz
external_llvm-6f4266506bca785828bacda55bd5db9172f990c6.tar.bz2
backing out my last commit, it was not intended to go on the trunk
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Use.h')
-rw-r--r--include/llvm/Use.h79
1 files changed, 21 insertions, 58 deletions
diff --git a/include/llvm/Use.h b/include/llvm/Use.h
index b116e8c..891eaf8 100644
--- a/include/llvm/Use.h
+++ b/include/llvm/Use.h
@@ -66,22 +66,11 @@ inline T *transferTag(const T *From, const T *To) {
// Use is here to make keeping the "use" list of a Value up-to-date really easy.
//
class Use {
- class UseWaymark;
- friend class UseWaymark;
- Value *getValue() const;
- /// nilUse - returns a 'token' that marks the end of the def/use chain
- static Use *nilUse(const Value *V) {
- return addTag((Use*)V, fullStopTagN);
- }
- static bool isNil(Use *U) { return extractTag<NextPtrTag, tagMaskN>(U) == fullStopTagN; }
- void showWaymarks() const;
- static bool isStop(Use *U) {
- return isStopTag(extractTag<NextPtrTag, tagMaskN>(U));
- }
-public:
+private:
/// init - specify Value and User
/// @deprecated in 2.4, will be removed soon
inline void init(Value *V, User *U);
+public:
/// swap - provide a fast substitute to std::swap<Use>
/// that also works with less standard-compliant compilers
void swap(Use &RHS);
@@ -92,7 +81,7 @@ private:
/// Destructor - Only for zap()
inline ~Use() {
- if (Val1) removeFromList();
+ if (Val) removeFromList();
}
/// Default ctor - This leaves the Use completely uninitialized. The only thing
@@ -102,22 +91,11 @@ private:
enum PrevPtrTag { zeroDigitTag = noTag
, oneDigitTag = tagOne
, stopTag = tagTwo
- , fullStopTag = tagThree
- , tagMask = tagThree };
-
- enum NextPtrTag { zeroDigitTagN = tagTwo
- , oneDigitTagN = tagOne
- , stopTagN = noTag
- , fullStopTagN = tagThree
- , tagMaskN = tagThree };
-
- static bool isStopTag(NextPtrTag T) {
- bool P[] = { true, false, false, true };
- return P[T];
- }
+ , fullStopTag = tagThree };
+
public:
- operator Value*() const { return get(); }
- inline Value *get() const;
+ operator Value*() const { return Val; }
+ Value *get() const { return Val; }
User *getUser() const;
const Use* getImpliedUser() const;
static Use *initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0);
@@ -130,38 +108,31 @@ public:
return RHS;
}
const Use &operator=(const Use &RHS) {
- set(RHS.Val1);
+ set(RHS.Val);
return *this;
}
- Value *operator->() { return get(); }
- const Value *operator->() const { return get(); }
+ Value *operator->() { return Val; }
+ const Value *operator->() const { return Val; }
- Use *getNext() const { return extractTag<NextPtrTag, tagMaskN>(Next) == fullStopTagN
- ? 0
- : stripTag<tagMaskN>(Next); }
+ Use *getNext() const { return Next; }
private:
- Value *Val1;
+ Value *Val;
Use *Next, **Prev;
void setPrev(Use **NewPrev) {
- Prev = transferTag<tagMask>(Prev, NewPrev);
+ Prev = transferTag<fullStopTag>(Prev, NewPrev);
}
void addToList(Use **List) {
Next = *List;
- Use *StrippedNext(getNext());
- if (StrippedNext) StrippedNext->setPrev(&Next);
+ if (Next) Next->setPrev(&Next);
setPrev(List);
*List = this;
}
void removeFromList() {
- // __builtin_prefetch(Next);
- Use **StrippedPrev = stripTag<tagMask>(Prev);
- Use *StrippedNext(getNext());
- if (isStop(Next))
- assert((isStop(*StrippedPrev) || (StrippedNext ? isStop(StrippedNext->Next) : true)) && "joining digits?");
+ Use **StrippedPrev = stripTag<fullStopTag>(Prev);
*StrippedPrev = Next;
- if (StrippedNext) StrippedNext->setPrev(StrippedPrev);
+ if (Next) Next->setPrev(StrippedPrev);
}
friend class Value;
@@ -190,10 +161,7 @@ class value_use_iterator : public forward_iterator<UserTy*, ptrdiff_t> {
typedef value_use_iterator<UserTy> _Self;
Use *U;
- explicit value_use_iterator(Use *u) : U(extractTag<Use::NextPtrTag, Use::tagMaskN>(u)
- == Use::fullStopTagN
- ? 0
- : stripTag<Use::tagMaskN>(u)) {}
+ explicit value_use_iterator(Use *u) : U(u) {}
friend class Value;
public:
typedef typename super::reference reference;
@@ -210,11 +178,11 @@ public:
}
/// atEnd - return true if this iterator is equal to use_end() on the value.
- bool atEnd() const { return !U; }
+ bool atEnd() const { return U == 0; }
// Iterator traversal: forward iteration only
_Self &operator++() { // Preincrement
- assert(!atEnd() && "Cannot increment end iterator!");
+ assert(U && "Cannot increment end iterator!");
U = U->getNext();
return *this;
}
@@ -222,9 +190,9 @@ public:
_Self tmp = *this; ++*this; return tmp;
}
- // Retrieve a reference to the current User
+ // Retrieve a pointer to the current User.
UserTy *operator*() const {
- assert(!atEnd() && "Cannot dereference end iterator!");
+ assert(U && "Cannot dereference end iterator!");
return U->getUser();
}
@@ -238,11 +206,6 @@ public:
unsigned getOperandNo() const;
};
-Value *Use::get() const {
- return fullStopTagN == extractTag<NextPtrTag, tagMaskN>(Next)
- ? reinterpret_cast<Value*>(stripTag<tagMaskN>(Next))
- : (Val1 == getValue() ? Val1 : 0); // should crash if not equal!
-}
template<> struct simplify_type<value_use_iterator<User> > {
typedef User* SimpleType;