RISC-V: Add support for B standard extension

Message ID 20240206173843.4007731-1-ewlu@rivosinc.com
State Accepted
Headers
Series RISC-V: Add support for B standard extension |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Edwin Lu Feb. 6, 2024, 5:38 p.m. UTC
  This patch adds support for recognizing the B standard extension to be the
collection of Zba, Zbb, Zbs extensions for consistency and conciseness across
toolchains

* https://github.com/riscv/riscv-b/tags

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc: Add imply rules for B extension
	* config/riscv/arch-canonicalize: ditto

Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
---
 gcc/common/config/riscv/riscv-common.cc | 7 +++++++
 gcc/config/riscv/arch-canonicalize      | 1 +
 2 files changed, 8 insertions(+)
  

Comments

Andrew Pinski Feb. 6, 2024, 5:41 p.m. UTC | #1
On Tue, Feb 6, 2024 at 9:39 AM Edwin Lu <ewlu@rivosinc.com> wrote:
>
> This patch adds support for recognizing the B standard extension to be the
> collection of Zba, Zbb, Zbs extensions for consistency and conciseness across
> toolchains
>
> * https://github.com/riscv/riscv-b/tags

Note this is/was recorded as PR 106531.

Thanks,
Andrew Pinski

>
> gcc/ChangeLog:
>
>         * common/config/riscv/riscv-common.cc: Add imply rules for B extension
>         * config/riscv/arch-canonicalize: ditto
>
> Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
> ---
>  gcc/common/config/riscv/riscv-common.cc | 7 +++++++
>  gcc/config/riscv/arch-canonicalize      | 1 +
>  2 files changed, 8 insertions(+)
>
> diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
> index 631ce8309a0..31117a7b0fd 100644
> --- a/gcc/common/config/riscv/riscv-common.cc
> +++ b/gcc/common/config/riscv/riscv-common.cc
> @@ -77,6 +77,10 @@ static const riscv_implied_info_t riscv_implied_info[] =
>    {"f", "zicsr"},
>    {"d", "zicsr"},
>
> +  {"b", "zba"},
> +  {"b", "zbb"},
> +  {"b", "zbs"},
> +
>    {"zdinx", "zfinx"},
>    {"zfinx", "zicsr"},
>    {"zdinx", "zicsr"},
> @@ -235,6 +239,8 @@ static const struct riscv_ext_version riscv_ext_version_table[] =
>    {"c", ISA_SPEC_CLASS_20190608, 2, 0},
>    {"c", ISA_SPEC_CLASS_2P2,      2, 0},
>
> +  {"b",       ISA_SPEC_CLASS_NONE, 1, 0},
> +
>    {"h",       ISA_SPEC_CLASS_NONE, 1, 0},
>
>    {"v",       ISA_SPEC_CLASS_NONE, 1, 0},
> @@ -388,6 +394,7 @@ static const struct riscv_ext_version riscv_ext_version_table[] =
>  /* Combine extensions defined in this table  */
>  static const struct riscv_ext_version riscv_combine_info[] =
>  {
> +  {"b",  ISA_SPEC_CLASS_NONE, 1, 0},
>    {"zk",  ISA_SPEC_CLASS_NONE, 1, 0},
>    {"zkn",  ISA_SPEC_CLASS_NONE, 1, 0},
>    {"zks",  ISA_SPEC_CLASS_NONE, 1, 0},
> diff --git a/gcc/config/riscv/arch-canonicalize b/gcc/config/riscv/arch-canonicalize
> index 629bed85347..dcfae732714 100755
> --- a/gcc/config/riscv/arch-canonicalize
> +++ b/gcc/config/riscv/arch-canonicalize
> @@ -41,6 +41,7 @@ LONG_EXT_PREFIXES = ['z', 's', 'h', 'x']
>  IMPLIED_EXT = {
>    "d" : ["f", "zicsr"],
>    "f" : ["zicsr"],
> +  "b" : ["zba", "zbb", "zbs"],
>    "zdinx" : ["zfinx", "zicsr"],
>    "zfinx" : ["zicsr"],
>    "zhinx" : ["zhinxmin", "zfinx", "zicsr"],
> --
> 2.34.1
>
  
Jeff Law Feb. 13, 2024, 4:16 p.m. UTC | #2
On 2/6/24 10:38, Edwin Lu wrote:
> This patch adds support for recognizing the B standard extension to be the
> collection of Zba, Zbb, Zbs extensions for consistency and conciseness across
> toolchains
> 
> * https://github.com/riscv/riscv-b/tags
> 
> gcc/ChangeLog:
> 
> 	* common/config/riscv/riscv-common.cc: Add imply rules for B extension
> 	* config/riscv/arch-canonicalize: ditto
So similar to Patrick's change, no major concerns here.  We just need to 
wait to see how the proposal moves through RVI before committing.

jeff
  

Patch

diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
index 631ce8309a0..31117a7b0fd 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -77,6 +77,10 @@  static const riscv_implied_info_t riscv_implied_info[] =
   {"f", "zicsr"},
   {"d", "zicsr"},
 
+  {"b", "zba"},
+  {"b", "zbb"},
+  {"b", "zbs"},
+
   {"zdinx", "zfinx"},
   {"zfinx", "zicsr"},
   {"zdinx", "zicsr"},
@@ -235,6 +239,8 @@  static const struct riscv_ext_version riscv_ext_version_table[] =
   {"c", ISA_SPEC_CLASS_20190608, 2, 0},
   {"c", ISA_SPEC_CLASS_2P2,      2, 0},
 
+  {"b",       ISA_SPEC_CLASS_NONE, 1, 0},
+
   {"h",       ISA_SPEC_CLASS_NONE, 1, 0},
 
   {"v",       ISA_SPEC_CLASS_NONE, 1, 0},
@@ -388,6 +394,7 @@  static const struct riscv_ext_version riscv_ext_version_table[] =
 /* Combine extensions defined in this table  */
 static const struct riscv_ext_version riscv_combine_info[] =
 {
+  {"b",  ISA_SPEC_CLASS_NONE, 1, 0},
   {"zk",  ISA_SPEC_CLASS_NONE, 1, 0},
   {"zkn",  ISA_SPEC_CLASS_NONE, 1, 0},
   {"zks",  ISA_SPEC_CLASS_NONE, 1, 0},
diff --git a/gcc/config/riscv/arch-canonicalize b/gcc/config/riscv/arch-canonicalize
index 629bed85347..dcfae732714 100755
--- a/gcc/config/riscv/arch-canonicalize
+++ b/gcc/config/riscv/arch-canonicalize
@@ -41,6 +41,7 @@  LONG_EXT_PREFIXES = ['z', 's', 'h', 'x']
 IMPLIED_EXT = {
   "d" : ["f", "zicsr"],
   "f" : ["zicsr"],
+  "b" : ["zba", "zbb", "zbs"],
   "zdinx" : ["zfinx", "zicsr"],
   "zfinx" : ["zicsr"],
   "zhinx" : ["zhinxmin", "zfinx", "zicsr"],