aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2023-08-03 00:42:54 +1000
committerJoel Sing <joel@sing.id.au>2023-08-22 02:46:11 +0000
commit26d4ce70d41fa65ae8e5d7437610aa2ee146803a (patch)
tree42cad8f983c4f0470262adcf9df2fbbc18142c8b /src/cmd/internal/obj
parent14f5eb7f31305c682c9734d682e7baa54a1cf63b (diff)
downloadgo-26d4ce70d41fa65ae8e5d7437610aa2ee146803a.tar.xz
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 <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>
Diffstat (limited to 'src/cmd/internal/obj')
-rw-r--r--src/cmd/internal/obj/arm64/asm_arm64_test.go24
-rw-r--r--src/cmd/internal/obj/arm64/asm_arm64_test.s18
2 files changed, 36 insertions, 6 deletions
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