diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 14063eac1f5..6d6255f2cc2 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -5347,8 +5347,17 @@ validateInstruction(MCInst &Inst, case ARM::LDRD: case ARM::LDRD_PRE: case ARM::LDRD_POST: { + unsigned RtReg = Inst.getOperand(0).getReg(); + // Rt can't be R14. + if (RtReg == ARM::LR) + return Error(Operands[3]->getStartLoc(), + "Rt can't be R14"); + unsigned Rt = MRI->getEncodingValue(RtReg); + // Rt must be even-numbered. + if ((Rt & 1) == 1) + return Error(Operands[3]->getStartLoc(), + "Rt must be even-numbered"); // Rt2 must be Rt + 1. - unsigned Rt = MRI->getEncodingValue(Inst.getOperand(0).getReg()); unsigned Rt2 = MRI->getEncodingValue(Inst.getOperand(1).getReg()); if (Rt2 != Rt + 1) return Error(Operands[3]->getStartLoc(), diff --git a/test/MC/ARM/arm-ldrd.s b/test/MC/ARM/arm-ldrd.s new file mode 100644 index 00000000000..8522d26a973 --- /dev/null +++ b/test/MC/ARM/arm-ldrd.s @@ -0,0 +1,20 @@ +// RUN: not llvm-mc -arch arm -mattr=+v5te \ +// RUN: < %s >/dev/null 2> %t +// RUN: grep "error: Rt must be even-numbered" %t | count 7 +// RUN: grep "error: Rt can't be R14" %t | count 7 +// rdar://14479793 + +ldrd r1, r2, [pc, #0] +ldrd lr, pc, [pc, #0] +ldrd r1, r2, [r3, #4] +ldrd lr, pc, [r3, #4] +ldrd r1, r2, [r3], #4 +ldrd lr, pc, [r3], #4 +ldrd r1, r2, [r3, #4]! +ldrd lr, pc, [r3, #4]! +ldrd r1, r2, [r3, -r4]! +ldrd lr, pc, [r3, -r4]! +ldrd r1, r2, [r3, r4] +ldrd lr, pc, [r3, r4] +ldrd r1, r2, [r3], r4 +ldrd lr, pc, [r3], r4 diff --git a/test/MC/ARM/arm-memory-instructions.s b/test/MC/ARM/arm-memory-instructions.s index e9f0c3da7c0..ad35dd26a04 100644 --- a/test/MC/ARM/arm-memory-instructions.s +++ b/test/MC/ARM/arm-memory-instructions.s @@ -114,21 +114,21 @@ _func: @------------------------------------------------------------------------------ @ LDRD (immediate) @------------------------------------------------------------------------------ - ldrd r3, r4, [r5] - ldrd r7, r8, [r2, #15] - ldrd r1, r2, [r9, #32]! + ldrd r2, r3, [r5] + ldrd r6, r7, [r2, #15] + ldrd r0, r1, [r9, #32]! ldrd r6, r7, [r1], #8 - ldrd r1, r2, [r8], #0 - ldrd r1, r2, [r8], #+0 - ldrd r1, r2, [r8], #-0 + ldrd r0, r1, [r8], #0 + ldrd r0, r1, [r8], #+0 + ldrd r0, r1, [r8], #-0 -@ CHECK: ldrd r3, r4, [r5] @ encoding: [0xd0,0x30,0xc5,0xe1] -@ CHECK: ldrd r7, r8, [r2, #15] @ encoding: [0xdf,0x70,0xc2,0xe1] -@ CHECK: ldrd r1, r2, [r9, #32]! @ encoding: [0xd0,0x12,0xe9,0xe1] -@ CHECK: ldrd r6, r7, [r1], #8 @ encoding: [0xd8,0x60,0xc1,0xe0] -@ CHECK: ldrd r1, r2, [r8], #0 @ encoding: [0xd0,0x10,0xc8,0xe0] -@ CHECK: ldrd r1, r2, [r8], #0 @ encoding: [0xd0,0x10,0xc8,0xe0] -@ CHECK: ldrd r1, r2, [r8], #-0 @ encoding: [0xd0,0x10,0x48,0xe0] +@ CHECK: ldrd r2, r3, [r5] @ encoding: [0xd0,0x20,0xc5,0xe1] +@ CHECK: ldrd r6, r7, [r2, #15] @ encoding: [0xdf,0x60,0xc2,0xe1] +@ CHECK: ldrd r0, r1, [r9, #32]! @ encoding: [0xd0,0x02,0xe9,0xe1] +@ CHECK: ldrd r6, r7, [r1], #8 @ encoding: [0xd8,0x60,0xc1,0xe0] +@ CHECK: ldrd r0, r1, [r8], #0 @ encoding: [0xd0,0x00,0xc8,0xe0] +@ CHECK: ldrd r0, r1, [r8], #0 @ encoding: [0xd0,0x00,0xc8,0xe0] +@ CHECK: ldrd r0, r1, [r8], #-0 @ encoding: [0xd0,0x00,0x48,0xe0] @------------------------------------------------------------------------------ @@ -143,15 +143,15 @@ Lbaz: .quad 0 @------------------------------------------------------------------------------ @ LDRD (register) @------------------------------------------------------------------------------ - ldrd r3, r4, [r1, r3] + ldrd r4, r5, [r1, r3] ldrd r4, r5, [r7, r2]! - ldrd r1, r2, [r8], r12 - ldrd r1, r2, [r8], -r12 + ldrd r0, r1, [r8], r12 + ldrd r0, r1, [r8], -r12 -@ CHECK: ldrd r3, r4, [r1, r3] @ encoding: [0xd3,0x30,0x81,0xe1] -@ CHECK: ldrd r4, r5, [r7, r2]! @ encoding: [0xd2,0x40,0xa7,0xe1] -@ CHECK: ldrd r1, r2, [r8], r12 @ encoding: [0xdc,0x10,0x88,0xe0] -@ CHECK: ldrd r1, r2, [r8], -r12 @ encoding: [0xdc,0x10,0x08,0xe0] +@ CHECK: ldrd r4, r5, [r1, r3] @ encoding: [0xd3,0x40,0x81,0xe1] +@ CHECK: ldrd r4, r5, [r7, r2]! @ encoding: [0xd2,0x40,0xa7,0xe1] +@ CHECK: ldrd r0, r1, [r8], r12 @ encoding: [0xdc,0x00,0x88,0xe0] +@ CHECK: ldrd r0, r1, [r8], -r12 @ encoding: [0xdc,0x00,0x08,0xe0] @------------------------------------------------------------------------------