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