[PATCH] x86/APX: add CMPcc/CTESTcc cases to noreg64 tests
Cui, Lili
lili.cui@intel.com
Mon Jul 15 14:21:07 GMT 2024
> This was missed when support for the insns was added. Just like for DATA16,
> in
>
> rex64 neg (%rax)
> rex64 neg (%r16)
> rex64 {nf} neg (%rax)
>
> it is not logical why the last one shouldn't be permitted. Bypassing that check
> requires other adjustments, though, to actually properly consume (and then
> squash) the prefix.
> ---
> While one could argue that other REX prefix forms should then also be
> permitted, they'd be of limited usefulness: That way only half of the register
> bits could be controlled, which would continue to be inconsistent (then in
> itself).
>
Looks good, thanks.
Lili.
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -4403,19 +4403,32 @@ build_rex2_prefix (void) static bool
> build_apx_evex_prefix (void) {
> - /* To mimic behavior for legacy insns, transform use of DATA16 into its
> - embedded-prefix representation. */
> - if (i.prefix[DATA_PREFIX] && i.tm.opcode_space == SPACE_EVEXMAP4)
> - {
> - if (i.tm.opcode_modifier.opcodeprefix)
> - {
> - as_bad (i.tm.opcode_modifier.opcodeprefix == PREFIX_0X66
> - ? _("same type of prefix used twice")
> - : _("conflicting use of `data16' prefix"));
> - return false;
> + /* To mimic behavior for legacy insns, transform use of DATA16 and REX64
> into
> + their embedded-prefix representations. */
> + if (i.tm.opcode_space == SPACE_EVEXMAP4)
> + {
> + if (i.prefix[DATA_PREFIX])
> + {
> + if (i.tm.opcode_modifier.opcodeprefix)
> + {
> + as_bad (i.tm.opcode_modifier.opcodeprefix == PREFIX_0X66
> + ? _("same type of prefix used twice")
> + : _("conflicting use of `data16' prefix"));
> + return false;
> + }
> + i.tm.opcode_modifier.opcodeprefix = PREFIX_0X66;
> + i.prefix[DATA_PREFIX] = 0;
> + }
> + if (i.prefix[REX_PREFIX] & REX_W)
> + {
> + if (i.suffix == QWORD_MNEM_SUFFIX)
> + {
> + as_bad (_("same type of prefix used twice"));
> + return false;
> + }
> + i.tm.opcode_modifier.vexw = VEXW1;
> + i.prefix[REX_PREFIX] = 0;
> }
> - i.tm.opcode_modifier.opcodeprefix = PREFIX_0X66;
> - i.prefix[DATA_PREFIX] = 0;
> }
>
> build_evex_prefix ();
> @@ -7817,7 +7830,12 @@ md_assemble (char *line)
> }
>
> /* Check for explicit REX prefix. */
> - if (i.prefix[REX_PREFIX] || i.rex_encoding)
> + if ((i.prefix[REX_PREFIX]
> + && (i.tm.opcode_space != SPACE_EVEXMAP4
> + /* To mimic behavior for legacy insns, permit use of REX64 for
> promoted
> + legacy instructions. */
> + || i.prefix[REX_PREFIX] != (REX_OPCODE | REX_W)))
> + || i.rex_encoding)
> {
> as_bad (_("REX prefix invalid with `%s'"), insn_name (&i.tm));
> return;
> --- a/gas/testsuite/gas/i386/noreg-intel64.l
> +++ b/gas/testsuite/gas/i386/noreg-intel64.l
> @@ -31,6 +31,14 @@
> .*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Warning: .* `bts'
> .*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ccmpa'
> +.*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ccmpa'
> +.*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ccmpa'
> +.*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ccmpa'
> +.*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Warning: .* `cmp'
> .*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Warning: .* `cmp'
> @@ -48,6 +56,12 @@
> .*:[1-9][0-9]*: Warning: .* `crc32'
> .*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ctesta'
> +.*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ctesta'
> +.*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ctesta'
> +.*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Warning: .* `dec'
> .*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Warning: .* `div'
> --- a/gas/testsuite/gas/i386/noreg64.d
> +++ b/gas/testsuite/gas/i386/noreg64.d
> @@ -24,6 +24,10 @@ Disassembly of section .text:
> *[a-f0-9]+: 0f ba 30 01 btrl \$0x1,\(%rax\)
> *[a-f0-9]+: 0f ba 28 01 btsl \$0x1,\(%rax\)
> *[a-f0-9]+: ff 10 call \*\(%rax\)
> + *[a-f0-9]+: 62 f4 04 07 83 38 01 ccmpal \{dfv=\} \$0x1,\(%rax\)
> + *[a-f0-9]+: 62 f4 04 07 81 38 89 00 00 00 ccmpal \{dfv=\}
> \$0x89,\(%rax\)
> + *[a-f0-9]+: 62 f4 04 07 81 38 34 12 00 00 ccmpal \{dfv=\}
> \$0x1234,\(%rax\)
> + *[a-f0-9]+: 62 f4 04 07 81 38 78 56 34 12 ccmpal \{dfv=\}
> \$0x12345678,\(%rax\)
> *[a-f0-9]+: 83 38 01 cmpl \$0x1,\(%rax\)
> *[a-f0-9]+: 81 38 89 00 00 00 cmpl \$0x89,\(%rax\)
> *[a-f0-9]+: 81 38 34 12 00 00 cmpl \$0x1234,\(%rax\)
> @@ -32,6 +36,9 @@ Disassembly of section .text:
> *[a-f0-9]+: a7 cmpsl %es:\(%rdi\),%ds:\(%rsi\)
> *[a-f0-9]+: f2 0f 38 f1 00 crc32l \(%rax\),%eax
> *[a-f0-9]+: f2 48 0f 38 f1 00 crc32q \(%rax\),%rax
> + *[a-f0-9]+: 62 f4 04 07 f7 00 89 00 00 00 ctestal \{dfv=\}
> \$0x89,\(%rax\)
> + *[a-f0-9]+: 62 f4 04 07 f7 00 34 12 00 00 ctestal \{dfv=\}
> \$0x1234,\(%rax\)
> + *[a-f0-9]+: 62 f4 04 07 f7 00 78 56 34 12 ctestal \{dfv=\}
> \$0x12345678,\(%rax\)
> *[a-f0-9]+: ff 08 decl \(%rax\)
> *[a-f0-9]+: f7 30 divl \(%rax\)
> *[a-f0-9]+: d8 00 fadds \(%rax\)
> --- a/gas/testsuite/gas/i386/noreg64.l
> +++ b/gas/testsuite/gas/i386/noreg64.l
> @@ -31,6 +31,14 @@
> .*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Warning: .* `bts'
> .*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ccmpa'
> +.*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ccmpa'
> +.*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ccmpa'
> +.*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ccmpa'
> +.*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Warning: .* `cmp'
> .*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Warning: .* `cmp'
> @@ -48,6 +56,12 @@
> .*:[1-9][0-9]*: Warning: .* `crc32'
> .*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ctesta'
> +.*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ctesta'
> +.*:[1-9][0-9]*: Info: .*
> +.*:[1-9][0-9]*: Warning: .* `ctesta'
> +.*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Warning: .* `dec'
> .*:[1-9][0-9]*: Info: .*
> .*:[1-9][0-9]*: Warning: .* `div'
> --- a/gas/testsuite/gas/i386/noreg64.s
> +++ b/gas/testsuite/gas/i386/noreg64.s
> @@ -41,6 +41,10 @@ noreg:
> pfx btr $1, (%rax)
> pfx bts $1, (%rax)
> pfx call *(%rax)
> + pfx ccmpa $1, (%rax)
> + pfx ccmpa $0x89, (%rax)
> + pfx ccmpa $0x1234, (%rax)
> + pfx ccmpa $0x12345678, (%rax)
> pfx cmp $1, (%rax)
> pfx cmp $0x89, (%rax)
> pfx cmp $0x1234, (%rax)
> @@ -49,6 +53,9 @@ noreg:
> pfx cmps %es:(%rdi), (%rsi)
> pfx crc32 (%rax), %eax
> pfx16 crc32 (%rax), %rax
> + pfx ctesta $0x89, (%rax)
> + pfx ctesta $0x1234, (%rax)
> + pfx ctesta $0x12345678, (%rax)
> pfx dec (%rax)
> pfx div (%rax)
> pfx fadd (%rax)
> --- a/gas/testsuite/gas/i386/noreg64-data16.d
> +++ b/gas/testsuite/gas/i386/noreg64-data16.d
> @@ -26,6 +26,10 @@ Disassembly of section .text:
> *[a-f0-9]+: 66 0f ba 30 01 btrw \$0x1,\(%rax\)
> *[a-f0-9]+: 66 0f ba 28 01 btsw \$0x1,\(%rax\)
> *[a-f0-9]+: 66 ff 10 callw \*\(%rax\)
> + *[a-f0-9]+: 62 f4 05 07 83 38 01[ ]+ccmpaw \{dfv=\} \$0x1,\(%rax\)
> + *[a-f0-9]+: 62 f4 05 07 81 38 89 00[ ]+ccmpaw \{dfv=\} \$0x89,\(%rax\)
> + *[a-f0-9]+: 62 f4 05 07 81 38 34 12[ ]+ccmpaw \{dfv=\} \$0x1234,\(%rax\)
> + *[a-f0-9]+: 62 f4 05 07 81 38 78 56[ ]+ccmpaw \{dfv=\} \$0x5678,\(%rax\)
> *[a-f0-9]+: 66 83 38 01 cmpw \$0x1,\(%rax\)
> *[a-f0-9]+: 66 81 38 89 00 cmpw \$0x89,\(%rax\)
> *[a-f0-9]+: 66 81 38 34 12 cmpw \$0x1234,\(%rax\)
> @@ -34,6 +38,9 @@ Disassembly of section .text:
> *[a-f0-9]+: 66 a7 cmpsw %es:\(%rdi\),%ds:\(%rsi\)
> *[a-f0-9]+: 66 f2 0f 38 f1 00 crc32w \(%rax\),%eax
> *[a-f0-9]+: 66 f2 48 0f 38 f1 00 data16 crc32q \(%rax\),%rax
> + *[a-f0-9]+: 62 f4 05 07 f7 00 89 00[ ]+ctestaw \{dfv=\} \$0x89,\(%rax\)
> + *[a-f0-9]+: 62 f4 05 07 f7 00 34 12[ ]+ctestaw \{dfv=\} \$0x1234,\(%rax\)
> + *[a-f0-9]+: 62 f4 05 07 f7 00 78 56[ ]+ctestaw \{dfv=\} \$0x5678,\(%rax\)
> *[a-f0-9]+: 66 ff 08 decw \(%rax\)
> *[a-f0-9]+: 66 f7 30 divw \(%rax\)
> *[a-f0-9]+: 66 d8 00 data16 fadds \(%rax\)
> --- a/gas/testsuite/gas/i386/noreg64-data16.e
> +++ b/gas/testsuite/gas/i386/noreg64-data16.e
> @@ -8,14 +8,18 @@
> .*:3: Warning: .*shortened.*
> .*:47: Info: .*
> .*:3: Warning: .*shortened.*
> -.*:99: Info: .*
> +.*:51: Info: .*
> .*:3: Warning: .*shortened.*
> -.*:117: Info: .*
> +.*:58: Info: .*
> .*:3: Warning: .*shortened.*
> -.*:146: Info: .*
> +.*:106: Info: .*
> .*:3: Warning: .*shortened.*
> -.*:170: Info: .*
> +.*:124: Info: .*
> .*:3: Warning: .*shortened.*
> -.*:175: Info: .*
> +.*:153: Info: .*
> .*:3: Warning: .*shortened.*
> -.*:179: Info: .*
> +.*:177: Info: .*
> +.*:3: Warning: .*shortened.*
> +.*:182: Info: .*
> +.*:3: Warning: .*shortened.*
> +.*:186: Info: .*
> --- a/gas/testsuite/gas/i386/noreg64-rex64.d
> +++ b/gas/testsuite/gas/i386/noreg64-rex64.d
> @@ -25,6 +25,10 @@ Disassembly of section .text:
> *[a-f0-9]+: 48 0f ba 30 01 btrq \$0x1,\(%rax\)
> *[a-f0-9]+: 48 0f ba 28 01 btsq \$0x1,\(%rax\)
> *[a-f0-9]+: 48 ff 10 rex\.W call \*\(%rax\)
> + *[a-f0-9]+: 62 f4 84 07 83 38 01[ ]+ccmpaq \{dfv=\} \$0x1,\(%rax\)
> + *[a-f0-9]+: 62 f4 84 07 81 38 89 00 00 00[ ]+ccmpaq \{dfv=\}
> \$0x89,\(%rax\)
> + *[a-f0-9]+: 62 f4 84 07 81 38 34 12 00 00[ ]+ccmpaq \{dfv=\}
> \$0x1234,\(%rax\)
> + *[a-f0-9]+: 62 f4 84 07 81 38 78 56 34 12[ ]+ccmpaq \{dfv=\}
> \$0x12345678,\(%rax\)
> *[a-f0-9]+: 48 83 38 01 cmpq \$0x1,\(%rax\)
> *[a-f0-9]+: 48 81 38 89 00 00 00 cmpq \$0x89,\(%rax\)
> *[a-f0-9]+: 48 81 38 34 12 00 00 cmpq \$0x1234,\(%rax\)
> @@ -32,6 +36,9 @@ Disassembly of section .text:
> *[a-f0-9]+: 48 a7 cmpsq %es:\(%rdi\),%ds:\(%rsi\)
> *[a-f0-9]+: 48 a7 cmpsq %es:\(%rdi\),%ds:\(%rsi\)
> *[a-f0-9]+: f2 48 0f 38 f1 00 crc32q \(%rax\),%rax
> + *[a-f0-9]+: 62 f4 84 07 f7 00 89 00 00 00[ ]+ctestaq \{dfv=\}
> \$0x89,\(%rax\)
> + *[a-f0-9]+: 62 f4 84 07 f7 00 34 12 00 00[ ]+ctestaq \{dfv=\}
> \$0x1234,\(%rax\)
> + *[a-f0-9]+: 62 f4 84 07 f7 00 78 56 34 12[ ]+ctestaq \{dfv=\}
> \$0x12345678,\(%rax\)
> *[a-f0-9]+: 48 ff 08 decq \(%rax\)
> *[a-f0-9]+: 48 f7 30 divq \(%rax\)
> *[a-f0-9]+: 48 d8 00 rex\.W fadds \(%rax\)
More information about the Binutils
mailing list