xref: /freebsd/contrib/llvm-project/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchInstPrinter.h (revision a4a491e2238b12ccd64d3faf9e6401487f6f1f1b)
1 //===-- LoongArchInstPrinter.h - Convert LoongArch MCInst to asm syntax ---===//
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 a LoongArch MCInst to a .s file.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHINSTPRINTER_H
14 #define LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHINSTPRINTER_H
15 
16 #include "MCTargetDesc/LoongArchMCTargetDesc.h"
17 #include "llvm/MC/MCInstPrinter.h"
18 
19 namespace llvm {
20 
21 class LoongArchInstPrinter : public MCInstPrinter {
22 public:
23   LoongArchInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
24                        const MCRegisterInfo &MRI)
25       : MCInstPrinter(MAI, MII, MRI) {}
26 
27   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
28                  const MCSubtargetInfo &STI, raw_ostream &O) override;
29   void printRegName(raw_ostream &O, unsigned RegNo) const override;
30 
31   // Autogenerated by tblgen.
32   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
33   void printInstruction(const MCInst *MI, uint64_t Address,
34                         const MCSubtargetInfo &STI, raw_ostream &O);
35   bool printAliasInstr(const MCInst *MI, uint64_t Address,
36                        const MCSubtargetInfo &STI, raw_ostream &O);
37   void printCustomAliasOperand(const MCInst *MI, uint64_t Address,
38                                unsigned OpIdx, unsigned PrintMethodIdx,
39                                const MCSubtargetInfo &STI, raw_ostream &O);
40   static const char *getRegisterName(unsigned RegNo);
41   static const char *getRegisterName(unsigned RegNo, unsigned AltIdx);
42 
43 private:
44   void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
45                     raw_ostream &O);
46 };
47 } // end namespace llvm
48 
49 #endif // LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHINSTPRINTER_H
50