public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gas: bpf: new test for MOV with C-like numbers ll suffix
@ 2023-10-30 15:02 Jose E. Marchesi
  2023-10-30 15:06 ` Jose E. Marchesi
  2023-10-30 15:16 ` Jan Beulich
  0 siblings, 2 replies; 7+ messages in thread
From: Jose E. Marchesi @ 2023-10-30 15:02 UTC (permalink / raw)
  To: binutils

The BPF pseudo-c syntax supports both MOV and LDDW instructions:

    mov:  r1 = EXPR
    lddw: r1 = EXPR ll

Note that the white space between EXPR and `ll' is necessary in order
to avoid ambiguity with the assembler's support for C-like numerical
suffixes.  This patch adds a new test to the GAS BPF testsuite to make
sure that instructions like:

    r1 = 666ll

are interpreted as `mov %r1,666', not as `lddw %r1,666'.

This matches clang's assembler behavior.

2023-10-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* testsuite/gas/bpf/alu-pseudoc.s: Add test to make sure C-like
	suffix `ll' is not interpreted as lddw syntax.
	* testsuite/gas/bpf/alu-pseudoc.d: Update expected results.
	* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
---
 gas/ChangeLog                          | 7 +++++++
 gas/testsuite/gas/bpf/alu-be-pseudoc.d | 1 +
 gas/testsuite/gas/bpf/alu-pseudoc.d    | 1 +
 gas/testsuite/gas/bpf/alu-pseudoc.s    | 2 ++
 4 files changed, 11 insertions(+)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index fef3c248196..230a4a73039 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,10 @@
+2023-10-30  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* testsuite/gas/bpf/alu-pseudoc.s: Add test to make sure C-like
+	suffix `ll' is not interpreted as lddw syntax.
+	* testsuite/gas/bpf/alu-pseudoc.d: Update expected results.
+	* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
+
 2023-10-02  Nick Clifton  <nickc@redhat.com>
 
 	PR 30861
diff --git a/gas/testsuite/gas/bpf/alu-be-pseudoc.d b/gas/testsuite/gas/bpf/alu-be-pseudoc.d
index 4c0f6ba9ca6..80d167c46ff 100644
--- a/gas/testsuite/gas/bpf/alu-be-pseudoc.d
+++ b/gas/testsuite/gas/bpf/alu-be-pseudoc.d
@@ -69,3 +69,4 @@ Disassembly of section .text:
  1d0:	d7 10 00 00 00 00 00 10 	r1 = bswap16 r1
  1d8:	d7 20 00 00 00 00 00 20 	r2 = bswap32 r2
  1e0:	d7 30 00 00 00 00 00 40 	r3 = bswap64 r3
+ 1e8:	b7 20 00 00 00 00 02 9a 	r2=0x29a
diff --git a/gas/testsuite/gas/bpf/alu-pseudoc.d b/gas/testsuite/gas/bpf/alu-pseudoc.d
index b5ab569563c..ea08c9a10da 100644
--- a/gas/testsuite/gas/bpf/alu-pseudoc.d
+++ b/gas/testsuite/gas/bpf/alu-pseudoc.d
@@ -69,3 +69,4 @@ Disassembly of section .text:
  1d0:	d7 01 00 00 10 00 00 00 	r1 = bswap16 r1
  1d8:	d7 02 00 00 20 00 00 00 	r2 = bswap32 r2
  1e0:	d7 03 00 00 40 00 00 00 	r3 = bswap64 r3
+ 1e8:	b7 02 00 00 9a 02 00 00 	r2=0x29a
\ No newline at end of file
diff --git a/gas/testsuite/gas/bpf/alu-pseudoc.s b/gas/testsuite/gas/bpf/alu-pseudoc.s
index 323a6522f22..3d60d4f7a77 100644
--- a/gas/testsuite/gas/bpf/alu-pseudoc.s
+++ b/gas/testsuite/gas/bpf/alu-pseudoc.s
@@ -61,3 +61,5 @@
         r1 = bswap16 r1
         r2 = bswap32 r2
         r3 = bswap64 r3
+        ;; The following is to be interpreted as a mov, not lddw.
+        r2 = 666ll
-- 
2.30.2


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

* Re: [PATCH] gas: bpf: new test for MOV with C-like numbers ll suffix
  2023-10-30 15:02 [PATCH] gas: bpf: new test for MOV with C-like numbers ll suffix Jose E. Marchesi
@ 2023-10-30 15:06 ` Jose E. Marchesi
  2023-10-30 15:16 ` Jan Beulich
  1 sibling, 0 replies; 7+ messages in thread
From: Jose E. Marchesi @ 2023-10-30 15:06 UTC (permalink / raw)
  To: binutils


This is pushed.

> The BPF pseudo-c syntax supports both MOV and LDDW instructions:
>
>     mov:  r1 = EXPR
>     lddw: r1 = EXPR ll
>
> Note that the white space between EXPR and `ll' is necessary in order
> to avoid ambiguity with the assembler's support for C-like numerical
> suffixes.  This patch adds a new test to the GAS BPF testsuite to make
> sure that instructions like:
>
>     r1 = 666ll
>
> are interpreted as `mov %r1,666', not as `lddw %r1,666'.
>
> This matches clang's assembler behavior.
>
> 2023-10-30  Jose E. Marchesi  <jose.marchesi@oracle.com>
>
> 	* testsuite/gas/bpf/alu-pseudoc.s: Add test to make sure C-like
> 	suffix `ll' is not interpreted as lddw syntax.
> 	* testsuite/gas/bpf/alu-pseudoc.d: Update expected results.
> 	* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
> ---
>  gas/ChangeLog                          | 7 +++++++
>  gas/testsuite/gas/bpf/alu-be-pseudoc.d | 1 +
>  gas/testsuite/gas/bpf/alu-pseudoc.d    | 1 +
>  gas/testsuite/gas/bpf/alu-pseudoc.s    | 2 ++
>  4 files changed, 11 insertions(+)
>
> diff --git a/gas/ChangeLog b/gas/ChangeLog
> index fef3c248196..230a4a73039 100644
> --- a/gas/ChangeLog
> +++ b/gas/ChangeLog
> @@ -1,3 +1,10 @@
> +2023-10-30  Jose E. Marchesi  <jose.marchesi@oracle.com>
> +
> +	* testsuite/gas/bpf/alu-pseudoc.s: Add test to make sure C-like
> +	suffix `ll' is not interpreted as lddw syntax.
> +	* testsuite/gas/bpf/alu-pseudoc.d: Update expected results.
> +	* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
> +
>  2023-10-02  Nick Clifton  <nickc@redhat.com>
>  
>  	PR 30861
> diff --git a/gas/testsuite/gas/bpf/alu-be-pseudoc.d b/gas/testsuite/gas/bpf/alu-be-pseudoc.d
> index 4c0f6ba9ca6..80d167c46ff 100644
> --- a/gas/testsuite/gas/bpf/alu-be-pseudoc.d
> +++ b/gas/testsuite/gas/bpf/alu-be-pseudoc.d
> @@ -69,3 +69,4 @@ Disassembly of section .text:
>   1d0:	d7 10 00 00 00 00 00 10 	r1 = bswap16 r1
>   1d8:	d7 20 00 00 00 00 00 20 	r2 = bswap32 r2
>   1e0:	d7 30 00 00 00 00 00 40 	r3 = bswap64 r3
> + 1e8:	b7 20 00 00 00 00 02 9a 	r2=0x29a
> diff --git a/gas/testsuite/gas/bpf/alu-pseudoc.d b/gas/testsuite/gas/bpf/alu-pseudoc.d
> index b5ab569563c..ea08c9a10da 100644
> --- a/gas/testsuite/gas/bpf/alu-pseudoc.d
> +++ b/gas/testsuite/gas/bpf/alu-pseudoc.d
> @@ -69,3 +69,4 @@ Disassembly of section .text:
>   1d0:	d7 01 00 00 10 00 00 00 	r1 = bswap16 r1
>   1d8:	d7 02 00 00 20 00 00 00 	r2 = bswap32 r2
>   1e0:	d7 03 00 00 40 00 00 00 	r3 = bswap64 r3
> + 1e8:	b7 02 00 00 9a 02 00 00 	r2=0x29a
> \ No newline at end of file
> diff --git a/gas/testsuite/gas/bpf/alu-pseudoc.s b/gas/testsuite/gas/bpf/alu-pseudoc.s
> index 323a6522f22..3d60d4f7a77 100644
> --- a/gas/testsuite/gas/bpf/alu-pseudoc.s
> +++ b/gas/testsuite/gas/bpf/alu-pseudoc.s
> @@ -61,3 +61,5 @@
>          r1 = bswap16 r1
>          r2 = bswap32 r2
>          r3 = bswap64 r3
> +        ;; The following is to be interpreted as a mov, not lddw.
> +        r2 = 666ll

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

* Re: [PATCH] gas: bpf: new test for MOV with C-like numbers ll suffix
  2023-10-30 15:02 [PATCH] gas: bpf: new test for MOV with C-like numbers ll suffix Jose E. Marchesi
  2023-10-30 15:06 ` Jose E. Marchesi
@ 2023-10-30 15:16 ` Jan Beulich
  2023-10-30 17:34   ` Jose E. Marchesi
  1 sibling, 1 reply; 7+ messages in thread
From: Jan Beulich @ 2023-10-30 15:16 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: binutils

On 30.10.2023 16:02, Jose E. Marchesi wrote:
> --- a/gas/testsuite/gas/bpf/alu-pseudoc.d
> +++ b/gas/testsuite/gas/bpf/alu-pseudoc.d
> @@ -69,3 +69,4 @@ Disassembly of section .text:
>   1d0:	d7 01 00 00 10 00 00 00 	r1 = bswap16 r1
>   1d8:	d7 02 00 00 20 00 00 00 	r2 = bswap32 r2
>   1e0:	d7 03 00 00 40 00 00 00 	r3 = bswap64 r3
> + 1e8:	b7 02 00 00 9a 02 00 00 	r2=0x29a
> \ No newline at end of file

Just as a remark - issues like this would be really nice to be taken
care of as files are touched. Imo much better than waiting for a
separate cleanup patch.

Jan

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

* Re: [PATCH] gas: bpf: new test for MOV with C-like numbers ll suffix
  2023-10-30 15:16 ` Jan Beulich
@ 2023-10-30 17:34   ` Jose E. Marchesi
  2023-10-31  7:30     ` Jan Beulich
  0 siblings, 1 reply; 7+ messages in thread
From: Jose E. Marchesi @ 2023-10-30 17:34 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils


> On 30.10.2023 16:02, Jose E. Marchesi wrote:
>> --- a/gas/testsuite/gas/bpf/alu-pseudoc.d
>> +++ b/gas/testsuite/gas/bpf/alu-pseudoc.d
>> @@ -69,3 +69,4 @@ Disassembly of section .text:
>>   1d0:	d7 01 00 00 10 00 00 00 	r1 = bswap16 r1
>>   1d8:	d7 02 00 00 20 00 00 00 	r2 = bswap32 r2
>>   1e0:	d7 03 00 00 40 00 00 00 	r3 = bswap64 r3
>> + 1e8:	b7 02 00 00 9a 02 00 00 	r2=0x29a
>> \ No newline at end of file
>
> Just as a remark - issues like this would be really nice to be taken
> care of as files are touched. Imo much better than waiting for a
> separate cleanup patch.

Your point being?

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

* Re: [PATCH] gas: bpf: new test for MOV with C-like numbers ll suffix
  2023-10-30 17:34   ` Jose E. Marchesi
@ 2023-10-31  7:30     ` Jan Beulich
  2023-10-31 10:12       ` Jose E. Marchesi
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Beulich @ 2023-10-31  7:30 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: binutils

On 30.10.2023 18:34, Jose E. Marchesi wrote:
> 
>> On 30.10.2023 16:02, Jose E. Marchesi wrote:
>>> --- a/gas/testsuite/gas/bpf/alu-pseudoc.d
>>> +++ b/gas/testsuite/gas/bpf/alu-pseudoc.d
>>> @@ -69,3 +69,4 @@ Disassembly of section .text:
>>>   1d0:	d7 01 00 00 10 00 00 00 	r1 = bswap16 r1
>>>   1d8:	d7 02 00 00 20 00 00 00 	r2 = bswap32 r2
>>>   1e0:	d7 03 00 00 40 00 00 00 	r3 = bswap64 r3
>>> + 1e8:	b7 02 00 00 9a 02 00 00 	r2=0x29a
>>> \ No newline at end of file
>>
>> Just as a remark - issues like this would be really nice to be taken
>> care of as files are touched. Imo much better than waiting for a
>> separate cleanup patch.
> 
> Your point being?

"No newline at end of file" is something that shouldn't happen in any
source files. Therefore when changing adjacent code it would be nice
if the missing newline was inserted at the same time.

Jan

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

* Re: [PATCH] gas: bpf: new test for MOV with C-like numbers ll suffix
  2023-10-31  7:30     ` Jan Beulich
@ 2023-10-31 10:12       ` Jose E. Marchesi
  2023-10-31 10:25         ` Jan Beulich
  0 siblings, 1 reply; 7+ messages in thread
From: Jose E. Marchesi @ 2023-10-31 10:12 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils


> On 30.10.2023 18:34, Jose E. Marchesi wrote:
>> 
>>> On 30.10.2023 16:02, Jose E. Marchesi wrote:
>>>> --- a/gas/testsuite/gas/bpf/alu-pseudoc.d
>>>> +++ b/gas/testsuite/gas/bpf/alu-pseudoc.d
>>>> @@ -69,3 +69,4 @@ Disassembly of section .text:
>>>>   1d0:	d7 01 00 00 10 00 00 00 	r1 = bswap16 r1
>>>>   1d8:	d7 02 00 00 20 00 00 00 	r2 = bswap32 r2
>>>>   1e0:	d7 03 00 00 40 00 00 00 	r3 = bswap64 r3
>>>> + 1e8:	b7 02 00 00 9a 02 00 00 	r2=0x29a
>>>> \ No newline at end of file
>>>
>>> Just as a remark - issues like this would be really nice to be taken
>>> care of as files are touched. Imo much better than waiting for a
>>> separate cleanup patch.
>> 
>> Your point being?
>
> "No newline at end of file" is something that shouldn't happen in any
> source files. Therefore when changing adjacent code it would be nice
> if the missing newline was inserted at the same time.

Yes, agreed.  In all candour, in this case I didn't even notice it
before pushing (was in a rush) or i would have done it.

Would you say the same applies to typos and other trivial fixes?
Usually I refrain from fixing these that I happen to notice while
working on something else, unless they are very coupled with the change
(like a typo in a comment describing the code I am changing) even if it
is very tempting to do otherwise.  I guess it is a question of degree.

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

* Re: [PATCH] gas: bpf: new test for MOV with C-like numbers ll suffix
  2023-10-31 10:12       ` Jose E. Marchesi
@ 2023-10-31 10:25         ` Jan Beulich
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Beulich @ 2023-10-31 10:25 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: binutils

On 31.10.2023 11:12, Jose E. Marchesi wrote:
> 
>> On 30.10.2023 18:34, Jose E. Marchesi wrote:
>>>
>>>> On 30.10.2023 16:02, Jose E. Marchesi wrote:
>>>>> --- a/gas/testsuite/gas/bpf/alu-pseudoc.d
>>>>> +++ b/gas/testsuite/gas/bpf/alu-pseudoc.d
>>>>> @@ -69,3 +69,4 @@ Disassembly of section .text:
>>>>>   1d0:	d7 01 00 00 10 00 00 00 	r1 = bswap16 r1
>>>>>   1d8:	d7 02 00 00 20 00 00 00 	r2 = bswap32 r2
>>>>>   1e0:	d7 03 00 00 40 00 00 00 	r3 = bswap64 r3
>>>>> + 1e8:	b7 02 00 00 9a 02 00 00 	r2=0x29a
>>>>> \ No newline at end of file
>>>>
>>>> Just as a remark - issues like this would be really nice to be taken
>>>> care of as files are touched. Imo much better than waiting for a
>>>> separate cleanup patch.
>>>
>>> Your point being?
>>
>> "No newline at end of file" is something that shouldn't happen in any
>> source files. Therefore when changing adjacent code it would be nice
>> if the missing newline was inserted at the same time.
> 
> Yes, agreed.  In all candour, in this case I didn't even notice it
> before pushing (was in a rush) or i would have done it.
> 
> Would you say the same applies to typos and other trivial fixes?
> Usually I refrain from fixing these that I happen to notice while
> working on something else, unless they are very coupled with the change
> (like a typo in a comment describing the code I am changing) even if it
> is very tempting to do otherwise.  I guess it is a question of degree.

My rule of thumb is that anything that's touched anyway can also have
cosmetic corrections alongside the main intended adjustment(s).

Jan

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

end of thread, other threads:[~2023-10-31 10:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-30 15:02 [PATCH] gas: bpf: new test for MOV with C-like numbers ll suffix Jose E. Marchesi
2023-10-30 15:06 ` Jose E. Marchesi
2023-10-30 15:16 ` Jan Beulich
2023-10-30 17:34   ` Jose E. Marchesi
2023-10-31  7:30     ` Jan Beulich
2023-10-31 10:12       ` Jose E. Marchesi
2023-10-31 10:25         ` Jan Beulich

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).