summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2011-08-22 23:01:07 +0000
committerJim Grosbach <grosbach@apple.com>2011-08-22 23:01:07 +0000
commit139acd21e69b914c53df5d7e8e8e755ad35d5f81 (patch)
tree47b52b041bc5392b06099d52553edcde5cc4e463
parent0869b900cca6f6f4c5b2726545c755ac72027b43 (diff)
downloadbcm5719-llvm-139acd21e69b914c53df5d7e8e8e755ad35d5f81.tar.gz
bcm5719-llvm-139acd21e69b914c53df5d7e8e8e755ad35d5f81.zip
Thumb assemmbly parsing diagnostic improvements for LDM.
llvm-svn: 138287
-rw-r--r--llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp14
-rw-r--r--llvm/test/MC/ARM/thumb-diagnostics.s4
2 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index 31300aea569..0632e85d361 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/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;
}
diff --git a/llvm/test/MC/ARM/thumb-diagnostics.s b/llvm/test/MC/ARM/thumb-diagnostics.s
index e201f0b4723..1dfb409284f 100644
--- a/llvm/test/MC/ARM/thumb-diagnostics.s
+++ b/llvm/test/MC/ARM/thumb-diagnostics.s
@@ -45,12 +45,16 @@ error: invalid operand for instruction
@ Invalid writeback and register lists for LDM
ldm r2!, {r5, r8}
ldm r2, {r5, r7}
+ ldm r2!, {r2, r3, r4}
@ CHECK-ERRORS: error: registers must be in range r0-r7
@ CHECK-ERRORS: ldm r2!, {r5, r8}
@ CHECK-ERRORS: ^
@ CHECK-ERRORS: error: writeback operator '!' expected
@ CHECK-ERRORS: ldm r2, {r5, r7}
@ CHECK-ERRORS: ^
+@ CHECK-ERRORS: error: writeback operator '!' not allowed when base register in register list
+@ CHECK-ERRORS: ldm r2!, {r2, r3}
+@ CHECK-ERRORS: ^
@ Out of range immediates for LSL instruction.
OpenPOWER on IntegriCloud