diff options
author | Chris Lattner <sabre@nondot.org> | 2010-09-06 21:54:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-09-06 21:54:15 +0000 |
commit | a008e8ac73cb3cf2eaf006fbb1b62905c8626758 (patch) | |
tree | 8867189fb700584ffa41f74430dd93849bdc4577 /utils | |
parent | fa0d74d58e6c70ef032afb5f83680276dc4d7370 (diff) | |
download | llvm-a008e8ac73cb3cf2eaf006fbb1b62905c8626758.tar.gz llvm-a008e8ac73cb3cf2eaf006fbb1b62905c8626758.tar.bz2 llvm-a008e8ac73cb3cf2eaf006fbb1b62905c8626758.tar.xz |
Now that we know if we had a total fail on the instruction mnemonic,
give a more detailed error. Before:
t.s:11:4: error: unrecognized instruction
addl $1, $1
^
t.s:12:4: error: unrecognized instruction
f2efqefa $1
^
After:
t.s:11:4: error: invalid operand for instruction
addl $1, $1
^
t.s:12:4: error: invalid instruction mnemonic 'f2efqefa'
f2efqefa $1
^
This fixes rdar://8017912 - llvm-mc says "unrecognized instruction" when it means "invalid operands"
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113176 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/AsmMatcherEmitter.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index a2222df223..4d8a7957c6 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -1559,7 +1559,8 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << " unsigned ComputeAvailableFeatures(const " << Target.getName() << "Subtarget *Subtarget) const;\n"; OS << " enum MatchResultTy {\n"; - OS << " Match_Success, Match_Fail, Match_MissingFeature\n"; + OS << " Match_Success, Match_MnemonicFail, Match_InvalidOperand,\n"; + OS << " Match_MissingFeature\n"; OS << " };\n"; OS << " MatchResultTy MatchInstructionImpl(const SmallVectorImpl<MCParsedAsmOperand*>" << " &Operands, MCInst &Inst);\n\n"; @@ -1687,7 +1688,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 << "+1)\n"; - OS << " return Match_Fail;\n\n"; + OS << " return Match_InvalidOperand;\n\n"; OS << " // Compute the class list for this operand vector.\n"; OS << " MatchClassKind Classes[" << MaxNumOperands << "];\n"; @@ -1696,7 +1697,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << " // Check for invalid operands before matching.\n"; OS << " if (Classes[i-1] == InvalidMatchClass)\n"; - OS << " return Match_Fail;\n"; + OS << " return Match_InvalidOperand;\n"; OS << " }\n\n"; OS << " // Mark unused classes.\n"; @@ -1716,6 +1717,10 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << " std::equal_range(MatchTable, MatchTable+" << Info.Instructions.size() << ", Mnemonic, LessOpcode());\n\n"; + OS << " // Return a more specific error code if no mnemonics match.\n"; + OS << " if (MnemonicRange.first == MnemonicRange.second)\n"; + OS << " return Match_MnemonicFail;\n\n"; + OS << " for (const MatchEntry *it = MnemonicRange.first, " << "*ie = MnemonicRange.second;\n"; OS << " it != ie; ++it) {\n"; @@ -1751,7 +1756,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << " // Okay, we had no match. Try to return a useful error code.\n"; OS << " if (HadMatchOtherThanFeatures) return Match_MissingFeature;\n"; - OS << " return Match_Fail;\n"; + OS << " return Match_InvalidOperand;\n"; OS << "}\n\n"; OS << "#endif // GET_MATCHER_IMPLEMENTATION\n\n"; |