Skip to content

Commit

Permalink
[TableGen] Stop using make_pair and make_tuple. NFC. (#81730)
Browse files Browse the repository at this point in the history
These are unnecessary since C++17.
  • Loading branch information
jayfoad committed Feb 14, 2024
1 parent 0323235 commit f723260
Show file tree
Hide file tree
Showing 34 changed files with 144 additions and 151 deletions.
22 changes: 11 additions & 11 deletions llvm/utils/TableGen/AsmMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ void AsmMatcherInfo::buildRegisterClasses(

if (!ContainingSet.empty()) {
RegisterSets.insert(ContainingSet);
RegisterMap.insert(std::make_pair(CGR.TheDef, ContainingSet));
RegisterMap.insert(std::pair(CGR.TheDef, ContainingSet));
}
}

Expand All @@ -1298,7 +1298,7 @@ void AsmMatcherInfo::buildRegisterClasses(
CI->DiagnosticType = "";
CI->IsOptional = false;
CI->DefaultMethod = ""; // unused
RegisterSetClasses.insert(std::make_pair(RS, CI));
RegisterSetClasses.insert(std::pair(RS, CI));
++Index;
}

Expand Down Expand Up @@ -1340,7 +1340,7 @@ void AsmMatcherInfo::buildRegisterClasses(
if (!CI->DiagnosticString.empty() && CI->DiagnosticType.empty())
CI->DiagnosticType = RC.getName();

RegisterClassClasses.insert(std::make_pair(Def, CI));
RegisterClassClasses.insert(std::pair(Def, CI));
}

// Populate the map for individual registers.
Expand Down Expand Up @@ -2193,7 +2193,7 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
ConversionRow.push_back(SrcOp2);

// Also create an 'enum' for this combination of tied operands.
auto Key = std::make_tuple(TiedOp, SrcOp1, SrcOp2);
auto Key = std::tuple(TiedOp, SrcOp1, SrcOp2);
TiedOperandsEnumMap.emplace(Key, TiedTupleName);
break;
}
Expand Down Expand Up @@ -2342,9 +2342,9 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
// For a tied operand, emit a reference to the TiedAsmOperandTable
// that contains the operand to copy, and the parsed operands to
// check for their tied constraints.
auto Key = std::make_tuple((uint8_t)ConversionTable[Row][i + 1],
(uint8_t)ConversionTable[Row][i + 2],
(uint8_t)ConversionTable[Row][i + 3]);
auto Key = std::tuple((uint8_t)ConversionTable[Row][i + 1],
(uint8_t)ConversionTable[Row][i + 2],
(uint8_t)ConversionTable[Row][i + 3]);
auto TiedOpndEnum = TiedOperandsEnumMap.find(Key);
assert(TiedOpndEnum != TiedOperandsEnumMap.end() &&
"No record for tied operand pair");
Expand Down Expand Up @@ -2812,7 +2812,7 @@ emitMnemonicAliasVariant(raw_ostream &OS, const AsmMatcherInfo &Info,

MatchCode += "return;";

Cases.push_back(std::make_pair(AliasEntry.first, MatchCode));
Cases.push_back(std::pair(AliasEntry.first, MatchCode));
}
StringMatcher("Mnemonic", Cases, OS).Emit(Indent);
}
Expand Down Expand Up @@ -2979,7 +2979,7 @@ emitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target,
"std::end(OperandMatchTable),\n";
OS << " Mnemonic, LessOpcodeOperand());\n\n";
} else {
OS << " auto MnemonicRange = std::make_pair(std::begin(OperandMatchTable),"
OS << " auto MnemonicRange = std::pair(std::begin(OperandMatchTable),"
" std::end(OperandMatchTable));\n";
OS << " if (!Mnemonic.empty())\n";
OS << " MnemonicRange =\n";
Expand Down Expand Up @@ -3154,7 +3154,7 @@ static void emitMnemonicChecker(raw_ostream &OS, CodeGenTarget &Target,
OS << " auto MnemonicRange = "
"std::equal_range(Start, End, Mnemonic, LessOpcode());\n\n";
} else {
OS << " auto MnemonicRange = std::make_pair(Start, End);\n";
OS << " auto MnemonicRange = std::pair(Start, End);\n";
OS << " unsigned SIndex = Mnemonic.empty() ? 0 : 1;\n";
OS << " if (!Mnemonic.empty())\n";
OS << " MnemonicRange = "
Expand Down Expand Up @@ -3629,7 +3629,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
OS << " auto MnemonicRange = "
"std::equal_range(Start, End, Mnemonic, LessOpcode());\n\n";
} else {
OS << " auto MnemonicRange = std::make_pair(Start, End);\n";
OS << " auto MnemonicRange = std::pair(Start, End);\n";
OS << " unsigned SIndex = Mnemonic.empty() ? 0 : 1;\n";
OS << " if (!Mnemonic.empty())\n";
OS << " MnemonicRange = "
Expand Down
15 changes: 7 additions & 8 deletions llvm/utils/TableGen/AsmWriterEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,12 @@ static void EmitInstructions(std::vector<AsmWriterInst> &Insts, raw_ostream &O,
O << " switch (MI->getOpcode()) {\n";
O << " default: llvm_unreachable(\"Unexpected opcode.\");\n";
std::vector<std::pair<std::string, AsmWriterOperand>> OpsToPrint;
OpsToPrint.push_back(
std::make_pair(FirstInst.CGI->Namespace.str() +
"::" + FirstInst.CGI->TheDef->getName().str(),
FirstInst.Operands[i]));
OpsToPrint.push_back(std::pair(FirstInst.CGI->Namespace.str() + "::" +
FirstInst.CGI->TheDef->getName().str(),
FirstInst.Operands[i]));

for (const AsmWriterInst &AWI : SimilarInsts) {
OpsToPrint.push_back(std::make_pair(
OpsToPrint.push_back(std::pair(
AWI.CGI->Namespace.str() + "::" + AWI.CGI->TheDef->getName().str(),
AWI.Operands[i]));
}
Expand Down Expand Up @@ -722,7 +721,7 @@ class IAPrinter {
void addOperand(StringRef Op, int OpIdx, int PrintMethodIdx = -1) {
assert(OpIdx >= 0 && OpIdx < 0xFE && "Idx out of range");
assert(PrintMethodIdx >= -1 && PrintMethodIdx < 0xFF && "Idx out of range");
OpMap[Op] = std::make_pair(OpIdx, PrintMethodIdx);
OpMap[Op] = std::pair(OpIdx, PrintMethodIdx);
}

unsigned getNumMIOps() { return NumMIOps; }
Expand Down Expand Up @@ -753,7 +752,7 @@ class IAPrinter {
Next = I;
}

return std::make_pair(StringRef(Start, I - Start), Next);
return std::pair(StringRef(Start, I - Start), Next);
}

std::string formatAliasString(uint32_t &UnescapedSize) {
Expand Down Expand Up @@ -858,7 +857,7 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {

const DagInit *DI = R->getValueAsDag("ResultInst");
AliasMap[getQualifiedName(DI->getOperatorAsDef(R->getLoc()))].insert(
std::make_pair(CodeGenInstAlias(R, Target), Priority));
std::pair(CodeGenInstAlias(R, Target), Priority));
}

// A map of which conditions need to be met for each instruction operand
Expand Down
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/CTagsEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Tag {
Line = LineAndColumn.first;
}
int operator<(const Tag &B) const {
return std::make_tuple(Id, BufferIdentifier, Line) <
std::make_tuple(B.Id, B.BufferIdentifier, B.Line);
return std::tuple(Id, BufferIdentifier, Line) <
std::tuple(B.Id, B.BufferIdentifier, B.Line);
}
void emit(raw_ostream &OS) const {
OS << Id << "\t" << BufferIdentifier << "\t" << Line << "\n";
Expand Down
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/CodeEmitterGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ CodeEmitterGen::getInstructionCases(Record *R, CodeGenTarget &Target) {
append(" }\n");
}
append(" }\n");
return std::make_pair(std::move(Case), std::move(BitOffsetCase));
return std::pair(std::move(Case), std::move(BitOffsetCase));
}
}
addInstructionCasesForEncoding(R, R, Target, Case, BitOffsetCase);
return std::make_pair(std::move(Case), std::move(BitOffsetCase));
return std::pair(std::move(Case), std::move(BitOffsetCase));
}

void CodeEmitterGen::addInstructionCasesForEncoding(
Expand Down
34 changes: 17 additions & 17 deletions llvm/utils/TableGen/CodeGenDAGPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,24 +530,24 @@ bool TypeInfer::EnforceSmallerThan(TypeSetByHwMode &Small, TypeSetByHwMode &Big,
auto LT = [](MVT A, MVT B) -> bool {
// Always treat non-scalable MVTs as smaller than scalable MVTs for the
// purposes of ordering.
auto ASize = std::make_tuple(A.isScalableVector(), A.getScalarSizeInBits(),
A.getSizeInBits().getKnownMinValue());
auto BSize = std::make_tuple(B.isScalableVector(), B.getScalarSizeInBits(),
B.getSizeInBits().getKnownMinValue());
auto ASize = std::tuple(A.isScalableVector(), A.getScalarSizeInBits(),
A.getSizeInBits().getKnownMinValue());
auto BSize = std::tuple(B.isScalableVector(), B.getScalarSizeInBits(),
B.getSizeInBits().getKnownMinValue());
return ASize < BSize;
};
auto SameKindLE = [](MVT A, MVT B) -> bool {
// This function is used when removing elements: when a vector is compared
// to a non-vector or a scalable vector to any non-scalable MVT, it should
// return false (to avoid removal).
if (std::make_tuple(A.isVector(), A.isScalableVector()) !=
std::make_tuple(B.isVector(), B.isScalableVector()))
if (std::tuple(A.isVector(), A.isScalableVector()) !=
std::tuple(B.isVector(), B.isScalableVector()))
return false;

return std::make_tuple(A.getScalarSizeInBits(),
A.getSizeInBits().getKnownMinValue()) <=
std::make_tuple(B.getScalarSizeInBits(),
B.getSizeInBits().getKnownMinValue());
return std::tuple(A.getScalarSizeInBits(),
A.getSizeInBits().getKnownMinValue()) <=
std::tuple(B.getScalarSizeInBits(),
B.getSizeInBits().getKnownMinValue());
};

for (unsigned M : Modes) {
Expand Down Expand Up @@ -751,8 +751,8 @@ bool TypeInfer::EnforceSameNumElts(TypeSetByHwMode &V, TypeSetByHwMode &W) {
namespace {
struct TypeSizeComparator {
bool operator()(const TypeSize &LHS, const TypeSize &RHS) const {
return std::make_tuple(LHS.isScalable(), LHS.getKnownMinValue()) <
std::make_tuple(RHS.isScalable(), RHS.getKnownMinValue());
return std::tuple(LHS.isScalable(), LHS.getKnownMinValue()) <
std::tuple(RHS.isScalable(), RHS.getKnownMinValue());
}
};
} // end anonymous namespace
Expand Down Expand Up @@ -2988,7 +2988,7 @@ TreePatternNodePtr TreePattern::ParseTreePattern(Init *TheInit,
// Check that the ComplexPattern uses are consistent: "(MY_PAT $a, $b)"
// and "(MY_PAT $b, $a)" should not be allowed in the same pattern;
// neither should "(MY_PAT_1 $a, $b)" and "(MY_PAT_2 $a, $b)".
auto OperandId = std::make_pair(Operator, i);
auto OperandId = std::pair(Operator, i);
auto PrevOp = ComplexPatternOperands.find(Child->getName());
if (PrevOp != ComplexPatternOperands.end()) {
if (PrevOp->getValue() != OperandId)
Expand Down Expand Up @@ -3197,7 +3197,7 @@ void CodeGenDAGPatterns::ParseNodeInfo() {

while (!Nodes.empty()) {
Record *R = Nodes.back();
SDNodes.insert(std::make_pair(R, SDNodeInfo(R, CGH)));
SDNodes.insert(std::pair(R, SDNodeInfo(R, CGH)));
Nodes.pop_back();
}

Expand All @@ -3217,7 +3217,7 @@ void CodeGenDAGPatterns::ParseNodeTransforms() {
Record *SDNode = XFormNode->getValueAsDef("Opcode");
StringRef Code = XFormNode->getValueAsString("XFormFunction");
SDNodeXForms.insert(
std::make_pair(XFormNode, NodeXForm(SDNode, std::string(Code))));
std::pair(XFormNode, NodeXForm(SDNode, std::string(Code))));

Xforms.pop_back();
}
Expand All @@ -3227,7 +3227,7 @@ void CodeGenDAGPatterns::ParseComplexPatterns() {
std::vector<Record *> AMs =
Records.getAllDerivedDefinitions("ComplexPattern");
while (!AMs.empty()) {
ComplexPatterns.insert(std::make_pair(AMs.back(), AMs.back()));
ComplexPatterns.insert(std::pair(AMs.back(), AMs.back()));
AMs.pop_back();
}
}
Expand Down Expand Up @@ -3340,7 +3340,7 @@ void CodeGenDAGPatterns::ParseDefaultOperands() {
std::vector<std::pair<Init *, StringInit *>> Ops;
for (unsigned op = 0, e = DefaultInfo->getNumArgs(); op != e; ++op)
Ops.push_back(
std::make_pair(DefaultInfo->getArg(op), DefaultInfo->getArgName(op)));
std::pair(DefaultInfo->getArg(op), DefaultInfo->getArgName(op)));
DagInit *DI = DagInit::get(SomeSDNode, nullptr, Ops);

// Create a TreePattern to parse this.
Expand Down
6 changes: 3 additions & 3 deletions llvm/utils/TableGen/CodeGenHwModes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ HwModeSelect::HwModeSelect(Record *R, CodeGenHwModes &CGH) {
}
for (unsigned i = 0, e = Modes.size(); i != e; ++i) {
unsigned ModeId = CGH.getHwModeId(Modes[i]);
Items.push_back(std::make_pair(ModeId, Objects[i]));
Items.push_back(std::pair(ModeId, Objects[i]));
}
}

Expand All @@ -71,11 +71,11 @@ CodeGenHwModes::CodeGenHwModes(RecordKeeper &RK) : Records(RK) {
if (R->getName() == DefaultModeName)
continue;
Modes.emplace_back(R);
ModeIds.insert(std::make_pair(R, Modes.size()));
ModeIds.insert(std::pair(R, Modes.size()));
}

for (Record *R : Records.getAllDerivedDefinitions("HwModeSelect")) {
auto P = ModeSelects.emplace(std::make_pair(R, HwModeSelect(R, *this)));
auto P = ModeSelects.emplace(std::pair(R, HwModeSelect(R, *this)));
assert(P.second);
(void)P;
}
Expand Down
6 changes: 3 additions & 3 deletions llvm/utils/TableGen/CodeGenInstAlias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) {
InstOpRec->getValueAsDef("ParserMatchClass")
->getValueAsString("Name") != "Imm")) {
ResultOperands.push_back(ResOp);
ResultInstOperandIndex.push_back(std::make_pair(i, -1));
ResultInstOperandIndex.push_back(std::pair(i, -1));
++AliasOpNo;

// Otherwise, we need to match each of the suboperands individually.
Expand All @@ -242,7 +242,7 @@ CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) {
Result->getArgName(AliasOpNo)->getAsUnquotedString() + "." +
MIOI->getArgName(SubOp)->getAsUnquotedString(),
SubRec);
ResultInstOperandIndex.push_back(std::make_pair(i, SubOp));
ResultInstOperandIndex.push_back(std::pair(i, SubOp));
}
++AliasOpNo;
}
Expand All @@ -260,7 +260,7 @@ CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) {
if (tryAliasOpMatch(Result, AliasOpNo, SubRec, false, R->getLoc(), T,
ResOp)) {
ResultOperands.push_back(ResOp);
ResultInstOperandIndex.push_back(std::make_pair(i, SubOp));
ResultInstOperandIndex.push_back(std::pair(i, SubOp));
++AliasOpNo;
} else {
PrintFatalError(
Expand Down
8 changes: 4 additions & 4 deletions llvm/utils/TableGen/CodeGenInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
}

OpInfo.SubOpNames[j] = SubArgName;
SubOpAliases[SubArgName] = std::make_pair(i, j);
SubOpAliases[SubArgName] = std::pair(i, j);
}
} else if (!EncoderMethod.empty()) {
// If we have no explicit sub-op dag, but have an top-level encoder
Expand Down Expand Up @@ -276,7 +276,7 @@ CGIOperandList::ParseOperandName(StringRef Op, bool AllowWholeOp) {
Op + "'");

// Otherwise, return the operand.
return std::make_pair(OpIdx, 0U);
return std::pair(OpIdx, 0U);
}

// Find the suboperand number involved.
Expand All @@ -289,13 +289,13 @@ CGIOperandList::ParseOperandName(StringRef Op, bool AllowWholeOp) {
// Find the operand with the right name.
for (unsigned i = 0, e = MIOpInfo->getNumArgs(); i != e; ++i)
if (MIOpInfo->getArgNameStr(i) == SubOpName)
return std::make_pair(OpIdx, i);
return std::pair(OpIdx, i);

// Otherwise, didn't find it!
PrintFatalError(TheDef->getLoc(), TheDef->getName() +
": unknown suboperand name in '" + Op +
"'");
return std::make_pair(0U, 0U);
return std::pair(0U, 0U);
}

static void ParseConstraint(StringRef CStr, CGIOperandList &Ops, Record *Rec) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/CodeGenInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class CGIOperandList {
for (unsigned i = 0;; ++i) {
assert(i < OperandList.size() && "Invalid flat operand #");
if (OperandList[i].MIOperandNo + OperandList[i].MINumOperands > Op)
return std::make_pair(i, Op - OperandList[i].MIOperandNo);
return std::pair(i, Op - OperandList[i].MIOperandNo);
}
}

Expand Down

0 comments on commit f723260

Please sign in to comment.