1
0
mirror of https://github.com/golang/go synced 2024-11-26 22:01:27 -07:00

cmd/asm,cmd/internal/obj/riscv: add more error tests for riscv64 assembly

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>
This commit is contained in:
Joel Sing 2021-08-21 18:40:20 +10:00
parent faf9c7d8fe
commit 5a687eeaf1
2 changed files with 14 additions and 1 deletions

View 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

View 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