mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-23 12:11:58 +00:00
Merge of r51073-51074 from use-diet branch.
Do not rely on std::swap<Use>, provide a (faster) member function instead. This change is primarily necessitated by MSVC++'s incompatibility with declaring std::swap<Use> to be a friend of Use. Also contains some minor tweaks to Use inline functions, to undo pointless changes that sneaked in with the last merge. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51078 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e3fc3858a2
commit
94fb68ba21
@ -760,7 +760,7 @@ public:
|
|||||||
/// @brief Swap operands and adjust predicate.
|
/// @brief Swap operands and adjust predicate.
|
||||||
void swapOperands() {
|
void swapOperands() {
|
||||||
SubclassData = getSwappedPredicate();
|
SubclassData = getSwappedPredicate();
|
||||||
std::swap(Op<0>(), Op<1>());
|
Op<0>().swap(Op<1>());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ICmpInst *clone() const;
|
virtual ICmpInst *clone() const;
|
||||||
@ -879,7 +879,7 @@ public:
|
|||||||
/// @brief Swap operands and adjust predicate.
|
/// @brief Swap operands and adjust predicate.
|
||||||
void swapOperands() {
|
void swapOperands() {
|
||||||
SubclassData = getSwappedPredicate();
|
SubclassData = getSwappedPredicate();
|
||||||
std::swap(Op<0>(), Op<1>());
|
Op<0>().swap(Op<1>());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual FCmpInst *clone() const;
|
virtual FCmpInst *clone() const;
|
||||||
|
@ -67,18 +67,20 @@ inline T *transferTag(const T *From, const T *To) {
|
|||||||
//
|
//
|
||||||
class Use {
|
class Use {
|
||||||
public:
|
public:
|
||||||
|
/// init - specify Value and User
|
||||||
|
/// @deprecated in 2.4, will be removed soon
|
||||||
inline void init(Value *V, User *U);
|
inline void init(Value *V, User *U);
|
||||||
|
/// swap - provide a fast substitute to std::swap<Use>
|
||||||
|
/// that also works with less standard-compliant compilers
|
||||||
|
void swap(Use &RHS);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Allow std::swap some intimacy
|
/// Copy ctor - do not implement
|
||||||
template <typename U> friend void std::swap(U&, U&);
|
Use(const Use &U);
|
||||||
|
|
||||||
/// Copy ctor - Only for std::swap
|
/// Destructor - Only for zap()
|
||||||
Use(const Use &U) { init(U.get(), 0); }
|
|
||||||
|
|
||||||
/// Destructor - Only for zap() and std::swap
|
|
||||||
inline ~Use() {
|
inline ~Use() {
|
||||||
if (get()) removeFromList();
|
if (Val) removeFromList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Default ctor - This leaves the Use completely uninitialized. The only thing
|
/// Default ctor - This leaves the Use completely uninitialized. The only thing
|
||||||
@ -107,7 +109,7 @@ public:
|
|||||||
return RHS;
|
return RHS;
|
||||||
}
|
}
|
||||||
const Use &operator=(const Use &RHS) {
|
const Use &operator=(const Use &RHS) {
|
||||||
set(RHS.get());
|
set(RHS.Val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1563,7 +1563,7 @@ const Value *BinaryOperator::getNotArgument(const Value *BinOp) {
|
|||||||
bool BinaryOperator::swapOperands() {
|
bool BinaryOperator::swapOperands() {
|
||||||
if (!isCommutative())
|
if (!isCommutative())
|
||||||
return true; // Can't commute operands
|
return true; // Can't commute operands
|
||||||
std::swap(Op<0>(), Op<1>());
|
Op<0>().swap(Op<1>());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,35 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// Use swap Implementation
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
void Use::swap(Use &RHS) {
|
||||||
|
Value *V1(Val);
|
||||||
|
Value *V2(RHS.Val);
|
||||||
|
if (V1 != V2) {
|
||||||
|
if (V1) {
|
||||||
|
removeFromList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (V2) {
|
||||||
|
RHS.removeFromList();
|
||||||
|
Val = V2;
|
||||||
|
V2->addUse(*this);
|
||||||
|
} else {
|
||||||
|
Val = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (V1) {
|
||||||
|
RHS.Val = V1;
|
||||||
|
V1->addUse(RHS);
|
||||||
|
} else {
|
||||||
|
RHS.Val = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Use getImpliedUser Implementation
|
// Use getImpliedUser Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user