public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: "binutils@sourceware.org" <binutils@sourceware.org>
Subject: Re: [PATCH v5 4/5] x86: correct VFPCLASSP{S,D} operand size handling
Date: Tue, 11 Feb 2020 12:49:00 -0000	[thread overview]
Message-ID: <ceab37e4-d1a0-6a4c-edb1-c4ba819f069e@suse.com> (raw)
In-Reply-To: <CAMe9rOrCjYWbEF4=_G0cH5J0Dj8DkOPaHCCN+L80iZrPMyYS9Q@mail.gmail.com>

On 11.02.2020 12:49, H.J. Lu wrote:
> On Tue, Feb 11, 2020 at 2:26 AM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> With AVX512VL disabled (e.g. when writing code for the Knights family
>> of processors) these insns aren't ambiguous when used with a memory
>> source, and hence should be accepted without suffix or operand size
>> specifier. When AVX512VL is enabled, to be consistent with this as
>> well as other ambiguous operand size handling it would seem better to
>> just warn about the ambiguity in AT&T mode, and still default to 512-bit
>> operands (on the assumption that the code may have been written without
>> AVX512VL in mind yet), but it was requested to leave AT&T syntax mode
>> alone here.
>>
>> gas/
>> 2020-02-XX  Jan Beulich  <jbeulich@suse.com>
>>
>>         * config/tc-i386.c (avx512): New (at file scope), moved from
>>         (check_VecOperands): ... here.
>>         (process_suffix): Add [XYZ]MMword operand size handling.
>>         * testsuite/gas/i386/avx512dq-inval.s: Add VFPCLASS tests.
>>         * testsuite/gas/i386/noavx512-2.s: Add Intel syntax VFPCLASS
>>         tests.
>>         * testsuite/gas/i386/avx512dq-inval.l,
>>         testsuite/gas/i386/noavx512-2.l: Adjust expectations.
>>
>> opcodes/
>> 2020-02-XX  Jan Beulich  <jbeulich@suse.com>
>>
>>         * i386-opc.tbl (vfpclasspd, vfpclassps): Add Intel sytax form
>>         with Unspecified, making the present one AT&T syntax only.
>>         * i386-tbl.h: Re-generate.
>> ---
>> v5: Re-base.
>> v4: Restrict to just Intel syntax mode. Re-base.
>> v3: Re-base.
>>
>> --- a/gas/config/tc-i386.c
>> +++ b/gas/config/tc-i386.c
>> @@ -1840,6 +1840,8 @@ cpu_flags_and_not (i386_cpu_flags x, i38
>>    return x;
>>  }
>>
>> +static const i386_cpu_flags avx512 = CPU_ANY_AVX512F_FLAGS;
>> +
>>  #define CPU_FLAGS_ARCH_MATCH           0x1
>>  #define CPU_FLAGS_64BIT_MATCH          0x2
>>
>> @@ -5352,7 +5354,6 @@ check_VecOperands (const insn_template *
>>  {
>>    unsigned int op;
>>    i386_cpu_flags cpu;
>> -  static const i386_cpu_flags avx512 = CPU_ANY_AVX512F_FLAGS;
>>
>>    /* Templates allowing for ZMMword as well as YMMword and/or XMMword for
>>       any one operand are implicity requiring AVX512VL support if the actual
>> @@ -6447,7 +6448,8 @@ process_suffix (void)
>>        /* Accept FLDENV et al without suffix.  */
>>        && (i.tm.opcode_modifier.no_ssuf || i.tm.opcode_modifier.floatmf))
>>      {
>> -      unsigned int suffixes;
>> +      unsigned int suffixes, evex = 0;
>> +      i386_cpu_flags cpu;
>>
>>        suffixes = !i.tm.opcode_modifier.no_bsuf;
>>        if (!i.tm.opcode_modifier.no_wsuf)
>> @@ -6461,7 +6463,55 @@ process_suffix (void)
>>        if (flag_code == CODE_64BIT && !i.tm.opcode_modifier.no_qsuf)
>>         suffixes |= 1 << 5;
>>
>> -      /* Are multiple suffixes allowed?  */
>> +      /* For [XYZ]MMWORD operands inspect operand sizes.  */
>> +      cpu = cpu_flags_and (i.tm.cpu_flags, avx512);
>> +      if (!cpu_flags_all_zero (&cpu) && !i.broadcast)
>> +       {
>> +         unsigned int op;
>> +
>> +         for (op = 0; op < i.tm.operands; ++op)
>> +           {
>> +             if (!cpu_arch_flags.bitfield.cpuavx512vl)
>> +               {
>> +                 if (i.tm.operand_types[op].bitfield.ymmword)
>> +                   i.tm.operand_types[op].bitfield.xmmword = 0;
>> +                 if (i.tm.operand_types[op].bitfield.zmmword)
>> +                   i.tm.operand_types[op].bitfield.ymmword = 0;
>> +                 if (!i.tm.opcode_modifier.evex
>> +                     || i.tm.opcode_modifier.evex == EVEXDYN)
>> +                   i.tm.opcode_modifier.evex = EVEX512;
>> +               }
>> +
>> +             if (i.tm.operand_types[op].bitfield.xmmword
>> +                 + i.tm.operand_types[op].bitfield.ymmword
>> +                 + i.tm.operand_types[op].bitfield.zmmword < 2)
>> +               continue;
>> +
>> +             /* Any properly sized operand disambiguates the insn.  */
>> +             if (i.types[op].bitfield.xmmword
>> +                 || i.types[op].bitfield.ymmword
>> +                 || i.types[op].bitfield.zmmword)
>> +               {
>> +                 suffixes &= ~(7 << 6);
>> +                 evex = 0;
>> +                 break;
>> +               }
>> +
>> +             if ((i.flags[op] & Operand_Mem)
>> +                 && i.tm.operand_types[op].bitfield.unspecified)
>> +               {
>> +                 if (i.tm.operand_types[op].bitfield.xmmword)
>> +                   suffixes |= 1 << 6;
>> +                 if (i.tm.operand_types[op].bitfield.ymmword)
>> +                   suffixes |= 1 << 7;
>> +                 if (i.tm.operand_types[op].bitfield.zmmword)
>> +                   suffixes |= 1 << 8;
>> +                 evex = EVEX512;
>> +               }
>> +           }
>> +       }
>> +
>> +      /* Are multiple suffixes / operand sizes allowed?  */
>>        if (suffixes & (suffixes - 1))
>>         {
>>           if (intel_syntax
>> @@ -6491,6 +6541,8 @@ process_suffix (void)
>>                    || (i.tm.base_opcode == 0x63
>>                        && i.tm.cpu_flags.bitfield.cpu64))
>>             /* handled below */;
>> +         else if (evex)
>> +           i.tm.opcode_modifier.evex = evex;
>>           else if (flag_code == CODE_16BIT)
>>             i.suffix = WORD_MNEM_SUFFIX;
>>           else if (!i.tm.opcode_modifier.no_lsuf)
> 
> So this change only impacts Intel syntax with AVX512VL disabled.  Why
> are there so many
> assembler changes?

There aren't "many" changes, it's just one larger block of code that
needs adding (paralleling the suffix checking for GPR(-like) operands).

>  If they are really needed, can you make them
> conditioned on Intel
> syntax?

Well, that block of code is the meat of the change, so yes, it is
needed. Some of what it does may also be beneficial for AT&T mode,
but yes, I think I can make all of it Intel-syntax only (with a
comment saying why this is).

Jan

  reply	other threads:[~2020-02-11 12:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11 10:23 [PATCH v5 0/5] x86: operand size handling improvements Jan Beulich
2020-02-11 10:25 ` [PATCH v5 1/5] x86: also disallow non-byte/-word registers with byte/word suffix Jan Beulich
2020-02-11 11:27   ` H.J. Lu
2020-02-11 10:25 ` [PATCH v5 3/5] x86: replace adhoc (partly wrong) ambiguous operand checking for MOVSX/MOVZX Jan Beulich
2020-02-11 10:25 ` [PATCH v5 2/5] x86: move certain MOVSX/MOVZX tests Jan Beulich
2020-02-11 11:43   ` H.J. Lu
2020-02-11 11:55     ` Jan Beulich
2020-02-11 12:20       ` H.J. Lu
2020-02-11 12:58         ` Jan Beulich
2020-02-11 13:02           ` H.J. Lu
2020-02-11 13:04             ` Jan Beulich
2020-02-11 13:07               ` H.J. Lu
2020-02-11 16:45                 ` Jan Beulich
2020-02-11 17:04                   ` H.J. Lu
2020-02-11 20:12                     ` [PATCH] x86: Remove movsx/movzx with memory operand from AT&T syntax H.J. Lu
2020-02-11 23:34                       ` H.J. Lu
2020-02-11 23:52                         ` H.J. Lu
2020-02-12  3:19                           ` [PATCH] x86: Remove movsx/movzx with 16/32-bit " H.J. Lu
2020-02-12  9:19                             ` Jan Beulich
2020-02-11 10:26 ` [PATCH v5 4/5] x86: correct VFPCLASSP{S,D} operand size handling Jan Beulich
2020-02-11 11:50   ` H.J. Lu
2020-02-11 12:49     ` Jan Beulich [this message]
2020-02-11 12:56       ` H.J. Lu
2020-02-11 10:27 ` [PATCH v5 5/5] x86-64: Intel64 adjustments for insns dealing with far pointers Jan Beulich
2020-02-11 11:53   ` H.J. Lu
2020-02-12  8: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=ceab37e4-d1a0-6a4c-edb1-c4ba819f069e@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.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).