Skip to content

Commit d0b8810

Browse files
committed
[TableGen] Indentation and whitespace fixes in generated code. NFC.
Some of these were found by running clang-format over the generated code, although that complains about far more issues than I have fixed here. Differential Revision: https://reviews.llvm.org/D90937
1 parent d61f2cf commit d0b8810

22 files changed

+100
-101
lines changed

llvm/test/TableGen/GlobalISelEmitter.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def HasC : Predicate<"Subtarget->hasC()"> { let RecomputePerFunction = 1; }
7070
// CHECK-LABEL: #ifdef GET_GLOBALISEL_TEMPORARIES_DECL
7171
// CHECK-NEXT: mutable MatcherState State;
7272
// CHECK-NEXT: typedef ComplexRendererFns(MyTargetInstructionSelector::*ComplexMatcherMemFn)(MachineOperand &) const;
73-
// CHECK-NEXT: typedef void(MyTargetInstructionSelector::*CustomRendererFn)(MachineInstrBuilder &, const MachineInstr&, int) const;
73+
// CHECK-NEXT: typedef void(MyTargetInstructionSelector::*CustomRendererFn)(MachineInstrBuilder &, const MachineInstr &, int) const;
7474
// CHECK-NEXT: const ISelInfoTy<PredicateBitset, ComplexMatcherMemFn, CustomRendererFn> ISelInfo;
7575
// CHECK-NEXT: static MyTargetInstructionSelector::ComplexMatcherMemFn ComplexPredicateFns[];
7676
// CHECK-NEXT: static MyTargetInstructionSelector::CustomRendererFn CustomRenderers[];

llvm/utils/TableGen/AsmMatcherEmitter.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,7 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
19801980
}
19811981
CvtOS << " unsigned OpIdx;\n";
19821982
CvtOS << " Inst.setOpcode(Opcode);\n";
1983-
CvtOS << " for (const uint8_t *p = Converter; *p; p+= 2) {\n";
1983+
CvtOS << " for (const uint8_t *p = Converter; *p; p += 2) {\n";
19841984
if (HasOptionalOperands) {
19851985
CvtOS << " OpIdx = *(p + 1) - DefaultsOffset[*(p + 1)];\n";
19861986
} else {
@@ -1990,14 +1990,14 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
19901990
CvtOS << " default: llvm_unreachable(\"invalid conversion entry!\");\n";
19911991
CvtOS << " case CVT_Reg:\n";
19921992
CvtOS << " static_cast<" << TargetOperandClass
1993-
<< "&>(*Operands[OpIdx]).addRegOperands(Inst, 1);\n";
1993+
<< " &>(*Operands[OpIdx]).addRegOperands(Inst, 1);\n";
19941994
CvtOS << " break;\n";
19951995
CvtOS << " case CVT_Tied: {\n";
19961996
CvtOS << " assert(OpIdx < (size_t)(std::end(TiedAsmOperandTable) -\n";
1997-
CvtOS << " std::begin(TiedAsmOperandTable)) &&\n";
1997+
CvtOS << " std::begin(TiedAsmOperandTable)) &&\n";
19981998
CvtOS << " \"Tied operand not found\");\n";
19991999
CvtOS << " unsigned TiedResOpnd = TiedAsmOperandTable[OpIdx][0];\n";
2000-
CvtOS << " if (TiedResOpnd != (uint8_t) -1)\n";
2000+
CvtOS << " if (TiedResOpnd != (uint8_t)-1)\n";
20012001
CvtOS << " Inst.addOperand(Inst.getOperand(TiedResOpnd));\n";
20022002
CvtOS << " break;\n";
20032003
CvtOS << " }\n";
@@ -2012,7 +2012,7 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
20122012
<< " assert(Kind < CVT_NUM_SIGNATURES && \"Invalid signature!\");\n"
20132013
<< " unsigned NumMCOperands = 0;\n"
20142014
<< " const uint8_t *Converter = ConversionTable[Kind];\n"
2015-
<< " for (const uint8_t *p = Converter; *p; p+= 2) {\n"
2015+
<< " for (const uint8_t *p = Converter; *p; p += 2) {\n"
20162016
<< " switch (*p) {\n"
20172017
<< " default: llvm_unreachable(\"invalid conversion entry!\");\n"
20182018
<< " case CVT_Reg:\n"
@@ -2129,12 +2129,12 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
21292129
<< OpInfo.MINumOperands << ");\n"
21302130
<< " } else {\n"
21312131
<< " static_cast<" << TargetOperandClass
2132-
<< "&>(*Operands[OpIdx])." << Op.Class->RenderMethod
2132+
<< " &>(*Operands[OpIdx])." << Op.Class->RenderMethod
21332133
<< "(Inst, " << OpInfo.MINumOperands << ");\n"
21342134
<< " }\n";
21352135
} else {
21362136
CvtOS << " static_cast<" << TargetOperandClass
2137-
<< "&>(*Operands[OpIdx])." << Op.Class->RenderMethod
2137+
<< " &>(*Operands[OpIdx])." << Op.Class->RenderMethod
21382138
<< "(Inst, " << OpInfo.MINumOperands << ");\n";
21392139
}
21402140
CvtOS << " break;\n";
@@ -2448,7 +2448,7 @@ static void emitValidateOperandClass(AsmMatcherInfo &Info,
24482448
OS << "static unsigned validateOperandClass(MCParsedAsmOperand &GOp, "
24492449
<< "MatchClassKind Kind) {\n";
24502450
OS << " " << Info.Target.getName() << "Operand &Operand = ("
2451-
<< Info.Target.getName() << "Operand&)GOp;\n";
2451+
<< Info.Target.getName() << "Operand &)GOp;\n";
24522452

24532453
// The InvalidMatchClass is not to match any operand.
24542454
OS << " if (Kind == InvalidMatchClass)\n";
@@ -2811,7 +2811,7 @@ static bool emitMnemonicAliases(raw_ostream &OS, const AsmMatcherInfo &Info,
28112811
Record *AsmVariant = Target.getAsmParserVariant(VC);
28122812
int AsmParserVariantNo = AsmVariant->getValueAsInt("Variant");
28132813
StringRef AsmParserVariantName = AsmVariant->getValueAsString("Name");
2814-
OS << " case " << AsmParserVariantNo << ":\n";
2814+
OS << " case " << AsmParserVariantNo << ":\n";
28152815
emitMnemonicAliasVariant(OS, Info, Aliases, /*Indent=*/2,
28162816
AsmParserVariantName);
28172817
OS << " break;\n";
@@ -2978,7 +2978,7 @@ static void emitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target,
29782978
"FeatureBitsets[it->RequiredFeaturesIdx];\n";
29792979
OS << " if (!ParseForAllFeatures && (AvailableFeatures & "
29802980
"RequiredFeatures) != RequiredFeatures)\n";
2981-
OS << " continue;\n\n";
2981+
OS << " continue;\n\n";
29822982

29832983
// Emit check to ensure the operand number matches.
29842984
OS << " // check if the operand in question has a custom parser.\n";
@@ -3011,10 +3011,10 @@ static void emitAsmTiedOperandConstraints(CodeGenTarget &Target,
30113011
OS << " uint64_t &ErrorInfo) {\n";
30123012
OS << " assert(Kind < CVT_NUM_SIGNATURES && \"Invalid signature!\");\n";
30133013
OS << " const uint8_t *Converter = ConversionTable[Kind];\n";
3014-
OS << " for (const uint8_t *p = Converter; *p; p+= 2) {\n";
3014+
OS << " for (const uint8_t *p = Converter; *p; p += 2) {\n";
30153015
OS << " switch (*p) {\n";
30163016
OS << " case CVT_Tied: {\n";
3017-
OS << " unsigned OpIdx = *(p+1);\n";
3017+
OS << " unsigned OpIdx = *(p + 1);\n";
30183018
OS << " assert(OpIdx < (size_t)(std::end(TiedAsmOperandTable) -\n";
30193019
OS << " std::begin(TiedAsmOperandTable)) &&\n";
30203020
OS << " \"Tied operand not found\");\n";
@@ -3086,7 +3086,7 @@ static void emitMnemonicSpellChecker(raw_ostream &OS, CodeGenTarget &Target,
30863086
OS << "\n";
30873087
OS << " std::string Res = \", did you mean: \";\n";
30883088
OS << " unsigned i = 0;\n";
3089-
OS << " for( ; i < Candidates.size() - 1; i++)\n";
3089+
OS << " for (; i < Candidates.size() - 1; i++)\n";
30903090
OS << " Res += Candidates[i].str() + \", \";\n";
30913091
OS << " return Res + Candidates[i].str() + \"?\";\n";
30923092
}
@@ -3255,7 +3255,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
32553255
OS << "#undef GET_ASSEMBLER_HEADER\n";
32563256
OS << " // This should be included into the middle of the declaration of\n";
32573257
OS << " // your subclasses implementation of MCTargetAsmParser.\n";
3258-
OS << " FeatureBitset ComputeAvailableFeatures(const FeatureBitset& FB) const;\n";
3258+
OS << " FeatureBitset ComputeAvailableFeatures(const FeatureBitset &FB) const;\n";
32593259
if (HasOptionalOperands) {
32603260
OS << " void convertToMCInst(unsigned Kind, MCInst &Inst, "
32613261
<< "unsigned Opcode,\n"
@@ -3559,12 +3559,12 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
35593559
OS << " // Get the instruction mnemonic, which is the first token.\n";
35603560
if (HasMnemonicFirst) {
35613561
OS << " StringRef Mnemonic = ((" << Target.getName()
3562-
<< "Operand&)*Operands[0]).getToken();\n\n";
3562+
<< "Operand &)*Operands[0]).getToken();\n\n";
35633563
} else {
35643564
OS << " StringRef Mnemonic;\n";
35653565
OS << " if (Operands[0]->isToken())\n";
35663566
OS << " Mnemonic = ((" << Target.getName()
3567-
<< "Operand&)*Operands[0]).getToken();\n\n";
3567+
<< "Operand &)*Operands[0]).getToken();\n\n";
35683568
}
35693569

35703570
if (HasMnemonicAliases) {
@@ -3614,7 +3614,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
36143614
}
36153615

36163616
OS << " DEBUG_WITH_TYPE(\"asm-matcher\", dbgs() << \"AsmMatcher: found \" <<\n"
3617-
<< " std::distance(MnemonicRange.first, MnemonicRange.second) << \n"
3617+
<< " std::distance(MnemonicRange.first, MnemonicRange.second) <<\n"
36183618
<< " \" encodings with mnemonic '\" << Mnemonic << \"'\\n\");\n\n";
36193619

36203620
OS << " // Return a more specific error code if no mnemonics match.\n";
@@ -3789,10 +3789,10 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
37893789
OS << " FeatureBitset NewMissingFeatures = RequiredFeatures & "
37903790
"~AvailableFeatures;\n";
37913791
OS << " DEBUG_WITH_TYPE(\"asm-matcher\", dbgs() << \"Missing target features:\";\n";
3792-
OS << " for (unsigned I = 0, E = NewMissingFeatures.size(); I != E; ++I)\n";
3793-
OS << " if (NewMissingFeatures[I])\n";
3794-
OS << " dbgs() << ' ' << I;\n";
3795-
OS << " dbgs() << \"\\n\");\n";
3792+
OS << " for (unsigned I = 0, E = NewMissingFeatures.size(); I != E; ++I)\n";
3793+
OS << " if (NewMissingFeatures[I])\n";
3794+
OS << " dbgs() << ' ' << I;\n";
3795+
OS << " dbgs() << \"\\n\");\n";
37963796
if (ReportMultipleNearMisses) {
37973797
OS << " FeaturesNearMiss = NearMissInfo::getMissedFeature(NewMissingFeatures);\n";
37983798
} else {
@@ -3927,7 +3927,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
39273927
OS << " getTargetOptions().MCNoDeprecatedWarn &&\n";
39283928
OS << " MII.getDeprecatedInfo(Inst, getSTI(), Info)) {\n";
39293929
OS << " SMLoc Loc = ((" << Target.getName()
3930-
<< "Operand&)*Operands[0]).getStartLoc();\n";
3930+
<< "Operand &)*Operands[0]).getStartLoc();\n";
39313931
OS << " getParser().Warning(Loc, Info, None);\n";
39323932
OS << " }\n";
39333933
}

llvm/utils/TableGen/AsmWriterEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) {
443443

444444
// Emit the starting string.
445445
O << " assert(Bits != 0 && \"Cannot print this instruction.\");\n"
446-
<< " O << AsmStrs+(Bits & " << (1 << AsmStrBits)-1 << ")-1;\n\n";
446+
<< " O << AsmStrs + (Bits & " << (1 << AsmStrBits)-1 << ") - 1;\n\n";
447447

448448
// Output the table driven operand information.
449449
BitsLeft = OpcodeInfoBits-AsmStrBits;

llvm/utils/TableGen/CallingConvEmitter.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void CallingConvEmitter::EmitCallingConv(Record *CC, raw_ostream &O) {
8585
EmitAction(CCActions->getElementAsRecord(i), 2, O);
8686
}
8787

88-
O << "\n return true; // CC didn't match.\n";
88+
O << "\n return true; // CC didn't match.\n";
8989
O << "}\n";
9090
}
9191

@@ -238,11 +238,11 @@ void CallingConvEmitter::EmitAction(Record *Action,
238238
O << IndentStr << "LocInfo = CCValAssign::FPExt;\n";
239239
} else {
240240
O << IndentStr << "if (ArgFlags.isSExt())\n"
241-
<< IndentStr << IndentStr << "LocInfo = CCValAssign::SExt;\n"
241+
<< IndentStr << " LocInfo = CCValAssign::SExt;\n"
242242
<< IndentStr << "else if (ArgFlags.isZExt())\n"
243-
<< IndentStr << IndentStr << "LocInfo = CCValAssign::ZExt;\n"
243+
<< IndentStr << " LocInfo = CCValAssign::ZExt;\n"
244244
<< IndentStr << "else\n"
245-
<< IndentStr << IndentStr << "LocInfo = CCValAssign::AExt;\n";
245+
<< IndentStr << " LocInfo = CCValAssign::AExt;\n";
246246
}
247247
} else if (Action->isSubClassOf("CCPromoteToUpperBitsInType")) {
248248
Record *DestTy = Action->getValueAsDef("DestTy");
@@ -254,11 +254,11 @@ void CallingConvEmitter::EmitAction(Record *Action,
254254
"point");
255255
} else {
256256
O << IndentStr << "if (ArgFlags.isSExt())\n"
257-
<< IndentStr << IndentStr << "LocInfo = CCValAssign::SExtUpper;\n"
257+
<< IndentStr << " LocInfo = CCValAssign::SExtUpper;\n"
258258
<< IndentStr << "else if (ArgFlags.isZExt())\n"
259-
<< IndentStr << IndentStr << "LocInfo = CCValAssign::ZExtUpper;\n"
259+
<< IndentStr << " LocInfo = CCValAssign::ZExtUpper;\n"
260260
<< IndentStr << "else\n"
261-
<< IndentStr << IndentStr << "LocInfo = CCValAssign::AExtUpper;\n";
261+
<< IndentStr << " LocInfo = CCValAssign::AExtUpper;\n";
262262
}
263263
} else if (Action->isSubClassOf("CCBitConvertToType")) {
264264
Record *DestTy = Action->getValueAsDef("DestTy");
@@ -282,7 +282,7 @@ void CallingConvEmitter::EmitAction(Record *Action,
282282
O << IndentStr
283283
<< "if (" << Action->getValueAsString("FuncName") << "(ValNo, ValVT, "
284284
<< "LocVT, LocInfo, ArgFlags, State))\n";
285-
O << IndentStr << IndentStr << "return false;\n";
285+
O << IndentStr << " return false;\n";
286286
} else {
287287
errs() << *Action;
288288
PrintFatalError(Action->getLoc(), "Unknown CCAction!");

llvm/utils/TableGen/CodeEmitterGen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ void CodeEmitterGen::run(raw_ostream &o) {
483483
<< " Inst = Inst.zext(" << BitWidth << ");\n"
484484
<< " if (Scratch.getBitWidth() != " << BitWidth << ")\n"
485485
<< " Scratch = Scratch.zext(" << BitWidth << ");\n"
486-
<< " LoadIntFromMemory(Inst, (uint8_t*)&InstBits[opcode * " << NumWords
486+
<< " LoadIntFromMemory(Inst, (uint8_t *)&InstBits[opcode * " << NumWords
487487
<< "], " << NumBytes << ");\n"
488488
<< " APInt &Value = Inst;\n"
489489
<< " APInt &op = Scratch;\n"
@@ -643,9 +643,9 @@ void CodeEmitterGen::run(raw_ostream &o) {
643643
<< " report_fatal_error(Msg.str());\n"
644644
<< " }\n"
645645
<< "#else\n"
646-
<< "// Silence unused variable warning on targets that don't use MCII for "
646+
<< " // Silence unused variable warning on targets that don't use MCII for "
647647
"other purposes (e.g. BPF).\n"
648-
<< "(void)MCII;\n"
648+
<< " (void)MCII;\n"
649649
<< "#endif // NDEBUG\n";
650650
o << "}\n";
651651
o << "#endif\n";

llvm/utils/TableGen/CodeGenMapTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void MapTableEmitter::emitBinSearch(raw_ostream &OS, unsigned TableSize) {
422422
OS << " unsigned start = 0;\n";
423423
OS << " unsigned end = " << TableSize << ";\n";
424424
OS << " while (start < end) {\n";
425-
OS << " mid = start + (end - start)/2;\n";
425+
OS << " mid = start + (end - start) / 2;\n";
426426
OS << " if (Opcode == " << InstrMapDesc.getName() << "Table[mid][0]) {\n";
427427
OS << " break;\n";
428428
OS << " }\n";

llvm/utils/TableGen/CodeGenRegisters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,7 @@ void CodeGenRegBank::computeRegUnitSets() {
20112011
if (RCRegUnits.empty())
20122012
continue;
20132013

2014-
LLVM_DEBUG(dbgs() << "RC " << RC.getName() << " Units: \n";
2014+
LLVM_DEBUG(dbgs() << "RC " << RC.getName() << " Units:\n";
20152015
for (auto U
20162016
: RCRegUnits) printRegUnitName(U);
20172017
dbgs() << "\n UnitSetIDs:");

llvm/utils/TableGen/DAGISelMatcherEmitter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void MatcherTableEmitter::EmitPatternMatchTable(raw_ostream &OS) {
250250
BeginEmitFunction(OS, "StringRef", "getPatternForIndex(unsigned Index)",
251251
true/*AddOverride*/);
252252
OS << "{\n";
253-
OS << "static const char * PATTERN_MATCH_TABLE[] = {\n";
253+
OS << "static const char *PATTERN_MATCH_TABLE[] = {\n";
254254

255255
for (const auto &It : VecPatterns) {
256256
OS << "\"" << It.first << "\",\n";
@@ -264,7 +264,7 @@ void MatcherTableEmitter::EmitPatternMatchTable(raw_ostream &OS) {
264264
BeginEmitFunction(OS, "StringRef", "getIncludePathForIndex(unsigned Index)",
265265
true/*AddOverride*/);
266266
OS << "{\n";
267-
OS << "static const char * INCLUDE_PATH_TABLE[] = {\n";
267+
OS << "static const char *INCLUDE_PATH_TABLE[] = {\n";
268268

269269
for (const auto &It : VecIncludeStrings) {
270270
OS << "\"" << It << "\",\n";
@@ -844,7 +844,7 @@ void MatcherTableEmitter::EmitNodePredicatesFunction(
844844
TreePredicateFn PredFn = Preds[i];
845845

846846
assert(!PredFn.isAlwaysTrue() && "No code in this predicate");
847-
OS << " case " << i << ": { \n";
847+
OS << " case " << i << ": {\n";
848848
for (auto *SimilarPred :
849849
NodePredicatesByCodeToRun[PredFn.getCodeToRunOnSDNode()])
850850
OS << " // " << TreePredicateFn(SimilarPred).getFnName() <<'\n';
@@ -887,7 +887,7 @@ void MatcherTableEmitter::EmitPredicateFunctions(raw_ostream &OS) {
887887
BeginEmitFunction(OS, "bool",
888888
"CheckComplexPattern(SDNode *Root, SDNode *Parent,\n"
889889
" SDValue N, unsigned PatternNo,\n"
890-
" SmallVectorImpl<std::pair<SDValue, SDNode*>> &Result)",
890+
" SmallVectorImpl<std::pair<SDValue, SDNode *>> &Result)",
891891
true/*AddOverride*/);
892892
OS << "{\n";
893893
OS << " unsigned NextRes = Result.size();\n";

llvm/utils/TableGen/DAGISelMatcherGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ void MatcherGen::EmitResultLeafAsOperand(const TreePatternNode *N,
744744
}
745745
}
746746

747-
errs() << "unhandled leaf node: \n";
747+
errs() << "unhandled leaf node:\n";
748748
N->dump();
749749
}
750750

llvm/utils/TableGen/DFAPacketizerEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void DFAPacketizerEmitter::emitForItineraries(
263263
OS << " " << ProcModelStartIdx[Model] << ", // " << Model->ModelName
264264
<< "\n";
265265
}
266-
OS << ScheduleClasses.size() << "\n};\n\n";
266+
OS << " " << ScheduleClasses.size() << "\n};\n\n";
267267

268268
// The type of a state in the nondeterministic automaton we're defining.
269269
using NfaStateTy = uint64_t;

0 commit comments

Comments
 (0)