public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, AArch64] Improve diagnostics on ldp/stp with invalid immediate offset
@ 2013-11-05 17:49 Yufeng Zhang
  2013-11-05 18:16 ` Marcus Shawcroft
  0 siblings, 1 reply; 2+ messages in thread
From: Yufeng Zhang @ 2013-11-05 17:49 UTC (permalink / raw)
  To: binutils; +Cc: Marcus Shawcroft

[-- Attachment #1: Type: text/plain, Size: 1125 bytes --]

Hi,

This patch improves diagnostics on ldp/stp with invalid immediate offset 
from

test.s:2: Error: address writeback expected at operand 3 -- `ldp 
x0,x1,[x2,#4]'
test.s:3: Error: unexpected address writeback at operand 3 -- `ldp 
x0,x1,[x2,#4]!'
test.s:4: Error: unexpected address writeback at operand 3 -- `ldp 
x0,x1,[x2],#4'

to

test.s:2: Error: immediate value should be a multiple of 8 at operand 3 
-- `ldp x0,x1,[x2,#4]'
test.s:3: Error: immediate value should be a multiple of 8 at operand 3 
-- `ldp x0,x1,[x2,#4]!'
test.s:4: Error: immediate value should be a multiple of 8 at operand 3 
-- `ldp x0,x1,[x2],#4'

The fix is done by using a lower-priority error code for writeback 
check, so that the higher-priority error of unaligned immediate offset 
can be exposed to gas.

OK for the trunk and 2.24?

Thanks,
Yufeng

opcodes/

	* aarch64-opc.c (set_syntax_error): New function.
	(operand_general_constraint_met_p): Replace set_other_error
	with set_syntax_error.

gas/testsuite/

	* gas/aarch64/diagnostic.s: Add tests of ldp/stp.
	* gas/aarch64/diagnostic.l: Update.

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 2954 bytes --]

diff --git a/gas/testsuite/gas/aarch64/diagnostic.l b/gas/testsuite/gas/aarch64/diagnostic.l
index cca8881..015e16a 100644
--- a/gas/testsuite/gas/aarch64/diagnostic.l
+++ b/gas/testsuite/gas/aarch64/diagnostic.l
@@ -87,3 +87,9 @@
 [^:]*:89: Error: shift amount expected to be 0 at operand 2 -- `movi v1.8b,97,lsl#8'
 [^:]*:90: Error: unknown or missing system register name at operand 1 -- `msr dummy,x1'
 [^:]*:91: Error: invalid floating-point constant at operand 2 -- `fmov s0,0x42000000'
+[^:]*:92: Error: immediate value should be a multiple of 8 at operand 3 -- `ldp x0,x1,\[x2,#4\]'
+[^:]*:93: Error: immediate value should be a multiple of 8 at operand 3 -- `ldp x0,x1,\[x2,#4\]!'
+[^:]*:94: Error: immediate value should be a multiple of 8 at operand 3 -- `ldp x0,x1,\[x2\],#4'
+[^:]*:95: Error: immediate value should be a multiple of 4 at operand 3 -- `stp w0,w1,\[x2,#3\]'
+[^:]*:96: Error: immediate value should be a multiple of 4 at operand 3 -- `stp w0,w1,\[x2,#2\]!'
+[^:]*:97: Error: immediate value should be a multiple of 4 at operand 3 -- `stp w0,w1,\[x2\],#1'
diff --git a/gas/testsuite/gas/aarch64/diagnostic.s b/gas/testsuite/gas/aarch64/diagnostic.s
index e5443ab..afa04b5 100644
--- a/gas/testsuite/gas/aarch64/diagnostic.s
+++ b/gas/testsuite/gas/aarch64/diagnostic.s
@@ -89,3 +89,9 @@
 	movi	v1.8b, 97, lsl #8
 	msr	dummy, x1
 	fmov	s0, 0x42000000
+	ldp	x0, x1, [x2, #4]
+	ldp	x0, x1, [x2, #4]!
+	ldp	x0, x1, [x2], #4
+	stp	w0, w1, [x2, #3]
+	stp	w0, w1, [x2, #2]!
+	stp	w0, w1, [x2], #1
diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c
index f32ee5e..0d16bd6 100644
--- a/opcodes/aarch64-opc.c
+++ b/opcodes/aarch64-opc.c
@@ -1122,6 +1122,15 @@ set_error (aarch64_operand_error *mismatch_detail,
 }
 
 static inline void
+set_syntax_error (aarch64_operand_error *mismatch_detail, int idx,
+		  const char* error)
+{
+  if (mismatch_detail == NULL)
+    return;
+  set_error (mismatch_detail, AARCH64_OPDE_SYNTAX_ERROR, idx, error);
+}
+
+static inline void
 set_out_of_range_error (aarch64_operand_error *mismatch_detail,
 			int idx, int lower_bound, int upper_bound,
 			const char* error)
@@ -1288,8 +1297,8 @@ operand_general_constraint_met_p (const aarch64_opnd_info *opnds, int idx,
 	case ldst_unpriv:
 	  if (opnd->addr.writeback == 1)
 	    {
-	      set_other_error (mismatch_detail, idx,
-			       _("unexpected address writeback"));
+	      set_syntax_error (mismatch_detail, idx,
+				_("unexpected address writeback"));
 	      return 0;
 	    }
 	  break;
@@ -1299,8 +1308,8 @@ operand_general_constraint_met_p (const aarch64_opnd_info *opnds, int idx,
 	case asisdlsop:
 	  if (opnd->addr.writeback == 0)
 	    {
-	      set_other_error (mismatch_detail, idx,
-			       _("address writeback expected"));
+	      set_syntax_error (mismatch_detail, idx,
+				_("address writeback expected"));
 	      return 0;
 	    }
 	  break;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, AArch64] Improve diagnostics on ldp/stp with invalid immediate offset
  2013-11-05 17:49 [PATCH, AArch64] Improve diagnostics on ldp/stp with invalid immediate offset Yufeng Zhang
@ 2013-11-05 18:16 ` Marcus Shawcroft
  0 siblings, 0 replies; 2+ messages in thread
From: Marcus Shawcroft @ 2013-11-05 18:16 UTC (permalink / raw)
  To: Yufeng Zhang; +Cc: binutils, Marcus Shawcroft

On 5 November 2013 17:49, Yufeng Zhang <Yufeng.Zhang@arm.com> wrote:

> opcodes/
>
>         * aarch64-opc.c (set_syntax_error): New function.
>         (operand_general_constraint_met_p): Replace set_other_error
>         with set_syntax_error.
>
> gas/testsuite/
>
>         * gas/aarch64/diagnostic.s: Add tests of ldp/stp.
>         * gas/aarch64/diagnostic.l: Update.

Ok, thanks.
/Marcus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-05 18:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-05 17:49 [PATCH, AArch64] Improve diagnostics on ldp/stp with invalid immediate offset Yufeng Zhang
2013-11-05 18:16 ` Marcus Shawcroft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).