diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/libs/llvm12/utils/TableGen/AsmMatcherEmitter.cpp | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/utils/TableGen/AsmMatcherEmitter.cpp')
-rw-r--r-- | contrib/libs/llvm12/utils/TableGen/AsmMatcherEmitter.cpp | 208 |
1 files changed, 104 insertions, 104 deletions
diff --git a/contrib/libs/llvm12/utils/TableGen/AsmMatcherEmitter.cpp b/contrib/libs/llvm12/utils/TableGen/AsmMatcherEmitter.cpp index 245aab5049..9d304910ba 100644 --- a/contrib/libs/llvm12/utils/TableGen/AsmMatcherEmitter.cpp +++ b/contrib/libs/llvm12/utils/TableGen/AsmMatcherEmitter.cpp @@ -612,7 +612,7 @@ struct MatchableInfo { /// operator< - Compare two matchables. bool operator<(const MatchableInfo &RHS) const { // The primary comparator is the instruction mnemonic. - if (int Cmp = Mnemonic.compare_lower(RHS.Mnemonic)) + if (int Cmp = Mnemonic.compare_lower(RHS.Mnemonic)) return Cmp == -1; if (AsmOperands.size() != RHS.AsmOperands.size()) @@ -789,8 +789,8 @@ public: } bool hasOptionalOperands() const { - return any_of(Classes, - [](const ClassInfo &Class) { return Class.IsOptional; }); + return any_of(Classes, + [](const ClassInfo &Class) { return Class.IsOptional; }); } }; @@ -1017,7 +1017,7 @@ void MatchableInfo::tokenizeAsmString(const AsmMatcherInfo &Info, case '$': { if (InTok) { - addAsmOperand(String.slice(Prev, i), IsIsolatedToken); + addAsmOperand(String.slice(Prev, i), IsIsolatedToken); InTok = false; IsIsolatedToken = false; } @@ -1112,7 +1112,7 @@ static std::string getEnumNameForToken(StringRef Str) { case '-': Res += "_MINUS_"; break; case '#': Res += "_HASH_"; break; default: - if (isAlnum(*it)) + if (isAlnum(*it)) Res += *it; else Res += "_" + utostr((unsigned) *it) + "_"; @@ -1977,7 +1977,7 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName, } CvtOS << " unsigned OpIdx;\n"; CvtOS << " Inst.setOpcode(Opcode);\n"; - CvtOS << " for (const uint8_t *p = Converter; *p; p += 2) {\n"; + CvtOS << " for (const uint8_t *p = Converter; *p; p += 2) {\n"; if (HasOptionalOperands) { CvtOS << " OpIdx = *(p + 1) - DefaultsOffset[*(p + 1)];\n"; } else { @@ -1987,14 +1987,14 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName, CvtOS << " default: llvm_unreachable(\"invalid conversion entry!\");\n"; CvtOS << " case CVT_Reg:\n"; CvtOS << " static_cast<" << TargetOperandClass - << " &>(*Operands[OpIdx]).addRegOperands(Inst, 1);\n"; + << " &>(*Operands[OpIdx]).addRegOperands(Inst, 1);\n"; CvtOS << " break;\n"; CvtOS << " case CVT_Tied: {\n"; CvtOS << " assert(OpIdx < (size_t)(std::end(TiedAsmOperandTable) -\n"; - CvtOS << " std::begin(TiedAsmOperandTable)) &&\n"; + CvtOS << " std::begin(TiedAsmOperandTable)) &&\n"; CvtOS << " \"Tied operand not found\");\n"; CvtOS << " unsigned TiedResOpnd = TiedAsmOperandTable[OpIdx][0];\n"; - CvtOS << " if (TiedResOpnd != (uint8_t)-1)\n"; + CvtOS << " if (TiedResOpnd != (uint8_t)-1)\n"; CvtOS << " Inst.addOperand(Inst.getOperand(TiedResOpnd));\n"; CvtOS << " break;\n"; CvtOS << " }\n"; @@ -2009,7 +2009,7 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName, << " assert(Kind < CVT_NUM_SIGNATURES && \"Invalid signature!\");\n" << " unsigned NumMCOperands = 0;\n" << " const uint8_t *Converter = ConversionTable[Kind];\n" - << " for (const uint8_t *p = Converter; *p; p += 2) {\n" + << " for (const uint8_t *p = Converter; *p; p += 2) {\n" << " switch (*p) {\n" << " default: llvm_unreachable(\"invalid conversion entry!\");\n" << " case CVT_Reg:\n" @@ -2126,12 +2126,12 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName, << OpInfo.MINumOperands << ");\n" << " } else {\n" << " static_cast<" << TargetOperandClass - << " &>(*Operands[OpIdx])." << Op.Class->RenderMethod + << " &>(*Operands[OpIdx])." << Op.Class->RenderMethod << "(Inst, " << OpInfo.MINumOperands << ");\n" << " }\n"; } else { CvtOS << " static_cast<" << TargetOperandClass - << " &>(*Operands[OpIdx])." << Op.Class->RenderMethod + << " &>(*Operands[OpIdx])." << Op.Class->RenderMethod << "(Inst, " << OpInfo.MINumOperands << ");\n"; } CvtOS << " break;\n"; @@ -2387,9 +2387,9 @@ static void emitMatchClassEnumeration(CodeGenTarget &Target, static void emitOperandMatchErrorDiagStrings(AsmMatcherInfo &Info, raw_ostream &OS) { // If the target does not use DiagnosticString for any operands, don't emit // an unused function. - if (llvm::all_of(Info.Classes, [](const ClassInfo &CI) { - return CI.DiagnosticString.empty(); - })) + if (llvm::all_of(Info.Classes, [](const ClassInfo &CI) { + return CI.DiagnosticString.empty(); + })) return; OS << "static const char *getMatchKindDiag(" << Info.Target.getName() @@ -2445,7 +2445,7 @@ static void emitValidateOperandClass(AsmMatcherInfo &Info, OS << "static unsigned validateOperandClass(MCParsedAsmOperand &GOp, " << "MatchClassKind Kind) {\n"; OS << " " << Info.Target.getName() << "Operand &Operand = (" - << Info.Target.getName() << "Operand &)GOp;\n"; + << Info.Target.getName() << "Operand &)GOp;\n"; // The InvalidMatchClass is not to match any operand. OS << " if (Kind == InvalidMatchClass)\n"; @@ -2808,7 +2808,7 @@ static bool emitMnemonicAliases(raw_ostream &OS, const AsmMatcherInfo &Info, Record *AsmVariant = Target.getAsmParserVariant(VC); int AsmParserVariantNo = AsmVariant->getValueAsInt("Variant"); StringRef AsmParserVariantName = AsmVariant->getValueAsString("Name"); - OS << " case " << AsmParserVariantNo << ":\n"; + OS << " case " << AsmParserVariantNo << ":\n"; emitMnemonicAliasVariant(OS, Info, Aliases, /*Indent=*/2, AsmParserVariantName); OS << " break;\n"; @@ -2877,7 +2877,7 @@ static void emitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target, OS << " { "; // Store a pascal-style length byte in the mnemonic. - std::string LenMnemonic = char(II.Mnemonic.size()) + II.Mnemonic.lower(); + std::string LenMnemonic = char(II.Mnemonic.size()) + II.Mnemonic.lower(); OS << StringTable.GetOrAddStringOffset(LenMnemonic, false) << " /* " << II.Mnemonic << " */, "; @@ -2975,7 +2975,7 @@ static void emitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target, "FeatureBitsets[it->RequiredFeaturesIdx];\n"; OS << " if (!ParseForAllFeatures && (AvailableFeatures & " "RequiredFeatures) != RequiredFeatures)\n"; - OS << " continue;\n\n"; + OS << " continue;\n\n"; // Emit check to ensure the operand number matches. OS << " // check if the operand in question has a custom parser.\n"; @@ -3008,10 +3008,10 @@ static void emitAsmTiedOperandConstraints(CodeGenTarget &Target, OS << " uint64_t &ErrorInfo) {\n"; OS << " assert(Kind < CVT_NUM_SIGNATURES && \"Invalid signature!\");\n"; OS << " const uint8_t *Converter = ConversionTable[Kind];\n"; - OS << " for (const uint8_t *p = Converter; *p; p += 2) {\n"; + OS << " for (const uint8_t *p = Converter; *p; p += 2) {\n"; OS << " switch (*p) {\n"; OS << " case CVT_Tied: {\n"; - OS << " unsigned OpIdx = *(p + 1);\n"; + OS << " unsigned OpIdx = *(p + 1);\n"; OS << " assert(OpIdx < (size_t)(std::end(TiedAsmOperandTable) -\n"; OS << " std::begin(TiedAsmOperandTable)) &&\n"; OS << " \"Tied operand not found\");\n"; @@ -3083,7 +3083,7 @@ static void emitMnemonicSpellChecker(raw_ostream &OS, CodeGenTarget &Target, OS << "\n"; OS << " std::string Res = \", did you mean: \";\n"; OS << " unsigned i = 0;\n"; - OS << " for (; i < Candidates.size() - 1; i++)\n"; + OS << " for (; i < Candidates.size() - 1; i++)\n"; OS << " Res += Candidates[i].str() + \", \";\n"; OS << " return Res + Candidates[i].str() + \"?\";\n"; } @@ -3091,68 +3091,68 @@ static void emitMnemonicSpellChecker(raw_ostream &OS, CodeGenTarget &Target, OS << "\n"; } -static void emitMnemonicChecker(raw_ostream &OS, - CodeGenTarget &Target, - unsigned VariantCount, - bool HasMnemonicFirst, - bool HasMnemonicAliases) { - OS << "static bool " << Target.getName() - << "CheckMnemonic(StringRef Mnemonic,\n"; - OS << " " - << "const FeatureBitset &AvailableFeatures,\n"; - OS << " " - << "unsigned VariantID) {\n"; - - if (!VariantCount) { - OS << " return false;\n"; - } else { - if (HasMnemonicAliases) { - OS << " // Process all MnemonicAliases to remap the mnemonic.\n"; - OS << " applyMnemonicAliases(Mnemonic, AvailableFeatures, VariantID);"; - OS << "\n\n"; - } - OS << " // Find the appropriate table for this asm variant.\n"; - OS << " const MatchEntry *Start, *End;\n"; - OS << " switch (VariantID) {\n"; - OS << " default: llvm_unreachable(\"invalid variant!\");\n"; - for (unsigned VC = 0; VC != VariantCount; ++VC) { - Record *AsmVariant = Target.getAsmParserVariant(VC); - int AsmVariantNo = AsmVariant->getValueAsInt("Variant"); - OS << " case " << AsmVariantNo << ": Start = std::begin(MatchTable" << VC - << "); End = std::end(MatchTable" << VC << "); break;\n"; - } - OS << " }\n\n"; - - OS << " // Search the table.\n"; - if (HasMnemonicFirst) { - OS << " auto MnemonicRange = " - "std::equal_range(Start, End, Mnemonic, LessOpcode());\n\n"; - } else { - OS << " auto MnemonicRange = std::make_pair(Start, End);\n"; - OS << " unsigned SIndex = Mnemonic.empty() ? 0 : 1;\n"; - OS << " if (!Mnemonic.empty())\n"; - OS << " MnemonicRange = " - << "std::equal_range(Start, End, Mnemonic.lower(), LessOpcode());\n\n"; - } - - OS << " if (MnemonicRange.first == MnemonicRange.second)\n"; - OS << " return false;\n\n"; - - OS << " for (const MatchEntry *it = MnemonicRange.first, " - << "*ie = MnemonicRange.second;\n"; - OS << " it != ie; ++it) {\n"; - OS << " const FeatureBitset &RequiredFeatures =\n"; - OS << " FeatureBitsets[it->RequiredFeaturesIdx];\n"; - OS << " if ((AvailableFeatures & RequiredFeatures) == "; - OS << "RequiredFeatures)\n"; - OS << " return true;\n"; - OS << " }\n"; - OS << " return false;\n"; - } - OS << "}\n"; - OS << "\n"; -} - +static void emitMnemonicChecker(raw_ostream &OS, + CodeGenTarget &Target, + unsigned VariantCount, + bool HasMnemonicFirst, + bool HasMnemonicAliases) { + OS << "static bool " << Target.getName() + << "CheckMnemonic(StringRef Mnemonic,\n"; + OS << " " + << "const FeatureBitset &AvailableFeatures,\n"; + OS << " " + << "unsigned VariantID) {\n"; + + if (!VariantCount) { + OS << " return false;\n"; + } else { + if (HasMnemonicAliases) { + OS << " // Process all MnemonicAliases to remap the mnemonic.\n"; + OS << " applyMnemonicAliases(Mnemonic, AvailableFeatures, VariantID);"; + OS << "\n\n"; + } + OS << " // Find the appropriate table for this asm variant.\n"; + OS << " const MatchEntry *Start, *End;\n"; + OS << " switch (VariantID) {\n"; + OS << " default: llvm_unreachable(\"invalid variant!\");\n"; + for (unsigned VC = 0; VC != VariantCount; ++VC) { + Record *AsmVariant = Target.getAsmParserVariant(VC); + int AsmVariantNo = AsmVariant->getValueAsInt("Variant"); + OS << " case " << AsmVariantNo << ": Start = std::begin(MatchTable" << VC + << "); End = std::end(MatchTable" << VC << "); break;\n"; + } + OS << " }\n\n"; + + OS << " // Search the table.\n"; + if (HasMnemonicFirst) { + OS << " auto MnemonicRange = " + "std::equal_range(Start, End, Mnemonic, LessOpcode());\n\n"; + } else { + OS << " auto MnemonicRange = std::make_pair(Start, End);\n"; + OS << " unsigned SIndex = Mnemonic.empty() ? 0 : 1;\n"; + OS << " if (!Mnemonic.empty())\n"; + OS << " MnemonicRange = " + << "std::equal_range(Start, End, Mnemonic.lower(), LessOpcode());\n\n"; + } + + OS << " if (MnemonicRange.first == MnemonicRange.second)\n"; + OS << " return false;\n\n"; + + OS << " for (const MatchEntry *it = MnemonicRange.first, " + << "*ie = MnemonicRange.second;\n"; + OS << " it != ie; ++it) {\n"; + OS << " const FeatureBitset &RequiredFeatures =\n"; + OS << " FeatureBitsets[it->RequiredFeaturesIdx];\n"; + OS << " if ((AvailableFeatures & RequiredFeatures) == "; + OS << "RequiredFeatures)\n"; + OS << " return true;\n"; + OS << " }\n"; + OS << " return false;\n"; + } + OS << "}\n"; + OS << "\n"; +} + // Emit a function mapping match classes to strings, for debugging. static void emitMatchClassKindNames(std::forward_list<ClassInfo> &Infos, raw_ostream &OS) { @@ -3252,7 +3252,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << "#undef GET_ASSEMBLER_HEADER\n"; OS << " // This should be included into the middle of the declaration of\n"; OS << " // your subclasses implementation of MCTargetAsmParser.\n"; - OS << " FeatureBitset ComputeAvailableFeatures(const FeatureBitset &FB) const;\n"; + OS << " FeatureBitset ComputeAvailableFeatures(const FeatureBitset &FB) const;\n"; if (HasOptionalOperands) { OS << " void convertToMCInst(unsigned Kind, MCInst &Inst, " << "unsigned Opcode,\n" @@ -3382,7 +3382,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { HasDeprecation |= MI->HasDeprecation; // Store a pascal-style length byte in the mnemonic. - std::string LenMnemonic = char(MI->Mnemonic.size()) + MI->Mnemonic.lower(); + std::string LenMnemonic = char(MI->Mnemonic.size()) + MI->Mnemonic.lower(); MaxMnemonicIndex = std::max(MaxMnemonicIndex, StringTable.GetOrAddStringOffset(LenMnemonic, false)); } @@ -3496,8 +3496,8 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { continue; // Store a pascal-style length byte in the mnemonic. - std::string LenMnemonic = - char(MI->Mnemonic.size()) + MI->Mnemonic.lower(); + std::string LenMnemonic = + char(MI->Mnemonic.size()) + MI->Mnemonic.lower(); OS << " { " << StringTable.GetOrAddStringOffset(LenMnemonic, false) << " /* " << MI->Mnemonic << " */, " << Target.getInstNamespace() << "::" @@ -3556,12 +3556,12 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << " // Get the instruction mnemonic, which is the first token.\n"; if (HasMnemonicFirst) { OS << " StringRef Mnemonic = ((" << Target.getName() - << "Operand &)*Operands[0]).getToken();\n\n"; + << "Operand &)*Operands[0]).getToken();\n\n"; } else { OS << " StringRef Mnemonic;\n"; OS << " if (Operands[0]->isToken())\n"; OS << " Mnemonic = ((" << Target.getName() - << "Operand &)*Operands[0]).getToken();\n\n"; + << "Operand &)*Operands[0]).getToken();\n\n"; } if (HasMnemonicAliases) { @@ -3611,7 +3611,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { } OS << " DEBUG_WITH_TYPE(\"asm-matcher\", dbgs() << \"AsmMatcher: found \" <<\n" - << " std::distance(MnemonicRange.first, MnemonicRange.second) <<\n" + << " std::distance(MnemonicRange.first, MnemonicRange.second) <<\n" << " \" encodings with mnemonic '\" << Mnemonic << \"'\\n\");\n\n"; OS << " // Return a more specific error code if no mnemonics match.\n"; @@ -3786,10 +3786,10 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << " FeatureBitset NewMissingFeatures = RequiredFeatures & " "~AvailableFeatures;\n"; OS << " DEBUG_WITH_TYPE(\"asm-matcher\", dbgs() << \"Missing target features:\";\n"; - OS << " for (unsigned I = 0, E = NewMissingFeatures.size(); I != E; ++I)\n"; - OS << " if (NewMissingFeatures[I])\n"; - OS << " dbgs() << ' ' << I;\n"; - OS << " dbgs() << \"\\n\");\n"; + OS << " for (unsigned I = 0, E = NewMissingFeatures.size(); I != E; ++I)\n"; + OS << " if (NewMissingFeatures[I])\n"; + OS << " dbgs() << ' ' << I;\n"; + OS << " dbgs() << \"\\n\");\n"; if (ReportMultipleNearMisses) { OS << " FeaturesNearMiss = NearMissInfo::getMissedFeature(NewMissingFeatures);\n"; } else { @@ -3924,7 +3924,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << " getTargetOptions().MCNoDeprecatedWarn &&\n"; OS << " MII.getDeprecatedInfo(Inst, getSTI(), Info)) {\n"; OS << " SMLoc Loc = ((" << Target.getName() - << "Operand &)*Operands[0]).getStartLoc();\n"; + << "Operand &)*Operands[0]).getStartLoc();\n"; OS << " getParser().Warning(Loc, Info, None);\n"; OS << " }\n"; } @@ -3967,14 +3967,14 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { emitMnemonicSpellChecker(OS, Target, VariantCount); OS << "#endif // GET_MNEMONIC_SPELL_CHECKER\n\n"; - - OS << "\n#ifdef GET_MNEMONIC_CHECKER\n"; - OS << "#undef GET_MNEMONIC_CHECKER\n\n"; - - emitMnemonicChecker(OS, Target, VariantCount, - HasMnemonicFirst, HasMnemonicAliases); - - OS << "#endif // GET_MNEMONIC_CHECKER\n\n"; + + OS << "\n#ifdef GET_MNEMONIC_CHECKER\n"; + OS << "#undef GET_MNEMONIC_CHECKER\n\n"; + + emitMnemonicChecker(OS, Target, VariantCount, + HasMnemonicFirst, HasMnemonicAliases); + + OS << "#endif // GET_MNEMONIC_CHECKER\n\n"; } namespace llvm { |