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