diff options
| author | Joel Sing <joel@sing.id.au> | 2025-09-10 00:17:00 +1000 |
|---|---|---|
| committer | Joel Sing <joel@sing.id.au> | 2025-11-13 04:17:37 -0800 |
| commit | 0f9c8fb29dfe70f3688bda95cb6cb38dfa7fff9f (patch) | |
| tree | 2944ba9d3669b23c459b58c1441bab7b7b14e5d1 /src/cmd/asm/internal/arch | |
| parent | a15d036ce25aa4dd7d2e0aa42ce0cc792cf31a5d (diff) | |
| download | go-0f9c8fb29dfe70f3688bda95cb6cb38dfa7fff9f.tar.xz | |
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>
Diffstat (limited to 'src/cmd/asm/internal/arch')
| -rw-r--r-- | src/cmd/asm/internal/arch/arch.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cmd/asm/internal/arch/arch.go b/src/cmd/asm/internal/arch/arch.go index 8481a8f378..fb9e785111 100644 --- a/src/cmd/asm/internal/arch/arch.go +++ b/src/cmd/asm/internal/arch/arch.go @@ -92,7 +92,8 @@ func jumpX86(word string) bool { func jumpRISCV(word string) bool { switch word { case "BEQ", "BEQZ", "BGE", "BGEU", "BGEZ", "BGT", "BGTU", "BGTZ", "BLE", "BLEU", "BLEZ", - "BLT", "BLTU", "BLTZ", "BNE", "BNEZ", "CALL", "JAL", "JALR", "JMP": + "BLT", "BLTU", "BLTZ", "BNE", "BNEZ", "CALL", "CBEQZ", "CBNEZ", "CJ", "CJALR", "CJR", + "JAL", "JALR", "JMP": return true } return false |
