]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/arm64: add test coverage for VMOVS and VMOVD
authorJoel Sing <joel@sing.id.au>
Wed, 2 Aug 2023 14:42:54 +0000 (00:42 +1000)
committerJoel Sing <joel@sing.id.au>
Tue, 22 Aug 2023 02:46:11 +0000 (02:46 +0000)
Change-Id: I31ba6696e124dccf37d674d090fdf04ba0a049a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/515616
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>

src/cmd/internal/obj/arm64/asm_arm64_test.go
src/cmd/internal/obj/arm64/asm_arm64_test.s

index 7d28f973880158659ff7981e7ec05e8d4fa5adf4..068039496a23f6451d0a8306f5f8c03bee503601 100644 (file)
@@ -301,13 +301,25 @@ func TestPCALIGN(t *testing.T) {
        }
 }
 
+func testvmovs() (r1, r2 uint64)
+func testvmovd() (r1, r2 uint64)
 func testvmovq() (r1, r2 uint64)
 
-// TestVMOVQ checks if the arm64 VMOVQ instruction is working properly.
-func TestVMOVQ(t *testing.T) {
-       a, b := testvmovq()
-       if a != 0x7040201008040201 || b != 0x3040201008040201 {
-               t.Errorf("TestVMOVQ got: a=0x%x, b=0x%x, want: a=0x7040201008040201, b=0x3040201008040201", a, b)
+func TestVMOV(t *testing.T) {
+       tests := []struct {
+               op           string
+               vmovFunc     func() (uint64, uint64)
+               wantA, wantB uint64
+       }{
+               {"VMOVS", testvmovs, 0x80402010, 0},
+               {"VMOVD", testvmovd, 0x7040201008040201, 0},
+               {"VMOVQ", testvmovq, 0x7040201008040201, 0x3040201008040201},
+       }
+       for _, test := range tests {
+               gotA, gotB := test.vmovFunc()
+               if gotA != test.wantA || gotB != test.wantB {
+                       t.Errorf("%v: got: a=0x%x, b=0x%x, want: a=0x%x, b=0x%x", test.op, gotA, gotB, test.wantA, test.wantB)
+               }
        }
 }
 
@@ -318,6 +330,6 @@ func TestMOVK(t *testing.T) {
        x := testmovk()
        want := uint64(40000 << 48)
        if x != want {
-               t.Errorf("TestMOVK got %x want %x\n", x, want)
+               t.Errorf("Got %x want %x\n", x, want)
        }
 }
index f85433c6e3ca3068721efcaa9d00d68bce71ccd8..e3fda57775f3af3032d411aac4ff896505872f27 100644 (file)
@@ -4,6 +4,24 @@
 
 #include "textflag.h"
 
+// testvmovs() (r1, r2 uint64)
+TEXT ·testvmovs(SB), NOSPLIT, $0-16
+       VMOVS   $0x80402010, V1
+       VMOV    V1.D[0], R0
+       VMOV    V1.D[1], R1
+       MOVD    R0, r1+0(FP)
+       MOVD    R1, r2+8(FP)
+       RET
+
+// testvmovd() (r1, r2 uint64)
+TEXT ·testvmovd(SB), NOSPLIT, $0-16
+       VMOVD   $0x7040201008040201, V1
+       VMOV    V1.D[0], R0
+       VMOV    V1.D[1], R1
+       MOVD    R0, r1+0(FP)
+       MOVD    R1, r2+8(FP)
+       RET
+
 // testvmovq() (r1, r2 uint64)
 TEXT ·testvmovq(SB), NOSPLIT, $0-16
        VMOVQ   $0x7040201008040201, $0x3040201008040201, V1