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 "X86InstPrinterCommon.h"
18 #include "llvm/Support/raw_ostream.h"
19 
20 namespace llvm {
21 
22 class X86IntelInstPrinter final : public X86InstPrinterCommon {
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     : X86InstPrinterCommon(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) 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 
printanymem(const MCInst * MI,unsigned OpNo,raw_ostream & O)43   void printanymem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
44     printMemReference(MI, OpNo, O);
45   }
46 
printopaquemem(const MCInst * MI,unsigned OpNo,raw_ostream & O)47   void printopaquemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
48     printMemReference(MI, OpNo, O);
49   }
50 
printi8mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)51   void printi8mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
52     O << "byte ptr ";
53     printMemReference(MI, OpNo, O);
54   }
printi16mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)55   void printi16mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
56     O << "word ptr ";
57     printMemReference(MI, OpNo, O);
58   }
printi32mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)59   void printi32mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
60     O << "dword ptr ";
61     printMemReference(MI, OpNo, O);
62   }
printi64mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)63   void printi64mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
64     O << "qword ptr ";
65     printMemReference(MI, OpNo, O);
66   }
printi128mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)67   void printi128mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
68     O << "xmmword ptr ";
69     printMemReference(MI, OpNo, O);
70   }
printi256mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)71   void printi256mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
72     O << "ymmword ptr ";
73     printMemReference(MI, OpNo, O);
74   }
printi512mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)75   void printi512mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
76     O << "zmmword ptr ";
77     printMemReference(MI, OpNo, O);
78   }
printf32mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)79   void printf32mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
80     O << "dword ptr ";
81     printMemReference(MI, OpNo, O);
82   }
printf64mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)83   void printf64mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
84     O << "qword ptr ";
85     printMemReference(MI, OpNo, O);
86   }
printf80mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)87   void printf80mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
88     O << "tbyte ptr ";
89     printMemReference(MI, OpNo, O);
90   }
printf128mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)91   void printf128mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
92     O << "xmmword ptr ";
93     printMemReference(MI, OpNo, O);
94   }
printf256mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)95   void printf256mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
96     O << "ymmword ptr ";
97     printMemReference(MI, OpNo, O);
98   }
printf512mem(const MCInst * MI,unsigned OpNo,raw_ostream & O)99   void printf512mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
100     O << "zmmword ptr ";
101     printMemReference(MI, OpNo, O);
102   }
103 
104 
printSrcIdx8(const MCInst * MI,unsigned OpNo,raw_ostream & O)105   void printSrcIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
106     O << "byte ptr ";
107     printSrcIdx(MI, OpNo, O);
108   }
printSrcIdx16(const MCInst * MI,unsigned OpNo,raw_ostream & O)109   void printSrcIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
110     O << "word ptr ";
111     printSrcIdx(MI, OpNo, O);
112   }
printSrcIdx32(const MCInst * MI,unsigned OpNo,raw_ostream & O)113   void printSrcIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
114     O << "dword ptr ";
115     printSrcIdx(MI, OpNo, O);
116   }
printSrcIdx64(const MCInst * MI,unsigned OpNo,raw_ostream & O)117   void printSrcIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
118     O << "qword ptr ";
119     printSrcIdx(MI, OpNo, O);
120   }
printDstIdx8(const MCInst * MI,unsigned OpNo,raw_ostream & O)121   void printDstIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
122     O << "byte ptr ";
123     printDstIdx(MI, OpNo, O);
124   }
printDstIdx16(const MCInst * MI,unsigned OpNo,raw_ostream & O)125   void printDstIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
126     O << "word ptr ";
127     printDstIdx(MI, OpNo, O);
128   }
printDstIdx32(const MCInst * MI,unsigned OpNo,raw_ostream & O)129   void printDstIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
130     O << "dword ptr ";
131     printDstIdx(MI, OpNo, O);
132   }
printDstIdx64(const MCInst * MI,unsigned OpNo,raw_ostream & O)133   void printDstIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
134     O << "qword ptr ";
135     printDstIdx(MI, OpNo, O);
136   }
printMemOffs8(const MCInst * MI,unsigned OpNo,raw_ostream & O)137   void printMemOffs8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
138     O << "byte ptr ";
139     printMemOffset(MI, OpNo, O);
140   }
printMemOffs16(const MCInst * MI,unsigned OpNo,raw_ostream & O)141   void printMemOffs16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
142     O << "word ptr ";
143     printMemOffset(MI, OpNo, O);
144   }
printMemOffs32(const MCInst * MI,unsigned OpNo,raw_ostream & O)145   void printMemOffs32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
146     O << "dword ptr ";
147     printMemOffset(MI, OpNo, O);
148   }
printMemOffs64(const MCInst * MI,unsigned OpNo,raw_ostream & O)149   void printMemOffs64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
150     O << "qword ptr ";
151     printMemOffset(MI, OpNo, O);
152   }
153 };
154 
155 } // end namespace llvm
156 
157 #endif // LLVM_LIB_TARGET_X86_INSTPRINTER_X86INTELINSTPRINTER_H
158