Skip to content

Commit 5a1f47a

Browse files
committed
cmd/internal/obj/riscv: fix LMUL encoding for MF2 and MF8
The encodings for the riscv64 special operands SPOP_MF2 and SPOP_MF8 are incorrect, i.e., their values are swapped. This leads to incorrect encodings for the VSETVLI and VSETIVLI instructions. The assembler currently encodes VSETVLI X10, E32, MF8, TA, MA, X12 as VSETVLI X10, E32, MF2, TA, MA, X12 We update the encodings for SPOP_MF2 and SPOP_MF8 so that they match the LMUL table in section "31.3.4. Vector type register, vtype" of the "RISC-V Instruction Set Manual Volume 1". Change-Id: Ic73355533d7c2a901ee060b35c2f7af6d58453e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/670016 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Joel Sing <joel@sing.id.au>
1 parent d13da63 commit 5a1f47a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/cmd/asm/internal/asm/testdata/riscv64.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,9 @@ start:
438438
VSETVLI X10, E32, M2, TA, MA, X12 // 5776150d
439439
VSETVLI X10, E32, M4, TA, MA, X12 // 5776250d
440440
VSETVLI X10, E32, M8, TA, MA, X12 // 5776350d
441-
VSETVLI X10, E32, MF2, TA, MA, X12 // 5776550d
441+
VSETVLI X10, E32, MF8, TA, MA, X12 // 5776550d
442442
VSETVLI X10, E32, MF4, TA, MA, X12 // 5776650d
443-
VSETVLI X10, E32, MF8, TA, MA, X12 // 5776750d
443+
VSETVLI X10, E32, MF2, TA, MA, X12 // 5776750d
444444
VSETVLI X10, E32, M1, TA, MA, X12 // 5776050d
445445
VSETVLI $15, E32, M1, TA, MA, X12 // 57f607cd
446446
VSETIVLI $0, E32, M1, TA, MA, X12 // 577600cd

src/cmd/internal/obj/riscv/cpu.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,9 +1297,9 @@ var specialOperands = map[SpecialOperand]struct {
12971297
SPOP_M2: {encoding: 1, name: "M2"},
12981298
SPOP_M4: {encoding: 2, name: "M4"},
12991299
SPOP_M8: {encoding: 3, name: "M8"},
1300-
SPOP_MF2: {encoding: 5, name: "MF2"},
1300+
SPOP_MF8: {encoding: 5, name: "MF8"},
13011301
SPOP_MF4: {encoding: 6, name: "MF4"},
1302-
SPOP_MF8: {encoding: 7, name: "MF8"},
1302+
SPOP_MF2: {encoding: 7, name: "MF2"},
13031303

13041304
SPOP_E8: {encoding: 0, name: "E8"},
13051305
SPOP_E16: {encoding: 1, name: "E16"},

0 commit comments

Comments
 (0)