diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-09-06 19:22:17 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-09-06 19:22:17 +0000 |
| commit | a22a368e7cdf2a2fac208df83401c70c87a160ea (patch) | |
| tree | 6d47ffe930194376b130d9bfb71ac8d5d4d7bf23 | |
| parent | 8128ca1c2caed5af396556d85208d0f3966c3244 (diff) | |
| download | bcm5719-llvm-a22a368e7cdf2a2fac208df83401c70c87a160ea.tar.gz bcm5719-llvm-a22a368e7cdf2a2fac208df83401c70c87a160ea.zip | |
change MatchInstructionImpl to return an enum instead of bool.
llvm-svn: 113165
| -rw-r--r-- | llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 10 | ||||
| -rw-r--r-- | llvm/utils/TableGen/AsmMatcherEmitter.cpp | 18 |
3 files changed, 18 insertions, 12 deletions
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index fef8eb08103..8507070fc66 100644 --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -83,7 +83,7 @@ private: bool MatchInstruction(SMLoc IDLoc, const SmallVectorImpl<MCParsedAsmOperand*> &Operands, MCInst &Inst) { - if (!MatchInstructionImpl(Operands, Inst)) + if (MatchInstructionImpl(Operands, Inst) == Match_Success) return false; // FIXME: We should give nicer diagnostics about the exact failure. diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index 7e922ed4f86..10c2b9c4616 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -881,7 +881,7 @@ X86ATTAsmParser::MatchInstruction(SMLoc IDLoc, assert(!Operands.empty() && "Unexpect empty operand list!"); // First, try a direct match. - if (!MatchInstructionImpl(Operands, Inst)) + if (MatchInstructionImpl(Operands, Inst) == Match_Success) return false; // FIXME: Ideally, we would only attempt suffix matches for things which are @@ -901,13 +901,13 @@ X86ATTAsmParser::MatchInstruction(SMLoc IDLoc, // Check for the various suffix matches. Tmp[Base.size()] = 'b'; - bool MatchB = MatchInstructionImpl(Operands, Inst); + bool MatchB = MatchInstructionImpl(Operands, Inst) != Match_Success; Tmp[Base.size()] = 'w'; - bool MatchW = MatchInstructionImpl(Operands, Inst); + bool MatchW = MatchInstructionImpl(Operands, Inst) != Match_Success; Tmp[Base.size()] = 'l'; - bool MatchL = MatchInstructionImpl(Operands, Inst); + bool MatchL = MatchInstructionImpl(Operands, Inst) != Match_Success; Tmp[Base.size()] = 'q'; - bool MatchQ = MatchInstructionImpl(Operands, Inst); + bool MatchQ = MatchInstructionImpl(Operands, Inst) != Match_Success; // Restore the old token. Op->setTokenValue(Base); diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index 515916efde7..1ecc1327b40 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -1544,9 +1544,14 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { // Information for the class declaration. OS << "\n#ifdef GET_ASSEMBLER_HEADER\n"; OS << "#undef GET_ASSEMBLER_HEADER\n"; + OS << " // This should be included into the middle of the declaration of \n"; + OS << " // your subclasses implementation of TargetAsmParser.\n"; OS << " unsigned ComputeAvailableFeatures(const " << Target.getName() << "Subtarget *Subtarget) const;\n"; - OS << "bool MatchInstructionImpl(const SmallVectorImpl<MCParsedAsmOperand*>" + OS << " enum MatchResultTy {\n"; + OS << " Match_Success, Match_Fail\n"; + OS << " };\n"; + OS << " MatchResultTy MatchInstructionImpl(const SmallVectorImpl<MCParsedAsmOperand*>" << " &Operands, MCInst &Inst);\n\n"; OS << "#endif // GET_ASSEMBLER_HEADER_INFO\n\n"; @@ -1594,7 +1599,8 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { it != ie; ++it) MaxNumOperands = std::max(MaxNumOperands, (*it)->Operands.size()); - OS << "bool " << Target.getName() << ClassName << "::\n" + OS << Target.getName() << ClassName << "::MatchResultTy " + << Target.getName() << ClassName << "::\n" << "MatchInstructionImpl(const SmallVectorImpl<MCParsedAsmOperand*>" << " &Operands,\n"; OS << " MCInst &Inst) {\n"; @@ -1653,7 +1659,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { // Emit code to compute the class list for this operand vector. OS << " // Eliminate obvious mismatches.\n"; OS << " if (Operands.size() > " << MaxNumOperands << ")\n"; - OS << " return true;\n\n"; + OS << " return Match_Fail;\n\n"; OS << " // Compute the class list for this operand vector.\n"; OS << " MatchClassKind Classes[" << MaxNumOperands << "];\n"; @@ -1662,7 +1668,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << " // Check for invalid operands before matching.\n"; OS << " if (Classes[i] == InvalidMatchClass)\n"; - OS << " return true;\n"; + OS << " return Match_Fail;\n"; OS << " }\n\n"; OS << " // Mark unused classes.\n"; @@ -1697,10 +1703,10 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { if (!InsnCleanupFn.empty()) OS << " " << InsnCleanupFn << "(Inst);\n"; - OS << " return false;\n"; + OS << " return Match_Success;\n"; OS << " }\n\n"; - OS << " return true;\n"; + OS << " return Match_Fail;\n"; OS << "}\n\n"; OS << "#endif // GET_MATCHER_IMPLEMENTATION\n\n"; |

