]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/asm,cmd/internal/obj/riscv: add more error tests for riscv64 assembly
authorJoel Sing <joel@sing.id.au>
Sat, 21 Aug 2021 08:40:20 +0000 (18:40 +1000)
committerJoel Sing <joel@sing.id.au>
Wed, 1 Sep 2021 06:18:05 +0000 (06:18 +0000)
Add more error tests for riscv64 assembly. Also avoid a panic when one of
these error conditions is hit.

Change-Id: If5d913894facbd67f7d014eab745da77c8c66ab0
Reviewed-on: https://go-review.googlesource.com/c/go/+/344228
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
src/cmd/asm/internal/asm/testdata/riscv64error.s
src/cmd/internal/obj/riscv/obj.go

index fb43e68fc1740b131328778f0612ccf99455674f..b09a1c7a8c969e9b4497311e7cf88fda89b3e5f9 100644 (file)
@@ -3,6 +3,14 @@
 // license that can be found in the LICENSE file.
 
 TEXT errors(SB),$0
+       MOV     $errors(SB), (X5)               // ERROR "unsupported addr MOV"
+       MOV     $8(SP), (X5)                    // ERROR "unsupported addr MOV"
+       MOVB    $8(SP), X5                      // ERROR "unsupported addr MOV"
+       MOVH    $8(SP), X5                      // ERROR "unsupported addr MOV"
+       MOVW    $8(SP), X5                      // ERROR "unsupported addr MOV"
+       MOVF    $8(SP), X5                      // ERROR "unsupported addr MOV"
+       MOV     $1234, 0(SP)                    // ERROR "constant load must target register"
+       MOV     $1234, 8(SP)                    // ERROR "constant load must target register"
        MOV     $0, 0(SP)                       // ERROR "constant load must target register"
        MOV     $0, 8(SP)                       // ERROR "constant load must target register"
        MOV     $1234, 0(SP)                    // ERROR "constant load must target register"
@@ -11,4 +19,8 @@ TEXT errors(SB),$0
        MOVH    $1, X5                          // ERROR "unsupported constant load"
        MOVW    $1, X5                          // ERROR "unsupported constant load"
        MOVF    $1, X5                          // ERROR "unsupported constant load"
+       MOVBU   X5, (X6)                        // ERROR "unsupported unsigned store"
+       MOVHU   X5, (X6)                        // ERROR "unsupported unsigned store"
+       MOVWU   X5, (X6)                        // ERROR "unsupported unsigned store"
+
        RET
index a305edab4b39348dcb803815e6ab842d28d724a7..f89e13d81c95b817b39ea598bce3b6652766addc 100644 (file)
@@ -271,6 +271,7 @@ func rewriteMOV(ctxt *obj.Link, newprog obj.ProgAlloc, p *obj.Prog) {
                        switch p.As {
                        case AMOVBU, AMOVHU, AMOVWU:
                                ctxt.Diag("unsupported unsigned store at %v", p)
+                               return
                        }
                        switch p.To.Name {
                        case obj.NAME_AUTO, obj.NAME_PARAM, obj.NAME_NONE:
@@ -1795,7 +1796,7 @@ func instructionsForProg(p *obj.Prog) []*instruction {
        case AMOV, AMOVB, AMOVH, AMOVW, AMOVBU, AMOVHU, AMOVWU, AMOVF, AMOVD:
                // Handle register to register moves.
                if p.From.Type != obj.TYPE_REG || p.To.Type != obj.TYPE_REG {
-                       break
+                       return nil
                }
                switch p.As {
                case AMOV: // MOV Ra, Rb -> ADDI $0, Ra, Rb