diff options
author | Jim Grosbach <grosbach@apple.com> | 2011-08-22 23:01:07 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2011-08-22 23:01:07 +0000 |
commit | 7260c6a4ea19f5eb94068296c1c8e01a99f17a01 (patch) | |
tree | 6e442d89d665ffeda7301d49cf28beb012dab3f9 /lib/Target/ARM/AsmParser/ARMAsmParser.cpp | |
parent | d937d951256372a24eb6ac9f048816b0873ed528 (diff) |
Thumb assemmbly parsing diagnostic improvements for LDM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138287 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/AsmParser/ARMAsmParser.cpp')
-rw-r--r-- | lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 31300aea56..0632e85d36 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -3084,6 +3084,9 @@ validateInstruction(MCInst &Inst, // Thumb LDM instructions are writeback iff the base register is not // in the register list. unsigned Rn = Inst.getOperand(0).getReg(); + bool hasWritebackToken = + (static_cast<ARMOperand*>(Operands[3])->isToken() && + static_cast<ARMOperand*>(Operands[3])->getToken() == "!"); bool doesWriteback = true; for (unsigned i = 3; i < Inst.getNumOperands(); ++i) { unsigned Reg = Inst.getOperand(i).getReg(); @@ -3091,15 +3094,18 @@ validateInstruction(MCInst &Inst, doesWriteback = false; // Anything other than a low register isn't legal here. if (!isARMLowRegister(Reg)) - return Error(Operands[4]->getStartLoc(), + return Error(Operands[3 + hasWritebackToken]->getStartLoc(), "registers must be in range r0-r7"); } // If we should have writeback, then there should be a '!' token. - if (doesWriteback && - (!static_cast<ARMOperand*>(Operands[3])->isToken() || - static_cast<ARMOperand*>(Operands[3])->getToken() != "!")) + if (doesWriteback && !hasWritebackToken) return Error(Operands[2]->getStartLoc(), "writeback operator '!' expected"); + // Likewise, if we should not have writeback, there must not be a '!' + if (!doesWriteback && hasWritebackToken) + return Error(Operands[3]->getStartLoc(), + "writeback operator '!' not allowed when base register " + "in register list"); break; } |