From: Ben Shi Date: Thu, 31 Mar 2022 14:34:32 +0000 (+0000) Subject: cmd/internal/obj/riscv: fix illegal form of MOV instructions X-Git-Tag: go1.19beta1~816 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5dbfa6e61a2a733bca601c330967d12a3a5b12f4;p=gostls13.git cmd/internal/obj/riscv: fix illegal form of MOV instructions The MOV like instructions should only have two operands. Change-Id: Icbfb49e47a91ac305194c2f140d3d81c912f6d6d GitHub-Last-Rev: 2b25aaa0ed126e8a019db09247953b27123d493f GitHub-Pull-Request: golang/go#52073 Reviewed-on: https://go-review.googlesource.com/c/go/+/397175 Run-TryBot: Ben Shi TryBot-Result: Gopher Robot Reviewed-by: mzh Reviewed-by: Cherry Mui --- diff --git a/src/cmd/asm/internal/asm/testdata/riscv64error.s b/src/cmd/asm/internal/asm/testdata/riscv64error.s index 238552565b..d3e43e721d 100644 --- a/src/cmd/asm/internal/asm/testdata/riscv64error.s +++ b/src/cmd/asm/internal/asm/testdata/riscv64error.s @@ -22,5 +22,9 @@ TEXT errors(SB),$0 MOVBU X5, (X6) // ERROR "unsupported unsigned store" MOVHU X5, (X6) // ERROR "unsupported unsigned store" MOVWU X5, (X6) // ERROR "unsupported unsigned store" + MOVF F0, F1, F2 // ERROR "illegal MOV instruction" + MOVD F0, F1, F2 // ERROR "illegal MOV instruction" + MOV X10, X11, X12 // ERROR "illegal MOV instruction" + MOVW X10, X11, X12 // ERROR "illegal MOV instruction" RET diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go index 47dbfc0fed..61044b0531 100644 --- a/src/cmd/internal/obj/riscv/obj.go +++ b/src/cmd/internal/obj/riscv/obj.go @@ -1806,6 +1806,11 @@ func instructionsForMOV(p *obj.Prog) []*instruction { ins := instructionForProg(p) inss := []*instruction{ins} + if p.Reg != 0 { + p.Ctxt.Diag("%v: illegal MOV instruction", p) + return nil + } + switch { case p.From.Type == obj.TYPE_CONST && p.To.Type == obj.TYPE_REG: // Handle constant to register moves.