[PATCH] Implement restrictions on SP in register list on LDM, LDMIA, LDMFD for ARM v7m

Tim Northover t.p.northover at gmail.com
Fri Oct 17 09:52:58 PDT 2014


Oops...

================
Comment at: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp:6001
@@ +6000,3 @@
+    if (Opcode == ARM::t2LDMIA_UPD) {
+      if (listContainsReg(Inst, 4, ARM::SP))
+        return Error(Operands.back()->getStartLoc(),
----------------
t.p.northover wrote:
> jyoti.allur wrote:
> > jyoti.allur wrote:
> > > t.p.northover wrote:
> > > > The list doesn't start at operand 4 here, does it? It looks like it should be 3 again on my tests.
> > > in some calls to checkLowRegisterList ( though this is a different function from listContainsReg, logic to read registers from list is same for both) operand 4 is used whenever a writeback expression exists in the instruction, since this case covered *_UPD case, 4 was used, correct me if my understanding is wrong.
> > i will change it to operand number 3 when checking for SP, although i am not sure why 4 is used in checkLowRegisterList in some cases.
> It depends on the exact instruction. I think STMs tend to start at 4, because they duplicate the address register for codegen purposes (once to be read, once to be written). The way to check is
> 
>     $ echo 'stmia r3!, {r0, r1}' | bin/llvm-mc -triple thumbv7 -show-inst
>             stm	r3!, {r0, r1}           @ <MCInst #2769 tSTMIA_UPD
>                                         @  <MCOperand Reg:69>
>                                         @  <MCOperand Reg:69>
>                                         @  <MCOperand Imm:14>
>                                         @  <MCOperand Reg:0>
>                                         @  <MCOperand Reg:66>
>                                         @  <MCOperand Reg:67>>
> 
> You see a duplicated 69 (the r3), a couple of predicate related operands, followed by the real register list starting at operand 4 (for tSTMIA_UPD). Hence line 6054.
I'm really sorry, you seem to have been right first time. Quite what test I did yesterday, I don't know. But today's one shows that t2LDMIA_UPD *does* start the list at 4.

http://reviews.llvm.org/D5827






More information about the llvm-commits mailing list