xref: /aosp_15_r20/external/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- HexagonInstPrinter.h - Convert Hexagon MCInst to assembly syntax --===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker //
11*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
12*9880d681SAndroid Build Coastguard Worker 
13*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_HEXAGON_INSTPRINTER_HEXAGONINSTPRINTER_H
14*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_HEXAGON_INSTPRINTER_HEXAGONINSTPRINTER_H
15*9880d681SAndroid Build Coastguard Worker 
16*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCInstPrinter.h"
17*9880d681SAndroid Build Coastguard Worker 
18*9880d681SAndroid Build Coastguard Worker namespace llvm {
19*9880d681SAndroid Build Coastguard Worker /// Prints bundles as a newline separated list of individual instructions
20*9880d681SAndroid Build Coastguard Worker /// Duplexes are separated by a vertical tab \v character
21*9880d681SAndroid Build Coastguard Worker /// A trailing line includes bundle properties such as endloop0/1
22*9880d681SAndroid Build Coastguard Worker ///
23*9880d681SAndroid Build Coastguard Worker /// r0 = add(r1, r2)
24*9880d681SAndroid Build Coastguard Worker /// r0 = #0 \v jump 0x0
25*9880d681SAndroid Build Coastguard Worker /// :endloop0 :endloop1
26*9880d681SAndroid Build Coastguard Worker class HexagonInstPrinter : public MCInstPrinter {
27*9880d681SAndroid Build Coastguard Worker public:
28*9880d681SAndroid Build Coastguard Worker   explicit HexagonInstPrinter(MCAsmInfo const &MAI, MCInstrInfo const &MII,
29*9880d681SAndroid Build Coastguard Worker                               MCRegisterInfo const &MRI);
30*9880d681SAndroid Build Coastguard Worker   void printInst(MCInst const *MI, raw_ostream &O, StringRef Annot,
31*9880d681SAndroid Build Coastguard Worker                  const MCSubtargetInfo &STI) override;
32*9880d681SAndroid Build Coastguard Worker   virtual StringRef getOpcodeName(unsigned Opcode) const;
33*9880d681SAndroid Build Coastguard Worker   void printInstruction(MCInst const *MI, raw_ostream &O);
34*9880d681SAndroid Build Coastguard Worker 
35*9880d681SAndroid Build Coastguard Worker   StringRef getRegName(unsigned RegNo) const;
36*9880d681SAndroid Build Coastguard Worker   static char const *getRegisterName(unsigned RegNo);
37*9880d681SAndroid Build Coastguard Worker   void printRegName(raw_ostream &O, unsigned RegNo) const override;
38*9880d681SAndroid Build Coastguard Worker 
39*9880d681SAndroid Build Coastguard Worker   void printOperand(MCInst const *MI, unsigned OpNo, raw_ostream &O) const;
40*9880d681SAndroid Build Coastguard Worker   void printExtOperand(MCInst const *MI, unsigned OpNo, raw_ostream &O) const;
41*9880d681SAndroid Build Coastguard Worker   void printUnsignedImmOperand(MCInst const *MI, unsigned OpNo,
42*9880d681SAndroid Build Coastguard Worker                                raw_ostream &O) const;
43*9880d681SAndroid Build Coastguard Worker   void printNegImmOperand(MCInst const *MI, unsigned OpNo,
44*9880d681SAndroid Build Coastguard Worker                           raw_ostream &O) const;
45*9880d681SAndroid Build Coastguard Worker   void printNOneImmOperand(MCInst const *MI, unsigned OpNo,
46*9880d681SAndroid Build Coastguard Worker                            raw_ostream &O) const;
47*9880d681SAndroid Build Coastguard Worker   void prints3_6ImmOperand(MCInst const *MI, unsigned OpNo,
48*9880d681SAndroid Build Coastguard Worker                            raw_ostream &O) const;
49*9880d681SAndroid Build Coastguard Worker   void prints3_7ImmOperand(MCInst const *MI, unsigned OpNo,
50*9880d681SAndroid Build Coastguard Worker                            raw_ostream &O) const;
51*9880d681SAndroid Build Coastguard Worker   void prints4_6ImmOperand(MCInst const *MI, unsigned OpNo,
52*9880d681SAndroid Build Coastguard Worker                            raw_ostream &O) const;
53*9880d681SAndroid Build Coastguard Worker   void prints4_7ImmOperand(MCInst const *MI, unsigned OpNo,
54*9880d681SAndroid Build Coastguard Worker                            raw_ostream &O) const;
55*9880d681SAndroid Build Coastguard Worker   void printBranchOperand(MCInst const *MI, unsigned OpNo,
56*9880d681SAndroid Build Coastguard Worker                           raw_ostream &O) const;
57*9880d681SAndroid Build Coastguard Worker   void printCallOperand(MCInst const *MI, unsigned OpNo, raw_ostream &O) const;
58*9880d681SAndroid Build Coastguard Worker   void printAbsAddrOperand(MCInst const *MI, unsigned OpNo,
59*9880d681SAndroid Build Coastguard Worker                            raw_ostream &O) const;
60*9880d681SAndroid Build Coastguard Worker   void printPredicateOperand(MCInst const *MI, unsigned OpNo,
61*9880d681SAndroid Build Coastguard Worker                              raw_ostream &O) const;
62*9880d681SAndroid Build Coastguard Worker   void printGlobalOperand(MCInst const *MI, unsigned OpNo,
63*9880d681SAndroid Build Coastguard Worker                           raw_ostream &O) const;
64*9880d681SAndroid Build Coastguard Worker   void printJumpTable(MCInst const *MI, unsigned OpNo, raw_ostream &O) const;
65*9880d681SAndroid Build Coastguard Worker   void printBrtarget(MCInst const *MI, unsigned OpNo, raw_ostream &O) const;
66*9880d681SAndroid Build Coastguard Worker 
67*9880d681SAndroid Build Coastguard Worker   void printConstantPool(MCInst const *MI, unsigned OpNo, raw_ostream &O) const;
68*9880d681SAndroid Build Coastguard Worker 
printSymbolHi(MCInst const * MI,unsigned OpNo,raw_ostream & O)69*9880d681SAndroid Build Coastguard Worker   void printSymbolHi(MCInst const *MI, unsigned OpNo, raw_ostream &O) const {
70*9880d681SAndroid Build Coastguard Worker     printSymbol(MI, OpNo, O, true);
71*9880d681SAndroid Build Coastguard Worker   }
printSymbolLo(MCInst const * MI,unsigned OpNo,raw_ostream & O)72*9880d681SAndroid Build Coastguard Worker   void printSymbolLo(MCInst const *MI, unsigned OpNo, raw_ostream &O) const {
73*9880d681SAndroid Build Coastguard Worker     printSymbol(MI, OpNo, O, false);
74*9880d681SAndroid Build Coastguard Worker   }
75*9880d681SAndroid Build Coastguard Worker 
getMAI()76*9880d681SAndroid Build Coastguard Worker   MCAsmInfo const &getMAI() const { return MAI; }
getMII()77*9880d681SAndroid Build Coastguard Worker   MCInstrInfo const &getMII() const { return MII; }
78*9880d681SAndroid Build Coastguard Worker 
79*9880d681SAndroid Build Coastguard Worker protected:
80*9880d681SAndroid Build Coastguard Worker   void printSymbol(MCInst const *MI, unsigned OpNo, raw_ostream &O,
81*9880d681SAndroid Build Coastguard Worker                    bool hi) const;
82*9880d681SAndroid Build Coastguard Worker 
83*9880d681SAndroid Build Coastguard Worker private:
84*9880d681SAndroid Build Coastguard Worker   MCInstrInfo const &MII;
85*9880d681SAndroid Build Coastguard Worker 
86*9880d681SAndroid Build Coastguard Worker   bool HasExtender;
87*9880d681SAndroid Build Coastguard Worker   void setExtender(MCInst const &MCI);
88*9880d681SAndroid Build Coastguard Worker };
89*9880d681SAndroid Build Coastguard Worker 
90*9880d681SAndroid Build Coastguard Worker } // end namespace llvm
91*9880d681SAndroid Build Coastguard Worker 
92*9880d681SAndroid Build Coastguard Worker #endif
93