Skip to content

Commit

Permalink
[TableGen] AsmMatcherEmitter.cpp: replace a sequence of "if" to "swit…
Browse files Browse the repository at this point in the history
…ch" in emitValidateOperandClass.

Differential Revision: http://reviews.llvm.org/D18394

llvm-svn: 265412
  • Loading branch information
vpykhtin committed Apr 5, 2016
1 parent 42991b3 commit 020c29e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions llvm/utils/TableGen/AsmMatcherEmitter.cpp
Expand Up @@ -2153,19 +2153,23 @@ static void emitValidateOperandClass(AsmMatcherInfo &Info,

// 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";
Expand Down

0 comments on commit 020c29e

Please sign in to comment.