[REVIEW,ONLY,2/3] MOCK: RISC-V: Add 'Zce' extension support

Message ID 8d7e2380a4ebb6795b33559ab98c5ca4e3881dcb.1690595772.git.research_trasio@irq.a4lg.com
State Unresolved
Headers
Series RISC-V: MOCK: Add 'Zce' extension support |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Tsukasa OI July 29, 2023, 1:56 a.m. UTC
  From: Tsukasa OI <research_trasio@irq.a4lg.com>

It adds a support for the 'Zce' superset compressed instruction extension
for embedded systems.

**THIS IS A MOCKUP**

Since 'Zcmp' and 'Zcmt' are not added to GNU Binutils yet, this commit is
just a mockup.  However, it outlines what will be required on the 'Zce'
support along with new complex implication design.

bfd/ChangeLog:

	* elfxx-riscv.c (check_implicit_for_f_zce): New function to check
	whether adding implication 'F' -> 'Zcf' is appropriate.
	(riscv_implicit_subsets): Add conditional implication from 'F'
	-> 'Zcf'.  (riscv_supported_std_z_ext): [MOCK] Add 'Zce' to the
	supported 'Z' extension list.
---
 bfd/elfxx-riscv.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
  

Patch

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 06ac521bdf27..94487306fae5 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1099,6 +1099,20 @@  check_implicit_for_i (const riscv_parse_subset_t *rps ATTRIBUTE_UNUSED,
 	      && subset->minor_version < 1));
 }
 
+/* Add the IMPLICIT only when the 'Zce' extension is also available
+   and XLEN is 32.  */
+
+static bool
+check_implicit_for_f_zce (const riscv_parse_subset_t *rps,
+			  const riscv_implicit_subset_t *implicit
+			      ATTRIBUTE_UNUSED,
+			  const riscv_subset_t *subset ATTRIBUTE_UNUSED)
+{
+  riscv_subset_t *tmp = NULL;
+  return *rps->xlen == 32
+	 && riscv_lookup_subset (rps->subset_list, "zce", &tmp);
+}
+
 /* All extension implications.  */
 
 static riscv_implicit_subset_t riscv_implicit_subsets[] =
@@ -1184,6 +1198,10 @@  static riscv_implicit_subset_t riscv_implicit_subsets[] =
   {"zvksg", "zvkg",	check_implicit_always},
   {"zvksc", "zvks",	check_implicit_always},
   {"zvksc", "zvbc",	check_implicit_always},
+  {"zce", "zca",	check_implicit_always},
+  {"zce", "zcb",	check_implicit_always},
+  {"zce", "zcmp",	check_implicit_always},
+  {"zce", "zcmt",	check_implicit_always},
   {"zcf", "zca",	check_implicit_always},
   {"zcd", "zca",	check_implicit_always},
   {"zcb", "zca",	check_implicit_always},
@@ -1194,6 +1212,9 @@  static riscv_implicit_subset_t riscv_implicit_subsets[] =
   {"sscofpmf", "zicsr",		check_implicit_always},
   {"ssstateen", "zicsr",	check_implicit_always},
   {"sstc", "zicsr",		check_implicit_always},
+  /* Complex implications (that should be checked after others).  */
+  {"f", "zcf",		check_implicit_for_f_zce},
+  /* Tail of the list.  */
   {NULL, NULL, NULL}
 };
 
@@ -1325,6 +1346,10 @@  static struct riscv_supported_ext riscv_supported_std_z_ext[] =
   {"zcb",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zcf",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zcd",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
+  /* MOCK: uncomment those lines once ready.  */
+  // {"zce",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
+  // {"zcmp",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
+  // {"zcmt",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {NULL, 0, 0, 0, 0}
 };