1 //===-- HexagonInstPrinter.h - Convert Hexagon MCInst to assembly syntax --===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class prints an Hexagon MCInst to a .s file.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_HEXAGON_INSTPRINTER_HEXAGONINSTPRINTER_H
15 #define LLVM_LIB_TARGET_HEXAGON_INSTPRINTER_HEXAGONINSTPRINTER_H
17 #include "llvm/MC/MCInstPrinter.h"
18 #include "llvm/MC/MCInstrInfo.h"
21 class HexagonAsmInstPrinter : public MCInstPrinter {
23 HexagonAsmInstPrinter(MCInstPrinter *RawPrinter);
24 void printInst(MCInst const *MI, raw_ostream &O, StringRef Annot,
25 MCSubtargetInfo const &STI) override;
26 void printRegName(raw_ostream &O, unsigned RegNo) const override;
27 std::unique_ptr<MCInstPrinter> RawPrinter;
29 /// Prints bundles as a newline separated list of individual instructions
30 /// Duplexes are separated by a vertical tab \v character
31 /// A trailing line includes bundle properties such as endloop0/1
34 /// r0 = #0 \v jump 0x0
35 /// :endloop0 :endloop1
36 class HexagonInstPrinter : public MCInstPrinter {
38 explicit HexagonInstPrinter(MCAsmInfo const &MAI,
39 MCInstrInfo const &MII,
40 MCRegisterInfo const &MRI)
41 : MCInstPrinter(MAI, MII, MRI), MII(MII) {}
43 void printInst(MCInst const *MI, raw_ostream &O, StringRef Annot,
44 const MCSubtargetInfo &STI) override;
45 virtual StringRef getOpcodeName(unsigned Opcode) const;
46 void printInstruction(const MCInst *MI, raw_ostream &O);
47 void printRegName(raw_ostream &OS, unsigned RegNo) const override;
48 static const char *getRegisterName(unsigned RegNo);
50 void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
51 void printImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
52 void printExtOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
53 void printUnsignedImmOperand(const MCInst *MI, unsigned OpNo,
54 raw_ostream &O) const;
55 void printNegImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
57 void printNOneImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
59 void printMEMriOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
61 void printFrameIndexOperand(const MCInst *MI, unsigned OpNo,
62 raw_ostream &O) const;
63 void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
65 void printCallOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
67 void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
69 void printPredicateOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
71 void printGlobalOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
73 void printJumpTable(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
74 void printExtBrtarget(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
76 void printConstantPool(const MCInst *MI, unsigned OpNo,
77 raw_ostream &O) const;
79 void printSymbolHi(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
80 { printSymbol(MI, OpNo, O, true); }
81 void printSymbolLo(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
82 { printSymbol(MI, OpNo, O, false); }
84 const MCInstrInfo &getMII() const {
89 void printSymbol(const MCInst *MI, unsigned OpNo, raw_ostream &O, bool hi)
93 const MCInstrInfo &MII;
96 void setExtender(MCInst const &MCI);
99 } // end namespace llvm