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 printBranchOperand(MCInst const *MI, unsigned OpNo, 48 raw_ostream &O) const; 49 void printCallOperand(MCInst const *MI, unsigned OpNo, raw_ostream &O) const; 50 void printAbsAddrOperand(MCInst const *MI, unsigned OpNo, 51 raw_ostream &O) const; 52 void printPredicateOperand(MCInst const *MI, unsigned OpNo, 53 raw_ostream &O) const; 54 void printGlobalOperand(MCInst const *MI, unsigned OpNo, 55 raw_ostream &O) const; 56 void printJumpTable(MCInst const *MI, unsigned OpNo, raw_ostream &O) const; 57 void printBrtarget(MCInst const *MI, unsigned OpNo, raw_ostream &O) const; 58 59 void printConstantPool(MCInst const *MI, unsigned OpNo, raw_ostream &O) const; 60 printSymbolHi(MCInst const * MI,unsigned OpNo,raw_ostream & O)61 void printSymbolHi(MCInst const *MI, unsigned OpNo, raw_ostream &O) const { 62 printSymbol(MI, OpNo, O, true); 63 } printSymbolLo(MCInst const * MI,unsigned OpNo,raw_ostream & O)64 void printSymbolLo(MCInst const *MI, unsigned OpNo, raw_ostream &O) const { 65 printSymbol(MI, OpNo, O, false); 66 } 67 getMAI()68 MCAsmInfo const &getMAI() const { return MAI; } getMII()69 MCInstrInfo const &getMII() const { return MII; } 70 71 protected: 72 void printSymbol(MCInst const *MI, unsigned OpNo, raw_ostream &O, 73 bool hi) const; 74 75 private: 76 MCInstrInfo const &MII; 77 78 bool HasExtender; 79 void setExtender(MCInst const &MCI); 80 }; 81 82 } // end namespace llvm 83 84 #endif 85