mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Thumb assemmbly parsing diagnostic improvements for LDM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138287 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -3084,6 +3084,9 @@ validateInstruction(MCInst &Inst,
|
|||||||
// Thumb LDM instructions are writeback iff the base register is not
|
// Thumb LDM instructions are writeback iff the base register is not
|
||||||
// in the register list.
|
// in the register list.
|
||||||
unsigned Rn = Inst.getOperand(0).getReg();
|
unsigned Rn = Inst.getOperand(0).getReg();
|
||||||
|
bool hasWritebackToken =
|
||||||
|
(static_cast<ARMOperand*>(Operands[3])->isToken() &&
|
||||||
|
static_cast<ARMOperand*>(Operands[3])->getToken() == "!");
|
||||||
bool doesWriteback = true;
|
bool doesWriteback = true;
|
||||||
for (unsigned i = 3; i < Inst.getNumOperands(); ++i) {
|
for (unsigned i = 3; i < Inst.getNumOperands(); ++i) {
|
||||||
unsigned Reg = Inst.getOperand(i).getReg();
|
unsigned Reg = Inst.getOperand(i).getReg();
|
||||||
@@ -3091,15 +3094,18 @@ validateInstruction(MCInst &Inst,
|
|||||||
doesWriteback = false;
|
doesWriteback = false;
|
||||||
// Anything other than a low register isn't legal here.
|
// Anything other than a low register isn't legal here.
|
||||||
if (!isARMLowRegister(Reg))
|
if (!isARMLowRegister(Reg))
|
||||||
return Error(Operands[4]->getStartLoc(),
|
return Error(Operands[3 + hasWritebackToken]->getStartLoc(),
|
||||||
"registers must be in range r0-r7");
|
"registers must be in range r0-r7");
|
||||||
}
|
}
|
||||||
// If we should have writeback, then there should be a '!' token.
|
// If we should have writeback, then there should be a '!' token.
|
||||||
if (doesWriteback &&
|
if (doesWriteback && !hasWritebackToken)
|
||||||
(!static_cast<ARMOperand*>(Operands[3])->isToken() ||
|
|
||||||
static_cast<ARMOperand*>(Operands[3])->getToken() != "!"))
|
|
||||||
return Error(Operands[2]->getStartLoc(),
|
return Error(Operands[2]->getStartLoc(),
|
||||||
"writeback operator '!' expected");
|
"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;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -45,12 +45,16 @@ error: invalid operand for instruction
|
|||||||
@ Invalid writeback and register lists for LDM
|
@ Invalid writeback and register lists for LDM
|
||||||
ldm r2!, {r5, r8}
|
ldm r2!, {r5, r8}
|
||||||
ldm r2, {r5, r7}
|
ldm r2, {r5, r7}
|
||||||
|
ldm r2!, {r2, r3, r4}
|
||||||
@ CHECK-ERRORS: error: registers must be in range r0-r7
|
@ CHECK-ERRORS: error: registers must be in range r0-r7
|
||||||
@ CHECK-ERRORS: ldm r2!, {r5, r8}
|
@ CHECK-ERRORS: ldm r2!, {r5, r8}
|
||||||
@ CHECK-ERRORS: ^
|
@ CHECK-ERRORS: ^
|
||||||
@ CHECK-ERRORS: error: writeback operator '!' expected
|
@ CHECK-ERRORS: error: writeback operator '!' expected
|
||||||
@ CHECK-ERRORS: ldm r2, {r5, r7}
|
@ CHECK-ERRORS: ldm r2, {r5, r7}
|
||||||
@ CHECK-ERRORS: ^
|
@ 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.
|
@ Out of range immediates for LSL instruction.
|
||||||
|
Reference in New Issue
Block a user