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