xref: /minix3/external/bsd/llvm/dist/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc //===-- X86DisassemblerDecoderInternal.h - Disassembler decoder -*- C++ -*-===//
2*0a6a1f1dSLionel Sambuc //
3*0a6a1f1dSLionel Sambuc //                     The LLVM Compiler Infrastructure
4*0a6a1f1dSLionel Sambuc //
5*0a6a1f1dSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6*0a6a1f1dSLionel Sambuc // License. See LICENSE.TXT for details.
7*0a6a1f1dSLionel Sambuc //
8*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
9*0a6a1f1dSLionel Sambuc //
10*0a6a1f1dSLionel Sambuc // This file is part of the X86 Disassembler.
11*0a6a1f1dSLionel Sambuc // It contains the public interface of the instruction decoder.
12*0a6a1f1dSLionel Sambuc // Documentation for the disassembler can be found in X86Disassembler.h.
13*0a6a1f1dSLionel Sambuc //
14*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
15f4a2713aSLionel Sambuc 
16*0a6a1f1dSLionel Sambuc #ifndef LLVM_LIB_TARGET_X86_DISASSEMBLER_X86DISASSEMBLERDECODER_H
17*0a6a1f1dSLionel Sambuc #define LLVM_LIB_TARGET_X86_DISASSEMBLER_X86DISASSEMBLERDECODER_H
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc #include "X86DisassemblerDecoderCommon.h"
20*0a6a1f1dSLionel Sambuc #include "llvm/ADT/ArrayRef.h"
21f4a2713aSLionel Sambuc 
22*0a6a1f1dSLionel Sambuc namespace llvm {
23*0a6a1f1dSLionel Sambuc namespace X86Disassembler {
24f4a2713aSLionel Sambuc 
25*0a6a1f1dSLionel Sambuc // Accessor functions for various fields of an Intel instruction
26f4a2713aSLionel Sambuc #define modFromModRM(modRM)  (((modRM) & 0xc0) >> 6)
27f4a2713aSLionel Sambuc #define regFromModRM(modRM)  (((modRM) & 0x38) >> 3)
28f4a2713aSLionel Sambuc #define rmFromModRM(modRM)   ((modRM) & 0x7)
29f4a2713aSLionel Sambuc #define scaleFromSIB(sib)    (((sib) & 0xc0) >> 6)
30f4a2713aSLionel Sambuc #define indexFromSIB(sib)    (((sib) & 0x38) >> 3)
31f4a2713aSLionel Sambuc #define baseFromSIB(sib)     ((sib) & 0x7)
32f4a2713aSLionel Sambuc #define wFromREX(rex)        (((rex) & 0x8) >> 3)
33f4a2713aSLionel Sambuc #define rFromREX(rex)        (((rex) & 0x4) >> 2)
34f4a2713aSLionel Sambuc #define xFromREX(rex)        (((rex) & 0x2) >> 1)
35f4a2713aSLionel Sambuc #define bFromREX(rex)        ((rex) & 0x1)
36f4a2713aSLionel Sambuc 
37*0a6a1f1dSLionel Sambuc #define rFromEVEX2of4(evex)     (((~(evex)) & 0x80) >> 7)
38*0a6a1f1dSLionel Sambuc #define xFromEVEX2of4(evex)     (((~(evex)) & 0x40) >> 6)
39*0a6a1f1dSLionel Sambuc #define bFromEVEX2of4(evex)     (((~(evex)) & 0x20) >> 5)
40*0a6a1f1dSLionel Sambuc #define r2FromEVEX2of4(evex)    (((~(evex)) & 0x10) >> 4)
41*0a6a1f1dSLionel Sambuc #define mmFromEVEX2of4(evex)    ((evex) & 0x3)
42*0a6a1f1dSLionel Sambuc #define wFromEVEX3of4(evex)     (((evex) & 0x80) >> 7)
43*0a6a1f1dSLionel Sambuc #define vvvvFromEVEX3of4(evex)  (((~(evex)) & 0x78) >> 3)
44*0a6a1f1dSLionel Sambuc #define ppFromEVEX3of4(evex)    ((evex) & 0x3)
45*0a6a1f1dSLionel Sambuc #define zFromEVEX4of4(evex)     (((evex) & 0x80) >> 7)
46*0a6a1f1dSLionel Sambuc #define l2FromEVEX4of4(evex)    (((evex) & 0x40) >> 6)
47*0a6a1f1dSLionel Sambuc #define lFromEVEX4of4(evex)     (((evex) & 0x20) >> 5)
48*0a6a1f1dSLionel Sambuc #define bFromEVEX4of4(evex)     (((evex) & 0x10) >> 4)
49*0a6a1f1dSLionel Sambuc #define v2FromEVEX4of4(evex)    (((~evex) & 0x8) >> 3)
50*0a6a1f1dSLionel Sambuc #define aaaFromEVEX4of4(evex)   ((evex) & 0x7)
51*0a6a1f1dSLionel Sambuc 
52f4a2713aSLionel Sambuc #define rFromVEX2of3(vex)       (((~(vex)) & 0x80) >> 7)
53f4a2713aSLionel Sambuc #define xFromVEX2of3(vex)       (((~(vex)) & 0x40) >> 6)
54f4a2713aSLionel Sambuc #define bFromVEX2of3(vex)       (((~(vex)) & 0x20) >> 5)
55f4a2713aSLionel Sambuc #define mmmmmFromVEX2of3(vex)   ((vex) & 0x1f)
56f4a2713aSLionel Sambuc #define wFromVEX3of3(vex)       (((vex) & 0x80) >> 7)
57f4a2713aSLionel Sambuc #define vvvvFromVEX3of3(vex)    (((~(vex)) & 0x78) >> 3)
58f4a2713aSLionel Sambuc #define lFromVEX3of3(vex)       (((vex) & 0x4) >> 2)
59f4a2713aSLionel Sambuc #define ppFromVEX3of3(vex)      ((vex) & 0x3)
60f4a2713aSLionel Sambuc 
61f4a2713aSLionel Sambuc #define rFromVEX2of2(vex)       (((~(vex)) & 0x80) >> 7)
62f4a2713aSLionel Sambuc #define vvvvFromVEX2of2(vex)    (((~(vex)) & 0x78) >> 3)
63f4a2713aSLionel Sambuc #define lFromVEX2of2(vex)       (((vex) & 0x4) >> 2)
64f4a2713aSLionel Sambuc #define ppFromVEX2of2(vex)      ((vex) & 0x3)
65f4a2713aSLionel Sambuc 
66f4a2713aSLionel Sambuc #define rFromXOP2of3(xop)       (((~(xop)) & 0x80) >> 7)
67f4a2713aSLionel Sambuc #define xFromXOP2of3(xop)       (((~(xop)) & 0x40) >> 6)
68f4a2713aSLionel Sambuc #define bFromXOP2of3(xop)       (((~(xop)) & 0x20) >> 5)
69f4a2713aSLionel Sambuc #define mmmmmFromXOP2of3(xop)   ((xop) & 0x1f)
70f4a2713aSLionel Sambuc #define wFromXOP3of3(xop)       (((xop) & 0x80) >> 7)
71f4a2713aSLionel Sambuc #define vvvvFromXOP3of3(vex)    (((~(vex)) & 0x78) >> 3)
72f4a2713aSLionel Sambuc #define lFromXOP3of3(xop)       (((xop) & 0x4) >> 2)
73f4a2713aSLionel Sambuc #define ppFromXOP3of3(xop)      ((xop) & 0x3)
74f4a2713aSLionel Sambuc 
75*0a6a1f1dSLionel Sambuc // These enums represent Intel registers for use by the decoder.
76f4a2713aSLionel Sambuc #define REGS_8BIT     \
77f4a2713aSLionel Sambuc   ENTRY(AL)           \
78f4a2713aSLionel Sambuc   ENTRY(CL)           \
79f4a2713aSLionel Sambuc   ENTRY(DL)           \
80f4a2713aSLionel Sambuc   ENTRY(BL)           \
81f4a2713aSLionel Sambuc   ENTRY(AH)           \
82f4a2713aSLionel Sambuc   ENTRY(CH)           \
83f4a2713aSLionel Sambuc   ENTRY(DH)           \
84f4a2713aSLionel Sambuc   ENTRY(BH)           \
85f4a2713aSLionel Sambuc   ENTRY(R8B)          \
86f4a2713aSLionel Sambuc   ENTRY(R9B)          \
87f4a2713aSLionel Sambuc   ENTRY(R10B)         \
88f4a2713aSLionel Sambuc   ENTRY(R11B)         \
89f4a2713aSLionel Sambuc   ENTRY(R12B)         \
90f4a2713aSLionel Sambuc   ENTRY(R13B)         \
91f4a2713aSLionel Sambuc   ENTRY(R14B)         \
92f4a2713aSLionel Sambuc   ENTRY(R15B)         \
93f4a2713aSLionel Sambuc   ENTRY(SPL)          \
94f4a2713aSLionel Sambuc   ENTRY(BPL)          \
95f4a2713aSLionel Sambuc   ENTRY(SIL)          \
96f4a2713aSLionel Sambuc   ENTRY(DIL)
97f4a2713aSLionel Sambuc 
98f4a2713aSLionel Sambuc #define EA_BASES_16BIT  \
99f4a2713aSLionel Sambuc   ENTRY(BX_SI)          \
100f4a2713aSLionel Sambuc   ENTRY(BX_DI)          \
101f4a2713aSLionel Sambuc   ENTRY(BP_SI)          \
102f4a2713aSLionel Sambuc   ENTRY(BP_DI)          \
103f4a2713aSLionel Sambuc   ENTRY(SI)             \
104f4a2713aSLionel Sambuc   ENTRY(DI)             \
105f4a2713aSLionel Sambuc   ENTRY(BP)             \
106f4a2713aSLionel Sambuc   ENTRY(BX)             \
107f4a2713aSLionel Sambuc   ENTRY(R8W)            \
108f4a2713aSLionel Sambuc   ENTRY(R9W)            \
109f4a2713aSLionel Sambuc   ENTRY(R10W)           \
110f4a2713aSLionel Sambuc   ENTRY(R11W)           \
111f4a2713aSLionel Sambuc   ENTRY(R12W)           \
112f4a2713aSLionel Sambuc   ENTRY(R13W)           \
113f4a2713aSLionel Sambuc   ENTRY(R14W)           \
114f4a2713aSLionel Sambuc   ENTRY(R15W)
115f4a2713aSLionel Sambuc 
116f4a2713aSLionel Sambuc #define REGS_16BIT    \
117f4a2713aSLionel Sambuc   ENTRY(AX)           \
118f4a2713aSLionel Sambuc   ENTRY(CX)           \
119f4a2713aSLionel Sambuc   ENTRY(DX)           \
120f4a2713aSLionel Sambuc   ENTRY(BX)           \
121f4a2713aSLionel Sambuc   ENTRY(SP)           \
122f4a2713aSLionel Sambuc   ENTRY(BP)           \
123f4a2713aSLionel Sambuc   ENTRY(SI)           \
124f4a2713aSLionel Sambuc   ENTRY(DI)           \
125f4a2713aSLionel Sambuc   ENTRY(R8W)          \
126f4a2713aSLionel Sambuc   ENTRY(R9W)          \
127f4a2713aSLionel Sambuc   ENTRY(R10W)         \
128f4a2713aSLionel Sambuc   ENTRY(R11W)         \
129f4a2713aSLionel Sambuc   ENTRY(R12W)         \
130f4a2713aSLionel Sambuc   ENTRY(R13W)         \
131f4a2713aSLionel Sambuc   ENTRY(R14W)         \
132f4a2713aSLionel Sambuc   ENTRY(R15W)
133f4a2713aSLionel Sambuc 
134f4a2713aSLionel Sambuc #define EA_BASES_32BIT  \
135f4a2713aSLionel Sambuc   ENTRY(EAX)            \
136f4a2713aSLionel Sambuc   ENTRY(ECX)            \
137f4a2713aSLionel Sambuc   ENTRY(EDX)            \
138f4a2713aSLionel Sambuc   ENTRY(EBX)            \
139f4a2713aSLionel Sambuc   ENTRY(sib)            \
140f4a2713aSLionel Sambuc   ENTRY(EBP)            \
141f4a2713aSLionel Sambuc   ENTRY(ESI)            \
142f4a2713aSLionel Sambuc   ENTRY(EDI)            \
143f4a2713aSLionel Sambuc   ENTRY(R8D)            \
144f4a2713aSLionel Sambuc   ENTRY(R9D)            \
145f4a2713aSLionel Sambuc   ENTRY(R10D)           \
146f4a2713aSLionel Sambuc   ENTRY(R11D)           \
147f4a2713aSLionel Sambuc   ENTRY(R12D)           \
148f4a2713aSLionel Sambuc   ENTRY(R13D)           \
149f4a2713aSLionel Sambuc   ENTRY(R14D)           \
150f4a2713aSLionel Sambuc   ENTRY(R15D)
151f4a2713aSLionel Sambuc 
152f4a2713aSLionel Sambuc #define REGS_32BIT  \
153f4a2713aSLionel Sambuc   ENTRY(EAX)        \
154f4a2713aSLionel Sambuc   ENTRY(ECX)        \
155f4a2713aSLionel Sambuc   ENTRY(EDX)        \
156f4a2713aSLionel Sambuc   ENTRY(EBX)        \
157f4a2713aSLionel Sambuc   ENTRY(ESP)        \
158f4a2713aSLionel Sambuc   ENTRY(EBP)        \
159f4a2713aSLionel Sambuc   ENTRY(ESI)        \
160f4a2713aSLionel Sambuc   ENTRY(EDI)        \
161f4a2713aSLionel Sambuc   ENTRY(R8D)        \
162f4a2713aSLionel Sambuc   ENTRY(R9D)        \
163f4a2713aSLionel Sambuc   ENTRY(R10D)       \
164f4a2713aSLionel Sambuc   ENTRY(R11D)       \
165f4a2713aSLionel Sambuc   ENTRY(R12D)       \
166f4a2713aSLionel Sambuc   ENTRY(R13D)       \
167f4a2713aSLionel Sambuc   ENTRY(R14D)       \
168f4a2713aSLionel Sambuc   ENTRY(R15D)
169f4a2713aSLionel Sambuc 
170f4a2713aSLionel Sambuc #define EA_BASES_64BIT  \
171f4a2713aSLionel Sambuc   ENTRY(RAX)            \
172f4a2713aSLionel Sambuc   ENTRY(RCX)            \
173f4a2713aSLionel Sambuc   ENTRY(RDX)            \
174f4a2713aSLionel Sambuc   ENTRY(RBX)            \
175f4a2713aSLionel Sambuc   ENTRY(sib64)          \
176f4a2713aSLionel Sambuc   ENTRY(RBP)            \
177f4a2713aSLionel Sambuc   ENTRY(RSI)            \
178f4a2713aSLionel Sambuc   ENTRY(RDI)            \
179f4a2713aSLionel Sambuc   ENTRY(R8)             \
180f4a2713aSLionel Sambuc   ENTRY(R9)             \
181f4a2713aSLionel Sambuc   ENTRY(R10)            \
182f4a2713aSLionel Sambuc   ENTRY(R11)            \
183f4a2713aSLionel Sambuc   ENTRY(R12)            \
184f4a2713aSLionel Sambuc   ENTRY(R13)            \
185f4a2713aSLionel Sambuc   ENTRY(R14)            \
186f4a2713aSLionel Sambuc   ENTRY(R15)
187f4a2713aSLionel Sambuc 
188f4a2713aSLionel Sambuc #define REGS_64BIT  \
189f4a2713aSLionel Sambuc   ENTRY(RAX)        \
190f4a2713aSLionel Sambuc   ENTRY(RCX)        \
191f4a2713aSLionel Sambuc   ENTRY(RDX)        \
192f4a2713aSLionel Sambuc   ENTRY(RBX)        \
193f4a2713aSLionel Sambuc   ENTRY(RSP)        \
194f4a2713aSLionel Sambuc   ENTRY(RBP)        \
195f4a2713aSLionel Sambuc   ENTRY(RSI)        \
196f4a2713aSLionel Sambuc   ENTRY(RDI)        \
197f4a2713aSLionel Sambuc   ENTRY(R8)         \
198f4a2713aSLionel Sambuc   ENTRY(R9)         \
199f4a2713aSLionel Sambuc   ENTRY(R10)        \
200f4a2713aSLionel Sambuc   ENTRY(R11)        \
201f4a2713aSLionel Sambuc   ENTRY(R12)        \
202f4a2713aSLionel Sambuc   ENTRY(R13)        \
203f4a2713aSLionel Sambuc   ENTRY(R14)        \
204f4a2713aSLionel Sambuc   ENTRY(R15)
205f4a2713aSLionel Sambuc 
206f4a2713aSLionel Sambuc #define REGS_MMX  \
207f4a2713aSLionel Sambuc   ENTRY(MM0)      \
208f4a2713aSLionel Sambuc   ENTRY(MM1)      \
209f4a2713aSLionel Sambuc   ENTRY(MM2)      \
210f4a2713aSLionel Sambuc   ENTRY(MM3)      \
211f4a2713aSLionel Sambuc   ENTRY(MM4)      \
212f4a2713aSLionel Sambuc   ENTRY(MM5)      \
213f4a2713aSLionel Sambuc   ENTRY(MM6)      \
214f4a2713aSLionel Sambuc   ENTRY(MM7)
215f4a2713aSLionel Sambuc 
216f4a2713aSLionel Sambuc #define REGS_XMM  \
217f4a2713aSLionel Sambuc   ENTRY(XMM0)     \
218f4a2713aSLionel Sambuc   ENTRY(XMM1)     \
219f4a2713aSLionel Sambuc   ENTRY(XMM2)     \
220f4a2713aSLionel Sambuc   ENTRY(XMM3)     \
221f4a2713aSLionel Sambuc   ENTRY(XMM4)     \
222f4a2713aSLionel Sambuc   ENTRY(XMM5)     \
223f4a2713aSLionel Sambuc   ENTRY(XMM6)     \
224f4a2713aSLionel Sambuc   ENTRY(XMM7)     \
225f4a2713aSLionel Sambuc   ENTRY(XMM8)     \
226f4a2713aSLionel Sambuc   ENTRY(XMM9)     \
227f4a2713aSLionel Sambuc   ENTRY(XMM10)    \
228f4a2713aSLionel Sambuc   ENTRY(XMM11)    \
229f4a2713aSLionel Sambuc   ENTRY(XMM12)    \
230f4a2713aSLionel Sambuc   ENTRY(XMM13)    \
231f4a2713aSLionel Sambuc   ENTRY(XMM14)    \
232f4a2713aSLionel Sambuc   ENTRY(XMM15)    \
233f4a2713aSLionel Sambuc   ENTRY(XMM16)    \
234f4a2713aSLionel Sambuc   ENTRY(XMM17)    \
235f4a2713aSLionel Sambuc   ENTRY(XMM18)    \
236f4a2713aSLionel Sambuc   ENTRY(XMM19)    \
237f4a2713aSLionel Sambuc   ENTRY(XMM20)    \
238f4a2713aSLionel Sambuc   ENTRY(XMM21)    \
239f4a2713aSLionel Sambuc   ENTRY(XMM22)    \
240f4a2713aSLionel Sambuc   ENTRY(XMM23)    \
241f4a2713aSLionel Sambuc   ENTRY(XMM24)    \
242f4a2713aSLionel Sambuc   ENTRY(XMM25)    \
243f4a2713aSLionel Sambuc   ENTRY(XMM26)    \
244f4a2713aSLionel Sambuc   ENTRY(XMM27)    \
245f4a2713aSLionel Sambuc   ENTRY(XMM28)    \
246f4a2713aSLionel Sambuc   ENTRY(XMM29)    \
247f4a2713aSLionel Sambuc   ENTRY(XMM30)    \
248f4a2713aSLionel Sambuc   ENTRY(XMM31)
249f4a2713aSLionel Sambuc 
250f4a2713aSLionel Sambuc #define REGS_YMM  \
251f4a2713aSLionel Sambuc   ENTRY(YMM0)     \
252f4a2713aSLionel Sambuc   ENTRY(YMM1)     \
253f4a2713aSLionel Sambuc   ENTRY(YMM2)     \
254f4a2713aSLionel Sambuc   ENTRY(YMM3)     \
255f4a2713aSLionel Sambuc   ENTRY(YMM4)     \
256f4a2713aSLionel Sambuc   ENTRY(YMM5)     \
257f4a2713aSLionel Sambuc   ENTRY(YMM6)     \
258f4a2713aSLionel Sambuc   ENTRY(YMM7)     \
259f4a2713aSLionel Sambuc   ENTRY(YMM8)     \
260f4a2713aSLionel Sambuc   ENTRY(YMM9)     \
261f4a2713aSLionel Sambuc   ENTRY(YMM10)    \
262f4a2713aSLionel Sambuc   ENTRY(YMM11)    \
263f4a2713aSLionel Sambuc   ENTRY(YMM12)    \
264f4a2713aSLionel Sambuc   ENTRY(YMM13)    \
265f4a2713aSLionel Sambuc   ENTRY(YMM14)    \
266f4a2713aSLionel Sambuc   ENTRY(YMM15)    \
267f4a2713aSLionel Sambuc   ENTRY(YMM16)    \
268f4a2713aSLionel Sambuc   ENTRY(YMM17)    \
269f4a2713aSLionel Sambuc   ENTRY(YMM18)    \
270f4a2713aSLionel Sambuc   ENTRY(YMM19)    \
271f4a2713aSLionel Sambuc   ENTRY(YMM20)    \
272f4a2713aSLionel Sambuc   ENTRY(YMM21)    \
273f4a2713aSLionel Sambuc   ENTRY(YMM22)    \
274f4a2713aSLionel Sambuc   ENTRY(YMM23)    \
275f4a2713aSLionel Sambuc   ENTRY(YMM24)    \
276f4a2713aSLionel Sambuc   ENTRY(YMM25)    \
277f4a2713aSLionel Sambuc   ENTRY(YMM26)    \
278f4a2713aSLionel Sambuc   ENTRY(YMM27)    \
279f4a2713aSLionel Sambuc   ENTRY(YMM28)    \
280f4a2713aSLionel Sambuc   ENTRY(YMM29)    \
281f4a2713aSLionel Sambuc   ENTRY(YMM30)    \
282f4a2713aSLionel Sambuc   ENTRY(YMM31)
283f4a2713aSLionel Sambuc 
284f4a2713aSLionel Sambuc #define REGS_ZMM  \
285f4a2713aSLionel Sambuc   ENTRY(ZMM0)     \
286f4a2713aSLionel Sambuc   ENTRY(ZMM1)     \
287f4a2713aSLionel Sambuc   ENTRY(ZMM2)     \
288f4a2713aSLionel Sambuc   ENTRY(ZMM3)     \
289f4a2713aSLionel Sambuc   ENTRY(ZMM4)     \
290f4a2713aSLionel Sambuc   ENTRY(ZMM5)     \
291f4a2713aSLionel Sambuc   ENTRY(ZMM6)     \
292f4a2713aSLionel Sambuc   ENTRY(ZMM7)     \
293f4a2713aSLionel Sambuc   ENTRY(ZMM8)     \
294f4a2713aSLionel Sambuc   ENTRY(ZMM9)     \
295f4a2713aSLionel Sambuc   ENTRY(ZMM10)    \
296f4a2713aSLionel Sambuc   ENTRY(ZMM11)    \
297f4a2713aSLionel Sambuc   ENTRY(ZMM12)    \
298f4a2713aSLionel Sambuc   ENTRY(ZMM13)    \
299f4a2713aSLionel Sambuc   ENTRY(ZMM14)    \
300f4a2713aSLionel Sambuc   ENTRY(ZMM15)    \
301f4a2713aSLionel Sambuc   ENTRY(ZMM16)    \
302f4a2713aSLionel Sambuc   ENTRY(ZMM17)    \
303f4a2713aSLionel Sambuc   ENTRY(ZMM18)    \
304f4a2713aSLionel Sambuc   ENTRY(ZMM19)    \
305f4a2713aSLionel Sambuc   ENTRY(ZMM20)    \
306f4a2713aSLionel Sambuc   ENTRY(ZMM21)    \
307f4a2713aSLionel Sambuc   ENTRY(ZMM22)    \
308f4a2713aSLionel Sambuc   ENTRY(ZMM23)    \
309f4a2713aSLionel Sambuc   ENTRY(ZMM24)    \
310f4a2713aSLionel Sambuc   ENTRY(ZMM25)    \
311f4a2713aSLionel Sambuc   ENTRY(ZMM26)    \
312f4a2713aSLionel Sambuc   ENTRY(ZMM27)    \
313f4a2713aSLionel Sambuc   ENTRY(ZMM28)    \
314f4a2713aSLionel Sambuc   ENTRY(ZMM29)    \
315f4a2713aSLionel Sambuc   ENTRY(ZMM30)    \
316f4a2713aSLionel Sambuc   ENTRY(ZMM31)
317f4a2713aSLionel Sambuc 
318*0a6a1f1dSLionel Sambuc #define REGS_MASKS \
319*0a6a1f1dSLionel Sambuc   ENTRY(K0)        \
320*0a6a1f1dSLionel Sambuc   ENTRY(K1)        \
321*0a6a1f1dSLionel Sambuc   ENTRY(K2)        \
322*0a6a1f1dSLionel Sambuc   ENTRY(K3)        \
323*0a6a1f1dSLionel Sambuc   ENTRY(K4)        \
324*0a6a1f1dSLionel Sambuc   ENTRY(K5)        \
325*0a6a1f1dSLionel Sambuc   ENTRY(K6)        \
326*0a6a1f1dSLionel Sambuc   ENTRY(K7)
327*0a6a1f1dSLionel Sambuc 
328f4a2713aSLionel Sambuc #define REGS_SEGMENT \
329f4a2713aSLionel Sambuc   ENTRY(ES)          \
330f4a2713aSLionel Sambuc   ENTRY(CS)          \
331f4a2713aSLionel Sambuc   ENTRY(SS)          \
332f4a2713aSLionel Sambuc   ENTRY(DS)          \
333f4a2713aSLionel Sambuc   ENTRY(FS)          \
334f4a2713aSLionel Sambuc   ENTRY(GS)
335f4a2713aSLionel Sambuc 
336f4a2713aSLionel Sambuc #define REGS_DEBUG  \
337f4a2713aSLionel Sambuc   ENTRY(DR0)        \
338f4a2713aSLionel Sambuc   ENTRY(DR1)        \
339f4a2713aSLionel Sambuc   ENTRY(DR2)        \
340f4a2713aSLionel Sambuc   ENTRY(DR3)        \
341f4a2713aSLionel Sambuc   ENTRY(DR4)        \
342f4a2713aSLionel Sambuc   ENTRY(DR5)        \
343f4a2713aSLionel Sambuc   ENTRY(DR6)        \
344*0a6a1f1dSLionel Sambuc   ENTRY(DR7)        \
345*0a6a1f1dSLionel Sambuc   ENTRY(DR8)        \
346*0a6a1f1dSLionel Sambuc   ENTRY(DR9)        \
347*0a6a1f1dSLionel Sambuc   ENTRY(DR10)       \
348*0a6a1f1dSLionel Sambuc   ENTRY(DR11)       \
349*0a6a1f1dSLionel Sambuc   ENTRY(DR12)       \
350*0a6a1f1dSLionel Sambuc   ENTRY(DR13)       \
351*0a6a1f1dSLionel Sambuc   ENTRY(DR14)       \
352*0a6a1f1dSLionel Sambuc   ENTRY(DR15)
353f4a2713aSLionel Sambuc 
354f4a2713aSLionel Sambuc #define REGS_CONTROL  \
355f4a2713aSLionel Sambuc   ENTRY(CR0)          \
356f4a2713aSLionel Sambuc   ENTRY(CR1)          \
357f4a2713aSLionel Sambuc   ENTRY(CR2)          \
358f4a2713aSLionel Sambuc   ENTRY(CR3)          \
359f4a2713aSLionel Sambuc   ENTRY(CR4)          \
360f4a2713aSLionel Sambuc   ENTRY(CR5)          \
361f4a2713aSLionel Sambuc   ENTRY(CR6)          \
362f4a2713aSLionel Sambuc   ENTRY(CR7)          \
363*0a6a1f1dSLionel Sambuc   ENTRY(CR8)          \
364*0a6a1f1dSLionel Sambuc   ENTRY(CR9)          \
365*0a6a1f1dSLionel Sambuc   ENTRY(CR10)         \
366*0a6a1f1dSLionel Sambuc   ENTRY(CR11)         \
367*0a6a1f1dSLionel Sambuc   ENTRY(CR12)         \
368*0a6a1f1dSLionel Sambuc   ENTRY(CR13)         \
369*0a6a1f1dSLionel Sambuc   ENTRY(CR14)         \
370*0a6a1f1dSLionel Sambuc   ENTRY(CR15)
371f4a2713aSLionel Sambuc 
372f4a2713aSLionel Sambuc #define ALL_EA_BASES  \
373f4a2713aSLionel Sambuc   EA_BASES_16BIT      \
374f4a2713aSLionel Sambuc   EA_BASES_32BIT      \
375f4a2713aSLionel Sambuc   EA_BASES_64BIT
376f4a2713aSLionel Sambuc 
377f4a2713aSLionel Sambuc #define ALL_SIB_BASES \
378f4a2713aSLionel Sambuc   REGS_32BIT          \
379f4a2713aSLionel Sambuc   REGS_64BIT
380f4a2713aSLionel Sambuc 
381f4a2713aSLionel Sambuc #define ALL_REGS      \
382f4a2713aSLionel Sambuc   REGS_8BIT           \
383f4a2713aSLionel Sambuc   REGS_16BIT          \
384f4a2713aSLionel Sambuc   REGS_32BIT          \
385f4a2713aSLionel Sambuc   REGS_64BIT          \
386f4a2713aSLionel Sambuc   REGS_MMX            \
387f4a2713aSLionel Sambuc   REGS_XMM            \
388f4a2713aSLionel Sambuc   REGS_YMM            \
389f4a2713aSLionel Sambuc   REGS_ZMM            \
390*0a6a1f1dSLionel Sambuc   REGS_MASKS          \
391f4a2713aSLionel Sambuc   REGS_SEGMENT        \
392f4a2713aSLionel Sambuc   REGS_DEBUG          \
393f4a2713aSLionel Sambuc   REGS_CONTROL        \
394f4a2713aSLionel Sambuc   ENTRY(RIP)
395f4a2713aSLionel Sambuc 
396*0a6a1f1dSLionel Sambuc /// \brief All possible values of the base field for effective-address
397*0a6a1f1dSLionel Sambuc /// computations, a.k.a. the Mod and R/M fields of the ModR/M byte.
398*0a6a1f1dSLionel Sambuc /// We distinguish between bases (EA_BASE_*) and registers that just happen
399*0a6a1f1dSLionel Sambuc /// to be referred to when Mod == 0b11 (EA_REG_*).
400*0a6a1f1dSLionel Sambuc enum EABase {
401f4a2713aSLionel Sambuc   EA_BASE_NONE,
402f4a2713aSLionel Sambuc #define ENTRY(x) EA_BASE_##x,
403f4a2713aSLionel Sambuc   ALL_EA_BASES
404f4a2713aSLionel Sambuc #undef ENTRY
405f4a2713aSLionel Sambuc #define ENTRY(x) EA_REG_##x,
406f4a2713aSLionel Sambuc   ALL_REGS
407f4a2713aSLionel Sambuc #undef ENTRY
408f4a2713aSLionel Sambuc   EA_max
409*0a6a1f1dSLionel Sambuc };
410f4a2713aSLionel Sambuc 
411*0a6a1f1dSLionel Sambuc /// \brief All possible values of the SIB index field.
412*0a6a1f1dSLionel Sambuc /// borrows entries from ALL_EA_BASES with the special case that
413*0a6a1f1dSLionel Sambuc /// sib is synonymous with NONE.
414*0a6a1f1dSLionel Sambuc /// Vector SIB: index can be XMM or YMM.
415*0a6a1f1dSLionel Sambuc enum SIBIndex {
416f4a2713aSLionel Sambuc   SIB_INDEX_NONE,
417f4a2713aSLionel Sambuc #define ENTRY(x) SIB_INDEX_##x,
418f4a2713aSLionel Sambuc   ALL_EA_BASES
419f4a2713aSLionel Sambuc   REGS_XMM
420f4a2713aSLionel Sambuc   REGS_YMM
421f4a2713aSLionel Sambuc   REGS_ZMM
422f4a2713aSLionel Sambuc #undef ENTRY
423f4a2713aSLionel Sambuc   SIB_INDEX_max
424*0a6a1f1dSLionel Sambuc };
425f4a2713aSLionel Sambuc 
426*0a6a1f1dSLionel Sambuc /// \brief All possible values of the SIB base field.
427*0a6a1f1dSLionel Sambuc enum SIBBase {
428f4a2713aSLionel Sambuc   SIB_BASE_NONE,
429f4a2713aSLionel Sambuc #define ENTRY(x) SIB_BASE_##x,
430f4a2713aSLionel Sambuc   ALL_SIB_BASES
431f4a2713aSLionel Sambuc #undef ENTRY
432f4a2713aSLionel Sambuc   SIB_BASE_max
433*0a6a1f1dSLionel Sambuc };
434f4a2713aSLionel Sambuc 
435*0a6a1f1dSLionel Sambuc /// \brief Possible displacement types for effective-address computations.
436f4a2713aSLionel Sambuc typedef enum {
437f4a2713aSLionel Sambuc   EA_DISP_NONE,
438f4a2713aSLionel Sambuc   EA_DISP_8,
439f4a2713aSLionel Sambuc   EA_DISP_16,
440f4a2713aSLionel Sambuc   EA_DISP_32
441f4a2713aSLionel Sambuc } EADisplacement;
442f4a2713aSLionel Sambuc 
443*0a6a1f1dSLionel Sambuc /// \brief All possible values of the reg field in the ModR/M byte.
444*0a6a1f1dSLionel Sambuc enum Reg {
445f4a2713aSLionel Sambuc #define ENTRY(x) MODRM_REG_##x,
446f4a2713aSLionel Sambuc   ALL_REGS
447f4a2713aSLionel Sambuc #undef ENTRY
448f4a2713aSLionel Sambuc   MODRM_REG_max
449*0a6a1f1dSLionel Sambuc };
450f4a2713aSLionel Sambuc 
451*0a6a1f1dSLionel Sambuc /// \brief All possible segment overrides.
452*0a6a1f1dSLionel Sambuc enum SegmentOverride {
453f4a2713aSLionel Sambuc   SEG_OVERRIDE_NONE,
454f4a2713aSLionel Sambuc   SEG_OVERRIDE_CS,
455f4a2713aSLionel Sambuc   SEG_OVERRIDE_SS,
456f4a2713aSLionel Sambuc   SEG_OVERRIDE_DS,
457f4a2713aSLionel Sambuc   SEG_OVERRIDE_ES,
458f4a2713aSLionel Sambuc   SEG_OVERRIDE_FS,
459f4a2713aSLionel Sambuc   SEG_OVERRIDE_GS,
460f4a2713aSLionel Sambuc   SEG_OVERRIDE_max
461*0a6a1f1dSLionel Sambuc };
462f4a2713aSLionel Sambuc 
463*0a6a1f1dSLionel Sambuc /// \brief Possible values for the VEX.m-mmmm field
464*0a6a1f1dSLionel Sambuc enum VEXLeadingOpcodeByte {
465f4a2713aSLionel Sambuc   VEX_LOB_0F = 0x1,
466f4a2713aSLionel Sambuc   VEX_LOB_0F38 = 0x2,
467f4a2713aSLionel Sambuc   VEX_LOB_0F3A = 0x3
468*0a6a1f1dSLionel Sambuc };
469f4a2713aSLionel Sambuc 
470*0a6a1f1dSLionel Sambuc enum XOPMapSelect {
471f4a2713aSLionel Sambuc   XOP_MAP_SELECT_8 = 0x8,
472f4a2713aSLionel Sambuc   XOP_MAP_SELECT_9 = 0x9,
473f4a2713aSLionel Sambuc   XOP_MAP_SELECT_A = 0xA
474*0a6a1f1dSLionel Sambuc };
475f4a2713aSLionel Sambuc 
476*0a6a1f1dSLionel Sambuc /// \brief Possible values for the VEX.pp/EVEX.pp field
477*0a6a1f1dSLionel Sambuc enum VEXPrefixCode {
478f4a2713aSLionel Sambuc   VEX_PREFIX_NONE = 0x0,
479f4a2713aSLionel Sambuc   VEX_PREFIX_66 = 0x1,
480f4a2713aSLionel Sambuc   VEX_PREFIX_F3 = 0x2,
481f4a2713aSLionel Sambuc   VEX_PREFIX_F2 = 0x3
482*0a6a1f1dSLionel Sambuc };
483f4a2713aSLionel Sambuc 
484*0a6a1f1dSLionel Sambuc enum VectorExtensionType {
485f4a2713aSLionel Sambuc   TYPE_NO_VEX_XOP   = 0x0,
486f4a2713aSLionel Sambuc   TYPE_VEX_2B       = 0x1,
487f4a2713aSLionel Sambuc   TYPE_VEX_3B       = 0x2,
488*0a6a1f1dSLionel Sambuc   TYPE_EVEX         = 0x3,
489*0a6a1f1dSLionel Sambuc   TYPE_XOP          = 0x4
490*0a6a1f1dSLionel Sambuc };
491f4a2713aSLionel Sambuc 
492*0a6a1f1dSLionel Sambuc /// \brief Type for the byte reader that the consumer must provide to
493*0a6a1f1dSLionel Sambuc /// the decoder. Reads a single byte from the instruction's address space.
494*0a6a1f1dSLionel Sambuc /// \param arg     A baton that the consumer can associate with any internal
495*0a6a1f1dSLionel Sambuc ///                state that it needs.
496*0a6a1f1dSLionel Sambuc /// \param byte    A pointer to a single byte in memory that should be set to
497*0a6a1f1dSLionel Sambuc ///                contain the value at address.
498*0a6a1f1dSLionel Sambuc /// \param address The address in the instruction's address space that should
499*0a6a1f1dSLionel Sambuc ///                be read from.
500*0a6a1f1dSLionel Sambuc /// \return        -1 if the byte cannot be read for any reason; 0 otherwise.
501f4a2713aSLionel Sambuc typedef int (*byteReader_t)(const void *arg, uint8_t *byte, uint64_t address);
502f4a2713aSLionel Sambuc 
503*0a6a1f1dSLionel Sambuc /// \brief Type for the logging function that the consumer can provide to
504*0a6a1f1dSLionel Sambuc /// get debugging output from the decoder.
505*0a6a1f1dSLionel Sambuc /// \param arg A baton that the consumer can associate with any internal
506*0a6a1f1dSLionel Sambuc ///            state that it needs.
507*0a6a1f1dSLionel Sambuc /// \param log A string that contains the message.  Will be reused after
508*0a6a1f1dSLionel Sambuc ///            the logger returns.
509f4a2713aSLionel Sambuc typedef void (*dlog_t)(void *arg, const char *log);
510f4a2713aSLionel Sambuc 
511*0a6a1f1dSLionel Sambuc /// The specification for how to extract and interpret a full instruction and
512*0a6a1f1dSLionel Sambuc /// its operands.
513*0a6a1f1dSLionel Sambuc struct InstructionSpecifier {
514*0a6a1f1dSLionel Sambuc   uint16_t operands;
515*0a6a1f1dSLionel Sambuc };
516*0a6a1f1dSLionel Sambuc 
517*0a6a1f1dSLionel Sambuc /// The x86 internal instruction, which is produced by the decoder.
518f4a2713aSLionel Sambuc struct InternalInstruction {
519*0a6a1f1dSLionel Sambuc   // Reader interface (C)
520f4a2713aSLionel Sambuc   byteReader_t reader;
521*0a6a1f1dSLionel Sambuc   // Opaque value passed to the reader
522f4a2713aSLionel Sambuc   const void* readerArg;
523*0a6a1f1dSLionel Sambuc   // The address of the next byte to read via the reader
524f4a2713aSLionel Sambuc   uint64_t readerCursor;
525f4a2713aSLionel Sambuc 
526*0a6a1f1dSLionel Sambuc   // Logger interface (C)
527f4a2713aSLionel Sambuc   dlog_t dlog;
528*0a6a1f1dSLionel Sambuc   // Opaque value passed to the logger
529f4a2713aSLionel Sambuc   void* dlogArg;
530f4a2713aSLionel Sambuc 
531*0a6a1f1dSLionel Sambuc   // General instruction information
532f4a2713aSLionel Sambuc 
533*0a6a1f1dSLionel Sambuc   // The mode to disassemble for (64-bit, protected, real)
534f4a2713aSLionel Sambuc   DisassemblerMode mode;
535*0a6a1f1dSLionel Sambuc   // The start of the instruction, usable with the reader
536f4a2713aSLionel Sambuc   uint64_t startLocation;
537*0a6a1f1dSLionel Sambuc   // The length of the instruction, in bytes
538f4a2713aSLionel Sambuc   size_t length;
539f4a2713aSLionel Sambuc 
540*0a6a1f1dSLionel Sambuc   // Prefix state
541f4a2713aSLionel Sambuc 
542*0a6a1f1dSLionel Sambuc   // 1 if the prefix byte corresponding to the entry is present; 0 if not
543f4a2713aSLionel Sambuc   uint8_t prefixPresent[0x100];
544*0a6a1f1dSLionel Sambuc   // contains the location (for use with the reader) of the prefix byte
545f4a2713aSLionel Sambuc   uint64_t prefixLocations[0x100];
546*0a6a1f1dSLionel Sambuc   // The value of the vector extension prefix(EVEX/VEX/XOP), if present
547*0a6a1f1dSLionel Sambuc   uint8_t vectorExtensionPrefix[4];
548*0a6a1f1dSLionel Sambuc   // The type of the vector extension prefix
549*0a6a1f1dSLionel Sambuc   VectorExtensionType vectorExtensionType;
550*0a6a1f1dSLionel Sambuc   // The value of the REX prefix, if present
551f4a2713aSLionel Sambuc   uint8_t rexPrefix;
552*0a6a1f1dSLionel Sambuc   // The location where a mandatory prefix would have to be (i.e., right before
553*0a6a1f1dSLionel Sambuc   // the opcode, or right before the REX prefix if one is present).
554f4a2713aSLionel Sambuc   uint64_t necessaryPrefixLocation;
555*0a6a1f1dSLionel Sambuc   // The segment override type
556f4a2713aSLionel Sambuc   SegmentOverride segmentOverride;
557*0a6a1f1dSLionel Sambuc   // 1 if the prefix byte, 0xf2 or 0xf3 is xacquire or xrelease
558*0a6a1f1dSLionel Sambuc   bool xAcquireRelease;
559f4a2713aSLionel Sambuc 
560*0a6a1f1dSLionel Sambuc   // Sizes of various critical pieces of data, in bytes
561f4a2713aSLionel Sambuc   uint8_t registerSize;
562f4a2713aSLionel Sambuc   uint8_t addressSize;
563f4a2713aSLionel Sambuc   uint8_t displacementSize;
564f4a2713aSLionel Sambuc   uint8_t immediateSize;
565f4a2713aSLionel Sambuc 
566*0a6a1f1dSLionel Sambuc   // Offsets from the start of the instruction to the pieces of data, which is
567*0a6a1f1dSLionel Sambuc   // needed to find relocation entries for adding symbolic operands.
568f4a2713aSLionel Sambuc   uint8_t displacementOffset;
569f4a2713aSLionel Sambuc   uint8_t immediateOffset;
570f4a2713aSLionel Sambuc 
571*0a6a1f1dSLionel Sambuc   // opcode state
572f4a2713aSLionel Sambuc 
573*0a6a1f1dSLionel Sambuc   // The last byte of the opcode, not counting any ModR/M extension
574f4a2713aSLionel Sambuc   uint8_t opcode;
575*0a6a1f1dSLionel Sambuc   // The ModR/M byte of the instruction, if it is an opcode extension
576f4a2713aSLionel Sambuc   uint8_t modRMExtension;
577f4a2713aSLionel Sambuc 
578*0a6a1f1dSLionel Sambuc   // decode state
579f4a2713aSLionel Sambuc 
580*0a6a1f1dSLionel Sambuc   // The type of opcode, used for indexing into the array of decode tables
581f4a2713aSLionel Sambuc   OpcodeType opcodeType;
582*0a6a1f1dSLionel Sambuc   // The instruction ID, extracted from the decode table
583f4a2713aSLionel Sambuc   uint16_t instructionID;
584*0a6a1f1dSLionel Sambuc   // The specifier for the instruction, from the instruction info table
585*0a6a1f1dSLionel Sambuc   const InstructionSpecifier *spec;
586f4a2713aSLionel Sambuc 
587*0a6a1f1dSLionel Sambuc   // state for additional bytes, consumed during operand decode.  Pattern:
588*0a6a1f1dSLionel Sambuc   // consumed___ indicates that the byte was already consumed and does not
589*0a6a1f1dSLionel Sambuc   // need to be consumed again.
590f4a2713aSLionel Sambuc 
591*0a6a1f1dSLionel Sambuc   // The VEX.vvvv field, which contains a third register operand for some AVX
592*0a6a1f1dSLionel Sambuc   // instructions.
593f4a2713aSLionel Sambuc   Reg                           vvvv;
594f4a2713aSLionel Sambuc 
595*0a6a1f1dSLionel Sambuc   // The writemask for AVX-512 instructions which is contained in EVEX.aaa
596*0a6a1f1dSLionel Sambuc   Reg                           writemask;
597*0a6a1f1dSLionel Sambuc 
598*0a6a1f1dSLionel Sambuc   // The ModR/M byte, which contains most register operands and some portion of
599*0a6a1f1dSLionel Sambuc   // all memory operands.
600*0a6a1f1dSLionel Sambuc   bool                          consumedModRM;
601f4a2713aSLionel Sambuc   uint8_t                       modRM;
602f4a2713aSLionel Sambuc 
603*0a6a1f1dSLionel Sambuc   // The SIB byte, used for more complex 32- or 64-bit memory operands
604*0a6a1f1dSLionel Sambuc   bool                          consumedSIB;
605f4a2713aSLionel Sambuc   uint8_t                       sib;
606f4a2713aSLionel Sambuc 
607*0a6a1f1dSLionel Sambuc   // The displacement, used for memory operands
608*0a6a1f1dSLionel Sambuc   bool                          consumedDisplacement;
609f4a2713aSLionel Sambuc   int32_t                       displacement;
610f4a2713aSLionel Sambuc 
611*0a6a1f1dSLionel Sambuc   // Immediates.  There can be two in some cases
612f4a2713aSLionel Sambuc   uint8_t                       numImmediatesConsumed;
613f4a2713aSLionel Sambuc   uint8_t                       numImmediatesTranslated;
614f4a2713aSLionel Sambuc   uint64_t                      immediates[2];
615f4a2713aSLionel Sambuc 
616*0a6a1f1dSLionel Sambuc   // A register or immediate operand encoded into the opcode
617f4a2713aSLionel Sambuc   Reg                           opcodeRegister;
618f4a2713aSLionel Sambuc 
619*0a6a1f1dSLionel Sambuc   // Portions of the ModR/M byte
620f4a2713aSLionel Sambuc 
621*0a6a1f1dSLionel Sambuc   // These fields determine the allowable values for the ModR/M fields, which
622*0a6a1f1dSLionel Sambuc   // depend on operand and address widths.
623f4a2713aSLionel Sambuc   EABase                        eaBaseBase;
624f4a2713aSLionel Sambuc   EABase                        eaRegBase;
625f4a2713aSLionel Sambuc   Reg                           regBase;
626f4a2713aSLionel Sambuc 
627*0a6a1f1dSLionel Sambuc   // The Mod and R/M fields can encode a base for an effective address, or a
628*0a6a1f1dSLionel Sambuc   // register.  These are separated into two fields here.
629f4a2713aSLionel Sambuc   EABase                        eaBase;
630f4a2713aSLionel Sambuc   EADisplacement                eaDisplacement;
631*0a6a1f1dSLionel Sambuc   // The reg field always encodes a register
632f4a2713aSLionel Sambuc   Reg                           reg;
633f4a2713aSLionel Sambuc 
634*0a6a1f1dSLionel Sambuc   // SIB state
635f4a2713aSLionel Sambuc   SIBIndex                      sibIndex;
636f4a2713aSLionel Sambuc   uint8_t                       sibScale;
637f4a2713aSLionel Sambuc   SIBBase                       sibBase;
638f4a2713aSLionel Sambuc 
639*0a6a1f1dSLionel Sambuc   ArrayRef<OperandSpecifier> operands;
640f4a2713aSLionel Sambuc };
641f4a2713aSLionel Sambuc 
642*0a6a1f1dSLionel Sambuc /// \brief Decode one instruction and store the decoding results in
643*0a6a1f1dSLionel Sambuc /// a buffer provided by the consumer.
644*0a6a1f1dSLionel Sambuc /// \param insn      The buffer to store the instruction in.  Allocated by the
645*0a6a1f1dSLionel Sambuc ///                  consumer.
646*0a6a1f1dSLionel Sambuc /// \param reader    The byteReader_t for the bytes to be read.
647*0a6a1f1dSLionel Sambuc /// \param readerArg An argument to pass to the reader for storing context
648*0a6a1f1dSLionel Sambuc ///                  specific to the consumer.  May be NULL.
649*0a6a1f1dSLionel Sambuc /// \param logger    The dlog_t to be used in printing status messages from the
650*0a6a1f1dSLionel Sambuc ///                  disassembler.  May be NULL.
651*0a6a1f1dSLionel Sambuc /// \param loggerArg An argument to pass to the logger for storing context
652*0a6a1f1dSLionel Sambuc ///                  specific to the logger.  May be NULL.
653*0a6a1f1dSLionel Sambuc /// \param startLoc  The address (in the reader's address space) of the first
654*0a6a1f1dSLionel Sambuc ///                  byte in the instruction.
655*0a6a1f1dSLionel Sambuc /// \param mode      The mode (16-bit, 32-bit, 64-bit) to decode in.
656*0a6a1f1dSLionel Sambuc /// \return          Nonzero if there was an error during decode, 0 otherwise.
657*0a6a1f1dSLionel Sambuc int decodeInstruction(InternalInstruction *insn,
658f4a2713aSLionel Sambuc                       byteReader_t reader,
659f4a2713aSLionel Sambuc                       const void *readerArg,
660f4a2713aSLionel Sambuc                       dlog_t logger,
661f4a2713aSLionel Sambuc                       void *loggerArg,
662f4a2713aSLionel Sambuc                       const void *miiArg,
663f4a2713aSLionel Sambuc                       uint64_t startLoc,
664f4a2713aSLionel Sambuc                       DisassemblerMode mode);
665f4a2713aSLionel Sambuc 
666*0a6a1f1dSLionel Sambuc /// \brief Print a message to debugs()
667*0a6a1f1dSLionel Sambuc /// \param file The name of the file printing the debug message.
668*0a6a1f1dSLionel Sambuc /// \param line The line number that printed the debug message.
669*0a6a1f1dSLionel Sambuc /// \param s    The message to print.
670*0a6a1f1dSLionel Sambuc void Debug(const char *file, unsigned line, const char *s);
671f4a2713aSLionel Sambuc 
672*0a6a1f1dSLionel Sambuc const char *GetInstrName(unsigned Opcode, const void *mii);
673f4a2713aSLionel Sambuc 
674*0a6a1f1dSLionel Sambuc } // namespace X86Disassembler
675*0a6a1f1dSLionel Sambuc } // namespace llvm
676f4a2713aSLionel Sambuc 
677f4a2713aSLionel Sambuc #endif
678