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