1
2
3
4
5 package arm64
6
7 import "testing"
8
9 func testvmovs() (r1, r2 uint64)
10 func testvmovd() (r1, r2 uint64)
11 func testvmovq() (r1, r2 uint64)
12
13 func TestVMOV(t *testing.T) {
14 tests := []struct {
15 op string
16 vmovFunc func() (uint64, uint64)
17 wantA, wantB uint64
18 }{
19 {"VMOVS", testvmovs, 0x80402010, 0},
20 {"VMOVD", testvmovd, 0x7040201008040201, 0},
21 {"VMOVQ", testvmovq, 0x7040201008040201, 0x3040201008040201},
22 }
23 for _, test := range tests {
24 gotA, gotB := test.vmovFunc()
25 if gotA != test.wantA || gotB != test.wantB {
26 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)
27 }
28 }
29 }
30
31 func testmovk() uint64
32
33
34 func TestMOVK(t *testing.T) {
35 x := testmovk()
36 want := uint64(40000 << 48)
37 if x != want {
38 t.Errorf("Got %x want %x\n", x, want)
39 }
40 }
41
42 func testCombined() (a uint64, b uint64)
43 func TestCombined(t *testing.T) {
44 got1, got2 := testCombined()
45 want1 := uint64(0xaaaaaaaaaaaaaaab)
46 want2 := uint64(0x0ff019940ff00ff0)
47 if got1 != want1 {
48 t.Errorf("First result, got %x want %x", got1, want1)
49 }
50 if got2 != want2 {
51 t.Errorf("First result, got %x want %x", got2, want2)
52 }
53 }
54
View as plain text