This source file includes following definitions.
- inat_is_legacy_prefix
- inat_is_address_size_prefix
- inat_is_operand_size_prefix
- inat_is_rex_prefix
- inat_last_prefix_id
- inat_is_vex_prefix
- inat_is_evex_prefix
- inat_is_vex3_prefix
- inat_is_escape
- inat_escape_id
- inat_is_group
- inat_group_id
- inat_group_common_attribute
- inat_has_immediate
- inat_immediate_size
- inat_has_modrm
- inat_is_force64
- inat_has_second_immediate
- inat_has_moffset
- inat_has_variant
- inat_accept_vex
- inat_must_vex
- inat_must_evex
1
2 #ifndef _ASM_X86_INAT_H
3 #define _ASM_X86_INAT_H
4
5
6
7
8
9 #include <asm/inat_types.h>
10
11
12
13
14
15
16 #define INAT_OPCODE_TABLE_SIZE 256
17 #define INAT_GROUP_TABLE_SIZE 8
18
19
20 #define INAT_PFX_OPNDSZ 1
21 #define INAT_PFX_REPE 2
22 #define INAT_PFX_REPNE 3
23
24 #define INAT_PFX_LOCK 4
25 #define INAT_PFX_CS 5
26 #define INAT_PFX_DS 6
27 #define INAT_PFX_ES 7
28 #define INAT_PFX_FS 8
29 #define INAT_PFX_GS 9
30 #define INAT_PFX_SS 10
31 #define INAT_PFX_ADDRSZ 11
32
33 #define INAT_PFX_REX 12
34
35 #define INAT_PFX_VEX2 13
36 #define INAT_PFX_VEX3 14
37 #define INAT_PFX_EVEX 15
38
39 #define INAT_LSTPFX_MAX 3
40 #define INAT_LGCPFX_MAX 11
41
42
43 #define INAT_IMM_BYTE 1
44 #define INAT_IMM_WORD 2
45 #define INAT_IMM_DWORD 3
46 #define INAT_IMM_QWORD 4
47 #define INAT_IMM_PTR 5
48 #define INAT_IMM_VWORD32 6
49 #define INAT_IMM_VWORD 7
50
51
52 #define INAT_PFX_OFFS 0
53 #define INAT_PFX_BITS 4
54 #define INAT_PFX_MAX ((1 << INAT_PFX_BITS) - 1)
55 #define INAT_PFX_MASK (INAT_PFX_MAX << INAT_PFX_OFFS)
56
57 #define INAT_ESC_OFFS (INAT_PFX_OFFS + INAT_PFX_BITS)
58 #define INAT_ESC_BITS 2
59 #define INAT_ESC_MAX ((1 << INAT_ESC_BITS) - 1)
60 #define INAT_ESC_MASK (INAT_ESC_MAX << INAT_ESC_OFFS)
61
62 #define INAT_GRP_OFFS (INAT_ESC_OFFS + INAT_ESC_BITS)
63 #define INAT_GRP_BITS 5
64 #define INAT_GRP_MAX ((1 << INAT_GRP_BITS) - 1)
65 #define INAT_GRP_MASK (INAT_GRP_MAX << INAT_GRP_OFFS)
66
67 #define INAT_IMM_OFFS (INAT_GRP_OFFS + INAT_GRP_BITS)
68 #define INAT_IMM_BITS 3
69 #define INAT_IMM_MASK (((1 << INAT_IMM_BITS) - 1) << INAT_IMM_OFFS)
70
71 #define INAT_FLAG_OFFS (INAT_IMM_OFFS + INAT_IMM_BITS)
72 #define INAT_MODRM (1 << (INAT_FLAG_OFFS))
73 #define INAT_FORCE64 (1 << (INAT_FLAG_OFFS + 1))
74 #define INAT_SCNDIMM (1 << (INAT_FLAG_OFFS + 2))
75 #define INAT_MOFFSET (1 << (INAT_FLAG_OFFS + 3))
76 #define INAT_VARIANT (1 << (INAT_FLAG_OFFS + 4))
77 #define INAT_VEXOK (1 << (INAT_FLAG_OFFS + 5))
78 #define INAT_VEXONLY (1 << (INAT_FLAG_OFFS + 6))
79 #define INAT_EVEXONLY (1 << (INAT_FLAG_OFFS + 7))
80
81 #define INAT_MAKE_PREFIX(pfx) (pfx << INAT_PFX_OFFS)
82 #define INAT_MAKE_ESCAPE(esc) (esc << INAT_ESC_OFFS)
83 #define INAT_MAKE_GROUP(grp) ((grp << INAT_GRP_OFFS) | INAT_MODRM)
84 #define INAT_MAKE_IMM(imm) (imm << INAT_IMM_OFFS)
85
86
87 #define INAT_SEG_REG_IGNORE 0
88 #define INAT_SEG_REG_DEFAULT 1
89 #define INAT_SEG_REG_CS 2
90 #define INAT_SEG_REG_SS 3
91 #define INAT_SEG_REG_DS 4
92 #define INAT_SEG_REG_ES 5
93 #define INAT_SEG_REG_FS 6
94 #define INAT_SEG_REG_GS 7
95
96
97 extern insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode);
98 extern int inat_get_last_prefix_id(insn_byte_t last_pfx);
99 extern insn_attr_t inat_get_escape_attribute(insn_byte_t opcode,
100 int lpfx_id,
101 insn_attr_t esc_attr);
102 extern insn_attr_t inat_get_group_attribute(insn_byte_t modrm,
103 int lpfx_id,
104 insn_attr_t esc_attr);
105 extern insn_attr_t inat_get_avx_attribute(insn_byte_t opcode,
106 insn_byte_t vex_m,
107 insn_byte_t vex_pp);
108
109
110 static inline int inat_is_legacy_prefix(insn_attr_t attr)
111 {
112 attr &= INAT_PFX_MASK;
113 return attr && attr <= INAT_LGCPFX_MAX;
114 }
115
116 static inline int inat_is_address_size_prefix(insn_attr_t attr)
117 {
118 return (attr & INAT_PFX_MASK) == INAT_PFX_ADDRSZ;
119 }
120
121 static inline int inat_is_operand_size_prefix(insn_attr_t attr)
122 {
123 return (attr & INAT_PFX_MASK) == INAT_PFX_OPNDSZ;
124 }
125
126 static inline int inat_is_rex_prefix(insn_attr_t attr)
127 {
128 return (attr & INAT_PFX_MASK) == INAT_PFX_REX;
129 }
130
131 static inline int inat_last_prefix_id(insn_attr_t attr)
132 {
133 if ((attr & INAT_PFX_MASK) > INAT_LSTPFX_MAX)
134 return 0;
135 else
136 return attr & INAT_PFX_MASK;
137 }
138
139 static inline int inat_is_vex_prefix(insn_attr_t attr)
140 {
141 attr &= INAT_PFX_MASK;
142 return attr == INAT_PFX_VEX2 || attr == INAT_PFX_VEX3 ||
143 attr == INAT_PFX_EVEX;
144 }
145
146 static inline int inat_is_evex_prefix(insn_attr_t attr)
147 {
148 return (attr & INAT_PFX_MASK) == INAT_PFX_EVEX;
149 }
150
151 static inline int inat_is_vex3_prefix(insn_attr_t attr)
152 {
153 return (attr & INAT_PFX_MASK) == INAT_PFX_VEX3;
154 }
155
156 static inline int inat_is_escape(insn_attr_t attr)
157 {
158 return attr & INAT_ESC_MASK;
159 }
160
161 static inline int inat_escape_id(insn_attr_t attr)
162 {
163 return (attr & INAT_ESC_MASK) >> INAT_ESC_OFFS;
164 }
165
166 static inline int inat_is_group(insn_attr_t attr)
167 {
168 return attr & INAT_GRP_MASK;
169 }
170
171 static inline int inat_group_id(insn_attr_t attr)
172 {
173 return (attr & INAT_GRP_MASK) >> INAT_GRP_OFFS;
174 }
175
176 static inline int inat_group_common_attribute(insn_attr_t attr)
177 {
178 return attr & ~INAT_GRP_MASK;
179 }
180
181 static inline int inat_has_immediate(insn_attr_t attr)
182 {
183 return attr & INAT_IMM_MASK;
184 }
185
186 static inline int inat_immediate_size(insn_attr_t attr)
187 {
188 return (attr & INAT_IMM_MASK) >> INAT_IMM_OFFS;
189 }
190
191 static inline int inat_has_modrm(insn_attr_t attr)
192 {
193 return attr & INAT_MODRM;
194 }
195
196 static inline int inat_is_force64(insn_attr_t attr)
197 {
198 return attr & INAT_FORCE64;
199 }
200
201 static inline int inat_has_second_immediate(insn_attr_t attr)
202 {
203 return attr & INAT_SCNDIMM;
204 }
205
206 static inline int inat_has_moffset(insn_attr_t attr)
207 {
208 return attr & INAT_MOFFSET;
209 }
210
211 static inline int inat_has_variant(insn_attr_t attr)
212 {
213 return attr & INAT_VARIANT;
214 }
215
216 static inline int inat_accept_vex(insn_attr_t attr)
217 {
218 return attr & INAT_VEXOK;
219 }
220
221 static inline int inat_must_vex(insn_attr_t attr)
222 {
223 return attr & (INAT_VEXONLY | INAT_EVEXONLY);
224 }
225
226 static inline int inat_must_evex(insn_attr_t attr)
227 {
228 return attr & INAT_EVEXONLY;
229 }
230 #endif