• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 HEXAGONINSTPRINTER_H
15 #define HEXAGONINSTPRINTER_H
16 
17 #include "HexagonMCInst.h"
18 #include "llvm/MC/MCInstPrinter.h"
19 
20 namespace llvm {
21   class HexagonInstPrinter : public MCInstPrinter {
22   public:
HexagonInstPrinter(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)23     explicit HexagonInstPrinter(const MCAsmInfo &MAI,
24                                 const MCInstrInfo &MII,
25                                 const MCRegisterInfo &MRI)
26       : MCInstPrinter(MAI, MII, MRI) {}
27 
28     virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);
29     void printInst(const HexagonMCInst *MI, raw_ostream &O, StringRef Annot);
30     virtual StringRef getOpcodeName(unsigned Opcode) const;
31     void printInstruction(const MCInst *MI, raw_ostream &O);
32     StringRef getRegName(unsigned RegNo) const;
33     static const char *getRegisterName(unsigned RegNo);
34 
35     void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
36     void printImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
37     void printExtOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
38     void printUnsignedImmOperand(const MCInst *MI, unsigned OpNo,
39                                  raw_ostream &O) const;
40     void printNegImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
41            const;
42     void printNOneImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
43            const;
44     void printMEMriOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
45            const;
46     void printFrameIndexOperand(const MCInst *MI, unsigned OpNo,
47                                 raw_ostream &O) const;
48     void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
49            const;
50     void printCallOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
51            const;
52     void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
53            const;
54     void printPredicateOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
55            const;
56     void printGlobalOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
57            const;
58     void printJumpTable(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
59 
60     void printConstantPool(const MCInst *MI, unsigned OpNo,
61                            raw_ostream &O) const;
62 
printSymbolHi(const MCInst * MI,unsigned OpNo,raw_ostream & O)63     void printSymbolHi(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
64       { printSymbol(MI, OpNo, O, true); }
printSymbolLo(const MCInst * MI,unsigned OpNo,raw_ostream & O)65     void printSymbolLo(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
66       { printSymbol(MI, OpNo, O, false); }
67 
68     bool isConstExtended(const MCInst *MI) const;
69   protected:
70     void printSymbol(const MCInst *MI, unsigned OpNo, raw_ostream &O, bool hi)
71            const;
72   };
73 
74 } // end namespace llvm
75 
76 #endif
77