X86IntelInstPrinter.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. //= X86IntelInstPrinter.h - Convert X86 MCInst to assembly syntax -*- 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 class prints an X86 MCInst to Intel style .s file syntax.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86INTELINSTPRINTER_H
  13. #define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86INTELINSTPRINTER_H
  14. #include "X86InstPrinterCommon.h"
  15. #include "llvm/Support/raw_ostream.h"
  16. namespace llvm {
  17. class X86IntelInstPrinter final : public X86InstPrinterCommon {
  18. public:
  19. X86IntelInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
  20. const MCRegisterInfo &MRI)
  21. : X86InstPrinterCommon(MAI, MII, MRI) {}
  22. void printRegName(raw_ostream &OS, MCRegister Reg) const override;
  23. void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
  24. const MCSubtargetInfo &STI, raw_ostream &OS) override;
  25. bool printVecCompareInstr(const MCInst *MI, raw_ostream &OS);
  26. // Autogenerated by tblgen, returns true if we successfully printed an
  27. // alias.
  28. bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &OS);
  29. void printCustomAliasOperand(const MCInst *MI, uint64_t Address,
  30. unsigned OpIdx, unsigned PrintMethodIdx,
  31. raw_ostream &O);
  32. // Autogenerated by tblgen.
  33. std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
  34. void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
  35. static const char *getRegisterName(MCRegister Reg);
  36. void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) override;
  37. void printMemReference(const MCInst *MI, unsigned Op, raw_ostream &O);
  38. void printMemOffset(const MCInst *MI, unsigned OpNo, raw_ostream &O);
  39. void printSrcIdx(const MCInst *MI, unsigned OpNo, raw_ostream &O);
  40. void printDstIdx(const MCInst *MI, unsigned OpNo, raw_ostream &O);
  41. void printU8Imm(const MCInst *MI, unsigned Op, raw_ostream &O);
  42. void printSTiRegOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS);
  43. void printbytemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  44. O << "byte ptr ";
  45. printMemReference(MI, OpNo, O);
  46. }
  47. void printwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  48. O << "word ptr ";
  49. printMemReference(MI, OpNo, O);
  50. }
  51. void printdwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  52. O << "dword ptr ";
  53. printMemReference(MI, OpNo, O);
  54. }
  55. void printqwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  56. O << "qword ptr ";
  57. printMemReference(MI, OpNo, O);
  58. }
  59. void printxmmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  60. O << "xmmword ptr ";
  61. printMemReference(MI, OpNo, O);
  62. }
  63. void printymmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  64. O << "ymmword ptr ";
  65. printMemReference(MI, OpNo, O);
  66. }
  67. void printzmmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  68. O << "zmmword ptr ";
  69. printMemReference(MI, OpNo, O);
  70. }
  71. void printtbytemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  72. O << "tbyte ptr ";
  73. printMemReference(MI, OpNo, O);
  74. }
  75. void printSrcIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  76. O << "byte ptr ";
  77. printSrcIdx(MI, OpNo, O);
  78. }
  79. void printSrcIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  80. O << "word ptr ";
  81. printSrcIdx(MI, OpNo, O);
  82. }
  83. void printSrcIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  84. O << "dword ptr ";
  85. printSrcIdx(MI, OpNo, O);
  86. }
  87. void printSrcIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  88. O << "qword ptr ";
  89. printSrcIdx(MI, OpNo, O);
  90. }
  91. void printDstIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  92. O << "byte ptr ";
  93. printDstIdx(MI, OpNo, O);
  94. }
  95. void printDstIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  96. O << "word ptr ";
  97. printDstIdx(MI, OpNo, O);
  98. }
  99. void printDstIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  100. O << "dword ptr ";
  101. printDstIdx(MI, OpNo, O);
  102. }
  103. void printDstIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  104. O << "qword ptr ";
  105. printDstIdx(MI, OpNo, O);
  106. }
  107. void printMemOffs8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  108. O << "byte ptr ";
  109. printMemOffset(MI, OpNo, O);
  110. }
  111. void printMemOffs16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  112. O << "word ptr ";
  113. printMemOffset(MI, OpNo, O);
  114. }
  115. void printMemOffs32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  116. O << "dword ptr ";
  117. printMemOffset(MI, OpNo, O);
  118. }
  119. void printMemOffs64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
  120. O << "qword ptr ";
  121. printMemOffset(MI, OpNo, O);
  122. }
  123. };
  124. } // end namespace llvm
  125. #endif // LLVM_LIB_TARGET_X86_MCTARGETDESC_X86INTELINSTPRINTER_H