Lines Matching refs:OS
1707 raw_ostream &OS) { in emitConvertFuncs() argument
1960 OS << "namespace {\n"; in emitConvertFuncs()
1963 OS << "enum OperatorConversionKind {\n"; in emitConvertFuncs()
1965 OS << " " << OperandConversionKinds[i] << ",\n"; in emitConvertFuncs()
1966 OS << " CVT_NUM_CONVERTERS\n"; in emitConvertFuncs()
1967 OS << "};\n\n"; in emitConvertFuncs()
1970 OS << "enum InstructionConversionKind {\n"; in emitConvertFuncs()
1974 OS << " " << *i << ",\n"; in emitConvertFuncs()
1975 OS << " CVT_NUM_SIGNATURES\n"; in emitConvertFuncs()
1976 OS << "};\n\n"; in emitConvertFuncs()
1979 OS << "} // end anonymous namespace\n\n"; in emitConvertFuncs()
1982 OS << "static const uint8_t ConversionTable[CVT_NUM_SIGNATURES][" in emitConvertFuncs()
1987 OS << " // " << InstructionConversionKinds[Row] << "\n"; in emitConvertFuncs()
1988 OS << " { "; in emitConvertFuncs()
1990 OS << OperandConversionKinds[ConversionTable[Row][i]] << ", " in emitConvertFuncs()
1992 OS << "CVT_Done },\n"; in emitConvertFuncs()
1995 OS << "};\n\n"; in emitConvertFuncs()
1998 OS << CvtOS.str(); in emitConvertFuncs()
2001 OS << OpOS.str(); in emitConvertFuncs()
2007 raw_ostream &OS) { in emitMatchClassEnumeration() argument
2008 OS << "namespace {\n\n"; in emitMatchClassEnumeration()
2010 OS << "/// MatchClassKind - The kinds of classes which participate in\n" in emitMatchClassEnumeration()
2012 OS << "enum MatchClassKind {\n"; in emitMatchClassEnumeration()
2013 OS << " InvalidMatchClass = 0,\n"; in emitMatchClassEnumeration()
2017 OS << " " << CI.Name << ", // "; in emitMatchClassEnumeration()
2019 OS << "'" << CI.ValueName << "'\n"; in emitMatchClassEnumeration()
2022 OS << "register class '" << CI.ValueName << "'\n"; in emitMatchClassEnumeration()
2024 OS << "derived register class\n"; in emitMatchClassEnumeration()
2026 OS << "user defined class '" << CI.ValueName << "'\n"; in emitMatchClassEnumeration()
2029 OS << " NumMatchClassKinds\n"; in emitMatchClassEnumeration()
2030 OS << "};\n\n"; in emitMatchClassEnumeration()
2032 OS << "}\n\n"; in emitMatchClassEnumeration()
2037 raw_ostream &OS) { in emitValidateOperandClass() argument
2038 OS << "static unsigned validateOperandClass(MCParsedAsmOperand &GOp, " in emitValidateOperandClass()
2040 OS << " " << Info.Target.getName() << "Operand &Operand = (" in emitValidateOperandClass()
2044 OS << " if (Kind == InvalidMatchClass)\n"; in emitValidateOperandClass()
2045 OS << " return MCTargetAsmParser::Match_InvalidOperand;\n\n"; in emitValidateOperandClass()
2049 OS << " if (Operand.isToken())\n"; in emitValidateOperandClass()
2050 OS << " return isSubclass(matchTokenString(Operand.getToken()), Kind) ?\n" in emitValidateOperandClass()
2063 OS << " // '" << CI.ClassName << "' class\n"; in emitValidateOperandClass()
2064 OS << " if (Kind == " << CI.Name << ") {\n"; in emitValidateOperandClass()
2065 OS << " if (Operand." << CI.PredicateMethod << "())\n"; in emitValidateOperandClass()
2066 OS << " return MCTargetAsmParser::Match_Success;\n"; in emitValidateOperandClass()
2068 OS << " return " << Info.Target.getName() << "AsmParser::Match_" in emitValidateOperandClass()
2070 OS << " }\n\n"; in emitValidateOperandClass()
2074 OS << " if (Operand.isReg()) {\n"; in emitValidateOperandClass()
2075 OS << " MatchClassKind OpKind;\n"; in emitValidateOperandClass()
2076 OS << " switch (Operand.getReg()) {\n"; in emitValidateOperandClass()
2077 OS << " default: OpKind = InvalidMatchClass; break;\n"; in emitValidateOperandClass()
2081 OS << " case " << Info.Target.getName() << "::" in emitValidateOperandClass()
2084 OS << " }\n"; in emitValidateOperandClass()
2085 OS << " return isSubclass(OpKind, Kind) ? " in emitValidateOperandClass()
2091 OS << " return MCTargetAsmParser::Match_InvalidOperand;\n"; in emitValidateOperandClass()
2092 OS << "}\n\n"; in emitValidateOperandClass()
2098 raw_ostream &OS) { in emitIsSubclass() argument
2099 OS << "/// isSubclass - Compute whether \\p A is a subclass of \\p B.\n"; in emitIsSubclass()
2100 OS << "static bool isSubclass(MatchClassKind A, MatchClassKind B) {\n"; in emitIsSubclass()
2101 OS << " if (A == B)\n"; in emitIsSubclass()
2102 OS << " return true;\n\n"; in emitIsSubclass()
2150 OS << SS.str(); in emitIsSubclass()
2152 OS << " return false;\n"; in emitIsSubclass()
2154 OS << "}\n\n"; in emitIsSubclass()
2161 raw_ostream &OS) { in emitMatchTokenString() argument
2173 OS << "static MatchClassKind matchTokenString(StringRef Name) {\n"; in emitMatchTokenString()
2175 StringMatcher("Name", Matches, OS).Emit(); in emitMatchTokenString()
2177 OS << " return InvalidMatchClass;\n"; in emitMatchTokenString()
2178 OS << "}\n\n"; in emitMatchTokenString()
2184 raw_ostream &OS) { in emitMatchRegisterName() argument
2199 OS << "static unsigned MatchRegisterName(StringRef Name) {\n"; in emitMatchRegisterName()
2201 StringMatcher("Name", Matches, OS).Emit(); in emitMatchRegisterName()
2203 OS << " return 0;\n"; in emitMatchRegisterName()
2204 OS << "}\n\n"; in emitMatchRegisterName()
2226 raw_ostream &OS) { in emitSubtargetFeatureFlagEnumeration() argument
2227 OS << "// Flags for subtarget features that participate in " in emitSubtargetFeatureFlagEnumeration()
2229 OS << "enum SubtargetFeatureFlag : " << getMinimalRequiredFeaturesType(Info) in emitSubtargetFeatureFlagEnumeration()
2235 OS << " " << SFI.getEnumName() << " = (1U << " << SFI.Index << "),\n"; in emitSubtargetFeatureFlagEnumeration()
2237 OS << " Feature_None = 0\n"; in emitSubtargetFeatureFlagEnumeration()
2238 OS << "};\n\n"; in emitSubtargetFeatureFlagEnumeration()
2242 static void emitOperandDiagnosticTypes(AsmMatcherInfo &Info, raw_ostream &OS) { in emitOperandDiagnosticTypes() argument
2257 OS << " Match_" << *I << ",\n"; in emitOperandDiagnosticTypes()
2258 OS << " END_OPERAND_DIAGNOSTIC_TYPES\n"; in emitOperandDiagnosticTypes()
2263 static void emitGetSubtargetFeatureName(AsmMatcherInfo &Info, raw_ostream &OS) { in emitGetSubtargetFeatureName() argument
2264 OS << "// User-level names for subtarget features that participate in\n" in emitGetSubtargetFeatureName()
2268 OS << " switch(Val) {\n"; in emitGetSubtargetFeatureName()
2274 OS << " case " << SFI.getEnumName() << ": return \"" in emitGetSubtargetFeatureName()
2277 OS << " default: return \"(unknown)\";\n"; in emitGetSubtargetFeatureName()
2278 OS << " }\n"; in emitGetSubtargetFeatureName()
2281 OS << " return \"(unknown)\";\n"; in emitGetSubtargetFeatureName()
2283 OS << "}\n\n"; in emitGetSubtargetFeatureName()
2289 raw_ostream &OS) { in emitComputeAvailableFeatures() argument
2293 OS << "unsigned " << Info.Target.getName() << ClassName << "::\n" in emitComputeAvailableFeatures()
2295 OS << " unsigned Features = 0;\n"; in emitComputeAvailableFeatures()
2301 OS << " if ("; in emitComputeAvailableFeatures()
2309 OS << " && "; in emitComputeAvailableFeatures()
2318 OS << "((FB & " << Info.Target.getName() << "::" << Cond << ")"; in emitComputeAvailableFeatures()
2320 OS << " == 0"; in emitComputeAvailableFeatures()
2322 OS << " != 0"; in emitComputeAvailableFeatures()
2323 OS << ")"; in emitComputeAvailableFeatures()
2332 OS << ")\n"; in emitComputeAvailableFeatures()
2333 OS << " Features |= " << SFI.getEnumName() << ";\n"; in emitComputeAvailableFeatures()
2335 OS << " return Features;\n"; in emitComputeAvailableFeatures()
2336 OS << "}\n\n"; in emitComputeAvailableFeatures()
2363 static void emitMnemonicAliasVariant(raw_ostream &OS,const AsmMatcherInfo &Info, in emitMnemonicAliasVariant() argument
2433 StringMatcher("Mnemonic", Cases, OS).Emit(Indent); in emitMnemonicAliasVariant()
2438 static bool emitMnemonicAliases(raw_ostream &OS, const AsmMatcherInfo &Info, in emitMnemonicAliases() argument
2448 OS << "static void applyMnemonicAliases(StringRef &Mnemonic, " in emitMnemonicAliases()
2450 OS << " switch (VariantID) {\n"; in emitMnemonicAliases()
2456 OS << " case " << AsmParserVariantNo << ":\n"; in emitMnemonicAliases()
2457 emitMnemonicAliasVariant(OS, Info, Aliases, /*Indent=*/2, in emitMnemonicAliases()
2459 OS << " break;\n"; in emitMnemonicAliases()
2461 OS << " }\n"; in emitMnemonicAliases()
2464 emitMnemonicAliasVariant(OS, Info, Aliases); in emitMnemonicAliases()
2466 OS << "}\n\n"; in emitMnemonicAliases()
2471 static void emitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target, in emitCustomOperandParsing() argument
2483 OS << "namespace {\n"; in emitCustomOperandParsing()
2484 OS << " struct OperandMatchEntry {\n"; in emitCustomOperandParsing()
2485 OS << " " << getMinimalRequiredFeaturesType(Info) in emitCustomOperandParsing()
2487 OS << " " << getMinimalTypeForRange(MaxMnemonicIndex) in emitCustomOperandParsing()
2489 OS << " " << getMinimalTypeForRange(Info.Classes.size()) in emitCustomOperandParsing()
2491 OS << " " << getMinimalTypeForRange(MaxMask) in emitCustomOperandParsing()
2493 OS << " StringRef getMnemonic() const {\n"; in emitCustomOperandParsing()
2494 OS << " return StringRef(MnemonicTable + Mnemonic + 1,\n"; in emitCustomOperandParsing()
2495 OS << " MnemonicTable[Mnemonic]);\n"; in emitCustomOperandParsing()
2496 OS << " }\n"; in emitCustomOperandParsing()
2497 OS << " };\n\n"; in emitCustomOperandParsing()
2499 OS << " // Predicate for searching for an opcode.\n"; in emitCustomOperandParsing()
2500 OS << " struct LessOpcodeOperand {\n"; in emitCustomOperandParsing()
2501 OS << " bool operator()(const OperandMatchEntry &LHS, StringRef RHS) {\n"; in emitCustomOperandParsing()
2502 OS << " return LHS.getMnemonic() < RHS;\n"; in emitCustomOperandParsing()
2503 OS << " }\n"; in emitCustomOperandParsing()
2504 OS << " bool operator()(StringRef LHS, const OperandMatchEntry &RHS) {\n"; in emitCustomOperandParsing()
2505 OS << " return LHS < RHS.getMnemonic();\n"; in emitCustomOperandParsing()
2506 OS << " }\n"; in emitCustomOperandParsing()
2507 OS << " bool operator()(const OperandMatchEntry &LHS,"; in emitCustomOperandParsing()
2508 OS << " const OperandMatchEntry &RHS) {\n"; in emitCustomOperandParsing()
2509 OS << " return LHS.getMnemonic() < RHS.getMnemonic();\n"; in emitCustomOperandParsing()
2510 OS << " }\n"; in emitCustomOperandParsing()
2511 OS << " };\n"; in emitCustomOperandParsing()
2513 OS << "} // end anonymous namespace.\n\n"; in emitCustomOperandParsing()
2515 OS << "static const OperandMatchEntry OperandMatchTable[" in emitCustomOperandParsing()
2518 OS << " /* Operand List Mask, Mnemonic, Operand Class, Features */\n"; in emitCustomOperandParsing()
2525 OS << " { "; in emitCustomOperandParsing()
2530 if (i) OS << "|"; in emitCustomOperandParsing()
2531 OS << II.RequiredFeatures[i]->getEnumName(); in emitCustomOperandParsing()
2534 OS << "0"; in emitCustomOperandParsing()
2538 OS << ", " << StringTable.GetOrAddStringOffset(LenMnemonic, false) in emitCustomOperandParsing()
2541 OS << OMI.CI->Name; in emitCustomOperandParsing()
2543 OS << ", " << OMI.OperandMask; in emitCustomOperandParsing()
2544 OS << " /* "; in emitCustomOperandParsing()
2549 OS << ", "; in emitCustomOperandParsing()
2550 OS << i; in emitCustomOperandParsing()
2553 OS << " */"; in emitCustomOperandParsing()
2555 OS << " },\n"; in emitCustomOperandParsing()
2557 OS << "};\n\n"; in emitCustomOperandParsing()
2561 OS << Target.getName() << ClassName << "::OperandMatchResultTy " in emitCustomOperandParsing()
2572 OS << " case " << CI->Name << ":\n" in emitCustomOperandParsing()
2576 OS << " default:\n"; in emitCustomOperandParsing()
2577 OS << " return MatchOperand_NoMatch;\n"; in emitCustomOperandParsing()
2578 OS << " }\n"; in emitCustomOperandParsing()
2579 OS << " return MatchOperand_NoMatch;\n"; in emitCustomOperandParsing()
2580 OS << "}\n\n"; in emitCustomOperandParsing()
2585 OS << Target.getName() << ClassName << "::OperandMatchResultTy " in emitCustomOperandParsing()
2591 OS << " // Get the current feature set.\n"; in emitCustomOperandParsing()
2592 OS << " unsigned AvailableFeatures = getAvailableFeatures();\n\n"; in emitCustomOperandParsing()
2594 OS << " // Get the next operand index.\n"; in emitCustomOperandParsing()
2595 OS << " unsigned NextOpNum = Operands.size()-1;\n"; in emitCustomOperandParsing()
2598 OS << " // Search the table.\n"; in emitCustomOperandParsing()
2599 OS << " std::pair<const OperandMatchEntry*, const OperandMatchEntry*>"; in emitCustomOperandParsing()
2600 OS << " MnemonicRange =\n"; in emitCustomOperandParsing()
2601 OS << " std::equal_range(OperandMatchTable, OperandMatchTable+" in emitCustomOperandParsing()
2605 OS << " if (MnemonicRange.first == MnemonicRange.second)\n"; in emitCustomOperandParsing()
2606 OS << " return MatchOperand_NoMatch;\n\n"; in emitCustomOperandParsing()
2608 OS << " for (const OperandMatchEntry *it = MnemonicRange.first,\n" in emitCustomOperandParsing()
2611 OS << " // equal_range guarantees that instruction mnemonic matches.\n"; in emitCustomOperandParsing()
2612 OS << " assert(Mnemonic == it->getMnemonic());\n\n"; in emitCustomOperandParsing()
2615 OS << " // check if the available features match\n"; in emitCustomOperandParsing()
2616 OS << " if ((AvailableFeatures & it->RequiredFeatures) " in emitCustomOperandParsing()
2618 OS << " continue;\n"; in emitCustomOperandParsing()
2619 OS << " }\n\n"; in emitCustomOperandParsing()
2622 OS << " // check if the operand in question has a custom parser.\n"; in emitCustomOperandParsing()
2623 OS << " if (!(it->OperandMask & (1 << NextOpNum)))\n"; in emitCustomOperandParsing()
2624 OS << " continue;\n\n"; in emitCustomOperandParsing()
2627 OS << " // call custom parse method to handle the operand\n"; in emitCustomOperandParsing()
2628 OS << " OperandMatchResultTy Result = "; in emitCustomOperandParsing()
2629 OS << "tryCustomParseOperand(Operands, it->Class);\n"; in emitCustomOperandParsing()
2630 OS << " if (Result != MatchOperand_NoMatch)\n"; in emitCustomOperandParsing()
2631 OS << " return Result;\n"; in emitCustomOperandParsing()
2632 OS << " }\n\n"; in emitCustomOperandParsing()
2634 OS << " // Okay, we had no match.\n"; in emitCustomOperandParsing()
2635 OS << " return MatchOperand_NoMatch;\n"; in emitCustomOperandParsing()
2636 OS << "}\n\n"; in emitCustomOperandParsing()
2639 void AsmMatcherEmitter::run(raw_ostream &OS) { in run() argument
2690 OS << "\n#ifdef GET_ASSEMBLER_HEADER\n"; in run()
2691 OS << "#undef GET_ASSEMBLER_HEADER\n"; in run()
2692 OS << " // This should be included into the middle of the declaration of\n"; in run()
2693 OS << " // your subclasses implementation of MCTargetAsmParser.\n"; in run()
2694 OS << " unsigned ComputeAvailableFeatures(uint64_t FeatureBits) const;\n"; in run()
2695 OS << " void convertToMCInst(unsigned Kind, MCInst &Inst, " in run()
2699 OS << " void convertToMapAndConstraints(unsigned Kind,\n "; in run()
2700 OS << " const OperandVector &Operands) override;\n"; in run()
2701 OS << " bool mnemonicIsValid(StringRef Mnemonic, unsigned VariantID) override;\n"; in run()
2702 OS << " unsigned MatchInstructionImpl(\n"; in run()
2703 OS.indent(27); in run()
2704 OS << "const OperandVector &Operands,\n" in run()
2711 OS << "\n enum OperandMatchResultTy {\n"; in run()
2712 OS << " MatchOperand_Success, // operand matched successfully\n"; in run()
2713 OS << " MatchOperand_NoMatch, // operand did not match\n"; in run()
2714 OS << " MatchOperand_ParseFail // operand matched but had errors\n"; in run()
2715 OS << " };\n"; in run()
2716 OS << " OperandMatchResultTy MatchOperandParserImpl(\n"; in run()
2717 OS << " OperandVector &Operands,\n"; in run()
2718 OS << " StringRef Mnemonic);\n"; in run()
2720 OS << " OperandMatchResultTy tryCustomParseOperand(\n"; in run()
2721 OS << " OperandVector &Operands,\n"; in run()
2722 OS << " unsigned MCK);\n\n"; in run()
2725 OS << "#endif // GET_ASSEMBLER_HEADER_INFO\n\n"; in run()
2728 OS << "\n#ifdef GET_OPERAND_DIAGNOSTIC_TYPES\n"; in run()
2729 OS << "#undef GET_OPERAND_DIAGNOSTIC_TYPES\n\n"; in run()
2730 emitOperandDiagnosticTypes(Info, OS); in run()
2731 OS << "#endif // GET_OPERAND_DIAGNOSTIC_TYPES\n\n"; in run()
2734 OS << "\n#ifdef GET_REGISTER_MATCHER\n"; in run()
2735 OS << "#undef GET_REGISTER_MATCHER\n\n"; in run()
2738 emitSubtargetFeatureFlagEnumeration(Info, OS); in run()
2743 emitMatchRegisterName(Target, AsmParser, OS); in run()
2745 OS << "#endif // GET_REGISTER_MATCHER\n\n"; in run()
2747 OS << "\n#ifdef GET_SUBTARGET_FEATURE_NAME\n"; in run()
2748 OS << "#undef GET_SUBTARGET_FEATURE_NAME\n\n"; in run()
2751 emitGetSubtargetFeatureName(Info, OS); in run()
2753 OS << "#endif // GET_SUBTARGET_FEATURE_NAME\n\n"; in run()
2755 OS << "\n#ifdef GET_MATCHER_IMPLEMENTATION\n"; in run()
2756 OS << "#undef GET_MATCHER_IMPLEMENTATION\n\n"; in run()
2759 bool HasMnemonicAliases = emitMnemonicAliases(OS, Info, Target); in run()
2764 emitConvertFuncs(Target, ClassName, Info.Matchables, OS); in run()
2767 emitMatchClassEnumeration(Target, Info.Classes, OS); in run()
2770 emitMatchTokenString(Target, Info.Classes, OS); in run()
2773 emitIsSubclass(Target, Info.Classes, OS); in run()
2776 emitValidateOperandClass(Info, OS); in run()
2779 emitComputeAvailableFeatures(Info, OS); in run()
2800 OS << "static const char *const MnemonicTable =\n"; in run()
2801 StringTable.EmitString(OS); in run()
2802 OS << ";\n\n"; in run()
2814 OS << "namespace {\n"; in run()
2815 OS << " struct MatchEntry {\n"; in run()
2816 OS << " " << getMinimalTypeForRange(MaxMnemonicIndex) in run()
2818 OS << " uint16_t Opcode;\n"; in run()
2819 OS << " " << getMinimalTypeForRange(Info.Matchables.size()) in run()
2821 OS << " " << getMinimalRequiredFeaturesType(Info) in run()
2823 OS << " " << getMinimalTypeForRange(Info.Classes.size()) in run()
2825 OS << " StringRef getMnemonic() const {\n"; in run()
2826 OS << " return StringRef(MnemonicTable + Mnemonic + 1,\n"; in run()
2827 OS << " MnemonicTable[Mnemonic]);\n"; in run()
2828 OS << " }\n"; in run()
2829 OS << " };\n\n"; in run()
2831 OS << " // Predicate for searching for an opcode.\n"; in run()
2832 OS << " struct LessOpcode {\n"; in run()
2833 OS << " bool operator()(const MatchEntry &LHS, StringRef RHS) {\n"; in run()
2834 OS << " return LHS.getMnemonic() < RHS;\n"; in run()
2835 OS << " }\n"; in run()
2836 OS << " bool operator()(StringRef LHS, const MatchEntry &RHS) {\n"; in run()
2837 OS << " return LHS < RHS.getMnemonic();\n"; in run()
2838 OS << " }\n"; in run()
2839 OS << " bool operator()(const MatchEntry &LHS, const MatchEntry &RHS) {\n"; in run()
2840 OS << " return LHS.getMnemonic() < RHS.getMnemonic();\n"; in run()
2841 OS << " }\n"; in run()
2842 OS << " };\n"; in run()
2844 OS << "} // end anonymous namespace.\n\n"; in run()
2851 OS << "static const MatchEntry MatchTable" << VC << "[] = {\n"; in run()
2862 OS << " { " << StringTable.GetOrAddStringOffset(LenMnemonic, false) in run()
2871 if (i) OS << "|"; in run()
2872 OS << II.RequiredFeatures[i]->getEnumName(); in run()
2875 OS << "0"; in run()
2877 OS << ", { "; in run()
2881 if (i) OS << ", "; in run()
2882 OS << Op.Class->Name; in run()
2884 OS << " }, },\n"; in run()
2887 OS << "};\n\n"; in run()
2891 OS << "bool " << Target.getName() << ClassName << "::\n" in run()
2893 OS << " // Find the appropriate table for this asm variant.\n"; in run()
2894 OS << " const MatchEntry *Start, *End;\n"; in run()
2895 OS << " switch (VariantID) {\n"; in run()
2896 OS << " default: // unreachable\n"; in run()
2900 OS << " case " << AsmVariantNo << ": Start = std::begin(MatchTable" << VC in run()
2903 OS << " }\n"; in run()
2904 OS << " // Search the table.\n"; in run()
2905 OS << " std::pair<const MatchEntry*, const MatchEntry*> MnemonicRange =\n"; in run()
2906 OS << " std::equal_range(Start, End, Mnemonic, LessOpcode());\n"; in run()
2907 OS << " return MnemonicRange.first != MnemonicRange.second;\n"; in run()
2908 OS << "}\n\n"; in run()
2911 OS << "unsigned " << Target.getName() << ClassName << "::\n" in run()
2914 OS << " MCInst &Inst,\n" in run()
2917 OS << " // Eliminate obvious mismatches.\n"; in run()
2918 OS << " if (Operands.size() > " << (MaxNumOperands+1) << ") {\n"; in run()
2919 OS << " ErrorInfo = " << (MaxNumOperands+1) << ";\n"; in run()
2920 OS << " return Match_InvalidOperand;\n"; in run()
2921 OS << " }\n\n"; in run()
2924 OS << " // Get the current feature set.\n"; in run()
2925 OS << " unsigned AvailableFeatures = getAvailableFeatures();\n\n"; in run()
2927 OS << " // Get the instruction mnemonic, which is the first token.\n"; in run()
2928 OS << " StringRef Mnemonic = ((" << Target.getName() in run()
2932 OS << " // Process all MnemonicAliases to remap the mnemonic.\n"; in run()
2933 OS << " applyMnemonicAliases(Mnemonic, AvailableFeatures, VariantID);\n\n"; in run()
2937 OS << " // Some state to try to produce better error messages.\n"; in run()
2938 OS << " bool HadMatchOtherThanFeatures = false;\n"; in run()
2939 OS << " bool HadMatchOtherThanPredicate = false;\n"; in run()
2940 OS << " unsigned RetCode = Match_InvalidOperand;\n"; in run()
2941 OS << " unsigned MissingFeatures = ~0U;\n"; in run()
2942 OS << " // Set ErrorInfo to the operand that mismatches if it is\n"; in run()
2943 OS << " // wrong for all instances of the instruction.\n"; in run()
2944 OS << " ErrorInfo = ~0U;\n"; in run()
2947 OS << " // Find the appropriate table for this asm variant.\n"; in run()
2948 OS << " const MatchEntry *Start, *End;\n"; in run()
2949 OS << " switch (VariantID) {\n"; in run()
2950 OS << " default: // unreachable\n"; in run()
2954 OS << " case " << AsmVariantNo << ": Start = std::begin(MatchTable" << VC in run()
2957 OS << " }\n"; in run()
2958 OS << " // Search the table.\n"; in run()
2959 OS << " std::pair<const MatchEntry*, const MatchEntry*> MnemonicRange =\n"; in run()
2960 OS << " std::equal_range(Start, End, Mnemonic, LessOpcode());\n\n"; in run()
2962 OS << " // Return a more specific error code if no mnemonics match.\n"; in run()
2963 OS << " if (MnemonicRange.first == MnemonicRange.second)\n"; in run()
2964 OS << " return Match_MnemonicFail;\n\n"; in run()
2966 OS << " for (const MatchEntry *it = MnemonicRange.first, " in run()
2968 OS << " it != ie; ++it) {\n"; in run()
2970 OS << " // equal_range guarantees that instruction mnemonic matches.\n"; in run()
2971 OS << " assert(Mnemonic == it->getMnemonic());\n"; in run()
2974 OS << " bool OperandsValid = true;\n"; in run()
2975 OS << " for (unsigned i = 0; i != " << MaxNumOperands << "; ++i) {\n"; in run()
2976 OS << " if (i + 1 >= Operands.size()) {\n"; in run()
2977 OS << " OperandsValid = (it->Classes[i] == " <<"InvalidMatchClass);\n"; in run()
2978 OS << " if (!OperandsValid) ErrorInfo = i + 1;\n"; in run()
2979 OS << " break;\n"; in run()
2980 OS << " }\n"; in run()
2981 OS << " unsigned Diag = validateOperandClass(*Operands[i+1],\n"; in run()
2982 OS.indent(43); in run()
2983 OS << "(MatchClassKind)it->Classes[i]);\n"; in run()
2984 OS << " if (Diag == Match_Success)\n"; in run()
2985 OS << " continue;\n"; in run()
2986 OS << " // If the generic handler indicates an invalid operand\n"; in run()
2987 OS << " // failure, check for a special case.\n"; in run()
2988 OS << " if (Diag == Match_InvalidOperand) {\n"; in run()
2989 OS << " Diag = validateTargetOperandClass(*Operands[i+1],\n"; in run()
2990 OS.indent(43); in run()
2991 OS << "(MatchClassKind)it->Classes[i]);\n"; in run()
2992 OS << " if (Diag == Match_Success)\n"; in run()
2993 OS << " continue;\n"; in run()
2994 OS << " }\n"; in run()
2995 OS << " // If this operand is broken for all of the instances of this\n"; in run()
2996 OS << " // mnemonic, keep track of it so we can report loc info.\n"; in run()
2997 OS << " // If we already had a match that only failed due to a\n"; in run()
2998 OS << " // target predicate, that diagnostic is preferred.\n"; in run()
2999 OS << " if (!HadMatchOtherThanPredicate &&\n"; in run()
3000 OS << " (it == MnemonicRange.first || ErrorInfo <= i+1)) {\n"; in run()
3001 OS << " ErrorInfo = i+1;\n"; in run()
3002 OS << " // InvalidOperand is the default. Prefer specificity.\n"; in run()
3003 OS << " if (Diag != Match_InvalidOperand)\n"; in run()
3004 OS << " RetCode = Diag;\n"; in run()
3005 OS << " }\n"; in run()
3006 OS << " // Otherwise, just reject this instance of the mnemonic.\n"; in run()
3007 OS << " OperandsValid = false;\n"; in run()
3008 OS << " break;\n"; in run()
3009 OS << " }\n\n"; in run()
3011 OS << " if (!OperandsValid) continue;\n"; in run()
3014 OS << " if ((AvailableFeatures & it->RequiredFeatures) " in run()
3016 OS << " HadMatchOtherThanFeatures = true;\n"; in run()
3017 OS << " unsigned NewMissingFeatures = it->RequiredFeatures & " in run()
3019 OS << " if (CountPopulation_32(NewMissingFeatures) <=\n" in run()
3021 OS << " MissingFeatures = NewMissingFeatures;\n"; in run()
3022 OS << " continue;\n"; in run()
3023 OS << " }\n"; in run()
3024 OS << "\n"; in run()
3025 OS << " if (matchingInlineAsm) {\n"; in run()
3026 OS << " Inst.setOpcode(it->Opcode);\n"; in run()
3027 OS << " convertToMapAndConstraints(it->ConvertFn, Operands);\n"; in run()
3028 OS << " return Match_Success;\n"; in run()
3029 OS << " }\n\n"; in run()
3030 OS << " // We have selected a definite instruction, convert the parsed\n" in run()
3032 OS << " convertToMCInst(it->ConvertFn, Inst, it->Opcode, Operands);\n"; in run()
3033 OS << "\n"; in run()
3036 OS << " // We have a potential match. Check the target predicate to\n" in run()
3051 OS << " " << InsnCleanupFn << "(Inst);\n"; in run()
3054 OS << " std::string Info;\n"; in run()
3055 OS << " if (MII.get(Inst.getOpcode()).getDeprecatedInfo(Inst, STI, Info)) {\n"; in run()
3056 OS << " SMLoc Loc = ((" << Target.getName() in run()
3058 OS << " Parser.Warning(Loc, Info, None);\n"; in run()
3059 OS << " }\n"; in run()
3062 OS << " return Match_Success;\n"; in run()
3063 OS << " }\n\n"; in run()
3065 OS << " // Okay, we had no match. Try to return a useful error code.\n"; in run()
3066 OS << " if (HadMatchOtherThanPredicate || !HadMatchOtherThanFeatures)\n"; in run()
3067 OS << " return RetCode;\n\n"; in run()
3068 OS << " // Missing feature matches return which features were missing\n"; in run()
3069 OS << " ErrorInfo = MissingFeatures;\n"; in run()
3070 OS << " return Match_MissingFeature;\n"; in run()
3071 OS << "}\n\n"; in run()
3074 emitCustomOperandParsing(OS, Target, Info, ClassName, StringTable, in run()
3077 OS << "#endif // GET_MATCHER_IMPLEMENTATION\n\n"; in run()
3082 void EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS) { in EmitAsmMatcher() argument
3083 emitSourceFileHeader("Assembly Matcher Source Fragment", OS); in EmitAsmMatcher()
3084 AsmMatcherEmitter(RK).run(OS); in EmitAsmMatcher()