From patchwork Thu Dec 1 14:35:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul-Antoine Arras X-Patchwork-Id: 61320 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 77FF63858024 for ; Thu, 1 Dec 2022 14:36:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id C778E3858421 for ; Thu, 1 Dec 2022 14:35:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C778E3858421 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.96,209,1665475200"; d="scan'208,223";a="88285998" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 01 Dec 2022 06:35:39 -0800 IronPort-SDR: TicMcwOZhbC+BKLsudxEzSsKNdY2tH8Ty1ytPEabxlbd3EI0ptIwzVRqhX/o+EwTGn2iwt8has tBJKCW4zEF5cx/kheK6v7MlWpoheF90zO1pTZZBa/+nWQv5HIdksMJPrMJch8t5MfBfiXkFPDu XHAZgqI+kN/Z8SxgkgZkoAkksmlx1O9P3bMiwYY3OzzD0dYppNgrx5UABkeu/D1qrgvFLgQ4bK +WuwuYVxblJz12eupbGG2xKXr/T5deKj3tIY5zfK9XF9N4qq7xGyK0GknWj3ArD/ohQy4eQTe9 OD8= Message-ID: Date: Thu, 1 Dec 2022 15:35:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: [PATCH] amdgcn: Add preprocessor builtins for every processor type Content-Language: en-GB To: Andrew Stubbs , Kwok Cheung Yeung CC: gcc-patches References: <202ee18b-90c8-830b-82a5-b705a9ec5c73@gmail.com> <82a884ed-ea1d-5116-fedf-42de6e22e730@codesourcery.com> <0600a1e2-d877-6522-15a9-0e5d0219a76b@codesourcery.com> From: Paul-Antoine Arras In-Reply-To: <0600a1e2-d877-6522-15a9-0e5d0219a76b@codesourcery.com> X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, BODY_8BITS, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi Andrew, all, On 01/12/2022 13:45, Andrew Stubbs wrote: > On 01/12/2022 11:10, Paul-Antoine Arras wrote: >> +      if >> (TARGET_FIJI)                                                         \ >> +    builtin_define >> ("__FIJI__");                                           \ >> +      else if >> (TARGET_VEGA10)                                                  \ >> +    builtin_define >> ("__VEGA10__");                                         \ >> +      else if >> (TARGET_VEGA20)                                                  \ >> +    builtin_define >> ("__VEGA20__");                                         \ >> +      else if >> (TARGET_GFX908)                                                  \ >> +    builtin_define >> ("__GFX908__");                                         \ >> +      else if >> (TARGET_GFX90a)                                                  \ >> +    builtin_define >> ("__GFX90a__");                                         \ >> +  } while (0) >> > > I don't think it makes sense to say __VEGA10__ when the user asked for > -march=gfx900. > > This whole naming thing is a bit of a mess already, so I think we'd do > better to either keep the same names throughout or match what LLVM does > (since it got to these first). > > Please use "__gfx900__" etc. (lower case). > > [...] > > P.S. If you want to split the patch into the GCN bits and the bits that > depend on metadirectives then we can apply the first part to mainline > right away. I believe this patch addresses your comments regarding the GCN bits. The new builtins are consistent with the LLVM naming convention (lower case, canonical name). For gfx803, I also kept '__fiji__' to be consistent with -march=fiji. Is it OK for mainline? Thanks, diff --git gcc/config/gcn/gcn-opts.h gcc/config/gcn/gcn-opts.h index b62dfb45f59..b54eae79faf 100644 --- gcc/config/gcn/gcn-opts.h +++ gcc/config/gcn/gcn-opts.h @@ -27,6 +27,12 @@ enum processor_type PROCESSOR_GFX90a }; +#define TARGET_FIJI (gcn_arch == PROCESSOR_FIJI) +#define TARGET_VEGA10 (gcn_arch == PROCESSOR_VEGA10) +#define TARGET_VEGA20 (gcn_arch == PROCESSOR_VEGA20) +#define TARGET_GFX908 (gcn_arch == PROCESSOR_GFX908) +#define TARGET_GFX90a (gcn_arch == PROCESSOR_GFX90a) + /* Set in gcn_option_override. */ extern enum gcn_isa { ISA_UNKNOWN, diff --git gcc/config/gcn/gcn.h gcc/config/gcn/gcn.h index 38f7212db59..1cc5981d904 100644 --- gcc/config/gcn/gcn.h +++ gcc/config/gcn/gcn.h @@ -16,20 +16,32 @@ #include "config/gcn/gcn-opts.h" -#define TARGET_CPU_CPP_BUILTINS() \ - do \ - { \ - builtin_define ("__AMDGCN__"); \ - if (TARGET_GCN3) \ - builtin_define ("__GCN3__"); \ - else if (TARGET_GCN5) \ - builtin_define ("__GCN5__"); \ - else if (TARGET_CDNA1) \ - builtin_define ("__CDNA1__"); \ - else if (TARGET_CDNA2) \ - builtin_define ("__CDNA2__"); \ - } \ - while(0) +#define TARGET_CPU_CPP_BUILTINS() \ + do \ + { \ + builtin_define ("__AMDGCN__"); \ + if (TARGET_GCN3) \ + builtin_define ("__GCN3__"); \ + else if (TARGET_GCN5) \ + builtin_define ("__GCN5__"); \ + else if (TARGET_CDNA1) \ + builtin_define ("__CDNA1__"); \ + else if (TARGET_CDNA2) \ + builtin_define ("__CDNA2__"); \ + if (TARGET_FIJI) \ + { \ + builtin_define ("__fiji__"); \ + builtin_define ("__gfx803__"); \ + } \ + else if (TARGET_VEGA10) \ + builtin_define ("__gfx900__"); \ + else if (TARGET_VEGA20) \ + builtin_define ("__gfx906__"); \ + else if (TARGET_GFX908) \ + builtin_define ("__gfx908__"); \ + else if (TARGET_GFX90a) \ + builtin_define ("__gfx90a__"); \ + } while (0) /* Support for a compile-time default architecture and tuning. The rules are: