xref: /freebsd/contrib/llvm-project/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchInstPrinter.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
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   bool applyTargetSpecificCLOption(StringRef Opt) override;
28 
29   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
30                  const MCSubtargetInfo &STI, raw_ostream &O) override;
31   void printRegName(raw_ostream &O, MCRegister Reg) const override;
32   void printAtomicMemOp(const MCInst *MI, unsigned OpNo,
33                         const MCSubtargetInfo &STI, raw_ostream &O);
34 
35   // Autogenerated by tblgen.
36   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
37   void printInstruction(const MCInst *MI, uint64_t Address,
38                         const MCSubtargetInfo &STI, raw_ostream &O);
39   bool printAliasInstr(const MCInst *MI, uint64_t Address,
40                        const MCSubtargetInfo &STI, raw_ostream &O);
41   void printCustomAliasOperand(const MCInst *MI, uint64_t Address,
42                                unsigned OpIdx, unsigned PrintMethodIdx,
43                                const MCSubtargetInfo &STI, raw_ostream &O);
44   static const char *getRegisterName(MCRegister Reg);
45   static const char *getRegisterName(MCRegister Reg, unsigned AltIdx);
46 
47 private:
48   void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
49                     raw_ostream &O);
50 };
51 } // end namespace llvm
52 
53 #endif // LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHINSTPRINTER_H
54