}
}
+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)
+ }
}
}
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)
}
}
#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