[llvm] r265412 - [TableGen] AsmMatcherEmitter.cpp: replace a sequence of "if" to "switch" in emitValidateOperandClass.
Valery Pykhtin via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 5 09:18:16 PDT 2016
Author: vpykhtin
Date: Tue Apr 5 11:18:16 2016
New Revision: 265412
URL: http://llvm.org/viewvc/llvm-project?rev=265412&view=rev
Log:
[TableGen] AsmMatcherEmitter.cpp: replace a sequence of "if" to "switch" in emitValidateOperandClass.
Differential Revision: http://reviews.llvm.org/D18394
Modified:
llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=265412&r1=265411&r2=265412&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Tue Apr 5 11:18:16 2016
@@ -2153,19 +2153,23 @@ static void emitValidateOperandClass(Asm
// Check the user classes. We don't care what order since we're only
// actually matching against one of them.
+ OS << " switch (Kind) {\n"
+ " default: break;\n";
for (const auto &CI : Info.Classes) {
if (!CI.isUserClass())
continue;
OS << " // '" << CI.ClassName << "' class\n";
- OS << " if (Kind == " << CI.Name << ") {\n";
+ OS << " case " << CI.Name << ":\n";
OS << " if (Operand." << CI.PredicateMethod << "())\n";
OS << " return MCTargetAsmParser::Match_Success;\n";
if (!CI.DiagnosticType.empty())
OS << " return " << Info.Target.getName() << "AsmParser::Match_"
<< CI.DiagnosticType << ";\n";
- OS << " }\n\n";
+ else
+ OS << " break;\n";
}
+ OS << " } // end switch (Kind)\n\n";
// Check for register operands, including sub-classes.
OS << " if (Operand.isReg()) {\n";
More information about the llvm-commits
mailing list