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 | e73d4f8ec7af68fc0f67811e4e004562ab538014 (patch) | |
tree | d5b01caeeb6511ef4ef1ce6e411d4c6cf2922c1e /lib/Target/ARM/AsmParser | |
parent | 6274ec48b3a3e1fbaf3a359868d53a76f20a4245 (diff) | |
download | external_llvm-e73d4f8ec7af68fc0f67811e4e004562ab538014.zip external_llvm-e73d4f8ec7af68fc0f67811e4e004562ab538014.tar.gz external_llvm-e73d4f8ec7af68fc0f67811e4e004562ab538014.tar.bz2 |
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]
^
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117611 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/AsmParser')
-rw-r--r-- | lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 9836ef5..88b2c61 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/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; } |