]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/Mips/InstPrinter/MipsInstPrinter.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / Mips / InstPrinter / MipsInstPrinter.h
1 //=== MipsInstPrinter.h - Convert Mips MCInst to assembly syntax -*- C++ -*-==//
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 a Mips MCInst to a .s file.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_MIPS_INSTPRINTER_MIPSINSTPRINTER_H
15 #define LLVM_LIB_TARGET_MIPS_INSTPRINTER_MIPSINSTPRINTER_H
16 #include "llvm/MC/MCInstPrinter.h"
17
18 namespace llvm {
19 // These enumeration declarations were originally in MipsInstrInfo.h but
20 // had to be moved here to avoid circular dependencies between
21 // LLVMMipsCodeGen and LLVMMipsAsmPrinter.
22 namespace Mips {
23 // Mips Branch Codes
24 enum FPBranchCode {
25   BRANCH_F,
26   BRANCH_T,
27   BRANCH_FL,
28   BRANCH_TL,
29   BRANCH_INVALID
30 };
31
32 // Mips Condition Codes
33 enum CondCode {
34   // To be used with float branch True
35   FCOND_F,
36   FCOND_UN,
37   FCOND_OEQ,
38   FCOND_UEQ,
39   FCOND_OLT,
40   FCOND_ULT,
41   FCOND_OLE,
42   FCOND_ULE,
43   FCOND_SF,
44   FCOND_NGLE,
45   FCOND_SEQ,
46   FCOND_NGL,
47   FCOND_LT,
48   FCOND_NGE,
49   FCOND_LE,
50   FCOND_NGT,
51
52   // To be used with float branch False
53   // This conditions have the same mnemonic as the
54   // above ones, but are used with a branch False;
55   FCOND_T,
56   FCOND_OR,
57   FCOND_UNE,
58   FCOND_ONE,
59   FCOND_UGE,
60   FCOND_OGE,
61   FCOND_UGT,
62   FCOND_OGT,
63   FCOND_ST,
64   FCOND_GLE,
65   FCOND_SNE,
66   FCOND_GL,
67   FCOND_NLT,
68   FCOND_GE,
69   FCOND_NLE,
70   FCOND_GT
71 };
72
73 const char *MipsFCCToString(Mips::CondCode CC);
74 } // end namespace Mips
75
76 class MipsInstPrinter : public MCInstPrinter {
77 public:
78   MipsInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
79                   const MCRegisterInfo &MRI)
80     : MCInstPrinter(MAI, MII, MRI) {}
81
82   // Autogenerated by tblgen.
83   void printInstruction(const MCInst *MI, raw_ostream &O);
84   static const char *getRegisterName(unsigned RegNo);
85
86   void printRegName(raw_ostream &OS, unsigned RegNo) const override;
87   void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
88                  const MCSubtargetInfo &STI) override;
89
90   bool printAliasInstr(const MCInst *MI, raw_ostream &OS);
91   void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
92                                unsigned PrintMethodIdx, raw_ostream &O);
93
94 private:
95   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
96   template <unsigned Bits, unsigned Offset = 0>
97   void printUImm(const MCInst *MI, int opNum, raw_ostream &O);
98   void printMemOperand(const MCInst *MI, int opNum, raw_ostream &O);
99   void printMemOperandEA(const MCInst *MI, int opNum, raw_ostream &O);
100   void printFCCOperand(const MCInst *MI, int opNum, raw_ostream &O);
101   void printSHFMask(const MCInst *MI, int opNum, raw_ostream &O);
102
103   bool printAlias(const char *Str, const MCInst &MI, unsigned OpNo,
104                   raw_ostream &OS);
105   bool printAlias(const char *Str, const MCInst &MI, unsigned OpNo0,
106                   unsigned OpNo1, raw_ostream &OS);
107   bool printAlias(const MCInst &MI, raw_ostream &OS);
108   void printSaveRestore(const MCInst *MI, raw_ostream &O);
109   void printRegisterList(const MCInst *MI, int opNum, raw_ostream &O);
110 };
111 } // end namespace llvm
112
113 #endif