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