cmd/asm, cmd/internal/obj: add riscv64 generic CSR ops

Support is added for the generic RISC-V CSR operations; CSRRC, CSRRCI,
CSRRS, CSRRSI, CSRRW, CSRRWI.  These instructions require special
handling as their second operand is a symbolic CSR register name and
not an immediate value or a register.  CSR names are implemented as
special operands.

RISC-V CSRs are not currently saved and restored when a go routine is
asynchronously pre-empted so it is only safe to use these instructions
in hand written assembler.  Note that CSRRS was already partially
supported by the assembler so this restriction predates this commit.
We mention it here as this commit makes CSRRS much easier to use.

Change-Id: I9ff8d804328b418a879d463e7d9cc31f489c7a00
Reviewed-on: https://go-review.googlesource.com/c/go/+/630519
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
Mark Ryan 2024-09-18 10:14:04 +02:00
parent f37d75472d
commit dd8276657f
8 changed files with 165 additions and 13 deletions

View file

@ -99,7 +99,7 @@ import (
//
// <symbolic constant name>
// Special symbolic constants for ARM64 (such as conditional flags, tlbi_op and so on)
// and RISCV64 (such as names for vector configuration instruction arguments).
// and RISCV64 (such as names for vector configuration instruction arguments and CSRs).
// Encoding:
// type = TYPE_SPECIAL
// offset = The constant value corresponding to this symbol