diff --git a/llvm/lib/Target/ARM/ARMInstrThumb2.td b/llvm/lib/Target/ARM/ARMInstrThumb2.td --- a/llvm/lib/Target/ARM/ARMInstrThumb2.td +++ b/llvm/lib/Target/ARM/ARMInstrThumb2.td @@ -4144,6 +4144,8 @@ bits<8> imm; let Inst{7-0} = imm; } +def : t2InstAlias<"movs{$p}\tpc, lr", (t2SUBS_PC_LR 0, pred:$p)>; +def : t2InstAlias<"movs{$p}.w\tpc, lr", (t2SUBS_PC_LR 0, pred:$p)>; // Hypervisor Call is a system instruction. let isCall = 1 in { diff --git a/llvm/test/MC/ARM/lsl-zero-errors.s b/llvm/test/MC/ARM/lsl-zero-errors.s --- a/llvm/test/MC/ARM/lsl-zero-errors.s +++ b/llvm/test/MC/ARM/lsl-zero-errors.s @@ -72,8 +72,7 @@ // CHECK-THUMBV7: note: operand must be a register in range [r0, r12] or r14 // CHECK-THUMBV8: note: operand must be a register in range [r0, r14] -// CHECK-THUMBV7: error: operand must be a register in range [r0, r12] or r14 -// CHECK-THUMBV8: error: operand must be a register in range [r0, r14] +// CHECK-NONARM: error: invalid instruction, any one of the following would fix this: // CHECK-NONARM-NEXT: movs pc, r0, lsl #0 // CHECK-NONARM: error: invalid instruction, any one of the following would fix this: @@ -82,8 +81,7 @@ // CHECK-NONARM: note: invalid operand for instruction // CHECK-NONARM: note: invalid operand for instruction -// CHECK-THUMBV7: error: operand must be a register in range [r0, r12] or r14 -// CHECK-THUMBV8: error: operand must be a register in range [r0, r14] +// CHECK-NONARM: error: invalid instruction, any one of the following would fix this: // CHECK-NONARM-NEXT: movs pc, pc, lsl #0 // CHECK-ARM: mov pc, r0 @ encoding: [0x00,0xf0,0xa0,0xe1] diff --git a/llvm/test/MC/ARM/thumb-mov.s b/llvm/test/MC/ARM/thumb-mov.s --- a/llvm/test/MC/ARM/thumb-mov.s +++ b/llvm/test/MC/ARM/thumb-mov.s @@ -13,13 +13,11 @@ movs pc, r0 movs r0, pc movs pc, pc -// CHECK: error: operand must be a register in range [r0, r14] +// CHECK: error: invalid instruction, any one of the following would fix this: // CHECK-NEXT: movs pc, r0 -// CHECK: note: operand must be a register in range [r0, r14] -// CHECK-NEXT: movs r0, pc -// CHECK: note: invalid operand for instruction +// CHECK: error: invalid instruction, any one of the following would fix this: // CHECK-NEXT: movs r0, pc -// CHECK: error: invalid instruction +// CHECK: error: invalid operand for instruction // CHECK-NEXT: movs pc, pc // mov.w selects t2MOVr @@ -39,13 +37,11 @@ movs.w pc, r0 movs.w r0, pc movs.w pc, pc -// CHECK: error: operand must be a register in range [r0, r14] +// CHECK: error: invalid instruction, any one of the following would fix this: // CHECK-NEXT: movs.w pc, r0 -// CHECK: note: operand must be a register in range [r0, r14] -// CHECK-NEXT: movs.w r0, pc -// CHECK: note: invalid operand for instruction +// CHECK: error: invalid instruction, any one of the following would fix this: // CHECK-NEXT: movs.w r0, pc -// CHECK: error: invalid instruction +// CHECK: error: invalid operand for instruction // CHECK-NEXT: movs.w pc, pc @@ -104,3 +100,11 @@ mov.w r0, sp // CHECK: mov.w sp, r0 @ encoding: [0x4f,0xea,0x00,0x0d] // CHECK: mov.w r0, sp @ encoding: [0x4f,0xea,0x0d,0x00] + + // `movs pc, lr` is an alias for `subs pc, lr, #0`. + movs pc, lr + movs.w pc, lr +// CHECK-V7: subs pc, lr, #0 @ encoding: [0xde,0xf3,0x00,0x8f] +// CHECK-V7: subs pc, lr, #0 @ encoding: [0xde,0xf3,0x00,0x8f] +// CHECK-V8: eret @ encoding: [0xde,0xf3,0x00,0x8f] +// CHECK-V8: eret @ encoding: [0xde,0xf3,0x00,0x8f]