mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-10 22:43:46 +00:00
[cleanup] Run clang-format over the Use code. It was *really*
inconsistent both with itself and with LLVM at large with formatting. The *s were on the wrong side, the indent was off, etc etc. This is much cleaner. Also, go clang-format laying out the array of tags in nice columns. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202799 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0a6057117e
commit
2bfe24c418
@ -37,12 +37,10 @@ namespace llvm {
|
|||||||
class Value;
|
class Value;
|
||||||
class User;
|
class User;
|
||||||
class Use;
|
class Use;
|
||||||
template<typename>
|
template <typename> struct simplify_type;
|
||||||
struct simplify_type;
|
|
||||||
|
|
||||||
// Use** is only 4-byte aligned.
|
// Use** is only 4-byte aligned.
|
||||||
template<>
|
template <> class PointerLikeTypeTraits<Use **> {
|
||||||
class PointerLikeTypeTraits<Use**> {
|
|
||||||
public:
|
public:
|
||||||
static inline void *getAsVoidPointer(Use **P) { return P; }
|
static inline void *getAsVoidPointer(Use **P) { return P; }
|
||||||
static inline Use **getFromVoidPointer(void *P) {
|
static inline Use **getFromVoidPointer(void *P) {
|
||||||
@ -83,18 +81,14 @@ private:
|
|||||||
|
|
||||||
/// Destructor - Only for zap()
|
/// Destructor - Only for zap()
|
||||||
~Use() {
|
~Use() {
|
||||||
if (Val) removeFromList();
|
if (Val)
|
||||||
|
removeFromList();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PrevPtrTag { zeroDigitTag
|
enum PrevPtrTag { zeroDigitTag, oneDigitTag, stopTag, fullStopTag };
|
||||||
, oneDigitTag
|
|
||||||
, stopTag
|
|
||||||
, fullStopTag };
|
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
Use(PrevPtrTag tag) : Val(0) {
|
Use(PrevPtrTag tag) : Val(0) { Prev.setInt(tag); }
|
||||||
Prev.setInt(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
operator Value *() const { return Val; }
|
operator Value *() const { return Val; }
|
||||||
@ -139,19 +133,19 @@ private:
|
|||||||
Use *Next;
|
Use *Next;
|
||||||
PointerIntPair<Use **, 2, PrevPtrTag> Prev;
|
PointerIntPair<Use **, 2, PrevPtrTag> Prev;
|
||||||
|
|
||||||
void setPrev(Use **NewPrev) {
|
void setPrev(Use **NewPrev) { Prev.setPointer(NewPrev); }
|
||||||
Prev.setPointer(NewPrev);
|
|
||||||
}
|
|
||||||
void addToList(Use **List) {
|
void addToList(Use **List) {
|
||||||
Next = *List;
|
Next = *List;
|
||||||
if (Next) Next->setPrev(&Next);
|
if (Next)
|
||||||
|
Next->setPrev(&Next);
|
||||||
setPrev(List);
|
setPrev(List);
|
||||||
*List = this;
|
*List = this;
|
||||||
}
|
}
|
||||||
void removeFromList() {
|
void removeFromList() {
|
||||||
Use **StrippedPrev = Prev.getPointer();
|
Use **StrippedPrev = Prev.getPointer();
|
||||||
*StrippedPrev = Next;
|
*StrippedPrev = Next;
|
||||||
if (Next) Next->setPrev(StrippedPrev);
|
if (Next)
|
||||||
|
Next->setPrev(StrippedPrev);
|
||||||
}
|
}
|
||||||
|
|
||||||
friend class Value;
|
friend class Value;
|
||||||
@ -161,19 +155,13 @@ private:
|
|||||||
/// casting operators.
|
/// casting operators.
|
||||||
template <> struct simplify_type<Use> {
|
template <> struct simplify_type<Use> {
|
||||||
typedef Value *SimpleType;
|
typedef Value *SimpleType;
|
||||||
static SimpleType getSimplifiedValue(Use &Val) {
|
static SimpleType getSimplifiedValue(Use &Val) { return Val.get(); }
|
||||||
return Val.get();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
template <> struct simplify_type<const Use> {
|
template <> struct simplify_type<const Use> {
|
||||||
typedef /*const*/ Value *SimpleType;
|
typedef /*const*/ Value *SimpleType;
|
||||||
static SimpleType getSimplifiedValue(const Use &Val) {
|
static SimpleType getSimplifiedValue(const Use &Val) { return Val.get(); }
|
||||||
return Val.get();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<typename UserTy> // UserTy == 'User' or 'const User'
|
template<typename UserTy> // UserTy == 'User' or 'const User'
|
||||||
class value_use_iterator : public std::iterator<std::forward_iterator_tag,
|
class value_use_iterator : public std::iterator<std::forward_iterator_tag,
|
||||||
UserTy*, ptrdiff_t> {
|
UserTy*, ptrdiff_t> {
|
||||||
|
@ -41,8 +41,7 @@ void Use::swap(Use &RHS) {
|
|||||||
User *Use::getUser() const {
|
User *Use::getUser() const {
|
||||||
const Use *End = getImpliedUser();
|
const Use *End = getImpliedUser();
|
||||||
const UserRef *ref = reinterpret_cast<const UserRef *>(End);
|
const UserRef *ref = reinterpret_cast<const UserRef *>(End);
|
||||||
return ref->getInt()
|
return ref->getInt() ? ref->getPointer()
|
||||||
? ref->getPointer()
|
|
||||||
: reinterpret_cast<User *>(const_cast<Use *>(End));
|
: reinterpret_cast<User *>(const_cast<Use *>(End));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,14 +55,11 @@ Use *Use::initTags(Use * const Start, Use *Stop) {
|
|||||||
while (Done < 20) {
|
while (Done < 20) {
|
||||||
if (Start == Stop--)
|
if (Start == Stop--)
|
||||||
return Start;
|
return Start;
|
||||||
static const PrevPtrTag tags[20] = { fullStopTag, oneDigitTag, stopTag,
|
static const PrevPtrTag tags[20] = {
|
||||||
oneDigitTag, oneDigitTag, stopTag,
|
fullStopTag, oneDigitTag, stopTag, oneDigitTag, oneDigitTag,
|
||||||
zeroDigitTag, oneDigitTag, oneDigitTag,
|
stopTag, zeroDigitTag, oneDigitTag, oneDigitTag, stopTag,
|
||||||
stopTag, zeroDigitTag, oneDigitTag,
|
zeroDigitTag, oneDigitTag, zeroDigitTag, oneDigitTag, stopTag,
|
||||||
zeroDigitTag, oneDigitTag, stopTag,
|
oneDigitTag, oneDigitTag, oneDigitTag, oneDigitTag, stopTag};
|
||||||
oneDigitTag, oneDigitTag, oneDigitTag,
|
|
||||||
oneDigitTag, stopTag
|
|
||||||
};
|
|
||||||
new (Stop) Use(tags[Done++]);
|
new (Stop) Use(tags[Done++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user