llvm.org GIT mirror llvm / fd06dd8
Correct POP handling for v7m git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225972 91177308-0d34-0410-b5e6-96231b3b80d8 Jyoti Allur 5 years ago
2 changed file(s) with 15 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
189189 }
190190
191191 bool validatetLDMRegList(MCInst Inst, const OperandVector &Operands,
192 unsigned ListNo, bool IsPop = false);
192 unsigned ListNo, bool IsARPop = false);
193193 bool validatetSTMRegList(MCInst Inst, const OperandVector &Operands,
194194 unsigned ListNo);
195195
60266026
60276027 bool ARMAsmParser::validatetLDMRegList(MCInst Inst,
60286028 const OperandVector &Operands,
6029 unsigned ListNo, bool IsPop) {
6029 unsigned ListNo, bool IsARPop) {
60306030 const ARMOperand &Op = static_cast(*Operands[ListNo]);
60316031 bool HasWritebackToken = Op.isToken() && Op.getToken() == "!";
60326032
60346034 bool ListContainsLR = listContainsReg(Inst, ListNo, ARM::LR);
60356035 bool ListContainsPC = listContainsReg(Inst, ListNo, ARM::PC);
60366036
6037 if (!IsPop && ListContainsSP)
6037 if (!IsARPop && ListContainsSP)
60386038 return Error(Operands[ListNo + HasWritebackToken]->getStartLoc(),
60396039 "SP may not be in the register list");
60406040 else if (ListContainsPC && ListContainsLR)
63376337 !isThumbTwo())
63386338 return Error(Operands[2]->getStartLoc(),
63396339 "registers must be in range r0-r7 or pc");
6340 if (validatetLDMRegList(Inst, Operands, 2, /*IsPop=*/true))
6340 if (validatetLDMRegList(Inst, Operands, 2, !isMClass()))
63416341 return true;
63426342 break;
63436343 }
0 @ RUN: not llvm-mc -triple thumbv7-eabi -filetype asm -o - %s 2>&1 \
11 @ RUN: | FileCheck %s
2 @ RUN: not llvm-mc -triple thumbv7a-eabi -filetype asm -o - %s 2>&1 \
3 @ RUN: | FileCheck --check-prefix=CHECK --check-prefix=CHECK-V7A %s
4 @ RUN: not llvm-mc -triple thumbv7m-eabi -filetype asm -o - %s 2>&1 \
5 @ RUN: | FileCheck --check-prefix=CHECK --check-prefix=CHECK-V7M %s
26
37 .syntax unified
48 .thumb
59
610 .global ldm
711 .type ldm,%function
8 ldb:
12 ldm:
913 ldm r0!, {r1, sp}
1014 @ CHECK: error: SP may not be in the register list
1115 @ CHECK: ldm r0!, {r1, sp}
2630 ldmdb:
2731 ldmdb r0!, {r1, sp}
2832 @ CHECK: error: SP may not be in the register list
29 ldm r0!, {lr, pc}
33 ldmdb r0!, {lr, pc}
3034 @ error: PC and LR may not be in the register list simultaneously
3135 itt eq
3236 ldmeq r0!, {r1, pc}
6266 @ CHECK: error: SP may not be in the register list
6367 push {pc}
6468 @ CHECK: error: PC may not be in the register list
65 push {sp,pc}
69 push {sp, pc}
6670 @ CHECK: error: SP and PC may not be in the register list
6771
6872 .global pop
6973 .type pop,%function
7074 pop:
75 pop {sp}
76 @ CHECK-V7M: error: SP may not be in the register list
7177 pop {lr, pc}
7278 @ CHECK: error: PC and LR may not be in the register list simultaneously
7379 @ CHECK: pop {lr, pc}
8389 .type valid,%function
8490 valid:
8591 pop {sp}
86 @ CHECK: ldr sp, [sp], #4
92 @ CHECK-V7A: ldr sp, [sp], #4
8793 pop {sp, pc}
88 @ CHECK: pop.w {sp, pc}
94 @ CHECK-V7A: pop.w {sp, pc}
8995 push.w {r0}
9096 @ CHECK: str r0, [sp, #-4]
9197 pop.w {r0}