1//===- ARMInstPrinter.h - Convert ARM 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 an ARM MCInst to a .s file.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef ARMINSTPRINTER_H
15#define ARMINSTPRINTER_H
16
17#include "llvm/MC/MCInstPrinter.h"
18#include "llvm/MC/MCSubtargetInfo.h"
19
20namespace llvm {
21
22class MCOperand;
23
24class ARMInstPrinter : public MCInstPrinter {
25public:
26  ARMInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
27                 const MCRegisterInfo &MRI, const MCSubtargetInfo &STI);
28
29  virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);
30  virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
31
32  // Autogenerated by tblgen.
33  void printInstruction(const MCInst *MI, raw_ostream &O);
34  static const char *getRegisterName(unsigned RegNo);
35
36
37  void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
38
39  void printSORegRegOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
40  void printSORegImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
41
42  void printAddrModeTBB(const MCInst *MI, unsigned OpNum, raw_ostream &O);
43  void printAddrModeTBH(const MCInst *MI, unsigned OpNum, raw_ostream &O);
44  void printAddrMode2Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
45  void printAM2PostIndexOp(const MCInst *MI, unsigned OpNum, raw_ostream &O);
46  void printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned OpNum,
47                                  raw_ostream &O);
48  void printAddrMode2OffsetOperand(const MCInst *MI, unsigned OpNum,
49                                   raw_ostream &O);
50  template <bool AlwaysPrintImm0>
51  void printAddrMode3Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
52  void printAddrMode3OffsetOperand(const MCInst *MI, unsigned OpNum,
53                                   raw_ostream &O);
54  void printAM3PostIndexOp(const MCInst *MI, unsigned Op, raw_ostream &O);
55  void printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op, raw_ostream &O,
56                                  bool AlwaysPrintImm0);
57  void printPostIdxImm8Operand(const MCInst *MI, unsigned OpNum,
58                               raw_ostream &O);
59  void printPostIdxRegOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
60  void printPostIdxImm8s4Operand(const MCInst *MI, unsigned OpNum,
61                               raw_ostream &O);
62
63  void printLdStmModeOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
64  template <bool AlwaysPrintImm0>
65  void printAddrMode5Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
66  void printAddrMode6Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
67  void printAddrMode7Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
68  void printAddrMode6OffsetOperand(const MCInst *MI, unsigned OpNum,
69                                   raw_ostream &O);
70
71  void printBitfieldInvMaskImmOperand(const MCInst *MI, unsigned OpNum,
72                                      raw_ostream &O);
73  void printMemBOption(const MCInst *MI, unsigned OpNum, raw_ostream &O);
74  void printShiftImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
75  void printPKHLSLShiftImm(const MCInst *MI, unsigned OpNum, raw_ostream &O);
76  void printPKHASRShiftImm(const MCInst *MI, unsigned OpNum, raw_ostream &O);
77
78  void printAdrLabelOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
79  void printThumbS4ImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
80  void printThumbSRImm(const MCInst *MI, unsigned OpNum, raw_ostream &O);
81  void printThumbITMask(const MCInst *MI, unsigned OpNum, raw_ostream &O);
82  void printThumbAddrModeRROperand(const MCInst *MI, unsigned OpNum,
83                                   raw_ostream &O);
84  void printThumbAddrModeImm5SOperand(const MCInst *MI, unsigned OpNum,
85                                      raw_ostream &O, unsigned Scale);
86  void printThumbAddrModeImm5S1Operand(const MCInst *MI, unsigned OpNum,
87                                       raw_ostream &O);
88  void printThumbAddrModeImm5S2Operand(const MCInst *MI, unsigned OpNum,
89                                       raw_ostream &O);
90  void printThumbAddrModeImm5S4Operand(const MCInst *MI, unsigned OpNum,
91                                       raw_ostream &O);
92  void printThumbAddrModeSPOperand(const MCInst *MI, unsigned OpNum,
93                                   raw_ostream &O);
94
95  void printT2SOOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
96  template<bool AlwaysPrintImm0>
97  void printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
98                                 raw_ostream &O);
99  void printT2AddrModeImm8Operand(const MCInst *MI, unsigned OpNum,
100                                  raw_ostream &O);
101  void printT2AddrModeImm8s4Operand(const MCInst *MI, unsigned OpNum,
102                                    raw_ostream &O);
103  void printT2AddrModeImm0_1020s4Operand(const MCInst *MI, unsigned OpNum,
104                                    raw_ostream &O);
105  void printT2AddrModeImm8OffsetOperand(const MCInst *MI, unsigned OpNum,
106                                        raw_ostream &O);
107  void printT2AddrModeImm8s4OffsetOperand(const MCInst *MI, unsigned OpNum,
108                                          raw_ostream &O);
109  void printT2AddrModeSoRegOperand(const MCInst *MI, unsigned OpNum,
110                                   raw_ostream &O);
111
112  void printSetendOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
113  void printCPSIMod(const MCInst *MI, unsigned OpNum, raw_ostream &O);
114  void printCPSIFlag(const MCInst *MI, unsigned OpNum, raw_ostream &O);
115  void printMSRMaskOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
116  void printPredicateOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
117  void printMandatoryPredicateOperand(const MCInst *MI, unsigned OpNum,
118                                      raw_ostream &O);
119  void printSBitModifierOperand(const MCInst *MI, unsigned OpNum,
120                                raw_ostream &O);
121  void printRegisterList(const MCInst *MI, unsigned OpNum, raw_ostream &O);
122  void printNoHashImmediate(const MCInst *MI, unsigned OpNum, raw_ostream &O);
123  void printPImmediate(const MCInst *MI, unsigned OpNum, raw_ostream &O);
124  void printCImmediate(const MCInst *MI, unsigned OpNum, raw_ostream &O);
125  void printCoprocOptionImm(const MCInst *MI, unsigned OpNum, raw_ostream &O);
126  void printFPImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
127  void printNEONModImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
128  void printImmPlusOneOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
129  void printRotImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
130  void printGPRPairOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
131
132  void printPCLabel(const MCInst *MI, unsigned OpNum, raw_ostream &O);
133  void printThumbLdrLabelOperand(const MCInst *MI, unsigned OpNum,
134                                 raw_ostream &O);
135  void printFBits16(const MCInst *MI, unsigned OpNum, raw_ostream &O);
136  void printFBits32(const MCInst *MI, unsigned OpNum, raw_ostream &O);
137  void printVectorIndex(const MCInst *MI, unsigned OpNum, raw_ostream &O);
138  void printVectorListOne(const MCInst *MI, unsigned OpNum, raw_ostream &O);
139  void printVectorListTwo(const MCInst *MI, unsigned OpNum, raw_ostream &O);
140  void printVectorListTwoSpaced(const MCInst *MI, unsigned OpNum,
141                               raw_ostream &O);
142  void printVectorListThree(const MCInst *MI, unsigned OpNum, raw_ostream &O);
143  void printVectorListFour(const MCInst *MI, unsigned OpNum, raw_ostream &O);
144  void printVectorListOneAllLanes(const MCInst *MI, unsigned OpNum,
145                                  raw_ostream &O);
146  void printVectorListTwoAllLanes(const MCInst *MI, unsigned OpNum,
147                                  raw_ostream &O);
148  void printVectorListThreeAllLanes(const MCInst *MI, unsigned OpNum,
149                                    raw_ostream &O);
150  void printVectorListFourAllLanes(const MCInst *MI, unsigned OpNum,
151                                   raw_ostream &O);
152  void printVectorListTwoSpacedAllLanes(const MCInst *MI, unsigned OpNum,
153                                        raw_ostream &O);
154  void printVectorListThreeSpacedAllLanes(const MCInst *MI, unsigned OpNum,
155                                          raw_ostream &O);
156  void printVectorListFourSpacedAllLanes(const MCInst *MI, unsigned OpNum,
157                                         raw_ostream &O);
158  void printVectorListThreeSpaced(const MCInst *MI, unsigned OpNum,
159                                  raw_ostream &O);
160  void printVectorListFourSpaced(const MCInst *MI, unsigned OpNum,
161                                  raw_ostream &O);
162};
163
164} // end namespace llvm
165
166#endif
167