Skip to content

[TableGen] Use std::move to avoid copy #113061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9e3c1f7
Use `std::move` to avoid copy
abhishek-kaushik22 Oct 19, 2024
53d66ac
Update CompressInstEmitter.cpp
abhishek-kaushik22 Oct 19, 2024
634cf6c
Update CodeGenInstAlias.cpp
abhishek-kaushik22 Oct 19, 2024
5543e53
Update CodeGenInstruction.cpp
abhishek-kaushik22 Oct 19, 2024
81e3415
Update OptionParserEmitter.cpp
abhishek-kaushik22 Oct 19, 2024
25d86a7
Update ARMTargetDefEmitter.cpp
abhishek-kaushik22 Oct 19, 2024
5e1e68b
Update CompressInstEmitter.cpp
abhishek-kaushik22 Oct 19, 2024
762d848
Update CompressInstEmitter.cpp
abhishek-kaushik22 Oct 19, 2024
6dceb23
Update FastISelEmitter.cpp
abhishek-kaushik22 Oct 20, 2024
8609235
Update FastISelEmitter.cpp
abhishek-kaushik22 Oct 20, 2024
debad0c
Update CompressInstEmitter.cpp
abhishek-kaushik22 Oct 20, 2024
499c37f
Update CallingConvEmitter.cpp
abhishek-kaushik22 Oct 20, 2024
041d906
Update FastISelEmitter.cpp
abhishek-kaushik22 Oct 20, 2024
de6dc48
Update CompressInstEmitter.cpp
abhishek-kaushik22 Oct 20, 2024
20117ae
Update FastISelEmitter.cpp
abhishek-kaushik22 Oct 20, 2024
466e392
Update CodeGenDAGPatterns.cpp
abhishek-kaushik22 Nov 20, 2024
dcbd219
Update DecoderEmitter.cpp
abhishek-kaushik22 Nov 20, 2024
21d4cad
Merge branch 'main' into test5
abhishek-kaushik22 Nov 20, 2024
754b81a
Merge branch 'test5' of https://github.com/abhishek-kaushik22/llvm-pr…
abhishek-kaushik22 Nov 20, 2024
b19b7cd
Update CodeGenDAGPatterns.cpp
abhishek-kaushik22 Nov 20, 2024
414f388
Merge branch 'main' into test5
abhishek-kaushik22 Nov 21, 2024
9061cc0
Update OptionParserEmitter.cpp
abhishek-kaushik22 Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/ARMTargetDefEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/CallingConvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
3 changes: 2 additions & 1 deletion llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/Common/CodeGenInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
13 changes: 7 additions & 6 deletions llvm/utils/TableGen/CompressInstEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -523,7 +524,7 @@ getReqFeatures(std::set<std::pair<bool, StringRef>> &FeaturesSet,
}

if (IsOr)
AnyOfFeatureSets.insert(AnyOfSet);
AnyOfFeatureSets.insert(std::move(AnyOfSet));
}
}

Expand Down
10 changes: 5 additions & 5 deletions llvm/utils/TableGen/DecoderEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions llvm/utils/TableGen/FastISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/OptionParserEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 << ", ";
Expand Down