1 //= X86IntelInstPrinter.h - Convert X86 MCInst to assembly syntax -*- 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 class prints an X86 MCInst to Intel style .s file syntax. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_X86_INSTPRINTER_X86INTELINSTPRINTER_H 15 #define LLVM_LIB_TARGET_X86_INSTPRINTER_X86INTELINSTPRINTER_H 16 17 #include "llvm/MC/MCInstPrinter.h" 18 #include "llvm/Support/raw_ostream.h" 19 20 namespace llvm { 21 22 class MCOperand; 23 24 class X86IntelInstPrinter final : public MCInstPrinter { 25 public: X86IntelInstPrinter(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)26 X86IntelInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, 27 const MCRegisterInfo &MRI) 28 : MCInstPrinter(MAI, MII, MRI) {} 29 30 void printRegName(raw_ostream &OS, unsigned RegNo) const override; 31 void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot, 32 const MCSubtargetInfo &STI) override; 33 34 // Autogenerated by tblgen. 35 void printInstruction(const MCInst *MI, raw_ostream &O); 36 static const char *getRegisterName(unsigned RegNo); 37 38 void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); 39 void printMemReference(const MCInst *MI, unsigned Op, raw_ostream &O); 40 void printSSEAVXCC(const MCInst *MI, unsigned Op, raw_ostream &O); 41 void printXOPCC(const MCInst *MI, unsigned Op, raw_ostream &O); 42 void printPCRelImm(const MCInst *MI, unsigned OpNo, raw_ostream &O); 43 void printMemOffset(const MCInst *MI, unsigned OpNo, raw_ostream &O); 44 void printSrcIdx(const MCInst *MI, unsigned OpNo, raw_ostream &O); 45 void printDstIdx(const MCInst *MI, unsigned OpNo, raw_ostream &O); 46 void printRoundingControl(const MCInst *MI, unsigned Op, raw_ostream &OS); 47 void printU8Imm(const MCInst *MI, unsigned Op, raw_ostream &O); 48 printanymem(const MCInst * MI,unsigned OpNo,raw_ostream & O)49 void printanymem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 50 printMemReference(MI, OpNo, O); 51 } 52 printopaquemem(const MCInst * MI,unsigned OpNo,raw_ostream & O)53 void printopaquemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 54 O << "opaque ptr "; 55 printMemReference(MI, OpNo, O); 56 } 57 printi8mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)58 void printi8mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 59 O << "byte ptr "; 60 printMemReference(MI, OpNo, O); 61 } printi16mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)62 void printi16mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 63 O << "word ptr "; 64 printMemReference(MI, OpNo, O); 65 } printi32mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)66 void printi32mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 67 O << "dword ptr "; 68 printMemReference(MI, OpNo, O); 69 } printi64mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)70 void printi64mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 71 O << "qword ptr "; 72 printMemReference(MI, OpNo, O); 73 } printi128mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)74 void printi128mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 75 O << "xmmword ptr "; 76 printMemReference(MI, OpNo, O); 77 } printi256mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)78 void printi256mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 79 O << "ymmword ptr "; 80 printMemReference(MI, OpNo, O); 81 } printi512mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)82 void printi512mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 83 O << "zmmword ptr "; 84 printMemReference(MI, OpNo, O); 85 } printf32mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)86 void printf32mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 87 O << "dword ptr "; 88 printMemReference(MI, OpNo, O); 89 } printf64mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)90 void printf64mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 91 O << "qword ptr "; 92 printMemReference(MI, OpNo, O); 93 } printf80mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)94 void printf80mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 95 O << "xword ptr "; 96 printMemReference(MI, OpNo, O); 97 } printf128mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)98 void printf128mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 99 O << "xmmword ptr "; 100 printMemReference(MI, OpNo, O); 101 } printf256mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)102 void printf256mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 103 O << "ymmword ptr "; 104 printMemReference(MI, OpNo, O); 105 } printf512mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)106 void printf512mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 107 O << "zmmword ptr "; 108 printMemReference(MI, OpNo, O); 109 } 110 111 printSrcIdx8(const MCInst * MI,unsigned OpNo,raw_ostream & O)112 void printSrcIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 113 O << "byte ptr "; 114 printSrcIdx(MI, OpNo, O); 115 } printSrcIdx16(const MCInst * MI,unsigned OpNo,raw_ostream & O)116 void printSrcIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 117 O << "word ptr "; 118 printSrcIdx(MI, OpNo, O); 119 } printSrcIdx32(const MCInst * MI,unsigned OpNo,raw_ostream & O)120 void printSrcIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 121 O << "dword ptr "; 122 printSrcIdx(MI, OpNo, O); 123 } printSrcIdx64(const MCInst * MI,unsigned OpNo,raw_ostream & O)124 void printSrcIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 125 O << "qword ptr "; 126 printSrcIdx(MI, OpNo, O); 127 } printDstIdx8(const MCInst * MI,unsigned OpNo,raw_ostream & O)128 void printDstIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 129 O << "byte ptr "; 130 printDstIdx(MI, OpNo, O); 131 } printDstIdx16(const MCInst * MI,unsigned OpNo,raw_ostream & O)132 void printDstIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 133 O << "word ptr "; 134 printDstIdx(MI, OpNo, O); 135 } printDstIdx32(const MCInst * MI,unsigned OpNo,raw_ostream & O)136 void printDstIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 137 O << "dword ptr "; 138 printDstIdx(MI, OpNo, O); 139 } printDstIdx64(const MCInst * MI,unsigned OpNo,raw_ostream & O)140 void printDstIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 141 O << "qword ptr "; 142 printDstIdx(MI, OpNo, O); 143 } printMemOffs8(const MCInst * MI,unsigned OpNo,raw_ostream & O)144 void printMemOffs8(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 145 O << "byte ptr "; 146 printMemOffset(MI, OpNo, O); 147 } printMemOffs16(const MCInst * MI,unsigned OpNo,raw_ostream & O)148 void printMemOffs16(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 149 O << "word ptr "; 150 printMemOffset(MI, OpNo, O); 151 } printMemOffs32(const MCInst * MI,unsigned OpNo,raw_ostream & O)152 void printMemOffs32(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 153 O << "dword ptr "; 154 printMemOffset(MI, OpNo, O); 155 } printMemOffs64(const MCInst * MI,unsigned OpNo,raw_ostream & O)156 void printMemOffs64(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 157 O << "qword ptr "; 158 printMemOffset(MI, OpNo, O); 159 } 160 }; 161 162 } 163 164 #endif 165