From patchwork Mon Apr 8 15:43:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1920888 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=ISLZZt8a; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VCtgN5KhVz1yYT for ; Tue, 9 Apr 2024 01:44:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CCE6A385841C for ; Mon, 8 Apr 2024 15:44:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id 36E143858410 for ; Mon, 8 Apr 2024 15:43:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 36E143858410 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 36E143858410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712591037; cv=none; b=k13JFHKqe1bjYrqrHUIQDvcYdByuD9ObG/P7Hb+ah/kiDRKlZomXtkb0QaCtsMhIX/cP6Jo7LIdnz6Dj+w8UHxenORPmI0JU015s/jsFl9iMiauekk1ZK7rPCTtjThy9bokjyQCfF3+Ruj0ECz/ABeVq6LUwFqsGMJDu3GWif6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712591037; c=relaxed/simple; bh=OGRL5ATMGnfMq3vsxd68UgyxbdddFGvjG4sB2DljAus=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BeoPZVY27LiQ8InH7AyPIUXP1lQcNnTR+Js8vczy0mIUqq0vJdQ0EMpAS5OVwuc2+PzsznT+JbP8oDZ0uHKJW4NETKdoZ4nZz99BotqQ25BtgUXKjnDVW39jP5glHnuFaqmT4xWrHv+L85N6hbI80NcCX2s1PcIieNoOAv05T/s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1e2a7b5ef7bso37794805ad.1 for ; Mon, 08 Apr 2024 08:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712591033; x=1713195833; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=P1M4EV4YnoKVCsy/Nnwpw0zyyAURSKdIvpePEFcth+I=; b=ISLZZt8aTh8xM+eY4HWLP3o9SFT+SvJaVWIUcsy1V48KzciEdhtN5bz+DJaWoyKKeE rA9psr3e9NXPqaGER6PYh4VSIkOugCU+hBBtywDa/Mszt8/14m6Yz+FhbRim98F2b3us INJwS2Iya2UzbhrZdi+m5pZjs/c+8lEQw8W2d+JL7/rAjcKkxbmSvr+KT4ilJSZjLMg+ uiMbaolLMoW3dTZi1s6m+RnZaXf3IB+uzgckVS6HMHN6+odkofyi9TwVVjl36jXIBkRC bT09VXNf9ZNm2wS6TrSqfDpmbG46rAIgXvswiYrH7ueMJMiu5lbmk5IBVNeRrVZ+75ab 6bVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712591033; x=1713195833; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=P1M4EV4YnoKVCsy/Nnwpw0zyyAURSKdIvpePEFcth+I=; b=Cutr2abPaBHOCJ1iA0WRa4DpH78gxFGfMcvNbBfyqN63xGJAUvwldHM8ujYCqHCUAs w/LaYhb1+NZbEKkTHtvGgaO9SC5BAMtcKdezLbGoTd1+GkzS23dHc0BTS0vts2xAxysj 6L7IS3W8K6/aHSNx7fCId8RkFFNBgI+IIsWVXe4pl0XAdMcYcOP2/Jvfyea43XVcukiS BqcMmzhFWWSuCH6GCZiXs55uj3qjE0gkGg/LKcQ9SkRYRbgnuUULtBmHpmgZ+oRSzio5 rMoCyEvOZ8gdkDwZFH9C5aSiAT/2KdtTn99ADzjCQb9DyYGBNl4P5IY/SeEQe1tvR5Mp /csQ== X-Gm-Message-State: AOJu0Yy6SnnGHwOuuHik5KQgl+7ca5WuqKYNpUDz5rp+bdbwljxaS4K5 IYhym+aQOwul70sYjqd+9g/q+zbTSxb3/hCEEowfR65GRDANh6Y3MWfk/6sw X-Google-Smtp-Source: AGHT+IHu+OYZ0e+LiT2JL0C9pOwRO/WlPivd1w09dYStzN8QcZcPCmBQ70LtirVik5ZLGU562xgGNQ== X-Received: by 2002:a17:902:d48c:b0:1e3:e541:a5f8 with SMTP id c12-20020a170902d48c00b001e3e541a5f8mr8125845plg.19.1712591032754; Mon, 08 Apr 2024 08:43:52 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.56.169.48]) by smtp.gmail.com with ESMTPSA id i18-20020a170902c95200b001dda32430b3sm7123431pla.89.2024.04.08.08.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 08:43:52 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id EE5557402F8; Mon, 8 Apr 2024 08:43:50 -0700 (PDT) From: "H.J. Lu" 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 Message-ID: <20240408154350.1182471-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3020.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_NONE, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org 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