diff options
| author | Mark Ryan <markdryan@rivosinc.com> | 2025-05-01 10:43:32 +0200 |
|---|---|---|
| committer | Mark Ryan <markdryan@rivosinc.com> | 2025-05-08 01:53:43 -0700 |
| commit | d000963d045bb279d347dbd3551e9468422c17af (patch) | |
| tree | 7f1546146b3466bf62de2e1ab4921ceb3ec05af8 /src/cmd/internal/obj | |
| parent | 5a1f47a7f716ce0dbd88128d18ce556dd9280c68 (diff) | |
| download | go-d000963d045bb279d347dbd3551e9468422c17af.tar.xz | |
cmd/internal/obj/riscv: reject invalid vadc/vsbc encodings
The RISC-V Instruction Set Manual Volume states that "for vadc and
vsbc, the instruction encoding is reserved if the destination vector
register is v0". The assembler currently allows instructions like
VADCVVM V1, V2, V0, V0
to be assembled. It's not clear what the behaviour of such
instructions will be on target hardware so it's best to disallow
them.
For reference, binutils (2.44-3.fc42) allows the instruction
vadc.vvm v0, v4, v8, v0
to be assembled and the instruction actually executes on a Banana PI
F3 without crashing. However, clang (20.1.2) refuses to assemble the
instruction, producing the following error.
error: the destination vector register group cannot be V0
vadc.vvm v0, v4, v8, v0
^
Change-Id: Ia913cbd864ae8dbcf9227f69b963c93a99481cff
Reviewed-on: https://go-review.googlesource.com/c/go/+/669315
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Diffstat (limited to 'src/cmd/internal/obj')
| -rw-r--r-- | src/cmd/internal/obj/riscv/obj.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go index f4a2cb5fa4..3c91a1f02c 100644 --- a/src/cmd/internal/obj/riscv/obj.go +++ b/src/cmd/internal/obj/riscv/obj.go @@ -3773,8 +3773,13 @@ func instructionsForProg(p *obj.Prog) []*instruction { ins.funct7 |= 1 // unmasked ins.rd, ins.rs1, ins.rs2 = uint32(p.To.Reg), uint32(p.From.Reg), REG_V0 - case AVADCVVM, AVADCVXM, AVMADCVVM, AVMADCVXM, AVSBCVVM, AVSBCVXM, AVMSBCVVM, AVMSBCVXM, AVADCVIM, AVMADCVIM, - AVMERGEVVM, AVMERGEVXM, AVMERGEVIM, AVFMERGEVFM: + case AVADCVIM, AVADCVVM, AVADCVXM, AVSBCVVM, AVSBCVXM: + if ins.rd == REG_V0 { + p.Ctxt.Diag("%v: invalid destination register V0", p) + } + fallthrough + + case AVMADCVVM, AVMADCVXM, AVMSBCVVM, AVMSBCVXM, AVMADCVIM, AVMERGEVVM, AVMERGEVXM, AVMERGEVIM, AVFMERGEVFM: if ins.rs3 != REG_V0 { p.Ctxt.Diag("%v: invalid vector mask register", p) } |
