public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Paul-Antoine Arras <parras@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-12] amdgcn: Add preprocessor builtins for every processor type
Date: Tue,  6 Dec 2022 13:57:43 +0000 (GMT)	[thread overview]
Message-ID: <20221206135743.56E00384C90B@sourceware.org> (raw)

https://gcc.gnu.org/g:a8db05dcf5819c7ddd5c71da40bb08a533551ae9

commit a8db05dcf5819c7ddd5c71da40bb08a533551ae9
Author: Paul-Antoine Arras <pa@codesourcery.com>
Date:   Thu Dec 1 15:09:54 2022 +0100

    amdgcn: Add preprocessor builtins for every processor type
    
    Provide a specific builtin for each possible value of '-march'.
    
    gcc/ChangeLog:
    
            * config/gcn/gcn-opts.h (TARGET_FIJI): -march=fiji.
            (TARGET_VEGA10): -march=gfx900.
            (TARGET_VEGA20): -march=gfx906.
            (TARGET_GFX908): -march=gfx908.
            (TARGET_GFX90a): -march=gfx90a.
            * config/gcn/gcn.h (TARGET_CPU_CPP_BUILTINS): Define a builtin that
            uniquely maps to '-march'.
    
    (cherry picked from commit e41b243302e9964e642924329826448afb21d28e)

Diff:
---
 gcc/ChangeLog.omp         | 13 +++++++++++++
 gcc/config/gcn/gcn-opts.h |  6 ++++++
 gcc/config/gcn/gcn.h      | 40 ++++++++++++++++++++++++++--------------
 3 files changed, 45 insertions(+), 14 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index b6204f7c760..bde15e5700a 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,16 @@
+2022-12-06  Paul-Antoine Arras <pa@codesourcery.com>
+
+	Backported from master:
+	2022-12-01  Paul-Antoine Arras <pa@codesourcery.com>
+
+	* config/gcn/gcn-opts.h (TARGET_FIJI): -march=fiji.
+	(TARGET_VEGA10): -march=gfx900.
+	(TARGET_VEGA20): -march=gfx906.
+	(TARGET_GFX908): -march=gfx908.
+	(TARGET_GFX90a): -march=gfx90a.
+	* config/gcn/gcn.h (TARGET_CPU_CPP_BUILTINS): Define a builtin that
+	uniquely maps to '-march'.
+
 2022-11-30  Paul-Antoine Arras <pa@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/config/gcn/gcn-opts.h b/gcc/config/gcn/gcn-opts.h
index 07ddc79cda3..fb7e5d9a5e9 100644
--- a/gcc/config/gcn/gcn-opts.h
+++ b/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 a/gcc/config/gcn/gcn.h b/gcc/config/gcn/gcn.h
index 38f7212db59..1cc5981d904 100644
--- a/gcc/config/gcn/gcn.h
+++ b/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:

                 reply	other threads:[~2022-12-06 13:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221206135743.56E00384C90B@sourceware.org \
    --to=parras@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).