LLVM  3.7.0
HexagonInstPrinter.h
Go to the documentation of this file.
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 LLVM_LIB_TARGET_HEXAGON_INSTPRINTER_HEXAGONINSTPRINTER_H
15 #define LLVM_LIB_TARGET_HEXAGON_INSTPRINTER_HEXAGONINSTPRINTER_H
16 
17 #include "llvm/MC/MCInstPrinter.h"
18 #include "llvm/MC/MCInstrInfo.h"
19 
20 namespace llvm {
22 public:
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;
28 };
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
32 ///
33 /// r0 = add(r1, r2)
34 /// r0 = #0 \v jump 0x0
35 /// :endloop0 :endloop1
37  public:
38  explicit HexagonInstPrinter(MCAsmInfo const &MAI,
39  MCInstrInfo const &MII,
40  MCRegisterInfo const &MRI)
41  : MCInstPrinter(MAI, MII, MRI), MII(MII) {}
42 
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);
49 
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)
56  const;
57  void printNOneImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
58  const;
59  void printMEMriOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
60  const;
61  void printFrameIndexOperand(const MCInst *MI, unsigned OpNo,
62  raw_ostream &O) const;
63  void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
64  const;
65  void printCallOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
66  const;
67  void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
68  const;
69  void printPredicateOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
70  const;
71  void printGlobalOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
72  const;
73  void printJumpTable(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
74  void printExtBrtarget(const MCInst *MI, unsigned OpNo, raw_ostream &O) const;
75 
76  void printConstantPool(const MCInst *MI, unsigned OpNo,
77  raw_ostream &O) const;
78 
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); }
83 
84  const MCInstrInfo &getMII() const {
85  return MII;
86  }
87 
88  protected:
89  void printSymbol(const MCInst *MI, unsigned OpNo, raw_ostream &O, bool hi)
90  const;
91 
92  private:
93  const MCInstrInfo &MII;
94 
95  bool HasExtender;
96  void setExtender(MCInst const &MCI);
97  };
98 
99 } // end namespace llvm
100 
101 #endif
void printFrameIndexOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
void printUnsignedImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
void printSymbol(const MCInst *MI, unsigned OpNo, raw_ostream &O, bool hi) const
const MCInstrInfo & getMII() const
void printJumpTable(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
std::unique_ptr< MCInstPrinter > RawPrinter
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
void printNOneImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
void printInst(MCInst const *MI, raw_ostream &O, StringRef Annot, const MCSubtargetInfo &STI) override
Print the specified MCInst to the specified raw_ostream.
void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
void printConstantPool(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
void printMEMriOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
void printInst(MCInst const *MI, raw_ostream &O, StringRef Annot, MCSubtargetInfo const &STI) override
Print the specified MCInst to the specified raw_ostream.
void printExtOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
static const char * getRegisterName(unsigned RegNo)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:58
void printSymbolHi(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
HexagonAsmInstPrinter(MCInstPrinter *RawPrinter)
void printNegImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
void printRegName(raw_ostream &O, unsigned RegNo) const override
Print the assembler register name.
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
Prints bundles as a newline separated list of individual instructions Duplexes are separated by a ver...
void printImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
const MCAsmInfo & MAI
Definition: MCInstPrinter.h:44
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:38
void printSymbolLo(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
MCSubtargetInfo - Generic base class for all target subtargets.
void printCallOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
virtual StringRef getOpcodeName(unsigned Opcode) const
void printInstruction(const MCInst *MI, raw_ostream &O)
void printExtBrtarget(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
HexagonInstPrinter(MCAsmInfo const &MAI, MCInstrInfo const &MII, MCRegisterInfo const &MRI)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
void printPredicateOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
void printRegName(raw_ostream &OS, unsigned RegNo) const override
Print the assembler register name.
void printGlobalOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const
const MCRegisterInfo & MRI
Definition: MCInstPrinter.h:46