diff options
author | Craig Topper <craig.topper@intel.com> | 2018-06-10 23:15:49 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2018-06-10 23:15:49 +0000 |
commit | 08f5c7b8c3d5b5b5ee832c987ec9683e22d454aa (patch) | |
tree | 0516da5ba810702647db8d17e87ea88c7869a658 /llvm/utils/TableGen/CodeGenDAGPatterns.cpp | |
parent | d78567f16f6ac38fcef0ad4313e93e8e960f502c (diff) | |
download | bcm5719-llvm-08f5c7b8c3d5b5b5ee832c987ec9683e22d454aa.tar.gz bcm5719-llvm-08f5c7b8c3d5b5b5ee832c987ec9683e22d454aa.zip |
[TableGen] Make better use of std::map::emplace and emplace construct the object in the map rather than moving it into it. Remove a use std::map::find by remembering the return from emplace.
llvm-svn: 334380
Diffstat (limited to 'llvm/utils/TableGen/CodeGenDAGPatterns.cpp')
-rw-r--r-- | llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 0a571bd8628..7365953c111 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -3572,21 +3572,22 @@ const DAGInstruction &CodeGenDAGPatterns::parseInstructionPattern( // Create and insert the instruction. // FIXME: InstImpResults should not be part of DAGInstruction. - TreePattern *InstPattern = I.get(); - DAGInstruction TheInst(std::move(I), Results, Operands, InstImpResults); - DAGInsts.emplace(InstPattern->getRecord(), std::move(TheInst)); + Record *R = I->getRecord(); + DAGInstruction &TheInst = + DAGInsts.emplace(std::piecewise_construct, std::forward_as_tuple(R), + std::forward_as_tuple(std::move(I), Results, Operands, + InstImpResults)).first->second; // Use a temporary tree pattern to infer all types and make sure that the // constructed result is correct. This depends on the instruction already // being inserted into the DAGInsts map. - TreePattern Temp(InstPattern->getRecord(), ResultPattern, false, *this); - Temp.InferAllTypes(&InstPattern->getNamedNodesMap()); + TreePattern Temp(TheInst.getPattern()->getRecord(), ResultPattern, false, + *this); + Temp.InferAllTypes(&TheInst.getPattern()->getNamedNodesMap()); - DAGInstruction &TheInsertedInst = - DAGInsts.find(InstPattern->getRecord())->second; - TheInsertedInst.setResultPattern(Temp.getOnlyTree()); + TheInst.setResultPattern(Temp.getOnlyTree()); - return TheInsertedInst; + return TheInst; } /// ParseInstructions - Parse all of the instructions, inlining and resolving |