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