xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/CSKY/MCTargetDesc/CSKYInstPrinter.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1fe6060f1SDimitry Andric //===-- CSKYInstPrinter.h - Convert CSKY MCInst to asm syntax ---*- C++ -*----//
2fe6060f1SDimitry Andric //
3fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6fe6060f1SDimitry Andric //
7fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
8fe6060f1SDimitry Andric //
9fe6060f1SDimitry Andric // This class prints a CSKY MCInst to a .s file.
10fe6060f1SDimitry Andric //
11fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
12fe6060f1SDimitry Andric 
13fe6060f1SDimitry Andric #ifndef LLVM_LIB_TARGET_CSKY_MCTARGETDESC_CSKYINSTPRINTER_H
14fe6060f1SDimitry Andric #define LLVM_LIB_TARGET_CSKY_MCTARGETDESC_CSKYINSTPRINTER_H
15fe6060f1SDimitry Andric 
16fe6060f1SDimitry Andric #include "MCTargetDesc/CSKYMCTargetDesc.h"
17fe6060f1SDimitry Andric #include "llvm/MC/MCInstPrinter.h"
18fe6060f1SDimitry Andric 
19fe6060f1SDimitry Andric namespace llvm {
20fe6060f1SDimitry Andric 
21fe6060f1SDimitry Andric class CSKYInstPrinter : public MCInstPrinter {
22349cc55cSDimitry Andric private:
23349cc55cSDimitry Andric   bool ABIRegNames = false;
24349cc55cSDimitry Andric 
25fe6060f1SDimitry Andric public:
CSKYInstPrinter(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)26fe6060f1SDimitry Andric   CSKYInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
27fe6060f1SDimitry Andric                   const MCRegisterInfo &MRI)
28fe6060f1SDimitry Andric       : MCInstPrinter(MAI, MII, MRI) {}
29fe6060f1SDimitry Andric 
30fe6060f1SDimitry Andric   bool applyTargetSpecificCLOption(StringRef Opt) override;
31fe6060f1SDimitry Andric 
32fe6060f1SDimitry Andric   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
33fe6060f1SDimitry Andric                  const MCSubtargetInfo &STI, raw_ostream &O) override;
34*bdd1243dSDimitry Andric   void printRegName(raw_ostream &O, MCRegister Reg) const override;
35fe6060f1SDimitry Andric 
36fe6060f1SDimitry Andric   void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
37fe6060f1SDimitry Andric                     raw_ostream &O, const char *Modifier = nullptr);
38fe6060f1SDimitry Andric 
3904eeddc0SDimitry Andric   void printFPRRegName(raw_ostream &O, unsigned RegNo) const;
4004eeddc0SDimitry Andric 
41fe6060f1SDimitry Andric   // Autogenerated by tblgen.
42fe6060f1SDimitry Andric   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
43fe6060f1SDimitry Andric   void printInstruction(const MCInst *MI, uint64_t Address,
44fe6060f1SDimitry Andric                         const MCSubtargetInfo &STI, raw_ostream &O);
45fe6060f1SDimitry Andric   bool printAliasInstr(const MCInst *MI, uint64_t Address,
46fe6060f1SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
47fe6060f1SDimitry Andric   void printCustomAliasOperand(const MCInst *MI, uint64_t Address,
48fe6060f1SDimitry Andric                                unsigned OpIdx, unsigned PrintMethodIdx,
49fe6060f1SDimitry Andric                                const MCSubtargetInfo &STI, raw_ostream &O);
50fe6060f1SDimitry Andric 
51349cc55cSDimitry Andric   void printDataSymbol(const MCInst *MI, unsigned OpNo,
52349cc55cSDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
53349cc55cSDimitry Andric   void printConstpool(const MCInst *MI, uint64_t Address, unsigned OpNo,
54349cc55cSDimitry Andric                       const MCSubtargetInfo &STI, raw_ostream &O);
55349cc55cSDimitry Andric   void printPSRFlag(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
56349cc55cSDimitry Andric                     raw_ostream &O);
57349cc55cSDimitry Andric   void printRegisterSeq(const MCInst *MI, unsigned OpNo,
58349cc55cSDimitry Andric                         const MCSubtargetInfo &STI, raw_ostream &O);
59349cc55cSDimitry Andric   void printRegisterList(const MCInst *MI, unsigned OpNo,
60349cc55cSDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
61349cc55cSDimitry Andric   void printCSKYSymbolOperand(const MCInst *MI, uint64_t Address, unsigned OpNo,
62349cc55cSDimitry Andric                               const MCSubtargetInfo &STI, raw_ostream &O);
63349cc55cSDimitry Andric   void printSPAddr(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
64349cc55cSDimitry Andric                    raw_ostream &O);
6504eeddc0SDimitry Andric   void printFPR(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
6604eeddc0SDimitry Andric                 raw_ostream &O);
67*bdd1243dSDimitry Andric   static const char *getRegisterName(MCRegister Reg);
68*bdd1243dSDimitry Andric   static const char *getRegisterName(MCRegister Reg, unsigned AltIdx);
69fe6060f1SDimitry Andric };
70fe6060f1SDimitry Andric 
71fe6060f1SDimitry Andric } // namespace llvm
72fe6060f1SDimitry Andric 
73fe6060f1SDimitry Andric #endif // LLVM_LIB_TARGET_CSKY_MCTARGETDESC_CSKYINSTPRINTER_H
74