From 69b454052628924ab8d4c5d5fdf18bdf9b699678 Mon Sep 17 00:00:00 2001 From: Tsukasa OI Date: Sat, 29 Jul 2023 01:08:08 +0000 Subject: [PATCH] MOCK: RISC-V: Add 'Zce' extension support 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 32b9b4f88b2..71f79235162 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -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[] = @@ -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}, @@ -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} }; @@ -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} };