From 2e6c72d3415fd67f0740e52898b5fc054eadd09b Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sun, 9 Apr 2023 20:53:45 -0700 Subject: [PATCH] [TableGen] Move vectors into DAGInstruction instead of copying them. NFC --- llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 8 ++++---- llvm/utils/TableGen/CodeGenDAGPatterns.h | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 4463fe5..fd120e1 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -3938,8 +3938,8 @@ void CodeGenDAGPatterns::parseInstructionPattern( // Create and insert the instruction. // FIXME: InstImpResults should not be part of DAGInstruction. Record *R = I.getRecord(); - DAGInsts.try_emplace(R, Results, Operands, InstImpResults, SrcPattern, - ResultPattern); + DAGInsts.try_emplace(R, std::move(Results), std::move(Operands), + std::move(InstImpResults), SrcPattern, ResultPattern); LLVM_DEBUG(I.dump()); } @@ -3979,8 +3979,8 @@ void CodeGenDAGPatterns::ParseInstructions() { } // Create and insert the instruction. - std::vector ImpResults; - Instructions.try_emplace(Instr, Results, Operands, ImpResults); + Instructions.try_emplace(Instr, std::move(Results), std::move(Operands), + std::vector()); continue; // no pattern. } diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h index 2fa99e2..b8159b2 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.h +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h @@ -1021,13 +1021,14 @@ class DAGInstruction { TreePatternNodePtr ResultPattern; public: - DAGInstruction(const std::vector &results, - const std::vector &operands, - const std::vector &impresults, + DAGInstruction(std::vector &&results, + std::vector &&operands, + std::vector &&impresults, TreePatternNodePtr srcpattern = nullptr, TreePatternNodePtr resultpattern = nullptr) - : Results(results), Operands(operands), ImpResults(impresults), - SrcPattern(srcpattern), ResultPattern(resultpattern) {} + : Results(std::move(results)), Operands(std::move(operands)), + ImpResults(std::move(impresults)), SrcPattern(srcpattern), + ResultPattern(resultpattern) {} unsigned getNumResults() const { return Results.size(); } unsigned getNumOperands() const { return Operands.size(); } -- 2.7.4