mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
IR: Move replaceWithUniqued(), etc., to source file, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226522 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
898c48822f
commit
c062fbe4ca
@ -774,7 +774,9 @@ public:
|
||||
/// it. Takes ownership of the temporary node.
|
||||
template <class T>
|
||||
static typename std::enable_if<std::is_base_of<MDNode, T>::value, T *>::type
|
||||
replaceWithUniqued(std::unique_ptr<T, TempMDNodeDeleter> N);
|
||||
replaceWithUniqued(std::unique_ptr<T, TempMDNodeDeleter> N) {
|
||||
return cast<T>(N.release()->replaceWithUniquedImpl());
|
||||
}
|
||||
|
||||
/// \brief Replace a temporary node with a distinct one.
|
||||
///
|
||||
@ -782,7 +784,13 @@ public:
|
||||
/// it. Takes ownership of the temporary node.
|
||||
template <class T>
|
||||
static typename std::enable_if<std::is_base_of<MDNode, T>::value, T *>::type
|
||||
replaceWithDistinct(std::unique_ptr<T, TempMDNodeDeleter> N);
|
||||
replaceWithDistinct(std::unique_ptr<T, TempMDNodeDeleter> N) {
|
||||
return cast<T>(N.release()->replaceWithDistinctImpl());
|
||||
}
|
||||
|
||||
private:
|
||||
MDNode *replaceWithUniquedImpl();
|
||||
MDNode *replaceWithDistinctImpl();
|
||||
|
||||
protected:
|
||||
/// \brief Set an operand.
|
||||
@ -856,28 +864,6 @@ public:
|
||||
static MDNode *getMostGenericRange(MDNode *A, MDNode *B);
|
||||
};
|
||||
|
||||
template <class NodeTy>
|
||||
typename std::enable_if<std::is_base_of<MDNode, NodeTy>::value, NodeTy *>::type
|
||||
MDNode::replaceWithUniqued(std::unique_ptr<NodeTy, TempMDNodeDeleter> Node) {
|
||||
// Try to uniquify in place.
|
||||
MDNode *UniquedNode = Node->uniquify();
|
||||
if (UniquedNode == Node.get()) {
|
||||
Node->makeUniqued();
|
||||
return Node.release();
|
||||
}
|
||||
|
||||
// Collision, so RAUW instead.
|
||||
Node->replaceAllUsesWith(UniquedNode);
|
||||
return cast<NodeTy>(UniquedNode);
|
||||
}
|
||||
|
||||
template <class NodeTy>
|
||||
typename std::enable_if<std::is_base_of<MDNode, NodeTy>::value, NodeTy *>::type
|
||||
MDNode::replaceWithDistinct(std::unique_ptr<NodeTy, TempMDNodeDeleter> Node) {
|
||||
Node->makeDistinct();
|
||||
return Node.release();
|
||||
}
|
||||
|
||||
/// \brief Tuple of metadata.
|
||||
///
|
||||
/// This is the simple \a MDNode arbitrary tuple. Nodes are uniqued by
|
||||
|
@ -509,6 +509,25 @@ void MDNode::resolveCycles() {
|
||||
}
|
||||
}
|
||||
|
||||
MDNode *MDNode::replaceWithUniquedImpl() {
|
||||
// Try to uniquify in place.
|
||||
MDNode *UniquedNode = uniquify();
|
||||
if (UniquedNode == this) {
|
||||
makeUniqued();
|
||||
return this;
|
||||
}
|
||||
|
||||
// Collision, so RAUW instead.
|
||||
replaceAllUsesWith(UniquedNode);
|
||||
deleteAsSubclass();
|
||||
return UniquedNode;
|
||||
}
|
||||
|
||||
MDNode *MDNode::replaceWithDistinctImpl() {
|
||||
makeDistinct();
|
||||
return this;
|
||||
}
|
||||
|
||||
void MDTuple::recalculateHash() {
|
||||
setHash(MDTupleInfo::KeyTy::calculateHash(this));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user