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 LLVM_LIB_TARGET_ARM_INSTPRINTER_ARMINSTPRINTER_H
15 #define LLVM_LIB_TARGET_ARM_INSTPRINTER_ARMINSTPRINTER_H
16 
17 #include "llvm/MC/MCInstPrinter.h"
18 #include "llvm/MC/MCSubtargetInfo.h"
19 
20 namespace llvm {
21 
22 class MCOperand;
23 
24 class ARMInstPrinter : public MCInstPrinter {
25 public:
26   ARMInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
27                  const MCRegisterInfo &MRI);
28 
29   void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
30                  const MCSubtargetInfo &STI) override;
31   void printRegName(raw_ostream &OS, unsigned RegNo) const override;
32 
33   // Autogenerated by tblgen.
34   void printInstruction(const MCInst *MI, const MCSubtargetInfo &STI,
35                         raw_ostream &O);
36   static const char *getRegisterName(unsigned RegNo);
37 
38   void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
39                     raw_ostream &O);
40 
41   void printSORegRegOperand(const MCInst *MI, unsigned OpNum,
42                             const MCSubtargetInfo &STI, raw_ostream &O);
43   void printSORegImmOperand(const MCInst *MI, unsigned OpNum,
44                             const MCSubtargetInfo &STI, raw_ostream &O);
45 
46   void printAddrModeTBB(const MCInst *MI, unsigned OpNum,
47                         const MCSubtargetInfo &STI, raw_ostream &O);
48   void printAddrModeTBH(const MCInst *MI, unsigned OpNum,
49                         const MCSubtargetInfo &STI, raw_ostream &O);
50   void printAddrMode2Operand(const MCInst *MI, unsigned OpNum,
51                              const MCSubtargetInfo &STI, raw_ostream &O);
52   void printAM2PostIndexOp(const MCInst *MI, unsigned OpNum,
53                            const MCSubtargetInfo &STI, raw_ostream &O);
54   void printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned OpNum,
55                                   const MCSubtargetInfo &STI, raw_ostream &O);
56   void printAddrMode2OffsetOperand(const MCInst *MI, unsigned OpNum,
57                                    const MCSubtargetInfo &STI, raw_ostream &O);
58   template <bool AlwaysPrintImm0>
59   void printAddrMode3Operand(const MCInst *MI, unsigned OpNum,
60                              const MCSubtargetInfo &STI, raw_ostream &O);
61   void printAddrMode3OffsetOperand(const MCInst *MI, unsigned OpNum,
62                                    const MCSubtargetInfo &STI, raw_ostream &O);
63   void printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op, raw_ostream &O,
64                                   bool AlwaysPrintImm0);
65   void printPostIdxImm8Operand(const MCInst *MI, unsigned OpNum,
66                                const MCSubtargetInfo &STI, raw_ostream &O);
67   void printPostIdxRegOperand(const MCInst *MI, unsigned OpNum,
68                               const MCSubtargetInfo &STI, raw_ostream &O);
69   void printPostIdxImm8s4Operand(const MCInst *MI, unsigned OpNum,
70                                  const MCSubtargetInfo &STI, raw_ostream &O);
71 
72   void printLdStmModeOperand(const MCInst *MI, unsigned OpNum,
73                              const MCSubtargetInfo &STI, raw_ostream &O);
74   template <bool AlwaysPrintImm0>
75   void printAddrMode5Operand(const MCInst *MI, unsigned OpNum,
76                              const MCSubtargetInfo &STI, raw_ostream &O);
77   void printAddrMode6Operand(const MCInst *MI, unsigned OpNum,
78                              const MCSubtargetInfo &STI, raw_ostream &O);
79   void printAddrMode7Operand(const MCInst *MI, unsigned OpNum,
80                              const MCSubtargetInfo &STI, raw_ostream &O);
81   void printAddrMode6OffsetOperand(const MCInst *MI, unsigned OpNum,
82                                    const MCSubtargetInfo &STI, raw_ostream &O);
83 
84   void printBitfieldInvMaskImmOperand(const MCInst *MI, unsigned OpNum,
85                                       const MCSubtargetInfo &STI,
86                                       raw_ostream &O);
87   void printMemBOption(const MCInst *MI, unsigned OpNum,
88                        const MCSubtargetInfo &STI, raw_ostream &O);
89   void printInstSyncBOption(const MCInst *MI, unsigned OpNum,
90                             const MCSubtargetInfo &STI, raw_ostream &O);
91   void printShiftImmOperand(const MCInst *MI, unsigned OpNum,
92                             const MCSubtargetInfo &STI, raw_ostream &O);
93   void printPKHLSLShiftImm(const MCInst *MI, unsigned OpNum,
94                            const MCSubtargetInfo &STI, raw_ostream &O);
95   void printPKHASRShiftImm(const MCInst *MI, unsigned OpNum,
96                            const MCSubtargetInfo &STI, raw_ostream &O);
97 
98   template <unsigned scale>
99   void printAdrLabelOperand(const MCInst *MI, unsigned OpNum,
100                             const MCSubtargetInfo &STI, raw_ostream &O);
101   void printThumbS4ImmOperand(const MCInst *MI, unsigned OpNum,
102                               const MCSubtargetInfo &STI, raw_ostream &O);
103   void printThumbSRImm(const MCInst *MI, unsigned OpNum,
104                        const MCSubtargetInfo &STI, raw_ostream &O);
105   void printThumbITMask(const MCInst *MI, unsigned OpNum,
106                         const MCSubtargetInfo &STI, raw_ostream &O);
107   void printThumbAddrModeRROperand(const MCInst *MI, unsigned OpNum,
108                                    const MCSubtargetInfo &STI, raw_ostream &O);
109   void printThumbAddrModeImm5SOperand(const MCInst *MI, unsigned OpNum,
110                                       const MCSubtargetInfo &STI,
111                                       raw_ostream &O, unsigned Scale);
112   void printThumbAddrModeImm5S1Operand(const MCInst *MI, unsigned OpNum,
113                                        const MCSubtargetInfo &STI,
114                                        raw_ostream &O);
115   void printThumbAddrModeImm5S2Operand(const MCInst *MI, unsigned OpNum,
116                                        const MCSubtargetInfo &STI,
117                                        raw_ostream &O);
118   void printThumbAddrModeImm5S4Operand(const MCInst *MI, unsigned OpNum,
119                                        const MCSubtargetInfo &STI,
120                                        raw_ostream &O);
121   void printThumbAddrModeSPOperand(const MCInst *MI, unsigned OpNum,
122                                    const MCSubtargetInfo &STI, raw_ostream &O);
123 
124   void printT2SOOperand(const MCInst *MI, unsigned OpNum,
125                         const MCSubtargetInfo &STI, raw_ostream &O);
126   template <bool AlwaysPrintImm0>
127   void printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
128                                  const MCSubtargetInfo &STI, raw_ostream &O);
129   template <bool AlwaysPrintImm0>
130   void printT2AddrModeImm8Operand(const MCInst *MI, unsigned OpNum,
131                                   const MCSubtargetInfo &STI, raw_ostream &O);
132   template <bool AlwaysPrintImm0>
133   void printT2AddrModeImm8s4Operand(const MCInst *MI, unsigned OpNum,
134                                     const MCSubtargetInfo &STI, raw_ostream &O);
135   void printT2AddrModeImm0_1020s4Operand(const MCInst *MI, unsigned OpNum,
136                                          const MCSubtargetInfo &STI,
137                                          raw_ostream &O);
138   void printT2AddrModeImm8OffsetOperand(const MCInst *MI, unsigned OpNum,
139                                         const MCSubtargetInfo &STI,
140                                         raw_ostream &O);
141   void printT2AddrModeImm8s4OffsetOperand(const MCInst *MI, unsigned OpNum,
142                                           const MCSubtargetInfo &STI,
143                                           raw_ostream &O);
144   void printT2AddrModeSoRegOperand(const MCInst *MI, unsigned OpNum,
145                                    const MCSubtargetInfo &STI, raw_ostream &O);
146 
147   void printSetendOperand(const MCInst *MI, unsigned OpNum,
148                           const MCSubtargetInfo &STI, raw_ostream &O);
149   void printCPSIMod(const MCInst *MI, unsigned OpNum,
150                     const MCSubtargetInfo &STI, raw_ostream &O);
151   void printCPSIFlag(const MCInst *MI, unsigned OpNum,
152                      const MCSubtargetInfo &STI, raw_ostream &O);
153   void printMSRMaskOperand(const MCInst *MI, unsigned OpNum,
154                            const MCSubtargetInfo &STI, raw_ostream &O);
155   void printBankedRegOperand(const MCInst *MI, unsigned OpNum,
156                              const MCSubtargetInfo &STI, raw_ostream &O);
157   void printPredicateOperand(const MCInst *MI, unsigned OpNum,
158                              const MCSubtargetInfo &STI, raw_ostream &O);
159   void printMandatoryPredicateOperand(const MCInst *MI, unsigned OpNum,
160                                       const MCSubtargetInfo &STI,
161                                       raw_ostream &O);
162   void printSBitModifierOperand(const MCInst *MI, unsigned OpNum,
163                                 const MCSubtargetInfo &STI, raw_ostream &O);
164   void printRegisterList(const MCInst *MI, unsigned OpNum,
165                          const MCSubtargetInfo &STI, raw_ostream &O);
166   void printNoHashImmediate(const MCInst *MI, unsigned OpNum,
167                             const MCSubtargetInfo &STI, raw_ostream &O);
168   void printPImmediate(const MCInst *MI, unsigned OpNum,
169                        const MCSubtargetInfo &STI, raw_ostream &O);
170   void printCImmediate(const MCInst *MI, unsigned OpNum,
171                        const MCSubtargetInfo &STI, raw_ostream &O);
172   void printCoprocOptionImm(const MCInst *MI, unsigned OpNum,
173                             const MCSubtargetInfo &STI, raw_ostream &O);
174   void printFPImmOperand(const MCInst *MI, unsigned OpNum,
175                          const MCSubtargetInfo &STI, raw_ostream &O);
176   void printNEONModImmOperand(const MCInst *MI, unsigned OpNum,
177                               const MCSubtargetInfo &STI, raw_ostream &O);
178   void printImmPlusOneOperand(const MCInst *MI, unsigned OpNum,
179                               const MCSubtargetInfo &STI, raw_ostream &O);
180   void printRotImmOperand(const MCInst *MI, unsigned OpNum,
181                           const MCSubtargetInfo &STI, raw_ostream &O);
182   void printModImmOperand(const MCInst *MI, unsigned OpNum,
183                           const MCSubtargetInfo &STI, raw_ostream &O);
184   void printGPRPairOperand(const MCInst *MI, unsigned OpNum,
185                            const MCSubtargetInfo &STI, raw_ostream &O);
186 
187   void printPCLabel(const MCInst *MI, unsigned OpNum,
188                     const MCSubtargetInfo &STI, raw_ostream &O);
189   void printThumbLdrLabelOperand(const MCInst *MI, unsigned OpNum,
190                                  const MCSubtargetInfo &STI, raw_ostream &O);
191   void printFBits16(const MCInst *MI, unsigned OpNum,
192                     const MCSubtargetInfo &STI, raw_ostream &O);
193   void printFBits32(const MCInst *MI, unsigned OpNum,
194                     const MCSubtargetInfo &STI, raw_ostream &O);
195   void printVectorIndex(const MCInst *MI, unsigned OpNum,
196                         const MCSubtargetInfo &STI, raw_ostream &O);
197   void printVectorListOne(const MCInst *MI, unsigned OpNum,
198                           const MCSubtargetInfo &STI, raw_ostream &O);
199   void printVectorListTwo(const MCInst *MI, unsigned OpNum,
200                           const MCSubtargetInfo &STI, raw_ostream &O);
201   void printVectorListTwoSpaced(const MCInst *MI, unsigned OpNum,
202                                 const MCSubtargetInfo &STI, raw_ostream &O);
203   void printVectorListThree(const MCInst *MI, unsigned OpNum,
204                             const MCSubtargetInfo &STI, raw_ostream &O);
205   void printVectorListFour(const MCInst *MI, unsigned OpNum,
206                            const MCSubtargetInfo &STI, raw_ostream &O);
207   void printVectorListOneAllLanes(const MCInst *MI, unsigned OpNum,
208                                   const MCSubtargetInfo &STI, raw_ostream &O);
209   void printVectorListTwoAllLanes(const MCInst *MI, unsigned OpNum,
210                                   const MCSubtargetInfo &STI, raw_ostream &O);
211   void printVectorListThreeAllLanes(const MCInst *MI, unsigned OpNum,
212                                     const MCSubtargetInfo &STI, raw_ostream &O);
213   void printVectorListFourAllLanes(const MCInst *MI, unsigned OpNum,
214                                    const MCSubtargetInfo &STI, raw_ostream &O);
215   void printVectorListTwoSpacedAllLanes(const MCInst *MI, unsigned OpNum,
216                                         const MCSubtargetInfo &STI,
217                                         raw_ostream &O);
218   void printVectorListThreeSpacedAllLanes(const MCInst *MI, unsigned OpNum,
219                                           const MCSubtargetInfo &STI,
220                                           raw_ostream &O);
221   void printVectorListFourSpacedAllLanes(const MCInst *MI, unsigned OpNum,
222                                          const MCSubtargetInfo &STI,
223                                          raw_ostream &O);
224   void printVectorListThreeSpaced(const MCInst *MI, unsigned OpNum,
225                                   const MCSubtargetInfo &STI, raw_ostream &O);
226   void printVectorListFourSpaced(const MCInst *MI, unsigned OpNum,
227                                  const MCSubtargetInfo &STI, raw_ostream &O);
228 };
229 
230 } // end namespace llvm
231 
232 #endif
233