]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arm: pass architecture extensions to assembler if supported
authorRichard Earnshaw <rearnsha@arm.com>
Tue, 21 Sep 2021 10:14:46 +0000 (11:14 +0100)
committerRichard Earnshaw <rearnsha@arm.com>
Tue, 21 Sep 2021 10:20:37 +0000 (11:20 +0100)
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
gcc/config.in
gcc/configure
gcc/configure.ac

index 481aa9e43d9c73e464e1e992ad7d94c30d2db001..de898a74165db4d7250aa0097dfab682beb0f99c 100644 (file)
@@ -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"
index d8a810bbc91e78e1c4f885fa899785020d135553..61cafe4f6c0ff0603a6bb728e8c47dfbd9bdeb85 100644 (file)
 #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
index 36dba4e09d6dc3f58dcd1a2a976c67f9231d70b7..b3de17009b803b000d8f22dd5efcc13f324ac385 100755 (executable)
@@ -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
index fadd34dbbb6325bc8bd87831f812bed1ab92fa46..7d3aab470306359035a1ba02aa8e10f526f8b48b 100644 (file)
@@ -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