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