Skip to content

Commit 26d4ce7

Browse files
committed
cmd/internal/obj/arm64: add test coverage for VMOVS and VMOVD
Change-Id: I31ba6696e124dccf37d674d090fdf04ba0a049a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/515616 Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Joel Sing <[email protected]>
1 parent 14f5eb7 commit 26d4ce7

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,25 @@ func TestPCALIGN(t *testing.T) {
301301
}
302302
}
303303

304+
func testvmovs() (r1, r2 uint64)
305+
func testvmovd() (r1, r2 uint64)
304306
func testvmovq() (r1, r2 uint64)
305307

306-
// TestVMOVQ checks if the arm64 VMOVQ instruction is working properly.
307-
func TestVMOVQ(t *testing.T) {
308-
a, b := testvmovq()
309-
if a != 0x7040201008040201 || b != 0x3040201008040201 {
310-
t.Errorf("TestVMOVQ got: a=0x%x, b=0x%x, want: a=0x7040201008040201, b=0x3040201008040201", a, b)
308+
func TestVMOV(t *testing.T) {
309+
tests := []struct {
310+
op string
311+
vmovFunc func() (uint64, uint64)
312+
wantA, wantB uint64
313+
}{
314+
{"VMOVS", testvmovs, 0x80402010, 0},
315+
{"VMOVD", testvmovd, 0x7040201008040201, 0},
316+
{"VMOVQ", testvmovq, 0x7040201008040201, 0x3040201008040201},
317+
}
318+
for _, test := range tests {
319+
gotA, gotB := test.vmovFunc()
320+
if gotA != test.wantA || gotB != test.wantB {
321+
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)
322+
}
311323
}
312324
}
313325

@@ -318,6 +330,6 @@ func TestMOVK(t *testing.T) {
318330
x := testmovk()
319331
want := uint64(40000 << 48)
320332
if x != want {
321-
t.Errorf("TestMOVK got %x want %x\n", x, want)
333+
t.Errorf("Got %x want %x\n", x, want)
322334
}
323335
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44

55
#include "textflag.h"
66

7+
// testvmovs() (r1, r2 uint64)
8+
TEXT ·testvmovs(SB), NOSPLIT, $0-16
9+
VMOVS $0x80402010, V1
10+
VMOV V1.D[0], R0
11+
VMOV V1.D[1], R1
12+
MOVD R0, r1+0(FP)
13+
MOVD R1, r2+8(FP)
14+
RET
15+
16+
// testvmovd() (r1, r2 uint64)
17+
TEXT ·testvmovd(SB), NOSPLIT, $0-16
18+
VMOVD $0x7040201008040201, V1
19+
VMOV V1.D[0], R0
20+
VMOV V1.D[1], R1
21+
MOVD R0, r1+0(FP)
22+
MOVD R1, r2+8(FP)
23+
RET
24+
725
// testvmovq() (r1, r2 uint64)
826
TEXT ·testvmovq(SB), NOSPLIT, $0-16
927
VMOVQ $0x7040201008040201, $0x3040201008040201, V1

0 commit comments

Comments
 (0)