From: Joel Sing Date: Wed, 2 Aug 2023 14:42:54 +0000 (+1000) Subject: cmd/internal/obj/arm64: add test coverage for VMOVS and VMOVD X-Git-Tag: go1.22rc1~1163 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=26d4ce70d41fa65ae8e5d7437610aa2ee146803a;p=gostls13.git 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 TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills Run-TryBot: Joel Sing --- diff --git a/src/cmd/internal/obj/arm64/asm_arm64_test.go b/src/cmd/internal/obj/arm64/asm_arm64_test.go index 7d28f97388..068039496a 100644 --- a/src/cmd/internal/obj/arm64/asm_arm64_test.go +++ b/src/cmd/internal/obj/arm64/asm_arm64_test.go @@ -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) } } diff --git a/src/cmd/internal/obj/arm64/asm_arm64_test.s b/src/cmd/internal/obj/arm64/asm_arm64_test.s index f85433c6e3..e3fda57775 100644 --- a/src/cmd/internal/obj/arm64/asm_arm64_test.s +++ b/src/cmd/internal/obj/arm64/asm_arm64_test.s @@ -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