qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, amonakov@ispras.ru
Subject: Re: [PATCH 4/6] meson: allow configuring the x86-64 baseline
Date: Thu, 20 Jun 2024 15:55:21 +0100	[thread overview]
Message-ID: <ZnRC2cVcDSlKs72d@redhat.com> (raw)
In-Reply-To: <20240620130254.415699-5-pbonzini@redhat.com>

On Thu, Jun 20, 2024 at 03:02:52PM +0200, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  meson.build                   | 41 ++++++++++++++++++++++++++++-------
>  meson_options.txt             |  3 +++
>  scripts/meson-buildoptions.sh |  3 +++
>  3 files changed, 39 insertions(+), 8 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index 97e00d6f59b..6e694ecd9fe 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -336,15 +336,40 @@ if host_arch == 'i386' and not cc.links('''
>    qemu_common_flags = ['-march=i486'] + qemu_common_flags
>  endif
>  
> -# Assume x86-64-v2 (minus CMPXCHG16B for 32-bit code)
> -if host_arch == 'i386'
> -  qemu_common_flags = ['-mfpmath=sse'] + qemu_common_flags
> -endif
> +# Pick x86-64 baseline version
>  if host_arch in ['i386', 'x86_64']
> -  qemu_common_flags = ['-mpopcnt', '-msse4.2'] + qemu_common_flags
> -endif
> -if host_arch == 'x86_64'
> -  qemu_common_flags = ['-mcx16'] + qemu_common_flags
> +  if get_option('x86_version') == '0' and host_arch == 'x86_64'
> +    error('x86_64-v1 required for x86-64 hosts')
> +  endif
> +
> +  # add flags for individual instruction set extensions
> +  if get_option('x86_version') >= '1'
> +    if host_arch == 'i386'
> +      qemu_common_flags = ['-mfpmath=sse'] + qemu_common_flags
> +    else
> +      # present on basically all processors but technically not part of
> +      # x86-64-v1, so only include -mneeded for x86-64 version 2 and above
> +      qemu_common_flags = ['-mcx16'] + qemu_common_flags
> +    endif
> +  endif
> +  if get_option('x86_version') >= '2'
> +    qemu_common_flags = ['-mpopcnt'] + qemu_common_flags
> +    qemu_common_flags = cc.get_supported_arguments('-mneeded') + qemu_common_flags
> +  endif
> +  if get_option('x86_version') >= '3'
> +    qemu_common_flags = ['-mmovbe', '-mabm', '-mbmi1', '-mbmi2', '-mfma', '-mf16c'] + qemu_common_flags
> +  endif
> +
> +  # add required vector instruction set (each level implies those below)
> +  if get_option('x86_version') == '1'
> +    qemu_common_flags = ['-msse2'] + qemu_common_flags
> +  elif get_option('x86_version') == '2'
> +    qemu_common_flags = ['-msse4.2'] + qemu_common_flags
> +  elif get_option('x86_version') == '3'
> +    qemu_common_flags = ['-mavx2'] + qemu_common_flags
> +  elif get_option('x86_version') == '4'
> +    qemu_common_flags = ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl'] + qemu_common_flags
> +  endif
>  endif


Any particular reason you chose to list various instructions individually
rather than just ask GCC for the full ABI ? I'd think all of the above
condences down to just

  # add flags for individual instruction set extensions
  if get_option('x86_version') >= '1'
    if host_arch == 'i386'
      qemu_common_flags = ['-mfpmath=sse'] + qemu_common_flags
    else
      # present on basically all processors but technically not part of
      # x86-64-v1, so only include -mneeded for x86-64 version 2 and above
      qemu_common_flags = ['-mcx16'] + qemu_common_flags
    endif
  endif
  if get_option('x86_version') >= '2'
    qemu_common_flags = ['-march=x86-64-v' + get_option('x86_version'), '-mneeded'] + qemu_common_flags
  endif


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2024-06-20 14:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 13:02 [PATCH 0/6] host/i386: allow configuring the x86-64 baseline Paolo Bonzini
2024-06-20 13:02 ` [PATCH 1/6] Revert "host/i386: assume presence of POPCNT" Paolo Bonzini
2024-06-20 13:02 ` [PATCH 2/6] Revert "host/i386: assume presence of SSSE3" Paolo Bonzini
2024-06-20 13:02 ` [PATCH 3/6] Revert "host/i386: assume presence of SSE2" Paolo Bonzini
2024-06-20 13:02 ` [PATCH 4/6] meson: allow configuring the x86-64 baseline Paolo Bonzini
2024-06-20 14:55   ` Daniel P. Berrangé [this message]
2024-06-20 15:02     ` Paolo Bonzini
2024-06-20 17:16   ` Richard Henderson
2024-06-20 13:02 ` [PATCH 5/6] meson: remove dead optimization option Paolo Bonzini
2024-06-20 17:04   ` Richard Henderson
2024-06-20 13:02 ` [PATCH 6/6] meson: require compiler support for chosen x86-64 instructions Paolo Bonzini
2024-06-20 15:01   ` Daniel P. Berrangé
2024-06-20 15:08     ` Paolo Bonzini
2024-06-20 17:21     ` Richard Henderson
2024-06-20 17:37       ` Paolo Bonzini

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=ZnRC2cVcDSlKs72d@redhat.com \
    --to=berrange@redhat.com \
    --cc=amonakov@ispras.ru \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 NNTP newsgroup(s).