]> Cypherpunks repositories - gostls13.git/commit
cmd/asm,cmd/internal/obj/riscv: add support for riscv compressed instructions
authorJoel Sing <joel@sing.id.au>
Tue, 9 Sep 2025 14:17:00 +0000 (00:17 +1000)
committerJoel Sing <joel@sing.id.au>
Thu, 13 Nov 2025 12:17:37 +0000 (04:17 -0800)
commit0f9c8fb29dfe70f3688bda95cb6cb38dfa7fff9f
tree2944ba9d3669b23c459b58c1441bab7b7b14e5d1
parenta15d036ce25aa4dd7d2e0aa42ce0cc792cf31a5d
cmd/asm,cmd/internal/obj/riscv: add support for riscv compressed instructions

Add support for compressed instructions in the RISC-V assembler. This
implements instruction validation and encoding for all instructions in
the "C" extension.

It is worth noting that the validation and encoding of these instructions
is far more convoluted then the typical instruction validation and
encoding. While the current model has been followed for now, it would be
worth revisiting this in the future and potentially switching to a table
based or even per-instruction implementation.

Additionally, the current instruction encoding is lacking some of the bits
needed for compressed instructions - this is solved by compressedEncoding,
which provides the missing information. This will also be addressed in the
future, likely by changing the instruction encoding format.

Updates #71105

Change-Id: I0f9359d63f93ebbdc6e708e79429b2d61eae220d
Reviewed-on: https://go-review.googlesource.com/c/go/+/713020
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
src/cmd/asm/internal/arch/arch.go
src/cmd/asm/internal/asm/testdata/riscv64.s
src/cmd/asm/internal/asm/testdata/riscv64validation.s
src/cmd/internal/obj/riscv/obj.go