This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] arm: permit certain indexed loads and stores with PC base address


As per the specification, use of PC there is valid.

gas/
2013-04-10  Jan Beulich <jbeulich@suse.com>

	* gas/config/tc-arm.c (encode_arm_addr_mode_3): Only reject base
	register being PC when is_t or writeback, and use distinct
	diagnostic for the latter case.

gas/testsuite/
2013-04-10  Jan Beulich <jbeulich@suse.com>

	* gas/testsuite/gas/arm/ldst-pc.s: Add index, non-writeback
	forms of various loads and stores with PC as base.
	* gas/testsuite/gas/arm/ldst-pc.d: Update accordingly.

--- 2013-04-10/gas/config/tc-arm.c
+++ 2013-04-10/gas/config/tc-arm.c
@@ -7202,8 +7202,10 @@ encode_arm_addr_mode_3 (int i, bfd_boole
   if (inst.operands[i].immisreg)
     {
       constraint ((inst.operands[i].imm == REG_PC
-		   || inst.operands[i].reg == REG_PC),
+		   || (is_t && inst.operands[i].reg == REG_PC)),
 		  BAD_PC_ADDRESSING);
+      constraint (inst.operands[i].reg == REG_PC && inst.operands[i].writeback,
+		  BAD_PC_WRITEBACK);
       inst.instruction |= inst.operands[i].imm;
       if (!inst.operands[i].negative)
 	inst.instruction |= INDEX_UP;
--- 2013-04-10/gas/testsuite/gas/arm/ldst-pc.d
+++ 2013-04-10/gas/testsuite/gas/arm/ldst-pc.d
@@ -7,10 +7,19 @@
 .*: +file format .*arm.*
 
 Disassembly of section .text:
-0+000 <[^>]*> e51f1008 	ldr	r1, \[pc, #-8\]	; 0+000 <[^>]*>
-0+004 <[^>]*> e79f1002 	ldr	r1, \[pc, r2\]
-0+008 <[^>]*> f55ff008 	pld	\[pc, #-8\]	; 0+008 <[^>]*>
-0+00c <[^>]*> f7dff001 	pld	\[pc, r1\]
-0+010 <[^>]*> f45ff008 	pli	\[pc, #-8\]	; 0+010 <[^>]*>
-0+014 <[^>]*> f6dff001 	pli	\[pc, r1\]
-0+018 <[^>]*> e58f1004 	str	r1, \[pc, #4\]	; 0+024 <[^>]*>
+(0[0-9a-f]+) <[^>]+> e51f1008 	ldr	r1, \[pc, #-8\]	; \1 <[^>]*>
+0[0-9a-f]+ <[^>]+> e79f1002 	ldr	r1, \[pc, r2\]
+0[0-9a-f]+ <[^>]+> e7df1002 	ldrb	r1, \[pc, r2\]
+0[0-9a-f]+ <[^>]+> e18f00d2 	ldrd	r0, \[pc, r2\]
+0[0-9a-f]+ <[^>]+> e19f10b2 	ldrh	r1, \[pc, r2\]
+0[0-9a-f]+ <[^>]+> e19f10d2 	ldrsb	r1, \[pc, r2\]
+0[0-9a-f]+ <[^>]+> e19f10f2 	ldrsh	r1, \[pc, r2\]
+(0[0-9a-f]+) <[^>]+> f55ff008 	pld	\[pc, #-8\]	; \1 <[^>]*>
+0[0-9a-f]+ <[^>]+> f7dff001 	pld	\[pc, r1\]
+(0[0-9a-f]+) <[^>]+> f45ff008 	pli	\[pc, #-8\]	; \1 <[^>]*>
+0[0-9a-f]+ <[^>]+> f6dff001 	pli	\[pc, r1\]
+0[0-9a-f]+ <[^>]+> e58f1004 	str	r1, \[pc, #4\]	; 0+038 <[^>]*>
+0[0-9a-f]+ <[^>]+> e78f1002 	str	r1, \[pc, r2\]
+0[0-9a-f]+ <[^>]+> e7cf1002 	strb	r1, \[pc, r2\]
+0[0-9a-f]+ <[^>]+> e18f00f2 	strd	r0, \[pc, r2\]
+0[0-9a-f]+ <[^>]+> e18f10b2 	strh	r1, \[pc, r2\]
--- 2013-04-10/gas/testsuite/gas/arm/ldst-pc.s
+++ 2013-04-10/gas/testsuite/gas/arm/ldst-pc.s
@@ -5,6 +5,11 @@
 	.align 2
 	ldr r1, [pc, #-8]
 	ldr r1, [pc, r2]
+	ldrb r1, [pc, r2]
+	ldrd r0, r1, [pc, r2]
+	ldrh r1, [pc, r2]
+	ldrsb r1, [pc, r2]
+	ldrsh r1, [pc, r2]
 
 	pld [pc, #-8]
 	pld [pc, r1]
@@ -13,3 +18,7 @@
 	pli [pc, r1]
 
 	str r1, [pc, #4]
+	str r1, [pc, r2]
+	strb r1, [pc, r2]
+	strd r0, r1, [pc, r2]
+	strh r1, [pc, r2]
--- 2013-04-10/gas/testsuite/gas/arm/sp-pc-validations-bad.l
+++ 2013-04-10/gas/testsuite/gas/arm/sp-pc-validations-bad.l
@@ -33,8 +33,8 @@
 [^:]*:56: Error: cannot use register index with PC-relative addressing -- `ldrd r0,r1,\[r2,pc\]'
 [^:]*:57: Error: cannot use register index with PC-relative addressing -- `ldrd r0,r1,\[r2,pc\]!'
 [^:]*:58: Error: cannot use register index with PC-relative addressing -- `ldrd r0,r1,\[r2\],pc'
-[^:]*:59: Error: cannot use register index with PC-relative addressing -- `ldrd r0,r1,\[pc,r2\]!'
-[^:]*:60: Error: cannot use register index with PC-relative addressing -- `ldrd r0,r1,\[pc\],r2'
+[^:]*:59: Error: cannot use writeback with PC-relative addressing -- `ldrd r0,r1,\[pc,r2\]!'
+[^:]*:60: Error: cannot use writeback with PC-relative addressing -- `ldrd r0,r1,\[pc\],r2'
 [^:]*:63: Error: r15 not allowed here -- `ldrex pc,\[r0\]'
 [^:]*:64: Error: instruction does not accept this addressing mode -- `ldrex r0,\[pc\]'
 [^:]*:67: Error: r15 not allowed here -- `ldrexb pc,\[r0\]'
@@ -53,8 +53,8 @@
 [^:]*:90: Error: cannot use register index with PC-relative addressing -- `ldrh r0,\[r1,pc\]'
 [^:]*:91: Error: cannot use register index with PC-relative addressing -- `ldrh r0,\[r1,pc\]!'
 [^:]*:92: Error: cannot use register index with PC-relative addressing -- `ldrh r0,\[r1\],pc'
-[^:]*:93: Error: cannot use register index with PC-relative addressing -- `ldrh r0,\[pc,r1\]!'
-[^:]*:94: Error: cannot use register index with PC-relative addressing -- `ldrh r0,\[pc\],r1'
+[^:]*:93: Error: cannot use writeback with PC-relative addressing -- `ldrh r0,\[pc,r1\]!'
+[^:]*:94: Error: cannot use writeback with PC-relative addressing -- `ldrh r0,\[pc\],r1'
 [^:]*:97: Error: r15 not allowed here -- `ldrht pc,\[r0\],#4'
 [^:]*:98: Error: cannot use writeback with PC-relative addressing -- `ldrht r0,\[pc\],#4'
 [^:]*:99: Error: r15 not allowed here -- `ldrht pc,\[r0\],r1'
@@ -71,8 +71,8 @@
 [^:]*:116: Error: cannot use register index with PC-relative addressing -- `ldrsb r0,\[r1,pc\]'
 [^:]*:117: Error: cannot use register index with PC-relative addressing -- `ldrsb r0,\[r1,pc\]!'
 [^:]*:118: Error: cannot use register index with PC-relative addressing -- `ldrsb r0,\[r1\],pc'
-[^:]*:119: Error: cannot use register index with PC-relative addressing -- `ldrsb r0,\[pc,r1\]!'
-[^:]*:120: Error: cannot use register index with PC-relative addressing -- `ldrsb r0,\[pc\],r1'
+[^:]*:119: Error: cannot use writeback with PC-relative addressing -- `ldrsb r0,\[pc,r1\]!'
+[^:]*:120: Error: cannot use writeback with PC-relative addressing -- `ldrsb r0,\[pc\],r1'
 [^:]*:123: Error: r15 not allowed here -- `ldrsbt pc,\[r0\],#4'
 [^:]*:124: Error: cannot use writeback with PC-relative addressing -- `ldrsbt r0,\[pc\],#4'
 [^:]*:125: Error: r15 not allowed here -- `ldrsbt pc,\[r0\],r1'
@@ -89,8 +89,8 @@
 [^:]*:142: Error: cannot use register index with PC-relative addressing -- `ldrsh r0,\[r1,pc\]'
 [^:]*:143: Error: cannot use register index with PC-relative addressing -- `ldrsh r0,\[r1,pc\]!'
 [^:]*:144: Error: cannot use register index with PC-relative addressing -- `ldrsh r0,\[r1\],pc'
-[^:]*:145: Error: cannot use register index with PC-relative addressing -- `ldrsh r0,\[pc,r1\]!'
-[^:]*:146: Error: cannot use register index with PC-relative addressing -- `ldrsh r0,\[pc\],r1'
+[^:]*:145: Error: cannot use writeback with PC-relative addressing -- `ldrsh r0,\[pc,r1\]!'
+[^:]*:146: Error: cannot use writeback with PC-relative addressing -- `ldrsh r0,\[pc\],r1'
 [^:]*:149: Error: r15 not allowed here -- `ldrsht pc,\[r0\],#4'
 [^:]*:150: Error: cannot use writeback with PC-relative addressing -- `ldrsht r0,\[pc\],#4'
 [^:]*:151: Error: r15 not allowed here -- `ldrsht pc,\[r0\],r1'
@@ -135,8 +135,8 @@
 [^:]*:209: Error: cannot use register index with PC-relative addressing -- `strd r0,r1,\[r2,pc\]'
 [^:]*:210: Error: cannot use register index with PC-relative addressing -- `strd r0,r1,\[r2,pc\]!'
 [^:]*:211: Error: cannot use register index with PC-relative addressing -- `strd r0,r1,\[r2\],pc'
-[^:]*:212: Error: cannot use register index with PC-relative addressing -- `strd r0,r1,\[pc,r2\]!'
-[^:]*:213: Error: cannot use register index with PC-relative addressing -- `strd r0,r1,\[pc\],r2'
+[^:]*:212: Error: cannot use writeback with PC-relative addressing -- `strd r0,r1,\[pc,r2\]!'
+[^:]*:213: Error: cannot use writeback with PC-relative addressing -- `strd r0,r1,\[pc\],r2'
 [^:]*:216: Error: r15 not allowed here -- `strex pc,r0,\[r1\]'
 [^:]*:217: Error: r15 not allowed here -- `strex r0,pc,\[r1\]'
 [^:]*:218: Error: instruction does not accept this addressing mode -- `strex r0,r1,\[pc\]'
@@ -159,8 +159,8 @@
 [^:]*:245: Error: cannot use register index with PC-relative addressing -- `strh r0,\[r1,pc\]'
 [^:]*:246: Error: cannot use register index with PC-relative addressing -- `strh r0,\[r1,pc\]!'
 [^:]*:247: Error: cannot use register index with PC-relative addressing -- `strh r0,\[r1\],pc'
-[^:]*:248: Error: cannot use register index with PC-relative addressing -- `strh r0,\[pc,r1\]!'
-[^:]*:249: Error: cannot use register index with PC-relative addressing -- `strh r0,\[pc\],r1'
+[^:]*:248: Error: cannot use writeback with PC-relative addressing -- `strh r0,\[pc,r1\]!'
+[^:]*:249: Error: cannot use writeback with PC-relative addressing -- `strh r0,\[pc\],r1'
 [^:]*:252: Error: r15 not allowed here -- `strht pc,\[r0\],#4'
 [^:]*:253: Error: cannot use writeback with PC-relative addressing -- `strht r0,\[pc\],#4'
 [^:]*:254: Error: r15 not allowed here -- `strht pc,\[r0\],r1'


Attachment: binutils-mainline-arm-ldst-pc.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]