public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: hongtao.liu@intel.com, ubizjak@gmail.com
Subject: [PATCH] x86: Define macros for APX options
Date: Mon,  8 Apr 2024 08:43:50 -0700	[thread overview]
Message-ID: <20240408154350.1182471-1-hjl.tools@gmail.com> (raw)

Define following macros for APX options:

1. __APX_EGPR__: -mapx-features=egpr.
2. __APX_PUSH2POP2__: -mapx-features=push2pop2.
3. __APX_NDD__: -mapx-features=ndd.
4. __APX_PPX__: -mapx-features=ppx.
5. __APX_INLINE_ASM_USE_GPR32__: -mapx-inline-asm-use-gpr32.

They can be used to make assembly codes compatible with APX options.
Some use cases are:

1. When __APX_PUSH2POP2__ is defined, assembly codes should always align
the outgoing stack to 16 bytes.
2. When __APX_INLINE_ASM_USE_GPR32__ is defined, inline asm statements
should contain only instructions compatible with r16-r31.

gcc/

	PR target/114587
	* config/i386/i386-c.cc (ix86_target_macros_internal): Define
	__APX_XXX__ for APX options.

gcc/testsuite/

	PR target/114587
	* gcc.target/i386/apx-3a.c: New test.
	* gcc.target/i386/apx-3b.c: Likewise.
	* gcc.target/i386/apx-3c.c: Likewise.
	* gcc.target/i386/apx-3d.c: Likewise.
	* gcc.target/i386/apx-3e.c: Likewise.
	* gcc.target/i386/apx-4.c: Likewise.
---
 gcc/config/i386/i386-c.cc              | 10 ++++++++++
 gcc/testsuite/gcc.target/i386/apx-3a.c |  6 ++++++
 gcc/testsuite/gcc.target/i386/apx-3b.c |  6 ++++++
 gcc/testsuite/gcc.target/i386/apx-3c.c |  6 ++++++
 gcc/testsuite/gcc.target/i386/apx-3d.c |  6 ++++++
 gcc/testsuite/gcc.target/i386/apx-3e.c | 18 ++++++++++++++++++
 gcc/testsuite/gcc.target/i386/apx-4.c  |  6 ++++++
 7 files changed, 58 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/apx-3a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/apx-3b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/apx-3c.c
 create mode 100644 gcc/testsuite/gcc.target/i386/apx-3d.c
 create mode 100644 gcc/testsuite/gcc.target/i386/apx-3e.c
 create mode 100644 gcc/testsuite/gcc.target/i386/apx-4.c

diff --git a/gcc/config/i386/i386-c.cc b/gcc/config/i386/i386-c.cc
index 226d277676c..b8cfba90fdc 100644
--- a/gcc/config/i386/i386-c.cc
+++ b/gcc/config/i386/i386-c.cc
@@ -751,6 +751,16 @@ ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
     def_or_undef (parse_in, "__AVX10_1_512__");
   if (isa_flag2 & OPTION_MASK_ISA2_APX_F)
     def_or_undef (parse_in, "__APX_F__");
+  if (TARGET_APX_EGPR)
+    def_or_undef (parse_in, "__APX_EGPR__");
+  if (TARGET_APX_PUSH2POP2)
+    def_or_undef (parse_in, "__APX_PUSH2POP2__");
+  if (TARGET_APX_NDD)
+    def_or_undef (parse_in, "__APX_NDD__");
+  if (TARGET_APX_PPX)
+    def_or_undef (parse_in, "__APX_PPX__");
+  if (ix86_apx_inline_asm_use_gpr32)
+    def_or_undef (parse_in, "__APX_INLINE_ASM_USE_GPR32__");
   if (TARGET_IAMCU)
     {
       def_or_undef (parse_in, "__iamcu");
diff --git a/gcc/testsuite/gcc.target/i386/apx-3a.c b/gcc/testsuite/gcc.target/i386/apx-3a.c
new file mode 100644
index 00000000000..86d3ef2061d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/apx-3a.c
@@ -0,0 +1,6 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-mapx-features=egpr" } */
+
+#ifndef __APX_EGPR__
+# error __APX_EGPR__ not defined
+#endif
diff --git a/gcc/testsuite/gcc.target/i386/apx-3b.c b/gcc/testsuite/gcc.target/i386/apx-3b.c
new file mode 100644
index 00000000000..611727a389a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/apx-3b.c
@@ -0,0 +1,6 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-mapx-features=push2pop2" } */
+
+#ifndef __APX_PUSH2POP2__
+# error __APX_PUSH2POP2__ not defined
+#endif
diff --git a/gcc/testsuite/gcc.target/i386/apx-3c.c b/gcc/testsuite/gcc.target/i386/apx-3c.c
new file mode 100644
index 00000000000..52655b6cfa5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/apx-3c.c
@@ -0,0 +1,6 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-mapx-features=ndd" } */
+
+#ifndef __APX_NDD__
+# error __APX_NDD__ not defined
+#endif
diff --git a/gcc/testsuite/gcc.target/i386/apx-3d.c b/gcc/testsuite/gcc.target/i386/apx-3d.c
new file mode 100644
index 00000000000..9b91af1d377
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/apx-3d.c
@@ -0,0 +1,6 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-mapx-features=ppx" } */
+
+#ifndef __APX_PPX__
+# error __APX_PPX__ not defined
+#endif
diff --git a/gcc/testsuite/gcc.target/i386/apx-3e.c b/gcc/testsuite/gcc.target/i386/apx-3e.c
new file mode 100644
index 00000000000..7278428e5c4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/apx-3e.c
@@ -0,0 +1,18 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-mapx-features=egpr,push2pop2,ndd,ppx" } */
+
+#ifndef __APX_EGPR__
+# error __APX_EGPR__ not defined
+#endif
+
+#ifndef __APX_PUSH2POP2__
+# error __APX_PUSH2POP2__ not defined
+#endif
+
+#ifndef __APX_NDD__
+# error __APX_NDD__ not defined
+#endif
+
+#ifndef __APX_PPX__
+# error __APX_PPX__ not defined
+#endif
diff --git a/gcc/testsuite/gcc.target/i386/apx-4.c b/gcc/testsuite/gcc.target/i386/apx-4.c
new file mode 100644
index 00000000000..1ba4ac036fc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/apx-4.c
@@ -0,0 +1,6 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-mapx-inline-asm-use-gpr32" } */
+
+#ifndef __APX_INLINE_ASM_USE_GPR32__
+# error __APX_INLINE_ASM_USE_GPR32__ not defined
+#endif
-- 
2.44.0


             reply	other threads:[~2024-04-08 15:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 15:43 H.J. Lu [this message]
2024-04-09  0:55 ` Hongtao Liu

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=20240408154350.1182471-1-hjl.tools@gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hongtao.liu@intel.com \
    --cc=ubizjak@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).