From 26fc0635c4a13d77a3cf186dcf60bfd2f4e990d6 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sun, 15 Jul 2018 06:52:49 +0000 Subject: [PATCH] [TableGen] std::move vectors into TreePatternNode. llvm-svn: 337121 --- llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 17 +++++++++-------- llvm/utils/TableGen/CodeGenDAGPatterns.h | 5 +++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 19c96fa789bd..1abe3a88bfbf 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -1803,7 +1803,7 @@ TreePatternNodePtr TreePatternNode::clone() const { CChildren.reserve(Children.size()); for (unsigned i = 0, e = getNumChildren(); i != e; ++i) CChildren.push_back(getChild(i)->clone()); - New = std::make_shared(getOperator(), CChildren, + New = std::make_shared(getOperator(), std::move(CChildren), getNumTypes()); } New->setName(getName()); @@ -1902,7 +1902,7 @@ void TreePatternNode::InlinePatternFragments( for (unsigned i = 0, e = ChildAlternatives.size(); i != e; ++i) NewChildren.push_back(ChildAlternatives[i][Idxs[i]]); TreePatternNodePtr R = std::make_shared( - getOperator(), NewChildren, getNumTypes()); + getOperator(), std::move(NewChildren), getNumTypes()); // Copy over properties. R->setName(getName()); @@ -2743,7 +2743,8 @@ TreePatternNodePtr TreePattern::ParseTreePattern(Init *TheInit, } TreePatternNodePtr Result = - std::make_shared(Operator, Children, NumResults); + std::make_shared(Operator, std::move(Children), + NumResults); Result->setName(OpName); if (Dag->getName()) { @@ -3604,7 +3605,7 @@ void CodeGenDAGPatterns::parseInstructionPattern( OpNode->setTransformFn(nullptr); std::vector Children; Children.push_back(OpNode); - OpNode = std::make_shared(Xform, Children, + OpNode = std::make_shared(Xform, std::move(Children), OpNode->getNumTypes()); } @@ -3616,7 +3617,7 @@ void CodeGenDAGPatterns::parseInstructionPattern( " occurs in pattern but not in operands list!"); TreePatternNodePtr ResultPattern = std::make_shared( - I.getRecord(), ResultNodeOperands, + I.getRecord(), std::move(ResultNodeOperands), GetNumNodeResults(I.getRecord(), *this)); // Copy fully inferred output node types to instruction result pattern. for (unsigned i = 0; i != NumResults; ++i) { @@ -4019,7 +4020,7 @@ void CodeGenDAGPatterns::ParseOnePattern(Record *TheDef, OpNode->setTransformFn(nullptr); std::vector Children; Children.push_back(OpNode); - OpNode = std::make_shared(Xform, Children, + OpNode = std::make_shared(Xform, std::move(Children), OpNode->getNumTypes()); } ResultNodeOperands.push_back(OpNode); @@ -4029,7 +4030,7 @@ void CodeGenDAGPatterns::ParseOnePattern(Record *TheDef, DstPattern->isLeaf() ? DstPattern : std::make_shared(DstPattern->getOperator(), - ResultNodeOperands, + std::move(ResultNodeOperands), DstPattern->getNumTypes()); for (unsigned i = 0, e = Result.getOnlyTree()->getNumTypes(); i != e; ++i) @@ -4252,7 +4253,7 @@ static void CombineChildVariants( for (unsigned i = 0, e = ChildVariants.size(); i != e; ++i) NewChildren.push_back(ChildVariants[i][Idxs[i]]); TreePatternNodePtr R = std::make_shared( - Orig->getOperator(), NewChildren, Orig->getNumTypes()); + Orig->getOperator(), std::move(NewChildren), Orig->getNumTypes()); // Copy over properties. R->setName(Orig->getName()); diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h index 5bdf4cd23f90..9be3816cc7fc 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.h +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h @@ -600,9 +600,10 @@ class TreePatternNode { std::vector Children; public: - TreePatternNode(Record *Op, std::vector &Ch, + TreePatternNode(Record *Op, std::vector Ch, unsigned NumResults) - : Operator(Op), Val(nullptr), TransformFn(nullptr), Children(Ch) { + : Operator(Op), Val(nullptr), TransformFn(nullptr), + Children(std::move(Ch)) { Types.resize(NumResults); } TreePatternNode(Init *val, unsigned NumResults) // leaf ctor