Skip to content

Commit 70eb2da

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 f33d1dc commit 70eb2da

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,10 +1222,14 @@ 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", "sscrind", check_implicit_always},
12251227
{"smcsrind", "zicsr", check_implicit_always},
12261228
{"smstateen", "ssstateen", check_implicit_always},
12271229
{"smepmp", "zicsr", check_implicit_always},
12281230
{"ssaia", "zicsr", check_implicit_always},
1231+
{"ssccfg", "zicsr", check_implicit_always}, /* Compat. */
1232+
{"ssccfg", "sscrind", check_implicit_always},
12291233
{"sscofpmf", "zicsr", check_implicit_always},
12301234
{"sscsrind", "zicsr", check_implicit_always},
12311235
{"ssstateen", "zicsr", check_implicit_always},
@@ -1377,10 +1381,12 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
13771381
static struct riscv_supported_ext riscv_supported_std_s_ext[] =
13781382
{
13791383
{"smaia", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1384+
{"smcdeleg", ISA_SPEC_CLASS_DRAFT, 0, 1, 0 },
13801385
{"smcsrind", ISA_SPEC_CLASS_DRAFT, 0, 1, 0 },
13811386
{"smepmp", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13821387
{"smstateen", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13831388
{"ssaia", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1389+
{"ssccfg", ISA_SPEC_CLASS_DRAFT, 0, 1, 0 },
13841390
{"sscofpmf", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13851391
{"sscsrind", ISA_SPEC_CLASS_DRAFT, 0, 1, 0 },
13861392
{"ssstateen", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -2026,6 +2032,24 @@ riscv_parse_check_conflicts (riscv_parse_subset_t *rps)
20262032
no_conflict = false;
20272033
}
20282034

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

0 commit comments

Comments
 (0)