]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/internal/obj/riscv: fix illegal form of MOV instructions
authorBen Shi <ben.shi@streamcomputing.com>
Thu, 31 Mar 2022 14:34:32 +0000 (14:34 +0000)
committerBen Shi <powerman1st@163.com>
Fri, 1 Apr 2022 01:17:45 +0000 (01:17 +0000)
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 <powerman1st@163.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: mzh <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/asm/internal/asm/testdata/riscv64error.s
src/cmd/internal/obj/riscv/obj.go

index 238552565bdd2f6fe1fe1f9769f7020403a6a5a7..d3e43e721db55e7068a47cf4b3bdd1a2b18968b2 100644 (file)
@@ -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
index 47dbfc0fed6c2d1640e6db57888a6d8af4425d1e..61044b053147c76e8caac32a36e8827bcf1b92db 100644 (file)
@@ -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.