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