1 //===- XtensaInstPrinter.h - Convert Xtensa MCInst to asm syntax -*- C++ -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //
9 //===----------------------------------------------------------------------===//
10 //
11 // This class prints an Xtensa MCInst to a .s file.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_XTENSA_MCTARGETDESC_XTENSAINSTPRINTER_H
16 #define LLVM_LIB_TARGET_XTENSA_MCTARGETDESC_XTENSAINSTPRINTER_H
17 
18 #include "llvm/MC/MCInstPrinter.h"
19 #include "llvm/Support/Compiler.h"
20 
21 namespace llvm {
22 class MCOperand;
23 
24 class XtensaInstPrinter : public MCInstPrinter {
25 public:
26   XtensaInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
27                     const MCRegisterInfo &MRI)
28       : MCInstPrinter(MAI, MII, MRI) {}
29 
30   // Automatically generated by tblgen.
31   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
32   void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
33   static const char *getRegisterName(MCRegister Reg);
34 
35   // Print the given operand.
36   static void printOperand(const MCOperand &MO, raw_ostream &O);
37 
38   // Override MCInstPrinter.
39   void printRegName(raw_ostream &O, MCRegister Reg) const override;
40   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
41                  const MCSubtargetInfo &STI, raw_ostream &O) override;
42 
43 private:
44   // Print various types of operand.
45   void printOperand(const MCInst *MI, int OpNum, raw_ostream &O);
46   void printMemOperand(const MCInst *MI, int OpNUm, raw_ostream &O);
47   void printBranchTarget(const MCInst *MI, int OpNum, raw_ostream &O);
48   void printJumpTarget(const MCInst *MI, int OpNum, raw_ostream &O);
49   void printCallOperand(const MCInst *MI, int OpNum, raw_ostream &O);
50   void printL32RTarget(const MCInst *MI, int OpNum, raw_ostream &O);
51 
52   void printImm8_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
53   void printImm8_sh8_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
54   void printImm12_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
55   void printImm12m_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
56   void printUimm4_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
57   void printUimm5_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
58   void printShimm1_31_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
59   void printImm1_16_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
60   void printOffset8m8_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
61   void printOffset8m16_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
62   void printOffset8m32_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
63   void printOffset4m32_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
64   void printB4const_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
65   void printB4constu_AsmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
66 };
67 } // end namespace llvm
68 
69 #endif /* LLVM_LIB_TARGET_XTENSA_MCTARGETDESC_XTENSAINSTPRINTER_H */
70