1 | //===- ARMInstPrinter.h - Convert ARM MCInst to assembly syntax -*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This class prints an ARM MCInst to a .s file. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMINSTPRINTER_H |
14 | #define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMINSTPRINTER_H |
15 | |
16 | #include "MCTargetDesc/ARMMCTargetDesc.h" |
17 | #include "llvm/MC/MCInstPrinter.h" |
18 | |
19 | namespace llvm { |
20 | |
21 | class ARMInstPrinter : public MCInstPrinter { |
22 | public: |
23 | ARMInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, |
24 | const MCRegisterInfo &MRI); |
25 | |
26 | bool applyTargetSpecificCLOption(StringRef Opt) override; |
27 | |
28 | void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, |
29 | const MCSubtargetInfo &STI, raw_ostream &O) override; |
30 | void printRegName(raw_ostream &OS, MCRegister Reg) const override; |
31 | |
32 | // Autogenerated by tblgen. |
33 | std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override; |
34 | void printInstruction(const MCInst *MI, uint64_t Address, |
35 | const MCSubtargetInfo &STI, raw_ostream &O); |
36 | virtual bool printAliasInstr(const MCInst *MI, uint64_t Address, |
37 | const MCSubtargetInfo &STI, raw_ostream &O); |
38 | virtual void printCustomAliasOperand(const MCInst *MI, uint64_t Address, |
39 | unsigned OpIdx, unsigned PrintMethodIdx, |
40 | const MCSubtargetInfo &STI, |
41 | raw_ostream &O); |
42 | static const char *getRegisterName(MCRegister Reg, |
43 | unsigned AltIdx = ARM::NoRegAltName); |
44 | |
45 | void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, |
46 | raw_ostream &O); |
47 | void printOperand(const MCInst *MI, uint64_t Address, unsigned OpNum, |
48 | const MCSubtargetInfo &STI, raw_ostream &O); |
49 | |
50 | void printSORegRegOperand(const MCInst *MI, unsigned OpNum, |
51 | const MCSubtargetInfo &STI, raw_ostream &O); |
52 | void printSORegImmOperand(const MCInst *MI, unsigned OpNum, |
53 | const MCSubtargetInfo &STI, raw_ostream &O); |
54 | |
55 | void printAddrModeTBB(const MCInst *MI, unsigned OpNum, |
56 | const MCSubtargetInfo &STI, raw_ostream &O); |
57 | void printAddrModeTBH(const MCInst *MI, unsigned OpNum, |
58 | const MCSubtargetInfo &STI, raw_ostream &O); |
59 | void printAddrMode2Operand(const MCInst *MI, unsigned OpNum, |
60 | const MCSubtargetInfo &STI, raw_ostream &O); |
61 | void printAM2PostIndexOp(const MCInst *MI, unsigned OpNum, |
62 | const MCSubtargetInfo &STI, raw_ostream &O); |
63 | void printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned OpNum, |
64 | const MCSubtargetInfo &STI, raw_ostream &O); |
65 | void printAddrMode2OffsetOperand(const MCInst *MI, unsigned OpNum, |
66 | const MCSubtargetInfo &STI, raw_ostream &O); |
67 | template <bool AlwaysPrintImm0> |
68 | void printAddrMode3Operand(const MCInst *MI, unsigned OpNum, |
69 | const MCSubtargetInfo &STI, raw_ostream &O); |
70 | void printAddrMode3OffsetOperand(const MCInst *MI, unsigned OpNum, |
71 | const MCSubtargetInfo &STI, raw_ostream &O); |
72 | void printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op, raw_ostream &O, |
73 | bool AlwaysPrintImm0); |
74 | void printPostIdxImm8Operand(const MCInst *MI, unsigned OpNum, |
75 | const MCSubtargetInfo &STI, raw_ostream &O); |
76 | void printPostIdxRegOperand(const MCInst *MI, unsigned OpNum, |
77 | const MCSubtargetInfo &STI, raw_ostream &O); |
78 | void printPostIdxImm8s4Operand(const MCInst *MI, unsigned OpNum, |
79 | const MCSubtargetInfo &STI, raw_ostream &O); |
80 | |
81 | void printLdStmModeOperand(const MCInst *MI, unsigned OpNum, |
82 | const MCSubtargetInfo &STI, raw_ostream &O); |
83 | template <bool AlwaysPrintImm0> |
84 | void printAddrMode5Operand(const MCInst *MI, unsigned OpNum, |
85 | const MCSubtargetInfo &STI, raw_ostream &O); |
86 | template <bool AlwaysPrintImm0> |
87 | void printAddrMode5FP16Operand(const MCInst *MI, unsigned OpNum, |
88 | const MCSubtargetInfo &STI, raw_ostream &O); |
89 | void printAddrMode6Operand(const MCInst *MI, unsigned OpNum, |
90 | const MCSubtargetInfo &STI, raw_ostream &O); |
91 | void printAddrMode7Operand(const MCInst *MI, unsigned OpNum, |
92 | const MCSubtargetInfo &STI, raw_ostream &O); |
93 | void printAddrMode6OffsetOperand(const MCInst *MI, unsigned OpNum, |
94 | const MCSubtargetInfo &STI, raw_ostream &O); |
95 | |
96 | void printBitfieldInvMaskImmOperand(const MCInst *MI, unsigned OpNum, |
97 | const MCSubtargetInfo &STI, |
98 | raw_ostream &O); |
99 | void printMemBOption(const MCInst *MI, unsigned OpNum, |
100 | const MCSubtargetInfo &STI, raw_ostream &O); |
101 | void printInstSyncBOption(const MCInst *MI, unsigned OpNum, |
102 | const MCSubtargetInfo &STI, raw_ostream &O); |
103 | void printTraceSyncBOption(const MCInst *MI, unsigned OpNum, |
104 | const MCSubtargetInfo &STI, raw_ostream &O); |
105 | void printShiftImmOperand(const MCInst *MI, unsigned OpNum, |
106 | const MCSubtargetInfo &STI, raw_ostream &O); |
107 | void printPKHLSLShiftImm(const MCInst *MI, unsigned OpNum, |
108 | const MCSubtargetInfo &STI, raw_ostream &O); |
109 | void printPKHASRShiftImm(const MCInst *MI, unsigned OpNum, |
110 | const MCSubtargetInfo &STI, raw_ostream &O); |
111 | |
112 | template <unsigned scale> |
113 | void printAdrLabelOperand(const MCInst *MI, unsigned OpNum, |
114 | const MCSubtargetInfo &STI, raw_ostream &O); |
115 | template <unsigned scale> |
116 | void printAdrLabelOperand(const MCInst *MI, uint64_t /*Address*/, |
117 | unsigned OpNum, const MCSubtargetInfo &STI, |
118 | raw_ostream &O) { |
119 | printAdrLabelOperand<scale>(MI, OpNum, STI, O); |
120 | } |
121 | void printThumbS4ImmOperand(const MCInst *MI, unsigned OpNum, |
122 | const MCSubtargetInfo &STI, raw_ostream &O); |
123 | void printThumbSRImm(const MCInst *MI, unsigned OpNum, |
124 | const MCSubtargetInfo &STI, raw_ostream &O); |
125 | void printThumbITMask(const MCInst *MI, unsigned OpNum, |
126 | const MCSubtargetInfo &STI, raw_ostream &O); |
127 | void printThumbAddrModeRROperand(const MCInst *MI, unsigned OpNum, |
128 | const MCSubtargetInfo &STI, raw_ostream &O); |
129 | void printThumbAddrModeImm5SOperand(const MCInst *MI, unsigned OpNum, |
130 | const MCSubtargetInfo &STI, |
131 | raw_ostream &O, unsigned Scale); |
132 | void printThumbAddrModeImm5S1Operand(const MCInst *MI, unsigned OpNum, |
133 | const MCSubtargetInfo &STI, |
134 | raw_ostream &O); |
135 | void printThumbAddrModeImm5S2Operand(const MCInst *MI, unsigned OpNum, |
136 | const MCSubtargetInfo &STI, |
137 | raw_ostream &O); |
138 | void printThumbAddrModeImm5S4Operand(const MCInst *MI, unsigned OpNum, |
139 | const MCSubtargetInfo &STI, |
140 | raw_ostream &O); |
141 | void printThumbAddrModeSPOperand(const MCInst *MI, unsigned OpNum, |
142 | const MCSubtargetInfo &STI, raw_ostream &O); |
143 | |
144 | void printT2SOOperand(const MCInst *MI, unsigned OpNum, |
145 | const MCSubtargetInfo &STI, raw_ostream &O); |
146 | template <bool AlwaysPrintImm0> |
147 | void printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum, |
148 | const MCSubtargetInfo &STI, raw_ostream &O); |
149 | template <bool AlwaysPrintImm0> |
150 | void printT2AddrModeImm8Operand(const MCInst *MI, unsigned OpNum, |
151 | const MCSubtargetInfo &STI, raw_ostream &O); |
152 | template <bool AlwaysPrintImm0> |
153 | void printT2AddrModeImm8s4Operand(const MCInst *MI, unsigned OpNum, |
154 | const MCSubtargetInfo &STI, raw_ostream &O); |
155 | void printT2AddrModeImm0_1020s4Operand(const MCInst *MI, unsigned OpNum, |
156 | const MCSubtargetInfo &STI, |
157 | raw_ostream &O); |
158 | void printT2AddrModeImm8OffsetOperand(const MCInst *MI, unsigned OpNum, |
159 | const MCSubtargetInfo &STI, |
160 | raw_ostream &O); |
161 | void printT2AddrModeImm8s4OffsetOperand(const MCInst *MI, unsigned OpNum, |
162 | const MCSubtargetInfo &STI, |
163 | raw_ostream &O); |
164 | void printT2AddrModeSoRegOperand(const MCInst *MI, unsigned OpNum, |
165 | const MCSubtargetInfo &STI, raw_ostream &O); |
166 | |
167 | void printSetendOperand(const MCInst *MI, unsigned OpNum, |
168 | const MCSubtargetInfo &STI, raw_ostream &O); |
169 | void printCPSIMod(const MCInst *MI, unsigned OpNum, |
170 | const MCSubtargetInfo &STI, raw_ostream &O); |
171 | void printCPSIFlag(const MCInst *MI, unsigned OpNum, |
172 | const MCSubtargetInfo &STI, raw_ostream &O); |
173 | void printMSRMaskOperand(const MCInst *MI, unsigned OpNum, |
174 | const MCSubtargetInfo &STI, raw_ostream &O); |
175 | void printBankedRegOperand(const MCInst *MI, unsigned OpNum, |
176 | const MCSubtargetInfo &STI, raw_ostream &O); |
177 | void printPredicateOperand(const MCInst *MI, unsigned OpNum, |
178 | const MCSubtargetInfo &STI, raw_ostream &O); |
179 | void printMandatoryPredicateOperand(const MCInst *MI, unsigned OpNum, |
180 | const MCSubtargetInfo &STI, |
181 | raw_ostream &O); |
182 | void printMandatoryRestrictedPredicateOperand(const MCInst *MI, |
183 | unsigned OpNum, |
184 | const MCSubtargetInfo &STI, |
185 | raw_ostream &O); |
186 | void printMandatoryInvertedPredicateOperand(const MCInst *MI, unsigned OpNum, |
187 | const MCSubtargetInfo &STI, |
188 | raw_ostream &O); |
189 | void printSBitModifierOperand(const MCInst *MI, unsigned OpNum, |
190 | const MCSubtargetInfo &STI, raw_ostream &O); |
191 | void printRegisterList(const MCInst *MI, unsigned OpNum, |
192 | const MCSubtargetInfo &STI, raw_ostream &O); |
193 | void printNoHashImmediate(const MCInst *MI, unsigned OpNum, |
194 | const MCSubtargetInfo &STI, raw_ostream &O); |
195 | void printPImmediate(const MCInst *MI, unsigned OpNum, |
196 | const MCSubtargetInfo &STI, raw_ostream &O); |
197 | void printCImmediate(const MCInst *MI, unsigned OpNum, |
198 | const MCSubtargetInfo &STI, raw_ostream &O); |
199 | void printCoprocOptionImm(const MCInst *MI, unsigned OpNum, |
200 | const MCSubtargetInfo &STI, raw_ostream &O); |
201 | void printFPImmOperand(const MCInst *MI, unsigned OpNum, |
202 | const MCSubtargetInfo &STI, raw_ostream &O); |
203 | void printVMOVModImmOperand(const MCInst *MI, unsigned OpNum, |
204 | const MCSubtargetInfo &STI, raw_ostream &O); |
205 | void printImmPlusOneOperand(const MCInst *MI, unsigned OpNum, |
206 | const MCSubtargetInfo &STI, raw_ostream &O); |
207 | void printRotImmOperand(const MCInst *MI, unsigned OpNum, |
208 | const MCSubtargetInfo &STI, raw_ostream &O); |
209 | void printModImmOperand(const MCInst *MI, unsigned OpNum, |
210 | const MCSubtargetInfo &STI, raw_ostream &O); |
211 | void printGPRPairOperand(const MCInst *MI, unsigned OpNum, |
212 | const MCSubtargetInfo &STI, raw_ostream &O); |
213 | |
214 | void printPCLabel(const MCInst *MI, unsigned OpNum, |
215 | const MCSubtargetInfo &STI, raw_ostream &O); |
216 | void printThumbLdrLabelOperand(const MCInst *MI, unsigned OpNum, |
217 | const MCSubtargetInfo &STI, raw_ostream &O); |
218 | void printThumbLdrLabelOperand(const MCInst *MI, uint64_t /*Address*/, |
219 | unsigned OpNum, const MCSubtargetInfo &STI, |
220 | raw_ostream &O) { |
221 | printThumbLdrLabelOperand(MI, OpNum, STI, O); |
222 | } |
223 | void printFBits16(const MCInst *MI, unsigned OpNum, |
224 | const MCSubtargetInfo &STI, raw_ostream &O); |
225 | void printFBits32(const MCInst *MI, unsigned OpNum, |
226 | const MCSubtargetInfo &STI, raw_ostream &O); |
227 | void printVectorIndex(const MCInst *MI, unsigned OpNum, |
228 | const MCSubtargetInfo &STI, raw_ostream &O); |
229 | void printVectorListOne(const MCInst *MI, unsigned OpNum, |
230 | const MCSubtargetInfo &STI, raw_ostream &O); |
231 | void printVectorListTwo(const MCInst *MI, unsigned OpNum, |
232 | const MCSubtargetInfo &STI, raw_ostream &O); |
233 | void printVectorListTwoSpaced(const MCInst *MI, unsigned OpNum, |
234 | const MCSubtargetInfo &STI, raw_ostream &O); |
235 | void printVectorListThree(const MCInst *MI, unsigned OpNum, |
236 | const MCSubtargetInfo &STI, raw_ostream &O); |
237 | void printVectorListFour(const MCInst *MI, unsigned OpNum, |
238 | const MCSubtargetInfo &STI, raw_ostream &O); |
239 | void printVectorListOneAllLanes(const MCInst *MI, unsigned OpNum, |
240 | const MCSubtargetInfo &STI, raw_ostream &O); |
241 | void printVectorListTwoAllLanes(const MCInst *MI, unsigned OpNum, |
242 | const MCSubtargetInfo &STI, raw_ostream &O); |
243 | void printVectorListThreeAllLanes(const MCInst *MI, unsigned OpNum, |
244 | const MCSubtargetInfo &STI, raw_ostream &O); |
245 | void printVectorListFourAllLanes(const MCInst *MI, unsigned OpNum, |
246 | const MCSubtargetInfo &STI, raw_ostream &O); |
247 | void printVectorListTwoSpacedAllLanes(const MCInst *MI, unsigned OpNum, |
248 | const MCSubtargetInfo &STI, |
249 | raw_ostream &O); |
250 | void printVectorListThreeSpacedAllLanes(const MCInst *MI, unsigned OpNum, |
251 | const MCSubtargetInfo &STI, |
252 | raw_ostream &O); |
253 | void printVectorListFourSpacedAllLanes(const MCInst *MI, unsigned OpNum, |
254 | const MCSubtargetInfo &STI, |
255 | raw_ostream &O); |
256 | void printVectorListThreeSpaced(const MCInst *MI, unsigned OpNum, |
257 | const MCSubtargetInfo &STI, raw_ostream &O); |
258 | void printVectorListFourSpaced(const MCInst *MI, unsigned OpNum, |
259 | const MCSubtargetInfo &STI, raw_ostream &O); |
260 | template<unsigned NumRegs> |
261 | void printMVEVectorList(const MCInst *MI, unsigned OpNum, |
262 | const MCSubtargetInfo &STI, raw_ostream &O); |
263 | template<int64_t Angle, int64_t Remainder> |
264 | void printComplexRotationOp(const MCInst *MI, unsigned OpNum, |
265 | const MCSubtargetInfo &STI, raw_ostream &O); |
266 | // MVE |
267 | void printVPTPredicateOperand(const MCInst *MI, unsigned OpNum, |
268 | const MCSubtargetInfo &STI, |
269 | raw_ostream &O); |
270 | void printVPTMask(const MCInst *MI, unsigned OpNum, |
271 | const MCSubtargetInfo &STI, raw_ostream &O); |
272 | template<int shift> |
273 | void printMveAddrModeRQOperand(const MCInst *MI, unsigned OpNum, |
274 | const MCSubtargetInfo &STI, raw_ostream &O); |
275 | void printMveSaturateOp(const MCInst *MI, unsigned OpNum, |
276 | const MCSubtargetInfo &STI, raw_ostream &O); |
277 | private: |
278 | unsigned DefaultAltIdx = ARM::NoRegAltName; |
279 | }; |
280 | |
281 | } // end namespace llvm |
282 | |
283 | #endif // LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMINSTPRINTER_H |
284 | |