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:
X86IntelInstPrinter(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)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, uint64_t Address, raw_ostream &OS);
35   void printCustomAliasOperand(const MCInst *MI, uint64_t Address,
36                                unsigned OpIdx, unsigned PrintMethodIdx,
37                                raw_ostream &O);
38 
39   // Autogenerated by tblgen.
40   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
41   void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
42   static const char *getRegisterName(unsigned RegNo);
43 
44   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) override;
45   void printMemReference(const MCInst *MI, unsigned Op, raw_ostream &O);
46   void printMemOffset(const MCInst *MI, unsigned OpNo, raw_ostream &O);
47   void printSrcIdx(const MCInst *MI, unsigned OpNo, raw_ostream &O);
48   void printDstIdx(const MCInst *MI, unsigned OpNo, raw_ostream &O);
49   void printU8Imm(const MCInst *MI, unsigned Op, raw_ostream &O);
50   void printSTiRegOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS);
51 
printbytemem(const MCInst * MI,unsigned OpNo,raw_ostream & O)52   void printbytemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
53     O << "byte ptr ";
54     printMemReference(MI, OpNo, O);
55   }
printwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)56   void printwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
57     O << "word ptr ";
58     printMemReference(MI, OpNo, O);
59   }
printdwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)60   void printdwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
61     O << "dword ptr ";
62     printMemReference(MI, OpNo, O);
63   }
printqwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)64   void printqwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
65     O << "qword ptr ";
66     printMemReference(MI, OpNo, O);
67   }
printxmmwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)68   void printxmmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
69     O << "xmmword ptr ";
70     printMemReference(MI, OpNo, O);
71   }
printymmwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)72   void printymmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
73     O << "ymmword ptr ";
74     printMemReference(MI, OpNo, O);
75   }
printzmmwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)76   void printzmmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
77     O << "zmmword ptr ";
78     printMemReference(MI, OpNo, O);
79   }
printtbytemem(const MCInst * MI,unsigned OpNo,raw_ostream & O)80   void printtbytemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
81     O << "tbyte ptr ";
82     printMemReference(MI, OpNo, O);
83   }
84 
85 
printSrcIdx8(const MCInst * MI,unsigned OpNo,raw_ostream & O)86   void printSrcIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
87     O << "byte ptr ";
88     printSrcIdx(MI, OpNo, O);
89   }
printSrcIdx16(const MCInst * MI,unsigned OpNo,raw_ostream & O)90   void printSrcIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
91     O << "word ptr ";
92     printSrcIdx(MI, OpNo, O);
93   }
printSrcIdx32(const MCInst * MI,unsigned OpNo,raw_ostream & O)94   void printSrcIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
95     O << "dword ptr ";
96     printSrcIdx(MI, OpNo, O);
97   }
printSrcIdx64(const MCInst * MI,unsigned OpNo,raw_ostream & O)98   void printSrcIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
99     O << "qword ptr ";
100     printSrcIdx(MI, OpNo, O);
101   }
printDstIdx8(const MCInst * MI,unsigned OpNo,raw_ostream & O)102   void printDstIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
103     O << "byte ptr ";
104     printDstIdx(MI, OpNo, O);
105   }
printDstIdx16(const MCInst * MI,unsigned OpNo,raw_ostream & O)106   void printDstIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
107     O << "word ptr ";
108     printDstIdx(MI, OpNo, O);
109   }
printDstIdx32(const MCInst * MI,unsigned OpNo,raw_ostream & O)110   void printDstIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
111     O << "dword ptr ";
112     printDstIdx(MI, OpNo, O);
113   }
printDstIdx64(const MCInst * MI,unsigned OpNo,raw_ostream & O)114   void printDstIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
115     O << "qword ptr ";
116     printDstIdx(MI, OpNo, O);
117   }
printMemOffs8(const MCInst * MI,unsigned OpNo,raw_ostream & O)118   void printMemOffs8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
119     O << "byte ptr ";
120     printMemOffset(MI, OpNo, O);
121   }
printMemOffs16(const MCInst * MI,unsigned OpNo,raw_ostream & O)122   void printMemOffs16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
123     O << "word ptr ";
124     printMemOffset(MI, OpNo, O);
125   }
printMemOffs32(const MCInst * MI,unsigned OpNo,raw_ostream & O)126   void printMemOffs32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
127     O << "dword ptr ";
128     printMemOffset(MI, OpNo, O);
129   }
printMemOffs64(const MCInst * MI,unsigned OpNo,raw_ostream & O)130   void printMemOffs64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
131     O << "qword ptr ";
132     printMemOffset(MI, OpNo, O);
133   }
134 };
135 
136 } // end namespace llvm
137 
138 #endif // LLVM_LIB_TARGET_X86_MCTARGETDESC_X86INTELINSTPRINTER_H
139