xref: /freebsd/contrib/llvm-project/llvm/lib/Target/X86/MCTargetDesc/X86ATTInstPrinter.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
10b57cec5SDimitry Andric //=- X86ATTInstPrinter.h - Convert X86 MCInst to assembly syntax --*- C++ -*-=//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This class prints an X86 MCInst to AT&T style .s file syntax.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86ATTINSTPRINTER_H
140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86ATTINSTPRINTER_H
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric #include "X86InstPrinterCommon.h"
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric namespace llvm {
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric class X86ATTInstPrinter final : public X86InstPrinterCommon {
210b57cec5SDimitry Andric public:
X86ATTInstPrinter(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)220b57cec5SDimitry Andric   X86ATTInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
230b57cec5SDimitry Andric                     const MCRegisterInfo &MRI)
240b57cec5SDimitry Andric       : X86InstPrinterCommon(MAI, MII, MRI), HasCustomInstComment(false) {}
250b57cec5SDimitry Andric 
26*bdd1243dSDimitry Andric   void printRegName(raw_ostream &OS, MCRegister Reg) const override;
27480093f4SDimitry Andric   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
28480093f4SDimitry Andric                  const MCSubtargetInfo &STI, raw_ostream &OS) override;
290b57cec5SDimitry Andric   bool printVecCompareInstr(const MCInst *MI, raw_ostream &OS);
300b57cec5SDimitry Andric 
310b57cec5SDimitry Andric   // Autogenerated by tblgen, returns true if we successfully printed an
320b57cec5SDimitry Andric   // alias.
335ffd83dbSDimitry Andric   bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &OS);
345ffd83dbSDimitry Andric   void printCustomAliasOperand(const MCInst *MI, uint64_t Address,
355ffd83dbSDimitry Andric                                unsigned OpIdx, unsigned PrintMethodIdx,
365ffd83dbSDimitry Andric                                raw_ostream &O);
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric   // Autogenerated by tblgen.
39e8d8bef9SDimitry Andric   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
40480093f4SDimitry Andric   void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &OS);
41*bdd1243dSDimitry Andric   static const char *getRegisterName(MCRegister Reg);
420b57cec5SDimitry Andric 
430b57cec5SDimitry Andric   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS) override;
440b57cec5SDimitry Andric   void printMemReference(const MCInst *MI, unsigned Op, raw_ostream &OS);
450b57cec5SDimitry Andric   void printMemOffset(const MCInst *MI, unsigned OpNo, raw_ostream &OS);
460b57cec5SDimitry Andric   void printSrcIdx(const MCInst *MI, unsigned Op, raw_ostream &O);
470b57cec5SDimitry Andric   void printDstIdx(const MCInst *MI, unsigned Op, raw_ostream &O);
480b57cec5SDimitry Andric   void printU8Imm(const MCInst *MI, unsigned Op, raw_ostream &OS);
490b57cec5SDimitry Andric   void printSTiRegOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS);
500b57cec5SDimitry Andric 
printbytemem(const MCInst * MI,unsigned OpNo,raw_ostream & O)510b57cec5SDimitry Andric   void printbytemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
520b57cec5SDimitry Andric     printMemReference(MI, OpNo, O);
530b57cec5SDimitry Andric   }
printwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)540b57cec5SDimitry Andric   void printwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
550b57cec5SDimitry Andric     printMemReference(MI, OpNo, O);
560b57cec5SDimitry Andric   }
printdwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)570b57cec5SDimitry Andric   void printdwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
580b57cec5SDimitry Andric     printMemReference(MI, OpNo, O);
590b57cec5SDimitry Andric   }
printqwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)600b57cec5SDimitry Andric   void printqwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
610b57cec5SDimitry Andric     printMemReference(MI, OpNo, O);
620b57cec5SDimitry Andric   }
printxmmwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)630b57cec5SDimitry Andric   void printxmmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
640b57cec5SDimitry Andric     printMemReference(MI, OpNo, O);
650b57cec5SDimitry Andric   }
printymmwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)660b57cec5SDimitry Andric   void printymmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
670b57cec5SDimitry Andric     printMemReference(MI, OpNo, O);
680b57cec5SDimitry Andric   }
printzmmwordmem(const MCInst * MI,unsigned OpNo,raw_ostream & O)690b57cec5SDimitry Andric   void printzmmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
700b57cec5SDimitry Andric     printMemReference(MI, OpNo, O);
710b57cec5SDimitry Andric   }
printtbytemem(const MCInst * MI,unsigned OpNo,raw_ostream & O)720b57cec5SDimitry Andric   void printtbytemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
730b57cec5SDimitry Andric     printMemReference(MI, OpNo, O);
740b57cec5SDimitry Andric   }
750b57cec5SDimitry Andric 
printSrcIdx8(const MCInst * MI,unsigned OpNo,raw_ostream & O)760b57cec5SDimitry Andric   void printSrcIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
770b57cec5SDimitry Andric     printSrcIdx(MI, OpNo, O);
780b57cec5SDimitry Andric   }
printSrcIdx16(const MCInst * MI,unsigned OpNo,raw_ostream & O)790b57cec5SDimitry Andric   void printSrcIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
800b57cec5SDimitry Andric     printSrcIdx(MI, OpNo, O);
810b57cec5SDimitry Andric   }
printSrcIdx32(const MCInst * MI,unsigned OpNo,raw_ostream & O)820b57cec5SDimitry Andric   void printSrcIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
830b57cec5SDimitry Andric     printSrcIdx(MI, OpNo, O);
840b57cec5SDimitry Andric   }
printSrcIdx64(const MCInst * MI,unsigned OpNo,raw_ostream & O)850b57cec5SDimitry Andric   void printSrcIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
860b57cec5SDimitry Andric     printSrcIdx(MI, OpNo, O);
870b57cec5SDimitry Andric   }
printDstIdx8(const MCInst * MI,unsigned OpNo,raw_ostream & O)880b57cec5SDimitry Andric   void printDstIdx8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
890b57cec5SDimitry Andric     printDstIdx(MI, OpNo, O);
900b57cec5SDimitry Andric   }
printDstIdx16(const MCInst * MI,unsigned OpNo,raw_ostream & O)910b57cec5SDimitry Andric   void printDstIdx16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
920b57cec5SDimitry Andric     printDstIdx(MI, OpNo, O);
930b57cec5SDimitry Andric   }
printDstIdx32(const MCInst * MI,unsigned OpNo,raw_ostream & O)940b57cec5SDimitry Andric   void printDstIdx32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
950b57cec5SDimitry Andric     printDstIdx(MI, OpNo, O);
960b57cec5SDimitry Andric   }
printDstIdx64(const MCInst * MI,unsigned OpNo,raw_ostream & O)970b57cec5SDimitry Andric   void printDstIdx64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
980b57cec5SDimitry Andric     printDstIdx(MI, OpNo, O);
990b57cec5SDimitry Andric   }
printMemOffs8(const MCInst * MI,unsigned OpNo,raw_ostream & O)1000b57cec5SDimitry Andric   void printMemOffs8(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
1010b57cec5SDimitry Andric     printMemOffset(MI, OpNo, O);
1020b57cec5SDimitry Andric   }
printMemOffs16(const MCInst * MI,unsigned OpNo,raw_ostream & O)1030b57cec5SDimitry Andric   void printMemOffs16(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
1040b57cec5SDimitry Andric     printMemOffset(MI, OpNo, O);
1050b57cec5SDimitry Andric   }
printMemOffs32(const MCInst * MI,unsigned OpNo,raw_ostream & O)1060b57cec5SDimitry Andric   void printMemOffs32(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
1070b57cec5SDimitry Andric     printMemOffset(MI, OpNo, O);
1080b57cec5SDimitry Andric   }
printMemOffs64(const MCInst * MI,unsigned OpNo,raw_ostream & O)1090b57cec5SDimitry Andric   void printMemOffs64(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
1100b57cec5SDimitry Andric     printMemOffset(MI, OpNo, O);
1110b57cec5SDimitry Andric   }
1120b57cec5SDimitry Andric 
1130b57cec5SDimitry Andric private:
1140b57cec5SDimitry Andric   bool HasCustomInstComment;
1150b57cec5SDimitry Andric };
1160b57cec5SDimitry Andric 
1170b57cec5SDimitry Andric } // end namespace llvm
1180b57cec5SDimitry Andric 
1190b57cec5SDimitry Andric #endif // LLVM_LIB_TARGET_X86_MCTARGETDESC_X86ATTINSTPRINTER_H
120