]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/arm64: fix assemble VLD1/VST1 bug
authorfanzha02 <fannie.zhang@arm.com>
Tue, 16 Jan 2018 03:00:04 +0000 (03:00 +0000)
committerCherry Zhang <cherryyz@google.com>
Tue, 23 Jan 2018 15:59:15 +0000 (15:59 +0000)
The current code misassembles VLD1/VST1 instruction with non-zero
offset. The offset is dropped silently without any error message.
The cause of the misassembling is the current code treats argument
(Rn)(Rm) as ZOREG type.

The fix changes the matching rules and considers (Rn)(Rm) as ROFF
type. The fix will report error information when assembles VLD1/VST1
(R8)(R13), [V1.16B].
The fix enables the ARM64Errors test.

Fixes #23448

Change-Id: I3dd518b91e9960131ffb8efcb685cb8df84b70eb
Reviewed-on: https://go-review.googlesource.com/87956
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/asm/internal/asm/endtoend_test.go
src/cmd/asm/internal/asm/testdata/arm64error.s [new file with mode: 0644]
src/cmd/internal/obj/arm64/asm7.go

index e877a5317861d272f4dc6ca381ce453b6f4e6f54..d8a447d95835d7213f5cecb08d15fc94a614e5f3 100644 (file)
@@ -385,6 +385,10 @@ func TestARM64Encoder(t *testing.T) {
        testEndToEnd(t, "arm64", "arm64enc")
 }
 
+func TestARM64Errors(t *testing.T) {
+       testErrors(t, "arm64", "arm64error")
+}
+
 func TestAMD64EndToEnd(t *testing.T) {
        testEndToEnd(t, "amd64", "amd64")
 }
diff --git a/src/cmd/asm/internal/asm/testdata/arm64error.s b/src/cmd/asm/internal/asm/testdata/arm64error.s
new file mode 100644 (file)
index 0000000..97af09c
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+TEXT errors(SB),$0
+       MOVD.P  300(R2), R3            // ERROR "offset out of range [-255,254]"
+       MOVD.P  R3, 344(R2)            // ERROR "offset out of range [-255,254]"
+       VLD1    (R8)(R13), [V2.B16]    // ERROR "illegal combination"
+       VLD1    8(R9), [V2.B16]        // ERROR "illegal combination"
+       VST1    [V1.B16], (R8)(R13)    // ERROR "illegal combination"
+       VST1    [V1.B16], 9(R2)        // ERROR "illegal combination"
+       VLD1    8(R8)(R13), [V2.B16]   // ERROR "illegal combination"
+       RET
index 824fece5505201e253040761a9f88d5e97a5fec8..fdf1fb565dc5cb1e5526e57ad61d820f2f16ec12 100644 (file)
@@ -584,6 +584,7 @@ var optab = []Optab{
        {AVADD, C_VREG, C_NONE, C_VREG, 89, 4, 0, 0, 0},
        {AVLD1, C_ZOREG, C_NONE, C_LIST, 81, 4, 0, 0, 0},
        {AVLD1, C_LOREG, C_NONE, C_LIST, 81, 4, 0, 0, C_XPOST},
+       {AVLD1, C_ROFF, C_NONE, C_LIST, 81, 4, 0, 0, C_XPOST},
        {AVMOV, C_ELEM, C_NONE, C_REG, 73, 4, 0, 0, 0},
        {AVMOV, C_REG, C_NONE, C_ARNG, 82, 4, 0, 0, 0},
        {AVMOV, C_ARNG, C_NONE, C_ARNG, 83, 4, 0, 0, 0},
@@ -592,6 +593,7 @@ var optab = []Optab{
        {AVREV32, C_ARNG, C_NONE, C_ARNG, 83, 4, 0, 0, 0},
        {AVST1, C_LIST, C_NONE, C_ZOREG, 84, 4, 0, 0, 0},
        {AVST1, C_LIST, C_NONE, C_LOREG, 84, 4, 0, 0, C_XPOST},
+       {AVST1, C_LIST, C_NONE, C_ROFF, 84, 4, 0, 0, C_XPOST},
        {AVDUP, C_ELEM, C_NONE, C_ARNG, 79, 4, 0, 0, 0},
        {AVADDV, C_ARNG, C_NONE, C_VREG, 85, 4, 0, 0, 0},
        {AVMOVI, C_ADDCON, C_NONE, C_ARNG, 86, 4, 0, 0, 0},
@@ -1268,6 +1270,12 @@ func (c *ctxt7) aclass(a *obj.Addr) int {
                        return autoclass(c.instoffset)
 
                case obj.NAME_NONE:
+                       if a.Index != 0 {
+                               if a.Offset != 0 {
+                                       return C_GOK
+                               }
+                               return C_ROFF
+                       }
                        c.instoffset = a.Offset
                        return oregclass(c.instoffset)
                }
@@ -1417,7 +1425,7 @@ func (c *ctxt7) oplook(p *obj.Prog) *Optab {
                }
        }
 
-       c.ctxt.Diag("illegal combination %v %v %v %v, %d %d", p, DRconv(a1), DRconv(a2), DRconv(a3), p.From.Type, p.To.Type)
+       c.ctxt.Diag("illegal combination: %v %v %v %v, %d %d", p, DRconv(a1), DRconv(a2), DRconv(a3), p.From.Type, p.To.Type)
        if ops == nil {
                ops = optab
        }
@@ -2523,7 +2531,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
                v := int32(p.From.Offset)
 
                if v < -256 || v > 255 {
-                       c.ctxt.Diag("offset out of range\n%v", p)
+                       c.ctxt.Diag("offset out of range [-255,254]: %v", p)
                }
                o1 = c.opldrpp(p, p.As)
                if o.scond == C_XPOST {
@@ -2537,7 +2545,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
                v := int32(p.To.Offset)
 
                if v < -256 || v > 255 {
-                       c.ctxt.Diag("offset out of range\n%v", p)
+                       c.ctxt.Diag("offset out of range [-255,254]: %v", p)
                }
                o1 = LD2STR(c.opldrpp(p, p.As))
                if o.scond == C_XPOST {