X86DisassemblerDecoder.h 16 KB

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