License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / tools / perf / arch / x86 / annotate / instructions.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
763d8960
ACM
2static struct ins x86__instructions[] = {
3 { .name = "add", .ops = &mov_ops, },
4 { .name = "addl", .ops = &mov_ops, },
5 { .name = "addq", .ops = &mov_ops, },
6 { .name = "addw", .ops = &mov_ops, },
7 { .name = "and", .ops = &mov_ops, },
8 { .name = "bts", .ops = &mov_ops, },
9 { .name = "call", .ops = &call_ops, },
10 { .name = "callq", .ops = &call_ops, },
11 { .name = "cmp", .ops = &mov_ops, },
12 { .name = "cmpb", .ops = &mov_ops, },
13 { .name = "cmpl", .ops = &mov_ops, },
14 { .name = "cmpq", .ops = &mov_ops, },
15 { .name = "cmpw", .ops = &mov_ops, },
16 { .name = "cmpxch", .ops = &mov_ops, },
17 { .name = "dec", .ops = &dec_ops, },
18 { .name = "decl", .ops = &dec_ops, },
19 { .name = "imul", .ops = &mov_ops, },
20 { .name = "inc", .ops = &dec_ops, },
21 { .name = "incl", .ops = &dec_ops, },
22 { .name = "ja", .ops = &jump_ops, },
23 { .name = "jae", .ops = &jump_ops, },
24 { .name = "jb", .ops = &jump_ops, },
25 { .name = "jbe", .ops = &jump_ops, },
26 { .name = "jc", .ops = &jump_ops, },
27 { .name = "jcxz", .ops = &jump_ops, },
28 { .name = "je", .ops = &jump_ops, },
29 { .name = "jecxz", .ops = &jump_ops, },
30 { .name = "jg", .ops = &jump_ops, },
31 { .name = "jge", .ops = &jump_ops, },
32 { .name = "jl", .ops = &jump_ops, },
33 { .name = "jle", .ops = &jump_ops, },
34 { .name = "jmp", .ops = &jump_ops, },
35 { .name = "jmpq", .ops = &jump_ops, },
36 { .name = "jna", .ops = &jump_ops, },
37 { .name = "jnae", .ops = &jump_ops, },
38 { .name = "jnb", .ops = &jump_ops, },
39 { .name = "jnbe", .ops = &jump_ops, },
40 { .name = "jnc", .ops = &jump_ops, },
41 { .name = "jne", .ops = &jump_ops, },
42 { .name = "jng", .ops = &jump_ops, },
43 { .name = "jnge", .ops = &jump_ops, },
44 { .name = "jnl", .ops = &jump_ops, },
45 { .name = "jnle", .ops = &jump_ops, },
46 { .name = "jno", .ops = &jump_ops, },
47 { .name = "jnp", .ops = &jump_ops, },
48 { .name = "jns", .ops = &jump_ops, },
49 { .name = "jnz", .ops = &jump_ops, },
50 { .name = "jo", .ops = &jump_ops, },
51 { .name = "jp", .ops = &jump_ops, },
52 { .name = "jpe", .ops = &jump_ops, },
53 { .name = "jpo", .ops = &jump_ops, },
54 { .name = "jrcxz", .ops = &jump_ops, },
55 { .name = "js", .ops = &jump_ops, },
56 { .name = "jz", .ops = &jump_ops, },
57 { .name = "lea", .ops = &mov_ops, },
58 { .name = "lock", .ops = &lock_ops, },
59 { .name = "mov", .ops = &mov_ops, },
60 { .name = "movb", .ops = &mov_ops, },
61 { .name = "movdqa", .ops = &mov_ops, },
62 { .name = "movl", .ops = &mov_ops, },
63 { .name = "movq", .ops = &mov_ops, },
64 { .name = "movslq", .ops = &mov_ops, },
65 { .name = "movzbl", .ops = &mov_ops, },
66 { .name = "movzwl", .ops = &mov_ops, },
67 { .name = "nop", .ops = &nop_ops, },
68 { .name = "nopl", .ops = &nop_ops, },
69 { .name = "nopw", .ops = &nop_ops, },
70 { .name = "or", .ops = &mov_ops, },
71 { .name = "orl", .ops = &mov_ops, },
72 { .name = "test", .ops = &mov_ops, },
73 { .name = "testb", .ops = &mov_ops, },
74 { .name = "testl", .ops = &mov_ops, },
75 { .name = "xadd", .ops = &mov_ops, },
76 { .name = "xbeginl", .ops = &jump_ops, },
77 { .name = "xbeginq", .ops = &jump_ops, },
78 { .name = "retq", .ops = &ret_ops, },
79};
69fb09f6
JY
80
81static bool x86__ins_is_fused(struct arch *arch, const char *ins1,
82 const char *ins2)
83{
84 if (arch->family != 6 || arch->model < 0x1e || strstr(ins2, "jmp"))
85 return false;
86
87 if (arch->model == 0x1e) {
88 /* Nehalem */
89 if ((strstr(ins1, "cmp") && !strstr(ins1, "xchg")) ||
90 strstr(ins1, "test")) {
91 return true;
92 }
93 } else {
94 /* Newer platform */
95 if ((strstr(ins1, "cmp") && !strstr(ins1, "xchg")) ||
96 strstr(ins1, "test") ||
97 strstr(ins1, "add") ||
98 strstr(ins1, "sub") ||
99 strstr(ins1, "and") ||
100 strstr(ins1, "inc") ||
101 strstr(ins1, "dec")) {
102 return true;
103 }
104 }
105
106 return false;
107}
108
109static int x86__cpuid_parse(struct arch *arch, char *cpuid)
110{
111 unsigned int family, model, stepping;
112 int ret;
113
114 /*
115 * cpuid = "GenuineIntel,family,model,stepping"
116 */
117 ret = sscanf(cpuid, "%*[^,],%u,%u,%u", &family, &model, &stepping);
118 if (ret == 3) {
119 arch->family = family;
120 arch->model = model;
121 return 0;
122 }
123
124 return -1;
125}