From c41bb43947a44989cc93e63ac2e3fd1bb4232169 Mon Sep 17 00:00:00 2001 From: Tsukasa OI Date: Mon, 5 Sep 2022 08:11:54 +0000 Subject: [PATCH] RISC-V: Imply 'Zicsr' from some privileged extensions As 'H', 'Smstateen', 'Sscofpmf' and 'Sstc' define their own CSRs, they implicitly require 'Zicsr' in the process. This commit adds such implicications. gas/ChangeLog: * testsuite/gas/riscv/march-imply-h.d: New test, at least for 'H'. bfd/ChangeLog: * elfxx-riscv.c (riscv_implicit_subsets): Add 'Zicsr' implicications for privileged extensions 'H', 'Smstateen', 'Sscofpmf' and 'Sstc'. --- bfd/elfxx-riscv.c | 4 ++++ gas/testsuite/gas/riscv/march-imply-h.d | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 gas/testsuite/gas/riscv/march-imply-h.d diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 2e91963bbfb..73848f725e6 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -1047,6 +1047,7 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] = {"g", "d", check_implicit_always}, {"g", "zicsr", check_implicit_always}, {"g", "zifencei", check_implicit_always}, + {"h", "zicsr", check_implicit_always}, {"q", "d", check_implicit_always}, {"v", "d", check_implicit_always}, {"v", "zve64d", check_implicit_always}, @@ -1098,6 +1099,9 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] = {"zks", "zbkx", check_implicit_always}, {"zks", "zksed", check_implicit_always}, {"zks", "zksh", check_implicit_always}, + {"smstateen", "zicsr", check_implicit_always}, + {"sscofpmf", "zicsr", check_implicit_always}, + {"sstc", "zicsr", check_implicit_always}, {NULL, NULL, NULL} }; diff --git a/gas/testsuite/gas/riscv/march-imply-h.d b/gas/testsuite/gas/riscv/march-imply-h.d new file mode 100644 index 00000000000..04ad9f6c0a5 --- /dev/null +++ b/gas/testsuite/gas/riscv/march-imply-h.d @@ -0,0 +1,6 @@ +#as: -march=rv32ih -march-attr -misa-spec=20191213 -mpriv-spec=1.12 +#readelf: -A +#source: empty.s +Attribute Section: riscv +File Attributes + Tag_RISCV_arch: "rv32i2p1_h1p0_zicsr2p0"