RISC-V: Generate ELF priv attributes if priv instruction are explicited used.
authorNelson Chu <nelson.chu@sifive.com>
Mon, 22 Jun 2020 08:11:18 +0000 (16:11 +0800)
committerNelson Chu <nelson.chu@sifive.com>
Tue, 23 Jun 2020 01:38:12 +0000 (09:38 +0800)
commit1a79004f61a433112a218c04b0f1aa9f0f9d868d
tree398fb787152c4427aa1f7dcfbc18a10f08b9f36c
parentc7c970e4c63f81479539220874a98aa74bc0e090
RISC-V: Generate ELF priv attributes if priv instruction are explicited used.

We should generate the ELF priv attributes only if,

1. The priv attributes are already set in the assembly file.
2. The CSR are explicited used.
3. The privileged instruction are explicited used.

* There are four privileged instruction defined in the v1.11 priv spec:
`mret`, `sret`, `wfi` and `sfence.vma`.

* `sfence.vm` is dropped in the v1.10 priv spec.

* `uret` is actually a N-ext instruction.  So it is better to regard it as
an user instruction rather than the priv instruction.

* `hret` is used to return from traps in H-mode.  H-mode is removed since
the v1.10 priv spec, but probably be added in the new hypervisor spec.
Therefore, `hret` should be controlled by the hypervisor spec rather than
priv spec in the future.

* `dret` is a debug instruction.  We should record the debug spec versions
once it is explicited used in the future.

gas/
* config/tc-riscv.c (explicit_priv_attr): Rename explicit_csr to
explicit_priv_attr.  It used to indicate CSR or priv instructions are
explictly used.
(riscv_is_priv_insn): Return True if it is a privileged instruction.
(riscv_ip): Call riscv_is_priv_insn to check whether the instruction
is privileged or not.  If it is, then set explicit_priv_attr to TRUE.
(riscv_write_out_attrs): Clarification of when to generate the elf
priv spec attributes.

* testsuite/gas/riscv/attribute-11.s: Add comments.
* testsuite/gas/riscv/attribute-14.s: New testcase.  Use symbol
`priv_insn_<n>` to decide which priv instruction is expected to used.
(<n> is a to g.)
* testsuite/gas/riscv/attribute-14a.d: Likewise.
* testsuite/gas/riscv/attribute-14b.d: Likewise.
* testsuite/gas/riscv/attribute-14c.d: Likewise.
* testsuite/gas/riscv/attribute-14d.d: Likewise.
* testsuite/gas/riscv/attribute-14e.d: Likewise.
gas/ChangeLog
gas/config/tc-riscv.c
gas/testsuite/gas/riscv/attribute-11.s
gas/testsuite/gas/riscv/attribute-14.s [new file with mode: 0644]
gas/testsuite/gas/riscv/attribute-14a.d [new file with mode: 0644]
gas/testsuite/gas/riscv/attribute-14b.d [new file with mode: 0644]
gas/testsuite/gas/riscv/attribute-14c.d [new file with mode: 0644]
gas/testsuite/gas/riscv/attribute-14d.d [new file with mode: 0644]
gas/testsuite/gas/riscv/attribute-14e.d [new file with mode: 0644]
This page took 0.024511 seconds and 4 git commands to generate.