Skip to content

Commit e7d54eb

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 f91776e commit e7d54eb

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 },
@@ -2029,6 +2035,24 @@ riscv_parse_check_conflicts (riscv_parse_subset_t *rps)
20292035
no_conflict = false;
20302036
}
20312037

2038+
bool support_counters = (riscv_subset_supports (rps, "zicntr")
2039+
|| riscv_subset_supports (rps, "zihpm"));
2040+
if (!support_counters)
2041+
{
2042+
if (riscv_subset_supports(rps, "smcdeleg"))
2043+
{
2044+
rps->error_handler
2045+
(_("`smcdeleg' requires either `zicntr' or `zihpm' extension"));
2046+
no_conflict = false;
2047+
}
2048+
if (riscv_subset_supports(rps, "ssccfg"))
2049+
{
2050+
rps->error_handler
2051+
(_("`ssccfg' requires either `zicntr' or `zihpm' extension"));
2052+
no_conflict = false;
2053+
}
2054+
}
2055+
20322056
bool support_zve = false;
20332057
bool support_zvl = false;
20342058
riscv_subset_t *s = rps->subset_list->head;

0 commit comments

Comments
 (0)