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