machine_x86.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include <QtCore/QString>
  3. #include <stdint.h>
  4. #include <bitset>
  5. class QTextStream;
  6. struct LivenessSet;
  7. /* Machine registers */
  8. enum eReg
  9. {
  10. rUNDEF = 0,
  11. rAX = 1, /* These are numbered relative to real 8086 */
  12. rCX = 2,
  13. rDX = 3,
  14. rBX = 4,
  15. rSP = 5,
  16. rBP = 6,
  17. rSI = 7,
  18. rDI = 8,
  19. rES = 9,
  20. rCS = 10,
  21. rSS = 11,
  22. rDS = 12,
  23. rAL = 13,
  24. rCL = 14,
  25. rDL = 15,
  26. rBL = 16,
  27. rAH = 17,
  28. rCH = 18,
  29. rDH = 19,
  30. rBH = 20,
  31. rTMP= 21, /* temp register for DIV/IDIV/MOD */
  32. rTMP2= 22, /* temp register for DIV/IDIV/MOD */
  33. /* Indexed modes go from INDEXBASE to INDEXBASE+7 */
  34. INDEX_BX_SI = 23, // "bx+si"
  35. INDEX_BX_DI, // "bx+di"
  36. INDEX_BP_SI, // "bp+si"
  37. INDEX_BP_DI, // "bp+di"
  38. INDEX_SI, // "si"
  39. INDEX_DI, // "di"
  40. INDEX_BP, // "bp"
  41. INDEX_BX, // "bx"
  42. LAST_REG
  43. };
  44. class SourceMachine
  45. {
  46. public:
  47. virtual bool physicalReg(eReg r)=0;
  48. };
  49. //class Machine_X86_Disassembler
  50. //{
  51. // void formatRM(std::ostringstream &p, uint32_t flg, const LLOperand &pm);
  52. //};
  53. class Machine_X86 : public SourceMachine
  54. {
  55. public:
  56. Machine_X86();
  57. virtual ~Machine_X86() {}
  58. static const QString & regName(eReg r);
  59. static const QString & opcodeName(unsigned r);
  60. static const QString & floatOpName(unsigned r);
  61. bool physicalReg(eReg r);
  62. /* Writes the registers that are set in the bitvector */
  63. //TODO: move this into Machine_X86 ?
  64. static void writeRegVector (QTextStream & ostr, const LivenessSet &regi);
  65. static eReg subRegH(eReg reg);
  66. static eReg subRegL(eReg reg);
  67. static bool isMemOff(eReg r);
  68. static bool isSubRegisterOf(eReg reg, eReg parent);
  69. static bool hasSubregisters(eReg reg);
  70. static bool isPartOfComposite(eReg reg);
  71. static eReg compositeParent(eReg reg);
  72. };