aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEdwin Lu <ewlu@rivosinc.com>2024-07-24 16:37:18 -0700
committerEdwin Lu <ewlu@rivosinc.com>2024-07-30 10:56:58 -0700
commit7ef8a9d4b1cea3fea3791859074df79b71abd549 (patch)
tree489b25ab6a4a14ff1402015feca74833afb2008d /gcc
parentee12a13d25778a1ad8a9b5dc63aadf9f4320088b (diff)
downloadgcc-7ef8a9d4b1cea3fea3791859074df79b71abd549.zip
gcc-7ef8a9d4b1cea3fea3791859074df79b71abd549.tar.gz
gcc-7ef8a9d4b1cea3fea3791859074df79b71abd549.tar.bz2
RISC-V: Add configure check for B extention support
Binutils 2.42 and before don't recognize the b extension in the march strings even though it supports zba_zbb_zbs. Add a configure check to ignore the b in the march string if found. gcc/ChangeLog: * common/config/riscv/riscv-common.cc (riscv_subset_list::to_string): Skip b in march string * config.in: Regenerate. * configure: Regenerate. * configure.ac: Add B assembler check Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/common/config/riscv/riscv-common.cc8
-rw-r--r--gcc/config.in6
-rwxr-xr-xgcc/configure31
-rw-r--r--gcc/configure.ac5
4 files changed, 50 insertions, 0 deletions
diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
index 0c12e12..1944c778 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -858,6 +858,7 @@ riscv_subset_list::to_string (bool version_p) const
bool skip_zifencei = false;
bool skip_zaamo_zalrsc = false;
bool skip_zicsr = false;
+ bool skip_b = false;
bool i2p0 = false;
/* For RISC-V ISA version 2.2 or earlier version, zicsr and zifencei is
@@ -890,6 +891,10 @@ riscv_subset_list::to_string (bool version_p) const
for users with an older version of binutils. */
skip_zaamo_zalrsc = true;
#endif
+#ifndef HAVE_AS_MARCH_B
+ /* Skip since binutils 2.42 and earlier don't recognize b. */
+ skip_b = true;
+#endif
for (subset = m_head; subset != NULL; subset = subset->next)
{
@@ -907,6 +912,9 @@ riscv_subset_list::to_string (bool version_p) const
if (skip_zaamo_zalrsc && subset->name == "zalrsc")
continue;
+ if (skip_b && subset->name == "b")
+ continue;
+
/* For !version_p, we only separate extension with underline for
multi-letter extension. */
if (!first &&
diff --git a/gcc/config.in b/gcc/config.in
index 3af153e..7fcabbe 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -629,6 +629,12 @@
#endif
+/* Define if the assembler understands -march=rv*_b. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_MARCH_B
+#endif
+
+
/* Define if the assembler understands -march=rv*_zaamo_zalrsc. */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_MARCH_ZAAMO_ZALRSC
diff --git a/gcc/configure b/gcc/configure
index 7541bde..557ea5f 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -30884,6 +30884,37 @@ $as_echo "#define HAVE_AS_MARCH_ZAAMO_ZALRSC 1" >>confdefs.h
fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -march=rv32i_b support" >&5
+$as_echo_n "checking assembler for -march=rv32i_b support... " >&6; }
+if ${gcc_cv_as_riscv_march_b+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_riscv_march_b=no
+ if test x$gcc_cv_as != x; then
+ $as_echo '' > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags -march=rv32i_b -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_riscv_march_b=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_riscv_march_b" >&5
+$as_echo "$gcc_cv_as_riscv_march_b" >&6; }
+if test $gcc_cv_as_riscv_march_b = yes; then
+
+$as_echo "#define HAVE_AS_MARCH_B 1" >>confdefs.h
+
+fi
+
;;
loongarch*-*-*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .dtprelword support" >&5
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 52c1780..eaa01d0 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5461,6 +5461,11 @@ configured with --enable-newlib-nano-formatted-io.])
[-march=rv32i_zaamo_zalrsc],,,
[AC_DEFINE(HAVE_AS_MARCH_ZAAMO_ZALRSC, 1,
[Define if the assembler understands -march=rv*_zaamo_zalrsc.])])
+ gcc_GAS_CHECK_FEATURE([-march=rv32i_b support],
+ gcc_cv_as_riscv_march_b,
+ [-march=rv32i_b],,,
+ [AC_DEFINE(HAVE_AS_MARCH_B, 1,
+ [Define if the assembler understands -march=rv*_b.])])
;;
loongarch*-*-*)
gcc_GAS_CHECK_FEATURE([.dtprelword support],