Skip to content

Commit 219136e

Browse files
committed
UNRATIFIED RISC-V: Add supervisor counter delegation extensions
[DO NOT MERGE] Until the Supervisor Counter Delegation Architecture Extension is frozen / ratified and final version number is determined, this patch should not be merged upstream. This commit uses version 0.1 as a placeholder because there's no version number in the current documentation. This commit adds support for two extensions from the Supervisor Counter Delegation Architecture Extension specification ('Smcdeleg' and 'Ssccfg') based on the latest documentation (as of 2023-08-07): <https://docs.google.com/document/d/1s-GeH5XpHBLzbQZucA8DPA7vvF7Xvf_nrPbrU2YLBcE> bfd/ChangeLog: * elfxx-riscv.c (riscv_implicit_subsets): Add related implications including the ones to 'Zicsr' for compatibility and excluding the ones to counter extensions that require *either* 'Zicntr' or 'Zihpm'. (riscv_supported_std_s_ext): Add 'Smcdeleg' and 'Ssccfg' extensions to the supported 'S' extension list. (riscv_parse_check_conflicts): Check existence of either 'Zicntr' or 'Zihpm' if either 'Smcdeleg' or 'Ssccfg' is enabled.
1 parent e7d479f commit 219136e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

bfd/elfxx-riscv.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,11 +1222,15 @@ static riscv_implicit_subset_t riscv_implicit_subsets[] =
12221222
{"zicntr", "zicsr", check_implicit_compat_counter_to_zicsr},
12231223
{"zihpm", "zicsr", check_implicit_compat_counter_to_zicsr},
12241224
{"smaia", "ssaia", check_implicit_always},
1225+
{"smcdeleg", "zicsr", check_implicit_always}, /* Compat. */
1226+
{"smcdeleg", "sscsrind", check_implicit_always},
12251227
{"smcntrpmf", "zicsr", check_implicit_always},
12261228
{"smcsrind", "zicsr", check_implicit_always},
12271229
{"smstateen", "ssstateen", check_implicit_always},
12281230
{"smepmp", "zicsr", check_implicit_always},
12291231
{"ssaia", "zicsr", check_implicit_always},
1232+
{"ssccfg", "zicsr", check_implicit_always}, /* Compat. */
1233+
{"ssccfg", "sscsrind", check_implicit_always},
12301234
{"sscofpmf", "zicsr", check_implicit_always},
12311235
{"sscsrind", "zicsr", check_implicit_always},
12321236
{"ssstateen", "zicsr", check_implicit_always},
@@ -1379,11 +1383,13 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
13791383
static struct riscv_supported_ext riscv_supported_std_s_ext[] =
13801384
{
13811385
{"smaia", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1386+
{"smcdeleg", ISA_SPEC_CLASS_DRAFT, 0, 1, 0 },
13821387
{"smcntrpmf", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13831388
{"smcsrind", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13841389
{"smepmp", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13851390
{"smstateen", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13861391
{"ssaia", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1392+
{"ssccfg", ISA_SPEC_CLASS_DRAFT, 0, 1, 0 },
13871393
{"sscofpmf", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13881394
{"sscsrind", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13891395
{"ssstateen", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -2037,6 +2043,24 @@ riscv_parse_check_conflicts (riscv_parse_subset_t *rps)
20372043
no_conflict = false;
20382044
}
20392045

2046+
bool support_counters = (riscv_subset_supports (rps, "zicntr")
2047+
|| riscv_subset_supports (rps, "zihpm"));
2048+
if (!support_counters)
2049+
{
2050+
if (riscv_subset_supports(rps, "smcdeleg"))
2051+
{
2052+
rps->error_handler
2053+
(_("`smcdeleg' requires either `zicntr' or `zihpm' extension"));
2054+
no_conflict = false;
2055+
}
2056+
if (riscv_subset_supports(rps, "ssccfg"))
2057+
{
2058+
rps->error_handler
2059+
(_("`ssccfg' requires either `zicntr' or `zihpm' extension"));
2060+
no_conflict = false;
2061+
}
2062+
}
2063+
20402064
bool support_zve = false;
20412065
bool support_zvl = false;
20422066
riscv_subset_t *s = rps->subset_list->head;

0 commit comments

Comments
 (0)