diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-10-28 21:41:58 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-10-28 21:41:58 +0000 |
| commit | d27b05e54a75166f2c8845bac74d0af6a072b8bb (patch) | |
| tree | 67daa7efc0b55b4c49b87fd7684e27465d4ded54 | |
| parent | 565141612f925f7b103742d121f4470fd7df5842 (diff) | |
| download | bcm5719-llvm-d27b05e54a75166f2c8845bac74d0af6a072b8bb.tar.gz bcm5719-llvm-d27b05e54a75166f2c8845bac74d0af6a072b8bb.zip | |
give better error diagnostics, for example:
t.s:1:14: error: invalid operand for instruction
vldr.64 d17, [r0]
^
instead of:
t.s:1:1: error: unrecognized instruction
vldr.64 d17, [r0]
^
llvm-svn: 117611
| -rw-r--r-- | llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 9836ef598fd..88b2c61604f 100644 --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -759,14 +759,29 @@ MatchAndEmitInstruction(SMLoc IDLoc, MCStreamer &Out) { MCInst Inst; unsigned ErrorInfo; - if (MatchInstructionImpl(Operands, Inst, ErrorInfo) == Match_Success) { + switch (MatchInstructionImpl(Operands, Inst, ErrorInfo)) { + case Match_Success: Out.EmitInstruction(Inst); return false; + + case Match_MissingFeature: + Error(IDLoc, "instruction requires a CPU feature not currently enabled"); + return true; + case Match_InvalidOperand: { + SMLoc ErrorLoc = IDLoc; + if (ErrorInfo != ~0U) { + if (ErrorInfo >= Operands.size()) + return Error(IDLoc, "too few operands for instruction"); + + ErrorLoc = ((ARMOperand*)Operands[ErrorInfo])->getStartLoc(); + if (ErrorLoc == SMLoc()) ErrorLoc = IDLoc; + } + + return Error(ErrorLoc, "invalid operand for instruction"); + } + case Match_MnemonicFail: + return Error(IDLoc, "unrecognized instruction mnemonic"); } - - // FIXME: We should give nicer diagnostics about the exact failure. - Error(IDLoc, "unrecognized instruction"); - return true; } |

