From patchwork Tue Sep 21 10:19:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Earnshaw X-Patchwork-Id: 1530660 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=iqdVHbXn; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4HDHVx4ntfz9sW5 for ; Tue, 21 Sep 2021 20:20:24 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 46957385842B for ; Tue, 21 Sep 2021 10:20:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 46957385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632219621; bh=zhHHau7zpuHFH0EUB2jSf52rs8cyd/eCSy7gIErIkZo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=iqdVHbXnXgihx+lCKl2h+Vdwl22+T1oWBCV18CPx4uYfm9Gh2ZiuCm8j2rAK33E3o H8Y2VuNFRjyAIW+I6dQSQ7l0GNEF8OWquzF6sZO62tjqfLgBwzrZktpbsb27V717uk WFDSWDUOoe/UwoRRaGq7ocJZwUCOt0JHGyRk8r2c= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 161663858C3A for ; Tue, 21 Sep 2021 10:19:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 161663858C3A Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 972B4106F; Tue, 21 Sep 2021 03:19:57 -0700 (PDT) Received: from e126323.arm.com (unknown [10.57.17.192]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A71A3F59C; Tue, 21 Sep 2021 03:19:56 -0700 (PDT) To: gcc patchlist Subject: [committed] arm: pass architecture extensions to assembler if supported Date: Tue, 21 Sep 2021 11:19:37 +0100 Message-Id: <20210921101937.3370864-1-rearnsha@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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-Patchwork-Original-From: Richard Earnshaw via Gcc-patches From: Richard Earnshaw Reply-To: Richard Earnshaw Cc: Richard Earnshaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" When I originally added the new extended architecture features support to GCC, the assembler was unable to parse the new feature lists on the command-line and would throw an error. This has now been fixed in GAS and the behaviour is the same as GCC. So this patch adds a configure-time test for the assembler in use to detect that it is recent enough to support this behaviour and then enables passing the architecture extensions to the assembler when this is the case. Although the assembly output generated by GCC does not rely on this, this should ease some issues when using GCC as a driver for compiling source written directly in assembly language when the programmer was expecting the appropriate options to be passed on the command line. gcc/ChangeLog: * configure.ac: Detect when the assembler supports new-style architecture extensions. * common/config/arm/arm-common.c (arm_rewrite_mcpu): Return the full CPU string if the assembler can grok it. (arm_rewrite_march): Likewise but for the architecture. * config.in: Regenerate. * configure: Regenerate. --- gcc/common/config/arm/arm-common.c | 10 +++++++++ gcc/config.in | 7 ++++++ gcc/configure | 35 ++++++++++++++++++++++++++++++ gcc/configure.ac | 10 +++++++++ 4 files changed, 62 insertions(+) diff --git a/gcc/common/config/arm/arm-common.c b/gcc/common/config/arm/arm-common.c index 481aa9e43d9..de898a74165 100644 --- a/gcc/common/config/arm/arm-common.c +++ b/gcc/common/config/arm/arm-common.c @@ -115,7 +115,12 @@ const char * arm_rewrite_mcpu (int argc, const char **argv) { gcc_assert (argc); + +#ifdef HAVE_GAS_ARM_EXTENDED_ARCH + return argv[argc - 1]; +#else return arm_rewrite_selected_cpu (argv[argc - 1]); +#endif } /* Comparator for arm_rewrite_selected_arch. Compare the two arch extension @@ -223,7 +228,12 @@ const char * arm_rewrite_march (int argc, const char **argv) { gcc_assert (argc); + +#ifdef HAVE_GAS_ARM_EXTENDED_ARCH + return argv[argc - 1]; +#else return arm_rewrite_selected_arch (argv[argc - 1]); +#endif } #include "arm-cpu-cdata.h" diff --git a/gcc/config.in b/gcc/config.in index d8a810bbc91..61cafe4f6c0 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1331,6 +1331,13 @@ #endif +/* Define if your Arm assembler permits context-specific feature extensions. + */ +#ifndef USED_FOR_TARGET +#undef HAVE_GAS_ARM_EXTENDED_ARCH +#endif + + /* Define if your assembler supports .balign and .p2align. */ #ifndef USED_FOR_TARGET #undef HAVE_GAS_BALIGN_AND_P2ALIGN diff --git a/gcc/configure b/gcc/configure index 36dba4e09d6..b3de17009b8 100755 --- a/gcc/configure +++ b/gcc/configure @@ -28881,6 +28881,41 @@ $as_echo "#define HAVE_GCN_SRAM_ECC_GFX908 1" >>confdefs.h fi ;; + arm*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for assembler for arm accepts context-specific architecture extensions" >&5 +$as_echo_n "checking assembler for assembler for arm accepts context-specific architecture extensions... " >&6; } +if ${gcc_cv_as_arm_option_extensions+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_arm_option_extensions=no + if test x$gcc_cv_as != x; then + $as_echo '.text + .thumb + .syntax unified + vmov.f32 s0, s1' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags -march=armv8.1-m.main+mve -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_arm_option_extensions=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_arm_option_extensions" >&5 +$as_echo "$gcc_cv_as_arm_option_extensions" >&6; } +if test $gcc_cv_as_arm_option_extensions = yes; then + +$as_echo "#define HAVE_GAS_ARM_EXTENDED_ARCH 1" >>confdefs.h + +fi + esac # ??? Not all targets support dwarf2 debug_line, even within a version diff --git a/gcc/configure.ac b/gcc/configure.ac index fadd34dbbb6..7d3aab47030 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5357,6 +5357,16 @@ case "$target" in [AC_DEFINE(HAVE_GCN_SRAM_ECC_GFX908, 1, [Define if your assembler allows -mattr=+sram-ecc for gfx908.])]) ;; + arm*) + gcc_GAS_CHECK_FEATURE([assembler for arm accepts context-specific architecture extensions], + gcc_cv_as_arm_option_extensions, + [-march=armv8.1-m.main+mve], + [.text + .thumb + .syntax unified + vmov.f32 s0, s1],, + [AC_DEFINE(HAVE_GAS_ARM_EXTENDED_ARCH, 1, + [Define if your Arm assembler permits context-specific feature extensions.])]) esac # ??? Not all targets support dwarf2 debug_line, even within a version