public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] i386: support micro-levels in target{,_clone} attrs [PR101696]
Date: Thu, 12 Aug 2021 17:22:55 +0200	[thread overview]
Message-ID: <18b1cf5b-a80c-fc00-e638-2f5b5d4136a9@suse.cz> (raw)
In-Reply-To: <CAMe9rOpdkD1KLjTwFPH7teEZFUbifNBWMnHLd+6DYc=rgv=3DA@mail.gmail.com>

On 8/12/21 4:51 PM, H.J. Lu wrote:
> On Thu, Aug 12, 2021 at 7:39 AM Martin Liška <mliska@suse.cz> wrote:
>>
>> On 8/12/21 4:25 PM, H.J. Lu wrote:
>>> Please send out the v2 patch with the enclosed patch.  I added some tests.
>>
>> Thanks, there's patch which includes your changes.
>>
>> Martin
> 
> diff --git a/gcc/common/config/i386/i386-isas.h
> b/gcc/common/config/i386/i386-isas.h
> index 898c18f3dda..cd9523b8fbc 100644
> --- a/gcc/common/config/i386/i386-isas.h
> +++ b/gcc/common/config/i386/i386-isas.h
> @@ -169,4 +169,8 @@ ISA_NAMES_TABLE_START
>     ISA_NAMES_TABLE_ENTRY("aeskle", FEATURE_AESKLE, P_NONE, NULL)
>     ISA_NAMES_TABLE_ENTRY("widekl", FEATURE_WIDEKL, P_NONE, "-mwidekl")
>     ISA_NAMES_TABLE_ENTRY("avxvnni", FEATURE_AVXVNNI, P_NONE, "-mavxvnni")
> +  ISA_NAMES_TABLE_ENTRY("x86-64", FEATURE_X86_64_BASELINE, P_NONE, NULL)
> +  ISA_NAMES_TABLE_ENTRY("x86-64-v2", FEATURE_X86_64_V2, P_NONE, NULL)
> +  ISA_NAMES_TABLE_ENTRY("x86-64-v3", FEATURE_X86_64_V3, P_NONE, NULL)
> +  ISA_NAMES_TABLE_ENTRY("x86-64-v4", FEATURE_X86_64_V4, P_NONE, NULL)
> 
> If they have proper feature_priority, can you avoid

I don't think so. First we likely want supporting "arch=x86-64-v3" rather than
"x86-64-v3" in e.g. 'target' attribute. That means a special handling by the code
I added.

The following fails as there's no corresponding -m$option.

pr101696.c:5:45: error: attribute ‘x86-64-v4’ argument ‘target’ is unknown

     5 | __attribute__ ((target ("x86-64-v4"))) void foo () {  __builtin_printf ("arch=x86-64-v4\n"); }

       |                                             ^~~


Or do I miss something and we can do it in a simpler way?

Cheers,
Martin

> 
> iff --git a/gcc/config/i386/i386-builtins.c b/gcc/config/i386/i386-builtins.c
> index 204e2903126..492873bb076 100644
> --- a/gcc/config/i386/i386-builtins.c
> +++ b/gcc/config/i386/i386-builtins.c
> @@ -1904,8 +1904,24 @@ get_builtin_code_for_version (tree decl, tree
> *predicate_list)
>    return 0;
>         new_target = TREE_TARGET_OPTION (target_node);
>         gcc_assert (new_target);
> -
> -      if (new_target->arch_specified && new_target->arch > 0)
> +      enum ix86_builtins builtin_fn = IX86_BUILTIN_CPU_IS;
> +
> +      /* Special case x86-64 micro-level architectures.  */
> +      const char *arch_name = attrs_str + strlen ("arch=");
> +      if (startswith (arch_name, "x86-64"))
> + {
> +   arg_str = arch_name;
> +   builtin_fn = IX86_BUILTIN_CPU_SUPPORTS;
> +   if (strcmp (arch_name, "x86-64") == 0)
> +     priority = P_X86_64_BASELINE;
> +   else if (strcmp (arch_name, "x86-64-v2") == 0)
> +     priority = P_X86_64_V2;
> +   else if (strcmp (arch_name, "x86-64-v3") == 0)
> +     priority = P_X86_64_V3;
> +   else if (strcmp (arch_name, "x86-64-v4") == 0)
> +     priority = P_X86_64_V4;
> + }
> 
>         if (predicate_list)
>    {
> -          predicate_decl = ix86_builtins [(int) IX86_BUILTIN_CPU_IS];
> +   predicate_decl = ix86_builtins [(int) builtin_fn];
> 
> Is this required?
> 


  reply	other threads:[~2021-08-12 15:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 14:12 Martin Liška
2021-08-12 14:25 ` [PATCH] i386: support micro-levels in target{, _clone} " H.J. Lu
2021-08-12 14:39   ` [PATCH] i386: support micro-levels in target{,_clone} " Martin Liška
2021-08-12 14:51     ` [PATCH] i386: support micro-levels in target{, _clone} " H.J. Lu
2021-08-12 15:22       ` Martin Liška [this message]
2021-08-12 15:26         ` H.J. Lu
2021-08-12 15:31           ` [PATCH] i386: support micro-levels in target{,_clone} " Martin Liška
2021-08-12 17:35             ` [PATCH] i386: support micro-levels in target{, _clone} " H.J. Lu
2021-08-13  8:10               ` [PATCH] i386: support micro-levels in target{,_clone} " Martin Liška
2021-08-13 13:41                 ` [PATCH] i386: support micro-levels in target{, _clone} " H.J. Lu
2021-09-13 13:28                   ` [PATCH] i386: support micro-levels in target{,_clone} " Martin Liška
2021-09-13 14:36             ` [PATCH] i386: support micro-levels in target{, _clone} " Uros Bizjak

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=18b1cf5b-a80c-fc00-e638-2f5b5d4136a9@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.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).