...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package x86_64
18
19 import (
20 `testing`
21
22 `github.com/davecgh/go-spew/spew`
23 )
24
25 func TestInstr_Encode(t *testing.T) {
26 m := []byte(nil)
27 a := CreateArch()
28 p := a.CreateProgram()
29 p.VPERMIL2PD(7, Sib(R8, R9, 1, 12345), YMM1, YMM2, YMM3).encode(&m)
30 spew.Dump(m)
31 }
32
33 func TestInstr_EncodeSegment(t *testing.T) {
34 m := []byte(nil)
35 a := CreateArch()
36 p := a.CreateProgram()
37 p.MOVQ(Abs(0x30), RCX).GS().encode(&m)
38 spew.Dump(m)
39 }
40
41 func BenchmarkInstr_Encode(b *testing.B) {
42 a := CreateArch()
43 m := make([]byte, 0, 16)
44 p := a.CreateProgram()
45 p.VPERMIL2PD(7, Sib(R8, R9, 1, 12345), YMM1, YMM2, YMM3).encode(&m)
46 p.Free()
47 b.SetBytes(int64(len(m)))
48 b.ResetTimer()
49 for i := 0; i < b.N; i++ {
50 m = m[:0]
51 p = a.CreateProgram()
52 p.VPERMIL2PD(7, Sib(R8, R9, 1, 12345), YMM1, YMM2, YMM3).encode(&m)
53 p.Free()
54 }
55 }
56
View as plain text