d02243b513002891369f2ab73d5d7b5d18aca148
[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   class HexagonInstPrinter : public MCInstPrinter {
22   public:
23     explicit HexagonInstPrinter(MCAsmInfo const &MAI,
24                                 MCInstrInfo const &MII,
25                                 MCRegisterInfo const &MRI)
26       : MCInstPrinter(MAI, MII, MRI), MII(MII) {}
27
28     void printInst(MCInst const *MI, raw_ostream &O, StringRef Annot) override;
29     virtual StringRef getOpcodeName(unsigned Opcode) const;
30     void printInstruction(const MCInst *MI, raw_ostream &O);
31     StringRef getRegName(unsigned RegNo) const;
32     static const char *getRegisterName(unsigned RegNo);
33
34     void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
35     void printImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
36     void printExtOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
37     void printUnsignedImmOperand(const MCInst *MI, unsigned OpNo,
38                                  raw_ostream &O) const;
39     void printNegImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
40            const;
41     void printNOneImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
42            const;
43     void printMEMriOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
44            const;
45     void printFrameIndexOperand(const MCInst *MI, unsigned OpNo,
46                                 raw_ostream &O) const;
47     void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
48            const;
49     void printCallOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
50            const;
51     void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
52            const;
53     void printPredicateOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
54            const;
55     void printGlobalOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
56            const;
57     void printJumpTable(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
58
59     void printConstantPool(const MCInst *MI, unsigned OpNo,
60                            raw_ostream &O) const;
61
62     void printSymbolHi(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
63       { printSymbol(MI, OpNo, O, true); }
64     void printSymbolLo(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
65       { printSymbol(MI, OpNo, O, false); }
66
67     const MCInstrInfo &getMII() const {
68       return MII;
69     }
70
71   protected:
72     void printSymbol(const MCInst *MI, unsigned OpNo, raw_ostream &O, bool hi)
73            const;
74
75     static const char PacketPadding;
76
77   private:
78     const MCInstrInfo &MII;
79
80   };
81
82 } // end namespace llvm
83
84 #endif