1 //=- X86ATTInstPrinter.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 AT&T style .s file syntax.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86ATTINSTPRINTER_H
14 #define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86ATTINSTPRINTER_H
15 
16 #include "X86InstPrinterCommon.h"
17 
18 namespace llvm {
19 
20 class X86ATTInstPrinter final : public X86InstPrinterCommon {
21 public:
X86ATTInstPrinter(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)22   X86ATTInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
23                     const MCRegisterInfo &MRI)
24       : X86InstPrinterCommon(MAI, MII, MRI), HasCustomInstComment(false) {}
25 
26   void printRegName(raw_ostream &OS, unsigned RegNo) const override;
27   void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot,
28                  const MCSubtargetInfo &STI) override;
29   bool printVecCompareInstr(const MCInst *MI, raw_ostream &OS);
30 
31   // Autogenerated by tblgen, returns true if we successfully printed an
32   // alias.
33   bool printAliasInstr(const MCInst *MI, raw_ostream &OS);
34   void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
35                                unsigned PrintMethodIdx, raw_ostream &O);
36 
37   // Autogenerated by tblgen.
38   void printInstruction(const MCInst *MI, raw_ostream &OS);
39   static const char *getRegisterName(unsigned RegNo);
40 
41   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS) override;
42   void printMemReference(const MCInst *MI, unsigned Op, raw_ostream &OS);
43   void printMemOffset(const MCInst *MI, unsigned OpNo, raw_ostream &OS);
44   void printSrcIdx(const MCInst *MI, unsigned Op, raw_ostream &O);
45   void printDstIdx(const MCInst *MI, unsigned Op, raw_ostream &O);
46   void printU8Imm(const MCInst *MI, unsigned Op, raw_ostream &OS);
47   void printSTiRegOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS);
48 
printanymem(const MCInst * MI,unsigned OpNo,raw_ostream & O)49   void printanymem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
50     printMemReference(MI, OpNo, O);
51   }
printopaquemem(const MCInst * MI,unsigned OpNo,raw_ostream & O)52   void printopaquemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
53     printMemReference(MI, OpNo, O);
54   }
55 
printbytemem(const MCInst * MI,unsigned OpNo,raw_ostream & O)56   void printbytemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
57     printMemReference(MI, OpNo, O);
58   }
printwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)59   void printwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
60     printMemReference(MI, OpNo, O);
61   }
printdwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)62   void printdwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
63     printMemReference(MI, OpNo, O);
64   }
printqwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)65   void printqwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
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     printMemReference(MI, OpNo, O);
70   }
printymmwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)71   void printymmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
72     printMemReference(MI, OpNo, O);
73   }
printzmmwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)74   void printzmmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
75     printMemReference(MI, OpNo, O);
76   }
printtbytemem(const MCInst * MI,unsigned OpNo,raw_ostream & O)77   void printtbytemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
78     printMemReference(MI, OpNo, O);
79   }
80 
printSrcIdx8(const MCInst * MI,unsigned OpNo,raw_ostream & O)81   void printSrcIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
82     printSrcIdx(MI, OpNo, O);
83   }
printSrcIdx16(const MCInst * MI,unsigned OpNo,raw_ostream & O)84   void printSrcIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
85     printSrcIdx(MI, OpNo, O);
86   }
printSrcIdx32(const MCInst * MI,unsigned OpNo,raw_ostream & O)87   void printSrcIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
88     printSrcIdx(MI, OpNo, O);
89   }
printSrcIdx64(const MCInst * MI,unsigned OpNo,raw_ostream & O)90   void printSrcIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
91     printSrcIdx(MI, OpNo, O);
92   }
printDstIdx8(const MCInst * MI,unsigned OpNo,raw_ostream & O)93   void printDstIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
94     printDstIdx(MI, OpNo, O);
95   }
printDstIdx16(const MCInst * MI,unsigned OpNo,raw_ostream & O)96   void printDstIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
97     printDstIdx(MI, OpNo, O);
98   }
printDstIdx32(const MCInst * MI,unsigned OpNo,raw_ostream & O)99   void printDstIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
100     printDstIdx(MI, OpNo, O);
101   }
printDstIdx64(const MCInst * MI,unsigned OpNo,raw_ostream & O)102   void printDstIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
103     printDstIdx(MI, OpNo, O);
104   }
printMemOffs8(const MCInst * MI,unsigned OpNo,raw_ostream & O)105   void printMemOffs8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
106     printMemOffset(MI, OpNo, O);
107   }
printMemOffs16(const MCInst * MI,unsigned OpNo,raw_ostream & O)108   void printMemOffs16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
109     printMemOffset(MI, OpNo, O);
110   }
printMemOffs32(const MCInst * MI,unsigned OpNo,raw_ostream & O)111   void printMemOffs32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
112     printMemOffset(MI, OpNo, O);
113   }
printMemOffs64(const MCInst * MI,unsigned OpNo,raw_ostream & O)114   void printMemOffs64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
115     printMemOffset(MI, OpNo, O);
116   }
117 
118 private:
119   bool HasCustomInstComment;
120 };
121 
122 } // end namespace llvm
123 
124 #endif // LLVM_LIB_TARGET_X86_MCTARGETDESC_X86ATTINSTPRINTER_H
125