]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
RISC-V: Extend .insn directive to support hardcode encoding.
authorNelson Chu <nelson.chu@sifive.com>
Fri, 16 Jul 2021 05:32:18 +0000 (22:32 -0700)
committerNelson Chu <nelson.chu@sifive.com>
Tue, 31 Aug 2021 04:50:27 +0000 (12:50 +0800)
commita262b82fdbf4cda3b0648b1adc32245ca3f78b7a
tree97b55d8f82454d447e1929683c72e127f520b5cf
parentad15549d514afa0602a0c0fca4b3bbf545a3c994
RISC-V: Extend .insn directive to support hardcode encoding.

The .insn directive can let users use their own instructions, or
some new instruction, which haven't supported in the old binutils.
For example, if users want to use sifive cache instruction, they
cannot just write "cflush.d1.l1" in the assembly code, they should
use ".insn i SYSTEM, 0, x0, x10, -0x40".  But the .insn directive
may not easy to use for some cases, and not so friendly to users.
Therefore, I believe most of the users will use ".word 0xfc050073",
to encode the instructions directly, rather than use .insn.  But
once we have supported the mapping symbols, the .word directives
are marked as data, so disassembler won't dump them as instructions
as usual.  I have discussed this with Kito many times, we all think
extend the .insn direcitve to support the hardcode encoding, is the
easiest way to resolve the problem.  Therefore, there are two more
.insn formats are proposed as follows,

(original) .insn <type>, <operand1>, <operand2>, ...
           .insn <insn-length>, <value>
           .insn <value>

The <type> is string, and the <insn-length> and <value> are constants.

gas/
* config/tc-riscv.c (riscv_ip_hardcode): Similar to riscv_ip,
but assembles an instruction according to the hardcode values
of .insn directive.
* doc/c-riscv.texi: Document two new .insn formats.
* testsuite/gas/riscv/insn-fail.d: New testcases.
* testsuite/gas/riscv/insn-fail.l: Likewise.
* testsuite/gas/riscv/insn-fail.s: Likewise.
* testsuite/gas/riscv/insn.d: Updated.
* testsuite/gas/riscv/insn.s: Likewise.
gas/config/tc-riscv.c
gas/doc/c-riscv.texi
gas/testsuite/gas/riscv/insn-fail.d [new file with mode: 0644]
gas/testsuite/gas/riscv/insn-fail.l [new file with mode: 0644]
gas/testsuite/gas/riscv/insn-fail.s [new file with mode: 0644]
gas/testsuite/gas/riscv/insn.d
gas/testsuite/gas/riscv/insn.s