From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 9DEB23853C21 for ; Thu, 12 Aug 2021 15:22:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9DEB23853C21 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7EB4F2198F; Thu, 12 Aug 2021 15:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628781776; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1kW6oGVbrH4RDF9ZwRIclMZxj+4fjeTLW5Tu4wKSA6o=; b=Bapsri+aZjEaVaLpSLsCoUbTlTLUoWXTmBWiwOZr4qJS54XkltxSkAWeQ8ORGpyHrSaKYN mGa+rEuoNz80NqIbmfQrsaix7NIS3VQrXYUWl34h8FNu21HKB0/4qYeJPogbzd1JL5uMxo BmYphxRBySiIte+aLQ9ZSZQcPrf+zrE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628781776; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1kW6oGVbrH4RDF9ZwRIclMZxj+4fjeTLW5Tu4wKSA6o=; b=F7eOIVYjZ6lpp20Y+jNkivW8j7nZJhOozpdg9MkohWIsM1wOgsiA8KIqzLyZjd+Yu1hvcG 5jeZmAuhTj9gyMBA== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 5A24613AC3; Thu, 12 Aug 2021 15:22:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id aEh6E9A8FWFvcQAAGKfGzw (envelope-from ); Thu, 12 Aug 2021 15:22:56 +0000 Subject: Re: [PATCH] i386: support micro-levels in target{,_clone} attrs [PR101696] To: "H.J. Lu" Cc: GCC Patches References: <09e4b2bd-2055-f0f8-e339-b1aeeff5176a@suse.cz> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <18b1cf5b-a80c-fc00-e638-2f5b5d4136a9@suse.cz> Date: Thu, 12 Aug 2021 17:22:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 15:23:08 -0000 On 8/12/21 4:51 PM, H.J. Lu wrote: > On Thu, Aug 12, 2021 at 7:39 AM Martin Liška 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? >