Skip to content

Commit

Permalink
MOCK: RISC-V: Add 'Zce' extension support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
a4lg committed Oct 19, 2023
1 parent 36579cc commit da638f2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions bfd/elfxx-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,19 @@ check_implicit_for_i (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 (riscv_parse_subset_t *rps,
const riscv_implicit_subset_t *implicit
ATTRIBUTE_UNUSED,
const riscv_subset_t *subset ATTRIBUTE_UNUSED)
{
return *rps->xlen == 32
&& riscv_subset_supports (rps, "zce");
}

/* All extension implications. */

static riscv_implicit_subset_t riscv_implicit_subsets[] =
Expand Down Expand Up @@ -1188,6 +1201,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},
Expand All @@ -1200,6 +1217,9 @@ static riscv_implicit_subset_t riscv_implicit_subsets[] =
{"ssstateen", "zicsr", check_implicit_always},
{"sstc", "zicsr", check_implicit_always},
{"svadu", "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}
};

Expand Down Expand Up @@ -1333,6 +1353,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}
};

Expand Down

0 comments on commit da638f2

Please sign in to comment.