* [PATCH] RISC-V: Add configure check for B extention support
@ 2024-07-24 23:50 Edwin Lu
2024-07-29 13:37 ` Kito Cheng
0 siblings, 1 reply; 3+ messages in thread
From: Edwin Lu @ 2024-07-24 23:50 UTC (permalink / raw)
To: gcc-patches; +Cc: gnu-toolchain, Edwin Lu
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>
---
gcc/common/config/riscv/riscv-common.cc | 8 +++++++
gcc/config.in | 6 +++++
gcc/configure | 31 +++++++++++++++++++++++++
gcc/configure.ac | 5 ++++
4 files changed, 50 insertions(+)
diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
index 682826c0e34..200a57e1bc8 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -857,6 +857,7 @@ riscv_subset_list::to_string (bool version_p) const
bool skip_zaamo_zalrsc = false;
bool skip_zabha = 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
@@ -891,6 +892,10 @@ riscv_subset_list::to_string (bool version_p) const
/* Skip since binutils 2.42 and earlier don't recognize zabha. */
skip_zabha = 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)
{
@@ -911,6 +916,9 @@ riscv_subset_list::to_string (bool version_p) const
if (skip_zabha && subset->name == "zabha")
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 bc819005bd6..96e829b9c93 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 01acca7fb5c..c5725c4cd44 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -30913,6 +30913,37 @@ if test $gcc_cv_as_riscv_march_zabha = yes; then
$as_echo "#define HAVE_AS_MARCH_ZABHA 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
;;
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 3f20c107b6a..93d9236ff36 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5466,6 +5466,11 @@ configured with --enable-newlib-nano-formatted-io.])
[-march=rv32i_zabha],,,
[AC_DEFINE(HAVE_AS_MARCH_ZABHA, 1,
[Define if the assembler understands -march=rv*_zabha.])])
+ 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],
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] RISC-V: Add configure check for B extention support
2024-07-24 23:50 [PATCH] RISC-V: Add configure check for B extention support Edwin Lu
@ 2024-07-29 13:37 ` Kito Cheng
2024-07-30 18:00 ` [Committed] " Edwin Lu
0 siblings, 1 reply; 3+ messages in thread
From: Kito Cheng @ 2024-07-29 13:37 UTC (permalink / raw)
To: Edwin Lu; +Cc: gcc-patches, gnu-toolchain
LGTM, although I said no binutils check for zacas and zabha, but B is
a different situation since GCC will add that if zba, zbb and zbs are
all present.
On Thu, Jul 25, 2024 at 7:51 AM Edwin Lu <ewlu@rivosinc.com> wrote:
>
> 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>
> ---
> gcc/common/config/riscv/riscv-common.cc | 8 +++++++
> gcc/config.in | 6 +++++
> gcc/configure | 31 +++++++++++++++++++++++++
> gcc/configure.ac | 5 ++++
> 4 files changed, 50 insertions(+)
>
> diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
> index 682826c0e34..200a57e1bc8 100644
> --- a/gcc/common/config/riscv/riscv-common.cc
> +++ b/gcc/common/config/riscv/riscv-common.cc
> @@ -857,6 +857,7 @@ riscv_subset_list::to_string (bool version_p) const
> bool skip_zaamo_zalrsc = false;
> bool skip_zabha = 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
> @@ -891,6 +892,10 @@ riscv_subset_list::to_string (bool version_p) const
> /* Skip since binutils 2.42 and earlier don't recognize zabha. */
> skip_zabha = 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)
> {
> @@ -911,6 +916,9 @@ riscv_subset_list::to_string (bool version_p) const
> if (skip_zabha && subset->name == "zabha")
> 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 bc819005bd6..96e829b9c93 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 01acca7fb5c..c5725c4cd44 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -30913,6 +30913,37 @@ if test $gcc_cv_as_riscv_march_zabha = yes; then
>
> $as_echo "#define HAVE_AS_MARCH_ZABHA 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
>
> ;;
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 3f20c107b6a..93d9236ff36 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -5466,6 +5466,11 @@ configured with --enable-newlib-nano-formatted-io.])
> [-march=rv32i_zabha],,,
> [AC_DEFINE(HAVE_AS_MARCH_ZABHA, 1,
> [Define if the assembler understands -march=rv*_zabha.])])
> + 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],
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Committed] RISC-V: Add configure check for B extention support
2024-07-29 13:37 ` Kito Cheng
@ 2024-07-30 18:00 ` Edwin Lu
0 siblings, 0 replies; 3+ messages in thread
From: Edwin Lu @ 2024-07-30 18:00 UTC (permalink / raw)
To: Kito Cheng; +Cc: gcc-patches, gnu-toolchain
Thanks! Committed
Edwin
On 7/29/2024 6:37 AM, Kito Cheng wrote:
> LGTM, although I said no binutils check for zacas and zabha, but B is
> a different situation since GCC will add that if zba, zbb and zbs are
> all present.
>
>
>
> On Thu, Jul 25, 2024 at 7:51 AM Edwin Lu <ewlu@rivosinc.com> wrote:
>> 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>
>> ---
>> gcc/common/config/riscv/riscv-common.cc | 8 +++++++
>> gcc/config.in | 6 +++++
>> gcc/configure | 31 +++++++++++++++++++++++++
>> gcc/configure.ac | 5 ++++
>> 4 files changed, 50 insertions(+)
>>
>> diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
>> index 682826c0e34..200a57e1bc8 100644
>> --- a/gcc/common/config/riscv/riscv-common.cc
>> +++ b/gcc/common/config/riscv/riscv-common.cc
>> @@ -857,6 +857,7 @@ riscv_subset_list::to_string (bool version_p) const
>> bool skip_zaamo_zalrsc = false;
>> bool skip_zabha = 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
>> @@ -891,6 +892,10 @@ riscv_subset_list::to_string (bool version_p) const
>> /* Skip since binutils 2.42 and earlier don't recognize zabha. */
>> skip_zabha = 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)
>> {
>> @@ -911,6 +916,9 @@ riscv_subset_list::to_string (bool version_p) const
>> if (skip_zabha && subset->name == "zabha")
>> 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 bc819005bd6..96e829b9c93 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 01acca7fb5c..c5725c4cd44 100755
>> --- a/gcc/configure
>> +++ b/gcc/configure
>> @@ -30913,6 +30913,37 @@ if test $gcc_cv_as_riscv_march_zabha = yes; then
>>
>> $as_echo "#define HAVE_AS_MARCH_ZABHA 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
>>
>> ;;
>> diff --git a/gcc/configure.ac b/gcc/configure.ac
>> index 3f20c107b6a..93d9236ff36 100644
>> --- a/gcc/configure.ac
>> +++ b/gcc/configure.ac
>> @@ -5466,6 +5466,11 @@ configured with --enable-newlib-nano-formatted-io.])
>> [-march=rv32i_zabha],,,
>> [AC_DEFINE(HAVE_AS_MARCH_ZABHA, 1,
>> [Define if the assembler understands -march=rv*_zabha.])])
>> + 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],
>> --
>> 2.34.1
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-30 18:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-24 23:50 [PATCH] RISC-V: Add configure check for B extention support Edwin Lu
2024-07-29 13:37 ` Kito Cheng
2024-07-30 18:00 ` [Committed] " Edwin Lu
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).