[llvm] 31ce47b - [TableGen] Use `std::move` to avoid copy (#113061)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 21 11:48:53 PST 2024
Author: abhishek-kaushik22
Date: 2024-11-21T11:48:46-08:00
New Revision: 31ce47b5d602996406a516184af054a45118beca
URL: https://github.com/llvm/llvm-project/commit/31ce47b5d602996406a516184af054a45118beca
DIFF: https://github.com/llvm/llvm-project/commit/31ce47b5d602996406a516184af054a45118beca.diff
LOG: [TableGen] Use `std::move` to avoid copy (#113061)
Added:
Modified:
llvm/utils/TableGen/ARMTargetDefEmitter.cpp
llvm/utils/TableGen/CallingConvEmitter.cpp
llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
llvm/utils/TableGen/Common/CodeGenInstruction.cpp
llvm/utils/TableGen/CompressInstEmitter.cpp
llvm/utils/TableGen/DecoderEmitter.cpp
llvm/utils/TableGen/FastISelEmitter.cpp
llvm/utils/TableGen/OptionParserEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/ARMTargetDefEmitter.cpp b/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
index adb5f1d95b5722..3b02f63e9490b1 100644
--- a/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
+++ b/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
@@ -223,7 +223,7 @@ static void emitARMTargetDef(const RecordKeeper &RK, raw_ostream &OS) {
// Name of the object in C++
const std::string CppSpelling = ArchInfoName(Major, Minor, ProfileUpper);
OS << "inline constexpr ArchInfo " << CppSpelling << " = {\n";
- CppSpellings.push_back(CppSpelling);
+ CppSpellings.push_back(std::move(CppSpelling));
OS << llvm::format(" VersionTuple{%d, %d},\n", Major, Minor);
OS << llvm::format(" %sProfile,\n", ProfileUpper.c_str());
diff --git a/llvm/utils/TableGen/CallingConvEmitter.cpp b/llvm/utils/TableGen/CallingConvEmitter.cpp
index de20303a5bfd20..444b10719cb034 100644
--- a/llvm/utils/TableGen/CallingConvEmitter.cpp
+++ b/llvm/utils/TableGen/CallingConvEmitter.cpp
@@ -163,9 +163,9 @@ void CallingConvEmitter::emitAction(const Record *Action, indent Indent,
O << Indent << "if (MCRegister Reg = State.AllocateReg(" << Name
<< ")) {\n";
if (SwiftAction)
- AssignedSwiftRegsMap[CurrentAction].insert(Name);
+ AssignedSwiftRegsMap[CurrentAction].insert(std::move(Name));
else
- AssignedRegsMap[CurrentAction].insert(Name);
+ AssignedRegsMap[CurrentAction].insert(std::move(Name));
} else {
O << Indent << "static const MCPhysReg RegList" << ++Counter
<< "[] = {\n";
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
index 163a1a78a2ec40..b6b669f18cfbce 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
@@ -3183,7 +3183,8 @@ void TreePattern::dump() const { print(errs()); }
CodeGenDAGPatterns::CodeGenDAGPatterns(const RecordKeeper &R,
PatternRewriterFn PatternRewriter)
: Records(R), Target(R), Intrinsics(R),
- LegalVTS(Target.getLegalValueTypes()), PatternRewriter(PatternRewriter) {
+ LegalVTS(Target.getLegalValueTypes()),
+ PatternRewriter(std::move(PatternRewriter)) {
ParseNodeInfo();
ParseNodeTransforms();
ParseComplexPatterns();
diff --git a/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp b/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
index 293ed76e0f5026..30694ac2bb2139 100644
--- a/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
@@ -228,7 +228,7 @@ CodeGenInstAlias::CodeGenInstAlias(const Record *R, const CodeGenTarget &T)
if (NumSubOps == 1 || (InstOpRec->getValue("ParserMatchClass") &&
InstOpRec->getValueAsDef("ParserMatchClass")
->getValueAsString("Name") != "Imm")) {
- ResultOperands.push_back(ResOp);
+ ResultOperands.push_back(std::move(ResOp));
ResultInstOperandIndex.push_back(std::pair(i, -1));
++AliasOpNo;
diff --git a/llvm/utils/TableGen/Common/CodeGenInstruction.cpp b/llvm/utils/TableGen/Common/CodeGenInstruction.cpp
index f72fe4c6fd5620..344c4c15e2ebd8 100644
--- a/llvm/utils/TableGen/Common/CodeGenInstruction.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenInstruction.cpp
@@ -137,7 +137,7 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
" has the same name as a previous operand!");
OperandInfo &OpInfo = OperandList.emplace_back(
- Rec, std::string(ArgName), std::string(PrintMethod),
+ Rec, std::string(ArgName), std::string(std::move(PrintMethod)),
OperandNamespace + "::" + OperandType, MIOperandNo, NumOps, MIOpInfo);
if (SubArgDag) {
@@ -180,7 +180,7 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
} else if (!EncoderMethod.empty()) {
// If we have no explicit sub-op dag, but have an top-level encoder
// method, the single encoder will multiple sub-ops, itself.
- OpInfo.EncoderMethodNames[0] = EncoderMethod;
+ OpInfo.EncoderMethodNames[0] = std::move(EncoderMethod);
for (unsigned j = 1; j < NumOps; ++j)
OpInfo.DoNotEncode[j] = true;
}
diff --git a/llvm/utils/TableGen/CompressInstEmitter.cpp b/llvm/utils/TableGen/CompressInstEmitter.cpp
index e087ff07266380..7ebfe50a86d0fb 100644
--- a/llvm/utils/TableGen/CompressInstEmitter.cpp
+++ b/llvm/utils/TableGen/CompressInstEmitter.cpp
@@ -115,8 +115,9 @@ class CompressInstEmitter {
CompressPat(const CodeGenInstruction &S, const CodeGenInstruction &D,
std::vector<const Record *> RF, IndexedMap<OpData> &SourceMap,
IndexedMap<OpData> &DestMap, bool IsCompressOnly)
- : Source(S), Dest(D), PatReqFeatures(RF), SourceOperandMap(SourceMap),
- DestOperandMap(DestMap), IsCompressOnly(IsCompressOnly) {}
+ : Source(S), Dest(D), PatReqFeatures(std::move(RF)),
+ SourceOperandMap(SourceMap), DestOperandMap(DestMap),
+ IsCompressOnly(IsCompressOnly) {}
};
enum EmitterType { Compress, Uncompress, CheckCompress };
const RecordKeeper &Records;
@@ -485,9 +486,9 @@ void CompressInstEmitter::evaluateCompressPat(const Record *Rec) {
return R->getValueAsBit("AssemblerMatcherPredicate");
});
- CompressPatterns.push_back(CompressPat(SourceInst, DestInst, PatReqFeatures,
- SourceOperandMap, DestOperandMap,
- Rec->getValueAsBit("isCompressOnly")));
+ CompressPatterns.push_back(CompressPat(
+ SourceInst, DestInst, std::move(PatReqFeatures), SourceOperandMap,
+ DestOperandMap, Rec->getValueAsBit("isCompressOnly")));
}
static void
@@ -523,7 +524,7 @@ getReqFeatures(std::set<std::pair<bool, StringRef>> &FeaturesSet,
}
if (IsOr)
- AnyOfFeatureSets.insert(AnyOfSet);
+ AnyOfFeatureSets.insert(std::move(AnyOfSet));
}
}
diff --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp
index 4d2320b31ea94a..90a6d0ee8acb57 100644
--- a/llvm/utils/TableGen/DecoderEmitter.cpp
+++ b/llvm/utils/TableGen/DecoderEmitter.cpp
@@ -1893,7 +1893,7 @@ OperandInfo getOpInfo(const Record *TypeRecord) {
bool HasCompleteDecoder =
HasCompleteDecoderBit ? HasCompleteDecoderBit->getValue() : true;
- return OperandInfo(Decoder, HasCompleteDecoder);
+ return OperandInfo(std::move(Decoder), HasCompleteDecoder);
}
static void parseVarLenInstOperand(const Record &Def,
@@ -2024,7 +2024,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
EncodingDef.getValueAsBit("hasCompleteDecoder");
InsnOperands.push_back(
OperandInfo(std::string(InstDecoder), HasCompleteInstDecoder));
- Operands[Opc] = InsnOperands;
+ Operands[Opc] = std::move(InsnOperands);
return Bits.getNumBits();
}
@@ -2059,7 +2059,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
MyName = Op.Name;
TiedNames[MyName] = TiedName;
- TiedNames[TiedName] = MyName;
+ TiedNames[TiedName] = std::move(MyName);
}
}
}
@@ -2112,7 +2112,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
addOneOperandFields(EncodingDef, Bits, TiedNames, SubOpName,
SubOpInfo);
- InsnOperands.push_back(SubOpInfo);
+ InsnOperands.push_back(std::move(SubOpInfo));
}
continue;
}
@@ -2143,7 +2143,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
// instruction! (This is a longstanding bug, which will be addressed in an
// upcoming change.)
if (OpInfo.numFields() > 0)
- InsnOperands.push_back(OpInfo);
+ InsnOperands.push_back(std::move(OpInfo));
}
}
Operands[Opc] = InsnOperands;
diff --git a/llvm/utils/TableGen/FastISelEmitter.cpp b/llvm/utils/TableGen/FastISelEmitter.cpp
index 2052222cae5e5f..58d2ecc3aaebc2 100644
--- a/llvm/utils/TableGen/FastISelEmitter.cpp
+++ b/llvm/utils/TableGen/FastISelEmitter.cpp
@@ -567,7 +567,7 @@ void FastISelMap::collectPatterns(const CodeGenDAGPatterns &CGP) {
++DstIndex;
}
- PhysRegInputs.push_back(PhysReg);
+ PhysRegInputs.push_back(std::move(PhysReg));
}
if (Op->getName() != "EXTRACT_SUBREG" && DstIndex < Dst.getNumChildren())
@@ -591,7 +591,8 @@ void FastISelMap::collectPatterns(const CodeGenDAGPatterns &CGP) {
// Ok, we found a pattern that we can handle. Remember it.
InstructionMemo Memo(Pattern.getDstPattern().getOperator()->getName(),
- DstRC, SubRegNo, PhysRegInputs, PredicateCheck);
+ DstRC, std::move(SubRegNo), std::move(PhysRegInputs),
+ PredicateCheck);
int complexity = Pattern.getPatternComplexity(CGP);
diff --git a/llvm/utils/TableGen/OptionParserEmitter.cpp b/llvm/utils/TableGen/OptionParserEmitter.cpp
index 86e8378ad5ac5d..48f5818938ae86 100644
--- a/llvm/utils/TableGen/OptionParserEmitter.cpp
+++ b/llvm/utils/TableGen/OptionParserEmitter.cpp
@@ -482,7 +482,7 @@ static void emitOptionParser(const RecordKeeper &Records, raw_ostream &OS) {
HelpTextsForVariants.push_back(std::make_pair(
VisibilityNames, VisibilityHelp->getValueAsString("Text")));
}
- emitHelpTextsForVariants(OS, HelpTextsForVariants);
+ emitHelpTextsForVariants(OS, std::move(HelpTextsForVariants));
// The option meta-variable name.
OS << ", ";
More information about the llvm-commits
mailing list