From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7896) id 4EF053858C39; Fri, 14 Oct 2022 05:23:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4EF053858C39 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tsukasa OI To: bfd-cvs@sourceware.org Subject: [binutils-gdb] RISC-V: Imply 'Zicsr' from privileged extensions with CSRs X-Act-Checkin: binutils-gdb X-Git-Author: Tsukasa OI X-Git-Refname: refs/heads/master X-Git-Oldrev: 637d7c14299eea2fbffb0e133ffe5e1883fbd43b X-Git-Newrev: b16e13328b14e2668e2a4355d587368ed040b680 Message-Id: <20221014052335.4EF053858C39@sourceware.org> Date: Fri, 14 Oct 2022 05:23:35 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2022 05:23:35 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db16e13328b14= e2668e2a4355d587368ed040b680 commit b16e13328b14e2668e2a4355d587368ed040b680 Author: Tsukasa OI Date: Mon Sep 5 08:11:54 2022 +0000 RISC-V: Imply 'Zicsr' from privileged extensions with CSRs =20 'H', 'Smstateen', 'Sscofpmf' and 'Sstc' are four privileged extensions = with their CSR definitions and 'Smepmp' is a privileged extension with addit= ional CSR bits. =20 Volume II: Privileged Architecture of the RISC-V ISA Manual states that= the privileged architecture requires the 'Zicsr' extension. However, curre= nt GNU Binutils has no direct way whether the program has dependency to the privileged architecture itself. =20 As a workaround, we should add implications from privileged extensions = that either add new CSRs, extend existing CSRs or depends on using CSRs. =20 This commit adds such implications for existing privileged extensions t= hat satisfy this condition. =20 gas/ChangeLog: =20 * testsuite/gas/riscv/march-imply-h.d: New test, at least for '= H'. =20 bfd/ChangeLog: =20 * elfxx-riscv.c (riscv_implicit_subsets): Add 'Zicsr' implicications for privileged extensions 'H', 'Smstateen', 'Sscofpmf', 'Sstc' and 'Smepmp'. Diff: --- bfd/elfxx-riscv.c | 5 +++++ gas/testsuite/gas/riscv/march-imply-h.d | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 1bcc6c0acb4..f0c91cc97f7 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -1047,6 +1047,7 @@ static struct riscv_implicit_subset riscv_implicit_su= bsets[] =3D {"g", "zicsr", check_implicit_always}, {"g", "zifencei", check_implicit_always}, {"m", "zmmul", check_implicit_always}, + {"h", "zicsr", check_implicit_always}, {"q", "d", check_implicit_always}, {"v", "d", check_implicit_always}, {"v", "zve64d", check_implicit_always}, @@ -1096,6 +1097,10 @@ static struct riscv_implicit_subset riscv_implicit_s= ubsets[] =3D {"zks", "zbkx", check_implicit_always}, {"zks", "zksed", check_implicit_always}, {"zks", "zksh", check_implicit_always}, + {"smepmp", "zicsr", check_implicit_always}, + {"smstateen", "zicsr", check_implicit_always}, + {"sscofpmf", "zicsr", check_implicit_always}, + {"sstc", "zicsr", check_implicit_always}, {NULL, NULL, NULL} }; =20 diff --git a/gas/testsuite/gas/riscv/march-imply-h.d b/gas/testsuite/gas/ri= scv/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=3Drv32ih -march-attr -misa-spec=3D20191213 -mpriv-spec=3D1.12 +#readelf: -A +#source: empty.s +Attribute Section: riscv +File Attributes + Tag_RISCV_arch: "rv32i2p1_h1p0_zicsr2p0"