public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "Cui, Lili" <lili.cui@intel.com>
Cc: "Lu, Hongjiu" <hongjiu.lu@intel.com>,
	"ccoutant@gmail.com" <ccoutant@gmail.com>,
	"binutils@sourceware.org" <binutils@sourceware.org>
Subject: Re: [PATCH 4/8] Add tests for APX GPR32 with extend evex prefix
Date: Thu, 16 Nov 2023 17:50:00 +0100	[thread overview]
Message-ID: <f3f4c04c-58ec-4214-9e58-cfc6af0f96f7@suse.com> (raw)
In-Reply-To: <SJ0PR11MB56003BCEF7BD7A4F641CA8959EB0A@SJ0PR11MB5600.namprd11.prod.outlook.com>

On 16.11.2023 16:34, Cui, Lili wrote:
>>> --- /dev/null
>>> +++ b/gas/testsuite/gas/i386/x86-64-apx-egpr-promote-inval.s
>>> @@ -0,0 +1,17 @@
>>> +# Check illegal 64bit APX EVEX promoted instructions
>>> +	.text
>>> +	.arch .nomovbe
>>> +	movbe (%r16), %r17
>>> +	movbe (%rax), %rcx
>>> +	.arch .noept
>>> +	invept (%r16), %r17
>>> +	invept (%rax), %rcx
>>> +	.arch .noavx512bw
>>> +	kmovq %k1, (%r16)
>>> +	kmovq %k1, (%r8)
>>> +	.arch .noavx512dq
>>> +	kmovb %k1, %r16d
>>> +	kmovb %k1, %r8d
>>> +	.arch .noavx512f
>>> +	kmovw %k1, %r16d
>>> +	kmovw %k1, %r8d
>>
>> What about BMI/BMI2 insns? Or AMX ones? (I surely missed further groups.)
> 
> We don’t want to list all the instructions here, just a few representatives.

Sure. I'm asking for representatives from the BMI and BMI2 groups.

>>> --- /dev/null
>>> +++ b/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s
>>> @@ -0,0 +1,29 @@
> # Check Illegal prefix for 64bit EVEX-promoted instructions
> 
>         .allow_index_reg
>         .text
> _start:
>         #movbe %r18w,%ax set EVEX.pp = f3 (illegal value).
>         .byte 0x62, 0xfc, 0x7e, 0x08, 0x60, 0xc2
>         .byte 0xff, 0xff
>         #movbe %r18w,%ax set EVEX.pp = f2 (illegal value).
>         .byte 0x62, 0xfc, 0x7f, 0x08, 0x60, 0xc2
>         .byte 0xff, 0xff
>         #VSIB vpgatherqq 0x7b(%rbp,%zmm17,8),%zmm16{%k1} set EVEX.P[10] == 0
>         #(illegal value).
>         .byte 0x62, 0xe2, 0xf9, 0x41, 0x91, 0x84, 0xcd, 0x7b, 0x00, 0x00, 0x00
>         .byte 0xff
>         #EVEX_MAP4 movbe %r18w,%ax set EVEX.mm == b01 (illegal value).
>         .byte 0x62, 0xfd, 0x7d, 0x08, 0x60, 0xc2
>         .byte 0xff, 0xff
>         #EVEX_MAP4 movbe %r18w,%ax set EVEX.aa(P[17:16]) == b01 (illegal value).
>         .byte 0x62, 0xfd, 0x7d, 0x09, 0x60, 0xc2
>         .byte 0xff, 0xff
>         #EVEX_MAP4 movbe %r18w,%ax set EVEX.zL'L == b001 (illegal value).
>         .byte 0x62, 0xfd, 0x7d, 0x28, 0x60, 0xc2
>         .byte 0xff, 0xff
>         #EVEX from VEX ldtilecfg 0x123(%r31,%rax,4),%r31 EVEX.P[17:16](EVEX.aa) == 1 (illegal value).
>         .byte 0x62, 0xda, 0x7c, 0x09, 0x49, 0x84, 0x87, 0x23, 0x01, 0x00, 0x00
>         #EVEX from VEX ldtilecfg 0x123(%r31,%rax,4),%r31 EVEX.P[22:21](EVEX.L’L) == 1 (illegal value).
>         .byte 0x62, 0xda, 0x7c, 0x28, 0x49, 0x84, 0x87, 0x23, 0x01, 0x00, 0x00
>         #EVEX from VEX ldtilecfg 0x123(%r31,%rax,4),%r31 EVEX.P[20](EVEX.b) == 1 (illegal value).
>         .byte 0x62, 0xda, 0x7c, 0x18, 0x49, 0x84, 0x87, 0x23, 0x01, 0x00, 0x00
> 
>> I suspect at least some of these can be expressed via .insn, which would
>> greatly help readability (i.e. recognizing what is actually being done, and
>> what's expected-wrong about it).
>>
> 
> Update test cases.
> I try to express the first case using .insn. I can't find a way to express EVEX.P[3:2] == 11, do you have any ideas?
> 
> 0x62, 0xfc  ---> EVEX.P[3:2] of normal EVEX must be 00.

There are terminology issues here again. The first case in the test talks
about EVEX.pp set to the equivalent of an F3 prefix. That's neither
encoded as 11, nor in EVEX.P[3:2] (I don't like the EVEX.P[] notation
anyway), but in EVEX.P[9:8].

Irrespective, these are some examples of what I use to encode MOVBE (note
that all of this Intel syntax and the comments are MASM-style):

	.insn EVEX.L0.66.M12.W0 0x60, di, ax		; movbe di, r16w
	.insn EVEX.L0.66.M12.W0 0x60, di, [rax]		; movbe di, [r16]
	.insn EVEX.L0.M4 0x60, xmm16, rdi		; movbe r16, rdi
	.insn EVEX.L0.M4.W0 0x60, xmm16, [rdi]		; movbe r16d, [rdi]
	.insn EVEX.L0.66.M4.W0 0x61, [rdi], xmm16	; movbe [rdi], r16w
	.insn EVEX.L0.M4 0x61, xmm16, edi		; movbe edi, r16d
	.insn EVEX.L0.M12 0x61, [rax], rdi		; movbe [r16], rdi

Surely you can find variations to support the forms you're after. Plus
if you think the .insn documentation is unclear, please point out what
you think needs improving.

>>> [...]
>>> +	crc32	r22,r31
>>> +	crc32	r22,QWORD PTR [r31]
>>> +	crc32	r17,r19b
>>> +	crc32	r21d,r19b
>>> +	crc32	ebx,BYTE PTR [r19]
>>> +	crc32	r23d,r31d
>>> +	crc32	r23d,DWORD PTR [r31]
>>> +	crc32	r21d,r31w
>>> +	crc32	r21d,WORD PTR [r31]
>>> +	crc32	r18,rax
>>
>> These could do with moving up, since otherwise things look to be sorted
>> alphabetically here. But seeing these also reminds me that the noreg64 test
>> also needs extending, to cover these new forms (handled by separate
>> templates).
>>
> 
> I'm confused here about adding crc test case in noreg64.s, could you elaborate on what testcase you want to add?
> 
>         pfx crc32       (%rax), %eax
>         pfx16 crc32     (%rax), %rax
> +       pfx crc32       (%r31),%r21d   ---> data size prefix invalid with `crc32'
> +       pfx crc32       (%r31),%r21     ---> data size prefix invalid with `crc32'

Well, of course you can't use the "pfx" macro (at least not as is), which
will emit a data size prefix when DATA16 is defined. Likewise it would emit
"rex64" when REX64 is defined, which doesn't make sense with EVEX-encoded
insns. Ideally you would introduce a new macro to control operand size in
an EVEX-like manner, just that I'm afraid that the way you're adding EVEX-
encoding support to gas doesn't offer any means equivalent to that of legacy
encodings. Hence only the "bare" EVEX-encoded insns (without the use of any
pfx*) should be added for the time being.

Also, ftaod, CRC32 was only an example here. Any new template you add which
allows for potentially ambiguous operand size will need an example added
here. This set of tests (noreg64*) is intended to be (and remain) exhaustive.

Albeit, thinking a little further, perhaps you simply want to introduce a
noreg64-evex.d referencing the same source file, but arranging for {evex} to
be emitted in the pfx macro (or a further clone thereof, as some of the
insns cannot be EVEX-encoded)? That would then also deal with covering all
relevant new templates (I think). You'd need to check what, if anything,
needs doing to the pfx16 and pfx64 macros. But of course you could also
introduce a fully standalone noreg64-apx.{s,d} test, to escape some of the
possible hassles.

Jan

  reply	other threads:[~2023-11-16 16:50 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 11:29 [PATCH v2 0/8] Support Intel APX EGPR Cui, Lili
2023-11-02 11:29 ` [PATCH 1/8] Support APX GPR32 with rex2 prefix Cui, Lili
2023-11-02 17:05   ` Jan Beulich
2023-11-03  6:20     ` Cui, Lili
2023-11-03 13:05     ` Jan Beulich
2023-11-03 14:19   ` Jan Beulich
2023-11-06 15:20     ` Cui, Lili
2023-11-06 16:08       ` Jan Beulich
2023-11-07  8:16         ` Cui, Lili
2023-11-07 10:43           ` Jan Beulich
2023-11-07 15:31             ` Cui, Lili
2023-11-07 15:43               ` Jan Beulich
2023-11-07 15:53                 ` Cui, Lili
2023-11-06 15:02   ` Jan Beulich
2023-11-07  8:06     ` Cui, Lili
2023-11-07 10:20       ` Jan Beulich
2023-11-07 14:32         ` Cui, Lili
2023-11-07 15:08           ` Jan Beulich
2023-11-06 15:39   ` Jan Beulich
2023-11-09  8:02     ` Cui, Lili
2023-11-09 10:52       ` Jan Beulich
2023-11-09 13:27         ` Cui, Lili
2023-11-09 15:22           ` Jan Beulich
2023-11-10  7:11             ` Cui, Lili
2023-11-10  9:14               ` Jan Beulich
2023-11-10  9:21                 ` Jan Beulich
2023-11-10 12:38                   ` Cui, Lili
2023-12-14 10:13                   ` Cui, Lili
2023-12-18 15:24                     ` Jan Beulich
2023-12-18 16:23                       ` H.J. Lu
2023-11-10  9:47                 ` Cui, Lili
2023-11-10  9:57                   ` Jan Beulich
2023-11-10 12:05                     ` Cui, Lili
2023-11-10 12:35                       ` Jan Beulich
2023-11-13  0:18                         ` Cui, Lili
2023-11-02 11:29 ` [PATCH 2/8] Created an empty EVEX_MAP4_ sub-table for EVEX instructions Cui, Lili
2023-11-02 11:29 ` [PATCH 3/8] Support APX GPR32 with extend evex prefix Cui, Lili
2023-11-02 11:29 ` [PATCH 4/8] Add tests for " Cui, Lili
2023-11-08  9:11   ` Jan Beulich
2023-11-15 14:56     ` Cui, Lili
2023-11-16  9:17       ` Jan Beulich
2023-11-16 15:34     ` Cui, Lili
2023-11-16 16:50       ` Jan Beulich [this message]
2023-11-17 12:42         ` Cui, Lili
2023-11-17 14:38           ` Jan Beulich
2023-11-22 13:40             ` Cui, Lili
2023-11-02 11:29 ` [PATCH 5/8] Support APX NDD Cui, Lili
2023-11-08 10:39   ` Jan Beulich
2023-11-20  1:19     ` Cui, Lili
2023-11-08 11:13   ` Jan Beulich
2023-11-20 12:36     ` Cui, Lili
2023-11-20 16:33       ` Jan Beulich
2023-11-22  7:46         ` Cui, Lili
2023-11-22  8:47           ` Jan Beulich
2023-11-22 10:45             ` Cui, Lili
2023-11-23 10:57               ` Jan Beulich
2023-11-23 12:14                 ` Cui, Lili
2023-11-24  6:56                 ` [PATCH v3 0/9] Support Intel APX EGPR Cui, Lili
2023-12-07  8:17                   ` Cui, Lili
2023-12-07  8:33                     ` Cui, Lili
2023-11-09  9:37   ` [PATCH 5/8] Support APX NDD Jan Beulich
2023-11-20  1:33     ` Cui, Lili
2023-11-20  8:19       ` Jan Beulich
2023-11-20 12:54         ` Cui, Lili
2023-11-20 16:43           ` Jan Beulich
2023-11-02 11:29 ` [PATCH 6/8] Support APX Push2/Pop2 Cui, Lili
2023-11-08 11:44   ` Jan Beulich
2023-11-08 12:52     ` Jan Beulich
2023-11-22  5:48     ` Cui, Lili
2023-11-22  8:53       ` Jan Beulich
2023-11-22 12:26         ` Cui, Lili
2023-11-09  9:57   ` Jan Beulich
2023-11-02 11:29 ` [PATCH 7/8] Support APX NDD optimized encoding Cui, Lili
2023-11-09 10:36   ` Jan Beulich
2023-11-10  5:43     ` Hu, Lin1
2023-11-10  9:54       ` Jan Beulich
2023-11-14  2:28         ` Hu, Lin1
2023-11-14 10:50           ` Jan Beulich
2023-11-15  2:52             ` Hu, Lin1
2023-11-15  8:57               ` Jan Beulich
2023-11-15  2:59             ` [PATCH][v3] " Hu, Lin1
2023-11-15  9:34               ` Jan Beulich
2023-11-17  7:24                 ` Hu, Lin1
2023-11-17  9:47                   ` Jan Beulich
2023-11-20  3:28                     ` Hu, Lin1
2023-11-20  8:34                       ` Jan Beulich
2023-11-14  2:58         ` [PATCH 1/2] Reorder APX insns in i386.tbl Hu, Lin1
2023-11-14 11:20           ` Jan Beulich
2023-11-15  1:49             ` Hu, Lin1
2023-11-15  8:52               ` Jan Beulich
2023-11-17  3:27                 ` Hu, Lin1
2023-11-02 11:29 ` [PATCH 8/8] Support APX JMPABS Cui, Lili
2023-11-09 12:59   ` Jan Beulich
2023-11-14  3:26     ` Hu, Lin1
2023-11-14 11:15       ` Jan Beulich
2023-11-24  5:40         ` Hu, Lin1
2023-11-24  7:21           ` Jan Beulich
2023-11-27  2:16             ` Hu, Lin1
2023-11-27  8:03               ` Jan Beulich
2023-11-27  8:46                 ` Hu, Lin1
2023-11-27  8:54                   ` Jan Beulich
2023-11-27  9:03                     ` Hu, Lin1
2023-11-27 10:32                       ` Jan Beulich
2023-12-04  7:33                         ` Hu, Lin1
2023-11-02 13:22 ` [PATCH v2 0/8] Support Intel APX EGPR Jan Beulich
2023-11-03 16:42   ` Cui, Lili
2023-11-06  7:30     ` Jan Beulich
2023-11-06 14:20       ` Cui, Lili
2023-11-06 14:44         ` Jan Beulich
2023-11-06 16:03           ` Cui, Lili
2023-11-06 16:10             ` Jan Beulich
2023-11-07  1:53               ` Cui, Lili
2023-11-07 10:11                 ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3f4c04c-58ec-4214-9e58-cfc6af0f96f7@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=ccoutant@gmail.com \
    --cc=hongjiu.lu@intel.com \
    --cc=lili.cui@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).