/src/capstonenext/arch/AArch64/AArch64InstPrinter.c
Line | Count | Source |
1 | | /* Capstone Disassembly Engine, http://www.capstone-engine.org */ |
2 | | /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2022, */ |
3 | | /* Rot127 <unisono@quyllur.org> 2022-2023 */ |
4 | | /* Automatically translated source file from LLVM. */ |
5 | | |
6 | | /* LLVM-commit: <commit> */ |
7 | | /* LLVM-tag: <tag> */ |
8 | | |
9 | | /* Only small edits allowed. */ |
10 | | /* For multiple similar edits, please create a Patch for the translator. */ |
11 | | |
12 | | /* Capstone's C++ file translator: */ |
13 | | /* https://github.com/capstone-engine/capstone/tree/next/suite/auto-sync */ |
14 | | |
15 | | //==-- AArch64InstPrinter.cpp - Convert AArch64 MCInst to assembly syntax --==// |
16 | | // |
17 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
18 | | // See https://llvm.org/LICENSE.txt for license information. |
19 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
20 | | // |
21 | | //===----------------------------------------------------------------------===// |
22 | | // |
23 | | // This class prints an AArch64 MCInst to a .s file. |
24 | | // |
25 | | //===----------------------------------------------------------------------===// |
26 | | |
27 | | #include <stdio.h> |
28 | | #include <string.h> |
29 | | #include <stdlib.h> |
30 | | #include <capstone/platform.h> |
31 | | |
32 | | #include "../../Mapping.h" |
33 | | #include "../../MCInst.h" |
34 | | #include "../../MCInstPrinter.h" |
35 | | #include "../../MCRegisterInfo.h" |
36 | | #include "../../SStream.h" |
37 | | #include "../../utils.h" |
38 | | #include "AArch64AddressingModes.h" |
39 | | #include "AArch64BaseInfo.h" |
40 | | #include "AArch64DisassemblerExtension.h" |
41 | | #include "AArch64InstPrinter.h" |
42 | | #include "AArch64Linkage.h" |
43 | | #include "AArch64Mapping.h" |
44 | | |
45 | | #define GET_BANKEDREG_IMPL |
46 | | #include "AArch64GenSystemOperands.inc" |
47 | | |
48 | 305k | #define CONCAT(a, b) CONCAT_(a, b) |
49 | 305k | #define CONCAT_(a, b) a##_##b |
50 | | |
51 | | #define CONCATs(a, b) CONCATS(a, b) |
52 | | #define CONCATS(a, b) a##b |
53 | | |
54 | | #define DEBUG_TYPE "asm-printer" |
55 | | |
56 | | // BEGIN Static declarations. |
57 | | // These functions must be declared statically here, because they |
58 | | // are also defined in the ARM module. |
59 | | // If they are not static, we fail during linking. |
60 | | |
61 | | static void printCustomAliasOperand(MCInst *MI, uint64_t Address, |
62 | | unsigned OpIdx, unsigned PrintMethodIdx, |
63 | | SStream *OS); |
64 | | |
65 | | static void printFPImmOperand(MCInst *MI, unsigned OpNum, SStream *O); |
66 | | |
67 | | #define DECLARE_printComplexRotationOp(Angle, Remainder) \ |
68 | | static void CONCAT(printComplexRotationOp, CONCAT(Angle, Remainder))( \ |
69 | | MCInst * MI, unsigned OpNo, SStream *O); |
70 | | DECLARE_printComplexRotationOp(180, 90); |
71 | | DECLARE_printComplexRotationOp(90, 0); |
72 | | |
73 | | // END Static declarations. |
74 | | |
75 | | #define GET_INSTRUCTION_NAME |
76 | | #define PRINT_ALIAS_INSTR |
77 | | #include "AArch64GenAsmWriter.inc" |
78 | | |
79 | | void printRegName(SStream *OS, unsigned Reg) |
80 | 509k | { |
81 | 509k | SStream_concat(OS, "%s%s", markup("<reg:"), |
82 | 509k | getRegisterName(Reg, AArch64_NoRegAltName)); |
83 | 509k | SStream_concat0(OS, markup(">")); |
84 | 509k | } |
85 | | |
86 | | void printRegNameAlt(SStream *OS, unsigned Reg, unsigned AltIdx) |
87 | 121k | { |
88 | 121k | SStream_concat(OS, "%s%s", markup("<reg:"), |
89 | 121k | getRegisterName(Reg, AltIdx)); |
90 | 121k | SStream_concat0(OS, markup(">")); |
91 | 121k | } |
92 | | |
93 | | const char *getRegName(unsigned Reg) |
94 | 0 | { |
95 | 0 | return getRegisterName(Reg, AArch64_NoRegAltName); |
96 | 0 | } |
97 | | |
98 | | void printInst(MCInst *MI, uint64_t Address, const char *Annot, SStream *O) |
99 | 250k | { |
100 | 250k | bool isAlias = false; |
101 | 250k | bool useAliasDetails = map_use_alias_details(MI); |
102 | 250k | map_set_fill_detail_ops(MI, useAliasDetails); |
103 | | |
104 | 250k | unsigned Opcode = MCInst_getOpcode(MI); |
105 | | |
106 | 250k | if (Opcode == AArch64_SYSxt) { |
107 | 2.49k | if (printSysAlias(MI, O)) { |
108 | 666 | isAlias = true; |
109 | 666 | MCInst_setIsAlias(MI, isAlias); |
110 | 666 | if (useAliasDetails) |
111 | 666 | return; |
112 | 666 | } |
113 | 2.49k | } |
114 | | |
115 | 249k | if (Opcode == AArch64_SYSPxt || Opcode == AArch64_SYSPxt_XZR) { |
116 | 2.13k | if (printSyspAlias(MI, O)) { |
117 | 984 | isAlias = true; |
118 | 984 | MCInst_setIsAlias(MI, isAlias); |
119 | 984 | if (useAliasDetails) |
120 | 984 | return; |
121 | 984 | } |
122 | 2.13k | } |
123 | | |
124 | | // RPRFM overlaps PRFM (reg), so try to print it as RPRFM here. |
125 | 248k | if ((Opcode == AArch64_PRFMroX) || (Opcode == AArch64_PRFMroW)) { |
126 | 309 | if (printRangePrefetchAlias(MI, O, Annot)) { |
127 | 0 | isAlias = true; |
128 | 0 | MCInst_setIsAlias(MI, isAlias); |
129 | 0 | if (useAliasDetails) |
130 | 0 | return; |
131 | 0 | } |
132 | 309 | } |
133 | | |
134 | | // SBFM/UBFM should print to a nicer aliased form if possible. |
135 | 248k | if (Opcode == AArch64_SBFMXri || Opcode == AArch64_SBFMWri || |
136 | 247k | Opcode == AArch64_UBFMXri || Opcode == AArch64_UBFMWri) { |
137 | 2.51k | MCOperand *Op0 = MCInst_getOperand(MI, (0)); |
138 | 2.51k | MCOperand *Op1 = MCInst_getOperand(MI, (1)); |
139 | 2.51k | MCOperand *Op2 = MCInst_getOperand(MI, (2)); |
140 | 2.51k | MCOperand *Op3 = MCInst_getOperand(MI, (3)); |
141 | | |
142 | 2.51k | bool IsSigned = (Opcode == AArch64_SBFMXri || |
143 | 1.87k | Opcode == AArch64_SBFMWri); |
144 | 2.51k | bool Is64Bit = (Opcode == AArch64_SBFMXri || |
145 | 1.87k | Opcode == AArch64_UBFMXri); |
146 | 2.51k | if (MCOperand_isImm(Op2) && MCOperand_getImm(Op2) == 0 && |
147 | 1.20k | MCOperand_isImm(Op3)) { |
148 | 1.20k | const char *AsmMnemonic = NULL; |
149 | | |
150 | 1.20k | switch (MCOperand_getImm(Op3)) { |
151 | 132 | default: |
152 | 132 | break; |
153 | 261 | case 7: |
154 | 261 | if (IsSigned) |
155 | 127 | AsmMnemonic = "sxtb"; |
156 | 134 | else if (!Is64Bit) |
157 | 58 | AsmMnemonic = "uxtb"; |
158 | 261 | break; |
159 | 320 | case 15: |
160 | 320 | if (IsSigned) |
161 | 119 | AsmMnemonic = "sxth"; |
162 | 201 | else if (!Is64Bit) |
163 | 96 | AsmMnemonic = "uxth"; |
164 | 320 | break; |
165 | 487 | case 31: |
166 | | // *xtw is only valid for signed 64-bit operations. |
167 | 487 | if (Is64Bit && IsSigned) |
168 | 261 | AsmMnemonic = "sxtw"; |
169 | 487 | break; |
170 | 1.20k | } |
171 | | |
172 | 1.20k | if (AsmMnemonic) { |
173 | 661 | SStream_concat(O, "%s", AsmMnemonic); |
174 | 661 | SStream_concat0(O, " "); |
175 | | |
176 | 661 | printRegName(O, MCOperand_getReg(Op0)); |
177 | 661 | SStream_concat0(O, ", "); |
178 | 661 | printRegName(O, getWRegFromXReg( |
179 | 661 | MCOperand_getReg(Op1))); |
180 | 661 | if (detail_is_set(MI) && useAliasDetails) { |
181 | 661 | AArch64_set_detail_op_reg( |
182 | 661 | MI, 0, MCOperand_getReg(Op0)); |
183 | 661 | AArch64_set_detail_op_reg( |
184 | 661 | MI, 1, |
185 | 661 | getWRegFromXReg( |
186 | 661 | MCOperand_getReg(Op1))); |
187 | 661 | if (strings_match(AsmMnemonic, "uxtb")) |
188 | 58 | AArch64_get_detail_op(MI, -1) |
189 | 58 | ->ext = |
190 | 58 | AARCH64_EXT_UXTB; |
191 | 603 | else if (strings_match(AsmMnemonic, |
192 | 603 | "sxtb")) |
193 | 127 | AArch64_get_detail_op(MI, -1) |
194 | 127 | ->ext = |
195 | 127 | AARCH64_EXT_SXTB; |
196 | 476 | else if (strings_match(AsmMnemonic, |
197 | 476 | "uxth")) |
198 | 96 | AArch64_get_detail_op(MI, -1) |
199 | 96 | ->ext = |
200 | 96 | AARCH64_EXT_UXTH; |
201 | 380 | else if (strings_match(AsmMnemonic, |
202 | 380 | "sxth")) |
203 | 119 | AArch64_get_detail_op(MI, -1) |
204 | 119 | ->ext = |
205 | 119 | AARCH64_EXT_SXTH; |
206 | 261 | else if (strings_match(AsmMnemonic, |
207 | 261 | "sxtw")) |
208 | 261 | AArch64_get_detail_op(MI, -1) |
209 | 261 | ->ext = |
210 | 261 | AARCH64_EXT_SXTW; |
211 | 0 | else |
212 | 0 | AArch64_get_detail_op(MI, -1) |
213 | 0 | ->ext = |
214 | 0 | AARCH64_EXT_INVALID; |
215 | 661 | } |
216 | 661 | isAlias = true; |
217 | 661 | MCInst_setIsAlias(MI, isAlias); |
218 | 661 | if (useAliasDetails) |
219 | 661 | return; |
220 | 0 | else |
221 | 0 | goto add_real_detail; |
222 | 661 | } |
223 | 1.20k | } |
224 | | |
225 | | // All immediate shifts are aliases, implemented using the Bitfield |
226 | | // instruction. In all cases the immediate shift amount shift must be in |
227 | | // the range 0 to (reg.size -1). |
228 | 1.84k | if (MCOperand_isImm(Op2) && MCOperand_isImm(Op3)) { |
229 | 1.84k | const char *AsmMnemonic = NULL; |
230 | 1.84k | int shift = 0; |
231 | 1.84k | int64_t immr = MCOperand_getImm(Op2); |
232 | 1.84k | int64_t imms = MCOperand_getImm(Op3); |
233 | 1.84k | if (Opcode == AArch64_UBFMWri && imms != 0x1F && |
234 | 176 | ((imms + 1) == immr)) { |
235 | 33 | AsmMnemonic = "lsl"; |
236 | 33 | shift = 31 - imms; |
237 | 1.81k | } else if (Opcode == AArch64_UBFMXri && imms != 0x3f && |
238 | 921 | ((imms + 1 == immr))) { |
239 | 85 | AsmMnemonic = "lsl"; |
240 | 85 | shift = 63 - imms; |
241 | 1.73k | } else if (Opcode == AArch64_UBFMWri && imms == 0x1f) { |
242 | 77 | AsmMnemonic = "lsr"; |
243 | 77 | shift = immr; |
244 | 1.65k | } else if (Opcode == AArch64_UBFMXri && imms == 0x3f) { |
245 | 39 | AsmMnemonic = "lsr"; |
246 | 39 | shift = immr; |
247 | 1.61k | } else if (Opcode == AArch64_SBFMWri && imms == 0x1f) { |
248 | 231 | AsmMnemonic = "asr"; |
249 | 231 | shift = immr; |
250 | 1.38k | } else if (Opcode == AArch64_SBFMXri && imms == 0x3f) { |
251 | 64 | AsmMnemonic = "asr"; |
252 | 64 | shift = immr; |
253 | 64 | } |
254 | 1.84k | if (AsmMnemonic) { |
255 | 529 | SStream_concat(O, "%s", AsmMnemonic); |
256 | 529 | SStream_concat0(O, " "); |
257 | | |
258 | 529 | printRegName(O, MCOperand_getReg(Op0)); |
259 | 529 | SStream_concat0(O, ", "); |
260 | 529 | printRegName(O, MCOperand_getReg(Op1)); |
261 | 529 | SStream_concat(O, "%s%s#%d", ", ", |
262 | 529 | markup("<imm:"), shift); |
263 | 529 | SStream_concat0(O, markup(">")); |
264 | 529 | if (detail_is_set(MI) && useAliasDetails) { |
265 | 529 | AArch64_set_detail_op_reg( |
266 | 529 | MI, 0, MCOperand_getReg(Op0)); |
267 | 529 | AArch64_set_detail_op_reg( |
268 | 529 | MI, 1, MCOperand_getReg(Op1)); |
269 | 529 | if (strings_match(AsmMnemonic, "lsl")) |
270 | 118 | AArch64_get_detail_op(MI, -1) |
271 | 118 | ->shift.type = |
272 | 118 | AARCH64_SFT_LSL; |
273 | 411 | else if (strings_match(AsmMnemonic, |
274 | 411 | "lsr")) |
275 | 116 | AArch64_get_detail_op(MI, -1) |
276 | 116 | ->shift.type = |
277 | 116 | AARCH64_SFT_LSR; |
278 | 295 | else if (strings_match(AsmMnemonic, |
279 | 295 | "asr")) |
280 | 295 | AArch64_get_detail_op(MI, -1) |
281 | 295 | ->shift.type = |
282 | 295 | AARCH64_SFT_ASR; |
283 | 0 | else |
284 | 0 | AArch64_get_detail_op(MI, -1) |
285 | 0 | ->shift.type = |
286 | 0 | AARCH64_SFT_INVALID; |
287 | 529 | AArch64_get_detail_op(MI, -1) |
288 | 529 | ->shift.value = shift; |
289 | 529 | } |
290 | 529 | isAlias = true; |
291 | 529 | MCInst_setIsAlias(MI, isAlias); |
292 | 529 | if (useAliasDetails) |
293 | 529 | return; |
294 | 0 | else |
295 | 0 | goto add_real_detail; |
296 | 529 | } |
297 | 1.84k | } |
298 | | |
299 | | // SBFIZ/UBFIZ aliases |
300 | 1.32k | if (MCOperand_getImm(Op2) > MCOperand_getImm(Op3)) { |
301 | 403 | SStream_concat(O, "%s", (IsSigned ? "sbfiz" : "ubfiz")); |
302 | 403 | SStream_concat0(O, " "); |
303 | | |
304 | 403 | printRegName(O, MCOperand_getReg(Op0)); |
305 | 403 | SStream_concat0(O, ", "); |
306 | 403 | printRegName(O, MCOperand_getReg(Op1)); |
307 | 403 | SStream_concat(O, "%s%s", ", ", markup("<imm:")); |
308 | 403 | printUInt32Bang(O, (Is64Bit ? 64 : 32) - |
309 | 403 | MCOperand_getImm(Op2)); |
310 | 403 | SStream_concat(O, "%s%s%s", markup(">"), ", ", |
311 | 403 | markup("<imm:")); |
312 | 403 | printInt64Bang(O, MCOperand_getImm(Op3) + 1); |
313 | 403 | SStream_concat0(O, markup(">")); |
314 | 403 | if (detail_is_set(MI) && useAliasDetails) { |
315 | 403 | AArch64_set_detail_op_reg( |
316 | 403 | MI, 0, MCOperand_getReg(Op0)); |
317 | 403 | AArch64_set_detail_op_reg( |
318 | 403 | MI, 1, MCOperand_getReg(Op1)); |
319 | 403 | AArch64_set_detail_op_imm( |
320 | 403 | MI, 2, AARCH64_OP_IMM, |
321 | 403 | (Is64Bit ? 64 : 32) - |
322 | 403 | MCOperand_getImm(Op2)); |
323 | 403 | AArch64_set_detail_op_imm( |
324 | 403 | MI, 3, AARCH64_OP_IMM, |
325 | 403 | MCOperand_getImm(Op3) + 1); |
326 | 403 | } |
327 | 403 | isAlias = true; |
328 | 403 | MCInst_setIsAlias(MI, isAlias); |
329 | 403 | if (useAliasDetails) |
330 | 403 | return; |
331 | 0 | else |
332 | 0 | goto add_real_detail; |
333 | 403 | } |
334 | | |
335 | | // Otherwise SBFX/UBFX is the preferred form |
336 | 917 | SStream_concat(O, "%s", (IsSigned ? "sbfx" : "ubfx")); |
337 | 917 | SStream_concat0(O, " "); |
338 | | |
339 | 917 | printRegName(O, MCOperand_getReg(Op0)); |
340 | 917 | SStream_concat0(O, ", "); |
341 | 917 | printRegName(O, MCOperand_getReg(Op1)); |
342 | 917 | SStream_concat(O, "%s%s", ", ", markup("<imm:")); |
343 | 917 | printInt64Bang(O, MCOperand_getImm(Op2)); |
344 | 917 | SStream_concat(O, "%s%s%s", markup(">"), ", ", markup("<imm:")); |
345 | 917 | printInt64Bang(O, MCOperand_getImm(Op3) - |
346 | 917 | MCOperand_getImm(Op2) + 1); |
347 | 917 | SStream_concat0(O, markup(">")); |
348 | 917 | if (detail_is_set(MI) && useAliasDetails) { |
349 | 917 | AArch64_set_detail_op_reg(MI, 0, MCOperand_getReg(Op0)); |
350 | 917 | AArch64_set_detail_op_reg(MI, 1, MCOperand_getReg(Op1)); |
351 | 917 | AArch64_set_detail_op_imm(MI, 2, AARCH64_OP_IMM, |
352 | 917 | MCOperand_getImm(Op2)); |
353 | 917 | AArch64_set_detail_op_imm( |
354 | 917 | MI, 3, AARCH64_OP_IMM, |
355 | 917 | MCOperand_getImm(Op3) - MCOperand_getImm(Op2) + |
356 | 917 | 1); |
357 | 917 | } |
358 | 917 | isAlias = true; |
359 | 917 | MCInst_setIsAlias(MI, isAlias); |
360 | 917 | if (useAliasDetails) |
361 | 917 | return; |
362 | 0 | else |
363 | 0 | goto add_real_detail; |
364 | 917 | } |
365 | | |
366 | 245k | if (Opcode == AArch64_BFMXri || Opcode == AArch64_BFMWri) { |
367 | 639 | isAlias = true; |
368 | 639 | MCInst_setIsAlias(MI, isAlias); |
369 | 639 | MCOperand *Op0 = MCInst_getOperand(MI, (0)); // Op1 == Op0 |
370 | 639 | MCOperand *Op2 = MCInst_getOperand(MI, (2)); |
371 | 639 | int ImmR = MCOperand_getImm(MCInst_getOperand(MI, (3))); |
372 | 639 | int ImmS = MCOperand_getImm(MCInst_getOperand(MI, (4))); |
373 | | |
374 | 639 | if ((MCOperand_getReg(Op2) == AArch64_WZR || |
375 | 614 | MCOperand_getReg(Op2) == AArch64_XZR) && |
376 | 352 | (ImmR == 0 || ImmS < ImmR) && |
377 | 121 | (AArch64_getFeatureBits(MI->csh->mode, |
378 | 121 | AArch64_FeatureAll) || |
379 | 0 | AArch64_getFeatureBits(MI->csh->mode, |
380 | 121 | AArch64_HasV8_2aOps))) { |
381 | | // BFC takes precedence over its entire range, sligtly differently |
382 | | // to BFI. |
383 | 121 | int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32; |
384 | 121 | int LSB = (BitWidth - ImmR) % BitWidth; |
385 | 121 | int Width = ImmS + 1; |
386 | | |
387 | 121 | SStream_concat0(O, "bfc "); |
388 | 121 | printRegName(O, MCOperand_getReg(Op0)); |
389 | 121 | SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"), |
390 | 121 | LSB); |
391 | 121 | SStream_concat(O, "%s%s%s#%d", markup(">"), ", ", |
392 | 121 | markup("<imm:"), Width); |
393 | 121 | SStream_concat0(O, markup(">")); |
394 | 121 | if (detail_is_set(MI) && useAliasDetails) { |
395 | 121 | AArch64_set_detail_op_reg( |
396 | 121 | MI, 0, MCOperand_getReg(Op0)); |
397 | 121 | AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM, |
398 | 121 | LSB); |
399 | 121 | AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM, |
400 | 121 | Width); |
401 | 121 | } |
402 | | |
403 | 121 | if (useAliasDetails) |
404 | 121 | return; |
405 | 0 | else |
406 | 0 | goto add_real_detail; |
407 | 518 | } else if (ImmS < ImmR) { |
408 | | // BFI alias |
409 | 195 | int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32; |
410 | 195 | int LSB = (BitWidth - ImmR) % BitWidth; |
411 | 195 | int Width = ImmS + 1; |
412 | | |
413 | 195 | SStream_concat0(O, "bfi "); |
414 | 195 | printRegName(O, MCOperand_getReg(Op0)); |
415 | 195 | SStream_concat0(O, ", "); |
416 | 195 | printRegName(O, MCOperand_getReg(Op2)); |
417 | 195 | SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"), |
418 | 195 | LSB); |
419 | 195 | SStream_concat(O, "%s%s%s#%d", markup(">"), ", ", |
420 | 195 | markup("<imm:"), Width); |
421 | 195 | SStream_concat0(O, markup(">")); |
422 | 195 | if (detail_is_set(MI) && useAliasDetails) { |
423 | 195 | AArch64_set_detail_op_reg( |
424 | 195 | MI, 0, MCOperand_getReg(Op0)); |
425 | 195 | AArch64_set_detail_op_reg( |
426 | 195 | MI, 2, MCOperand_getReg(Op2)); |
427 | 195 | AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM, |
428 | 195 | LSB); |
429 | 195 | AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM, |
430 | 195 | Width); |
431 | 195 | } |
432 | 195 | if (useAliasDetails) |
433 | 195 | return; |
434 | 0 | else |
435 | 0 | goto add_real_detail; |
436 | 195 | } |
437 | | |
438 | 323 | int LSB = ImmR; |
439 | 323 | int Width = ImmS - ImmR + 1; |
440 | | // Otherwise BFXIL the preferred form |
441 | 323 | SStream_concat0(O, "bfxil "); |
442 | 323 | printRegName(O, MCOperand_getReg(Op0)); |
443 | 323 | SStream_concat0(O, ", "); |
444 | 323 | printRegName(O, MCOperand_getReg(Op2)); |
445 | 323 | SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"), LSB); |
446 | 323 | SStream_concat(O, "%s%s%s#%d", markup(">"), ", ", |
447 | 323 | markup("<imm:"), Width); |
448 | 323 | SStream_concat0(O, markup(">")); |
449 | 323 | if (detail_is_set(MI) && useAliasDetails) { |
450 | 323 | AArch64_set_detail_op_reg(MI, 0, MCOperand_getReg(Op0)); |
451 | 323 | AArch64_set_detail_op_reg(MI, 2, MCOperand_getReg(Op2)); |
452 | 323 | AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM, LSB); |
453 | 323 | AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM, Width); |
454 | 323 | } |
455 | 323 | if (useAliasDetails) |
456 | 323 | return; |
457 | 323 | } |
458 | | |
459 | | // Symbolic operands for MOVZ, MOVN and MOVK already imply a shift |
460 | | // (e.g. :gottprel_g1: is always going to be "lsl #16") so it should not be |
461 | | // printed. |
462 | 245k | if ((Opcode == AArch64_MOVZXi || Opcode == AArch64_MOVZWi || |
463 | 244k | Opcode == AArch64_MOVNXi || Opcode == AArch64_MOVNWi) && |
464 | 1.60k | MCOperand_isExpr(MCInst_getOperand(MI, (1)))) { |
465 | 0 | printUInt64Bang(O, MCInst_getOpVal(MI, 1)); |
466 | 0 | if (detail_is_set(MI) && useAliasDetails) { |
467 | 0 | AArch64_set_detail_op_imm(MI, 1, AARCH64_OP_IMM, |
468 | 0 | MCInst_getOpVal(MI, 1)); |
469 | 0 | } |
470 | 0 | } |
471 | | |
472 | 245k | if ((Opcode == AArch64_MOVKXi || Opcode == AArch64_MOVKWi) && |
473 | 833 | MCOperand_isExpr(MCInst_getOperand(MI, (2)))) { |
474 | 0 | printUInt64Bang(O, MCInst_getOpVal(MI, 2)); |
475 | 0 | if (detail_is_set(MI) && useAliasDetails) { |
476 | 0 | AArch64_set_detail_op_imm(MI, 2, AARCH64_OP_IMM, |
477 | 0 | MCInst_getOpVal(MI, 2)); |
478 | 0 | } |
479 | 0 | } |
480 | | |
481 | | // MOVZ, MOVN and "ORR wzr, #imm" instructions are aliases for MOV, but |
482 | | // their domains overlap so they need to be prioritized. The chain is "MOVZ |
483 | | // lsl #0 > MOVZ lsl #N > MOVN lsl #0 > MOVN lsl #N > ORR". The highest |
484 | | // instruction that can represent the move is the MOV alias, and the rest |
485 | | // get printed normally. |
486 | 245k | if ((Opcode == AArch64_MOVZXi || Opcode == AArch64_MOVZWi) && |
487 | 679 | MCOperand_isImm(MCInst_getOperand(MI, (1))) && |
488 | 679 | MCOperand_isImm(MCInst_getOperand(MI, (2)))) { |
489 | 679 | int RegWidth = Opcode == AArch64_MOVZXi ? 64 : 32; |
490 | 679 | int Shift = MCOperand_getImm(MCInst_getOperand(MI, (2))); |
491 | 679 | uint64_t Value = |
492 | 679 | (uint64_t)MCOperand_getImm(MCInst_getOperand(MI, (1))) |
493 | 679 | << Shift; |
494 | | |
495 | 679 | bool SuppressMovAlias = |
496 | 679 | (MI->csh->syntax & |
497 | 679 | CS_OPT_SYNTAX_AARCH64_EXPLICIT_WIDE_IMM) && |
498 | 0 | Shift != 0; |
499 | | |
500 | 679 | if (!SuppressMovAlias && |
501 | 679 | AArch64_AM_isMOVZMovAlias( |
502 | 679 | Value, Shift, Opcode == AArch64_MOVZXi ? 64 : 32)) { |
503 | 596 | isAlias = true; |
504 | 596 | MCInst_setIsAlias(MI, isAlias); |
505 | 596 | SStream_concat0(O, "mov "); |
506 | 596 | printRegName(O, MCOperand_getReg( |
507 | 596 | MCInst_getOperand(MI, (0)))); |
508 | 596 | SStream_concat(O, "%s%s", ", ", markup("<imm:")); |
509 | 596 | printInt64Bang(O, SignExtend64(Value, RegWidth)); |
510 | 596 | SStream_concat0(O, markup(">")); |
511 | 596 | if (detail_is_set(MI) && useAliasDetails) { |
512 | 596 | AArch64_set_detail_op_reg( |
513 | 596 | MI, 0, MCInst_getOpVal(MI, 0)); |
514 | 596 | AArch64_set_detail_op_imm( |
515 | 596 | MI, 1, AARCH64_OP_IMM, |
516 | 596 | SignExtend64(Value, RegWidth)); |
517 | 596 | } |
518 | 596 | if (useAliasDetails) |
519 | 596 | return; |
520 | 596 | } |
521 | 679 | } |
522 | | |
523 | 244k | if ((Opcode == AArch64_MOVNXi || Opcode == AArch64_MOVNWi) && |
524 | 923 | MCOperand_isImm(MCInst_getOperand(MI, (1))) && |
525 | 923 | MCOperand_isImm(MCInst_getOperand(MI, (2)))) { |
526 | 923 | int RegWidth = Opcode == AArch64_MOVNXi ? 64 : 32; |
527 | 923 | int Shift = MCOperand_getImm(MCInst_getOperand(MI, (2))); |
528 | 923 | uint64_t Value = |
529 | 923 | ~((uint64_t)MCOperand_getImm(MCInst_getOperand(MI, (1))) |
530 | 923 | << Shift); |
531 | 923 | if (RegWidth == 32) |
532 | 184 | Value = Value & 0xffffffff; |
533 | | |
534 | 923 | bool SuppressMovAlias = |
535 | 923 | (MI->csh->syntax & |
536 | 923 | CS_OPT_SYNTAX_AARCH64_EXPLICIT_WIDE_IMM) && |
537 | 0 | Shift != 0; |
538 | | |
539 | 923 | if (!SuppressMovAlias && |
540 | 923 | AArch64_AM_isMOVNMovAlias(Value, Shift, RegWidth)) { |
541 | 800 | isAlias = true; |
542 | 800 | MCInst_setIsAlias(MI, isAlias); |
543 | 800 | SStream_concat0(O, "mov "); |
544 | 800 | printRegName(O, MCOperand_getReg( |
545 | 800 | MCInst_getOperand(MI, (0)))); |
546 | 800 | SStream_concat(O, "%s%s", ", ", markup("<imm:")); |
547 | 800 | printInt64Bang(O, SignExtend64(Value, RegWidth)); |
548 | 800 | SStream_concat0(O, markup(">")); |
549 | 800 | if (detail_is_set(MI) && useAliasDetails) { |
550 | 800 | AArch64_set_detail_op_reg( |
551 | 800 | MI, 0, MCInst_getOpVal(MI, 0)); |
552 | 800 | AArch64_set_detail_op_imm( |
553 | 800 | MI, 1, AARCH64_OP_IMM, |
554 | 800 | SignExtend64(Value, RegWidth)); |
555 | 800 | } |
556 | 800 | if (useAliasDetails) |
557 | 800 | return; |
558 | 800 | } |
559 | 923 | } |
560 | | |
561 | 243k | if ((Opcode == AArch64_ORRXri || Opcode == AArch64_ORRWri) && |
562 | 2.20k | (MCOperand_getReg(MCInst_getOperand(MI, (1))) == AArch64_XZR || |
563 | 1.34k | MCOperand_getReg(MCInst_getOperand(MI, (1))) == AArch64_WZR) && |
564 | 1.34k | MCOperand_isImm(MCInst_getOperand(MI, (2)))) { |
565 | 1.34k | int RegWidth = Opcode == AArch64_ORRXri ? 64 : 32; |
566 | 1.34k | uint64_t Value = AArch64_AM_decodeLogicalImmediate( |
567 | 1.34k | MCOperand_getImm(MCInst_getOperand(MI, (2))), RegWidth); |
568 | 1.34k | if (!AArch64_AM_isAnyMOVWMovAlias(Value, RegWidth)) { |
569 | 683 | isAlias = true; |
570 | 683 | MCInst_setIsAlias(MI, isAlias); |
571 | 683 | SStream_concat0(O, "mov "); |
572 | 683 | printRegName(O, MCOperand_getReg( |
573 | 683 | MCInst_getOperand(MI, (0)))); |
574 | 683 | SStream_concat(O, "%s%s", ", ", markup("<imm:")); |
575 | 683 | printInt64Bang(O, SignExtend64(Value, RegWidth)); |
576 | 683 | SStream_concat0(O, markup(">")); |
577 | 683 | if (detail_is_set(MI) && useAliasDetails) { |
578 | 683 | AArch64_set_detail_op_reg( |
579 | 683 | MI, 0, MCInst_getOpVal(MI, 0)); |
580 | 683 | AArch64_set_detail_op_imm( |
581 | 683 | MI, 2, AARCH64_OP_IMM, |
582 | 683 | SignExtend64(Value, RegWidth)); |
583 | 683 | } |
584 | 683 | if (useAliasDetails) |
585 | 683 | return; |
586 | 683 | } |
587 | 1.34k | } |
588 | | |
589 | 243k | if (Opcode == AArch64_SPACE) { |
590 | 0 | isAlias = true; |
591 | 0 | MCInst_setIsAlias(MI, isAlias); |
592 | 0 | SStream_concat1(O, ' '); |
593 | 0 | SStream_concat(O, "%s", " SPACE "); |
594 | 0 | printInt64(O, MCOperand_getImm(MCInst_getOperand(MI, (1)))); |
595 | 0 | if (detail_is_set(MI) && useAliasDetails) { |
596 | 0 | AArch64_set_detail_op_imm(MI, 1, AARCH64_OP_IMM, |
597 | 0 | MCInst_getOpVal(MI, 1)); |
598 | 0 | } |
599 | 0 | if (useAliasDetails) |
600 | 0 | return; |
601 | 0 | } |
602 | | |
603 | 243k | if (!isAlias) |
604 | 243k | isAlias |= printAliasInstr(MI, Address, O); |
605 | | |
606 | 243k | add_real_detail: |
607 | 243k | MCInst_setIsAlias(MI, isAlias); |
608 | | |
609 | 243k | if (!isAlias || !useAliasDetails) { |
610 | 219k | map_set_fill_detail_ops(MI, !(isAlias && useAliasDetails)); |
611 | 219k | if (isAlias) |
612 | 0 | SStream_Close(O); |
613 | 219k | printInstruction(MI, Address, O); |
614 | 219k | if (isAlias) |
615 | 0 | SStream_Open(O); |
616 | 219k | } |
617 | 243k | } |
618 | | |
619 | | bool printRangePrefetchAlias(MCInst *MI, SStream *O, const char *Annot) |
620 | 309 | { |
621 | 309 | unsigned Opcode = MCInst_getOpcode(MI); |
622 | | |
623 | 309 | #ifndef NDEBUG |
624 | | |
625 | 309 | #endif |
626 | | |
627 | 309 | unsigned PRFOp = MCOperand_getImm(MCInst_getOperand(MI, (0))); |
628 | 309 | unsigned Mask = 0x18; // 0b11000 |
629 | 309 | if ((PRFOp & Mask) != Mask) |
630 | 309 | return false; // Rt != '11xxx', it's a PRFM instruction. |
631 | | |
632 | 0 | unsigned Rm = MCOperand_getReg(MCInst_getOperand(MI, (2))); |
633 | | |
634 | | // "Rm" must be a 64-bit GPR for RPRFM. |
635 | 0 | if (MCRegisterInfo_getRegClass(MI->MRI, Rm)) |
636 | 0 | Rm = MCRegisterInfo_getMatchingSuperReg( |
637 | 0 | MI->MRI, Rm, AArch64_sub_32, |
638 | 0 | MCRegisterInfo_getRegClass(MI->MRI, Rm)); |
639 | |
|
640 | 0 | unsigned SignExtend = MCOperand_getImm( |
641 | 0 | MCInst_getOperand(MI, (3))); // encoded in "option<2>". |
642 | 0 | unsigned Shift = |
643 | 0 | MCOperand_getImm(MCInst_getOperand(MI, (4))); // encoded in "S". |
644 | |
|
645 | 0 | unsigned Option0 = (Opcode == AArch64_PRFMroX) ? 1 : 0; |
646 | | |
647 | | // encoded in "option<2>:option<0>:S:Rt<2:0>". |
648 | 0 | unsigned RPRFOp = (SignExtend << 5) | (Option0 << 4) | (Shift << 3) | |
649 | 0 | (PRFOp & 0x7); |
650 | |
|
651 | 0 | SStream_concat0(O, "rprfm "); |
652 | 0 | const AArch64RPRFM_RPRFM *RPRFM = |
653 | 0 | AArch64RPRFM_lookupRPRFMByEncoding(RPRFOp); |
654 | 0 | if (RPRFM) { |
655 | 0 | SStream_concat0(O, RPRFM->Name); |
656 | 0 | } else { |
657 | 0 | printUInt32Bang(O, RPRFOp); |
658 | 0 | SStream_concat(O, ", "); |
659 | 0 | } |
660 | 0 | SStream_concat0(O, getRegisterName(Rm, AArch64_NoRegAltName)); |
661 | 0 | SStream_concat0(O, ", ["); |
662 | 0 | printOperand(MI, 1, O); // "Rn". |
663 | 0 | SStream_concat0(O, "]"); |
664 | |
|
665 | 0 | return true; |
666 | 309 | } |
667 | | |
668 | | bool printSysAlias(MCInst *MI, SStream *O) |
669 | 2.49k | { |
670 | 2.49k | MCOperand *Op1 = MCInst_getOperand(MI, (0)); |
671 | 2.49k | MCOperand *Cn = MCInst_getOperand(MI, (1)); |
672 | 2.49k | MCOperand *Cm = MCInst_getOperand(MI, (2)); |
673 | 2.49k | MCOperand *Op2 = MCInst_getOperand(MI, (3)); |
674 | | |
675 | 2.49k | unsigned Op1Val = MCOperand_getImm(Op1); |
676 | 2.49k | unsigned CnVal = MCOperand_getImm(Cn); |
677 | 2.49k | unsigned CmVal = MCOperand_getImm(Cm); |
678 | 2.49k | unsigned Op2Val = MCOperand_getImm(Op2); |
679 | | |
680 | 2.49k | uint16_t Encoding = Op2Val; |
681 | 2.49k | Encoding |= CmVal << 3; |
682 | 2.49k | Encoding |= CnVal << 7; |
683 | 2.49k | Encoding |= Op1Val << 11; |
684 | | |
685 | 2.49k | bool NeedsReg; |
686 | 2.49k | const char *Ins; |
687 | 2.49k | const char *Name; |
688 | | |
689 | 2.49k | if (CnVal == 7) { |
690 | 1.62k | switch (CmVal) { |
691 | 50 | default: |
692 | 50 | return false; |
693 | | // Maybe IC, maybe Prediction Restriction |
694 | 236 | case 1: |
695 | 236 | switch (Op1Val) { |
696 | 21 | default: |
697 | 21 | return false; |
698 | 184 | case 0: |
699 | 184 | goto Search_IC; |
700 | 31 | case 3: |
701 | 31 | goto Search_PRCTX; |
702 | 236 | } |
703 | | // Prediction Restriction aliases |
704 | 614 | case 3: { |
705 | 645 | Search_PRCTX: |
706 | 645 | if (Op1Val != 3 || CnVal != 7 || CmVal != 3) |
707 | 40 | return false; |
708 | | |
709 | 605 | unsigned int Requires = |
710 | 605 | Op2Val == 6 ? AArch64_FeatureSPECRES2 : |
711 | 605 | AArch64_FeaturePredRes; |
712 | 605 | if (!(AArch64_getFeatureBits(MI->csh->mode, |
713 | 605 | AArch64_FeatureAll) || |
714 | 0 | AArch64_getFeatureBits(MI->csh->mode, Requires))) |
715 | 0 | return false; |
716 | | |
717 | 605 | NeedsReg = true; |
718 | 605 | switch (Op2Val) { |
719 | 235 | default: |
720 | 235 | return false; |
721 | 89 | case 4: |
722 | 89 | Ins = "cfp "; |
723 | 89 | break; |
724 | 258 | case 5: |
725 | 258 | Ins = "dvp "; |
726 | 258 | break; |
727 | 12 | case 6: |
728 | 12 | Ins = "cosp "; |
729 | 12 | break; |
730 | 11 | case 7: |
731 | 11 | Ins = "cpp "; |
732 | 11 | break; |
733 | 605 | } |
734 | 370 | Name = "RCTX"; |
735 | 370 | } break; |
736 | | // IC aliases |
737 | 37 | case 5: { |
738 | 221 | Search_IC: { |
739 | 221 | const AArch64IC_IC *IC = AArch64IC_lookupICByEncoding(Encoding); |
740 | 221 | if (!IC || |
741 | 16 | !AArch64_testFeatureList(MI->csh->mode, IC->FeaturesRequired)) |
742 | 205 | return false; |
743 | 16 | if (detail_is_set(MI)) { |
744 | 16 | aarch64_sysop sysop = { 0 }; |
745 | 16 | sysop.reg = IC->SysReg; |
746 | 16 | sysop.sub_type = AARCH64_OP_IC; |
747 | 16 | AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG; |
748 | 16 | AArch64_get_detail_op(MI, 0)->sysop = sysop; |
749 | 16 | AArch64_inc_op_count(MI); |
750 | 16 | } |
751 | | |
752 | 16 | NeedsReg = IC->NeedsReg; |
753 | 16 | Ins = "ic "; |
754 | 16 | Name = IC->Name; |
755 | 16 | } |
756 | 16 | } break; |
757 | | // DC aliases |
758 | 64 | case 4: |
759 | 158 | case 6: |
760 | 208 | case 10: |
761 | 235 | case 11: |
762 | 260 | case 12: |
763 | 347 | case 13: |
764 | 571 | case 14: { |
765 | 571 | const AArch64DC_DC *DC = |
766 | 571 | AArch64DC_lookupDCByEncoding(Encoding); |
767 | 571 | if (!DC || !AArch64_testFeatureList( |
768 | 187 | MI->csh->mode, DC->FeaturesRequired)) |
769 | 384 | return false; |
770 | 187 | if (detail_is_set(MI)) { |
771 | 187 | aarch64_sysop sysop = { 0 }; |
772 | 187 | sysop.alias = DC->SysAlias; |
773 | 187 | sysop.sub_type = AARCH64_OP_DC; |
774 | 187 | AArch64_get_detail_op(MI, 0)->type = |
775 | 187 | AARCH64_OP_SYSALIAS; |
776 | 187 | AArch64_get_detail_op(MI, 0)->sysop = sysop; |
777 | 187 | AArch64_inc_op_count(MI); |
778 | 187 | } |
779 | | |
780 | 187 | NeedsReg = true; |
781 | 187 | Ins = "dc "; |
782 | 187 | Name = DC->Name; |
783 | 187 | } break; |
784 | | // AT aliases |
785 | 43 | case 8: |
786 | 118 | case 9: { |
787 | 118 | const AArch64AT_AT *AT = |
788 | 118 | AArch64AT_lookupATByEncoding(Encoding); |
789 | 118 | if (!AT || !AArch64_testFeatureList( |
790 | 32 | MI->csh->mode, AT->FeaturesRequired)) |
791 | 86 | return false; |
792 | | |
793 | 32 | if (detail_is_set(MI)) { |
794 | 32 | aarch64_sysop sysop = { 0 }; |
795 | 32 | sysop.alias = AT->SysAlias; |
796 | 32 | sysop.sub_type = AARCH64_OP_AT; |
797 | 32 | AArch64_get_detail_op(MI, 0)->type = |
798 | 32 | AARCH64_OP_SYSALIAS; |
799 | 32 | AArch64_get_detail_op(MI, 0)->sysop = sysop; |
800 | 32 | AArch64_inc_op_count(MI); |
801 | 32 | } |
802 | 32 | NeedsReg = true; |
803 | 32 | Ins = "at "; |
804 | 32 | Name = AT->Name; |
805 | 32 | } break; |
806 | 1.62k | } |
807 | 1.62k | } else if (CnVal == 8 || CnVal == 9) { |
808 | | // TLBI aliases |
809 | 559 | const AArch64TLBI_TLBI *TLBI = |
810 | 559 | AArch64TLBI_lookupTLBIByEncoding(Encoding); |
811 | 559 | if (!TLBI || !AArch64_testFeatureList(MI->csh->mode, |
812 | 61 | TLBI->FeaturesRequired)) |
813 | 498 | return false; |
814 | | |
815 | 61 | if (detail_is_set(MI)) { |
816 | 61 | aarch64_sysop sysop = { 0 }; |
817 | 61 | sysop.reg = TLBI->SysReg; |
818 | 61 | sysop.sub_type = AARCH64_OP_TLBI; |
819 | 61 | AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG; |
820 | 61 | AArch64_get_detail_op(MI, 0)->sysop = sysop; |
821 | 61 | AArch64_inc_op_count(MI); |
822 | 61 | } |
823 | 61 | NeedsReg = TLBI->NeedsReg; |
824 | 61 | Ins = "tlbi "; |
825 | 61 | Name = TLBI->Name; |
826 | 61 | } else |
827 | 305 | return false; |
828 | | |
829 | 1.33k | #define TMP_STR_LEN 32 |
830 | 666 | char Str[TMP_STR_LEN] = { 0 }; |
831 | 666 | append_to_str_lower(Str, TMP_STR_LEN, Ins); |
832 | 666 | append_to_str_lower(Str, TMP_STR_LEN, Name); |
833 | 666 | #undef TMP_STR_LEN |
834 | | |
835 | 666 | SStream_concat1(O, ' '); |
836 | 666 | SStream_concat0(O, Str); |
837 | 666 | if (NeedsReg) { |
838 | 623 | SStream_concat0(O, ", "); |
839 | 623 | printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (4)))); |
840 | 623 | AArch64_set_detail_op_reg(MI, 4, MCInst_getOpVal(MI, 4)); |
841 | 623 | } |
842 | | |
843 | 666 | return true; |
844 | 2.49k | } |
845 | | |
846 | | bool printSyspAlias(MCInst *MI, SStream *O) |
847 | 2.13k | { |
848 | 2.13k | MCOperand *Op1 = MCInst_getOperand(MI, (0)); |
849 | 2.13k | MCOperand *Cn = MCInst_getOperand(MI, (1)); |
850 | 2.13k | MCOperand *Cm = MCInst_getOperand(MI, (2)); |
851 | 2.13k | MCOperand *Op2 = MCInst_getOperand(MI, (3)); |
852 | | |
853 | 2.13k | unsigned Op1Val = MCOperand_getImm(Op1); |
854 | 2.13k | unsigned CnVal = MCOperand_getImm(Cn); |
855 | 2.13k | unsigned CmVal = MCOperand_getImm(Cm); |
856 | 2.13k | unsigned Op2Val = MCOperand_getImm(Op2); |
857 | | |
858 | 2.13k | uint16_t Encoding = Op2Val; |
859 | 2.13k | Encoding |= CmVal << 3; |
860 | 2.13k | Encoding |= CnVal << 7; |
861 | 2.13k | Encoding |= Op1Val << 11; |
862 | | |
863 | 2.13k | const char *Ins; |
864 | 2.13k | const char *Name; |
865 | | |
866 | 2.13k | if (CnVal == 8 || CnVal == 9) { |
867 | | // TLBIP aliases |
868 | | |
869 | 1.39k | if (CnVal == 9) { |
870 | 70 | if (!AArch64_getFeatureBits(MI->csh->mode, |
871 | 70 | AArch64_FeatureAll) || |
872 | 70 | !AArch64_getFeatureBits(MI->csh->mode, |
873 | 70 | AArch64_FeatureXS)) |
874 | 0 | return false; |
875 | 70 | Encoding &= ~(1 << 7); |
876 | 70 | } |
877 | | |
878 | 1.39k | const AArch64TLBI_TLBI *TLBI = |
879 | 1.39k | AArch64TLBI_lookupTLBIByEncoding(Encoding); |
880 | 1.39k | if (!TLBI || !AArch64_testFeatureList(MI->csh->mode, |
881 | 984 | TLBI->FeaturesRequired)) |
882 | 411 | return false; |
883 | | |
884 | 984 | if (detail_is_set(MI)) { |
885 | 984 | aarch64_sysop sysop = { 0 }; |
886 | 984 | sysop.reg = TLBI->SysReg; |
887 | 984 | sysop.sub_type = AARCH64_OP_TLBI; |
888 | 984 | AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG; |
889 | 984 | AArch64_get_detail_op(MI, 0)->sysop = sysop; |
890 | 984 | AArch64_inc_op_count(MI); |
891 | 984 | } |
892 | 984 | Ins = "tlbip "; |
893 | 984 | Name = TLBI->Name; |
894 | 984 | } else |
895 | 741 | return false; |
896 | | |
897 | 2.03k | #define TMP_STR_LEN 32 |
898 | 984 | char Str[TMP_STR_LEN] = { 0 }; |
899 | 984 | append_to_str_lower(Str, TMP_STR_LEN, Ins); |
900 | 984 | append_to_str_lower(Str, TMP_STR_LEN, Name); |
901 | | |
902 | 984 | if (CnVal == 9) { |
903 | 64 | append_to_str_lower(Str, TMP_STR_LEN, "nxs"); |
904 | 64 | } |
905 | 984 | #undef TMP_STR_LEN |
906 | | |
907 | 984 | SStream_concat1(O, ' '); |
908 | 984 | SStream_concat0(O, Str); |
909 | 984 | SStream_concat0(O, ", "); |
910 | 984 | if (MCOperand_getReg(MCInst_getOperand(MI, (4))) == AArch64_XZR) |
911 | 886 | printSyspXzrPair(MI, 4, O); |
912 | 98 | else |
913 | 98 | CONCAT(printGPRSeqPairsClassOperand, 64)(MI, 4, O); |
914 | | |
915 | 984 | return true; |
916 | 2.13k | } |
917 | | |
918 | | #define DEFINE_printMatrix(EltSize) \ |
919 | | void CONCAT(printMatrix, EltSize)(MCInst * MI, unsigned OpNum, \ |
920 | | SStream *O) \ |
921 | 6.09k | { \ |
922 | 6.09k | AArch64_add_cs_detail_1( \ |
923 | 6.09k | MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \ |
924 | 6.09k | EltSize); \ |
925 | 6.09k | MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \ |
926 | 6.09k | \ |
927 | 6.09k | printRegName(O, MCOperand_getReg(RegOp)); \ |
928 | 6.09k | switch (EltSize) { \ |
929 | 309 | case 0: \ |
930 | 309 | break; \ |
931 | 0 | case 8: \ |
932 | 0 | SStream_concat0(O, ".b"); \ |
933 | 0 | break; \ |
934 | 1.34k | case 16: \ |
935 | 1.34k | SStream_concat0(O, ".h"); \ |
936 | 1.34k | break; \ |
937 | 3.15k | case 32: \ |
938 | 3.15k | SStream_concat0(O, ".s"); \ |
939 | 3.15k | break; \ |
940 | 1.28k | case 64: \ |
941 | 1.28k | SStream_concat0(O, ".d"); \ |
942 | 1.28k | break; \ |
943 | 0 | case 128: \ |
944 | 0 | SStream_concat0(O, ".q"); \ |
945 | 0 | break; \ |
946 | 0 | default: \ |
947 | 0 | CS_ASSERT_RET(0 && "Unsupported element size"); \ |
948 | 6.09k | } \ |
949 | 6.09k | } Line | Count | Source | 921 | 1.28k | { \ | 922 | 1.28k | AArch64_add_cs_detail_1( \ | 923 | 1.28k | MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \ | 924 | 1.28k | EltSize); \ | 925 | 1.28k | MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \ | 926 | 1.28k | \ | 927 | 1.28k | printRegName(O, MCOperand_getReg(RegOp)); \ | 928 | 1.28k | switch (EltSize) { \ | 929 | 0 | case 0: \ | 930 | 0 | break; \ | 931 | 0 | case 8: \ | 932 | 0 | SStream_concat0(O, ".b"); \ | 933 | 0 | break; \ | 934 | 0 | case 16: \ | 935 | 0 | SStream_concat0(O, ".h"); \ | 936 | 0 | break; \ | 937 | 0 | case 32: \ | 938 | 0 | SStream_concat0(O, ".s"); \ | 939 | 0 | break; \ | 940 | 1.28k | case 64: \ | 941 | 1.28k | SStream_concat0(O, ".d"); \ | 942 | 1.28k | break; \ | 943 | 0 | case 128: \ | 944 | 0 | SStream_concat0(O, ".q"); \ | 945 | 0 | break; \ | 946 | 0 | default: \ | 947 | 0 | CS_ASSERT_RET(0 && "Unsupported element size"); \ | 948 | 1.28k | } \ | 949 | 1.28k | } |
Line | Count | Source | 921 | 3.15k | { \ | 922 | 3.15k | AArch64_add_cs_detail_1( \ | 923 | 3.15k | MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \ | 924 | 3.15k | EltSize); \ | 925 | 3.15k | MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \ | 926 | 3.15k | \ | 927 | 3.15k | printRegName(O, MCOperand_getReg(RegOp)); \ | 928 | 3.15k | switch (EltSize) { \ | 929 | 0 | case 0: \ | 930 | 0 | break; \ | 931 | 0 | case 8: \ | 932 | 0 | SStream_concat0(O, ".b"); \ | 933 | 0 | break; \ | 934 | 0 | case 16: \ | 935 | 0 | SStream_concat0(O, ".h"); \ | 936 | 0 | break; \ | 937 | 3.15k | case 32: \ | 938 | 3.15k | SStream_concat0(O, ".s"); \ | 939 | 3.15k | break; \ | 940 | 0 | case 64: \ | 941 | 0 | SStream_concat0(O, ".d"); \ | 942 | 0 | break; \ | 943 | 0 | case 128: \ | 944 | 0 | SStream_concat0(O, ".q"); \ | 945 | 0 | break; \ | 946 | 0 | default: \ | 947 | 0 | CS_ASSERT_RET(0 && "Unsupported element size"); \ | 948 | 3.15k | } \ | 949 | 3.15k | } |
Line | Count | Source | 921 | 1.34k | { \ | 922 | 1.34k | AArch64_add_cs_detail_1( \ | 923 | 1.34k | MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \ | 924 | 1.34k | EltSize); \ | 925 | 1.34k | MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \ | 926 | 1.34k | \ | 927 | 1.34k | printRegName(O, MCOperand_getReg(RegOp)); \ | 928 | 1.34k | switch (EltSize) { \ | 929 | 0 | case 0: \ | 930 | 0 | break; \ | 931 | 0 | case 8: \ | 932 | 0 | SStream_concat0(O, ".b"); \ | 933 | 0 | break; \ | 934 | 1.34k | case 16: \ | 935 | 1.34k | SStream_concat0(O, ".h"); \ | 936 | 1.34k | break; \ | 937 | 0 | case 32: \ | 938 | 0 | SStream_concat0(O, ".s"); \ | 939 | 0 | break; \ | 940 | 0 | case 64: \ | 941 | 0 | SStream_concat0(O, ".d"); \ | 942 | 0 | break; \ | 943 | 0 | case 128: \ | 944 | 0 | SStream_concat0(O, ".q"); \ | 945 | 0 | break; \ | 946 | 0 | default: \ | 947 | 0 | CS_ASSERT_RET(0 && "Unsupported element size"); \ | 948 | 1.34k | } \ | 949 | 1.34k | } |
Line | Count | Source | 921 | 309 | { \ | 922 | 309 | AArch64_add_cs_detail_1( \ | 923 | 309 | MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \ | 924 | 309 | EltSize); \ | 925 | 309 | MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \ | 926 | 309 | \ | 927 | 309 | printRegName(O, MCOperand_getReg(RegOp)); \ | 928 | 309 | switch (EltSize) { \ | 929 | 309 | case 0: \ | 930 | 309 | break; \ | 931 | 0 | case 8: \ | 932 | 0 | SStream_concat0(O, ".b"); \ | 933 | 0 | break; \ | 934 | 0 | case 16: \ | 935 | 0 | SStream_concat0(O, ".h"); \ | 936 | 0 | break; \ | 937 | 0 | case 32: \ | 938 | 0 | SStream_concat0(O, ".s"); \ | 939 | 0 | break; \ | 940 | 0 | case 64: \ | 941 | 0 | SStream_concat0(O, ".d"); \ | 942 | 0 | break; \ | 943 | 0 | case 128: \ | 944 | 0 | SStream_concat0(O, ".q"); \ | 945 | 0 | break; \ | 946 | 0 | default: \ | 947 | 0 | CS_ASSERT_RET(0 && "Unsupported element size"); \ | 948 | 309 | } \ | 949 | 309 | } |
|
950 | | DEFINE_printMatrix(64); |
951 | | DEFINE_printMatrix(32); |
952 | | DEFINE_printMatrix(16); |
953 | | DEFINE_printMatrix(0); |
954 | | |
955 | | #define DEFINE_printMatrixTileVector(IsVertical) \ |
956 | | void CONCAT(printMatrixTileVector, \ |
957 | | IsVertical)(MCInst * MI, unsigned OpNum, SStream *O) \ |
958 | 4.93k | { \ |
959 | 4.93k | AArch64_add_cs_detail_1( \ |
960 | 4.93k | MI, \ |
961 | 4.93k | CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \ |
962 | 4.93k | OpNum, IsVertical); \ |
963 | 4.93k | MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \ |
964 | 4.93k | \ |
965 | 4.93k | const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \ |
966 | 4.93k | AArch64_NoRegAltName); \ |
967 | 4.93k | \ |
968 | 4.93k | /* Diet builds have no register-name table; skip printing. */ \ |
969 | 4.93k | if (!RegName) \ |
970 | 4.93k | return; \ |
971 | 4.93k | \ |
972 | 4.93k | unsigned buf_len = strlen(RegName) + 1; \ |
973 | 4.93k | char *Base = cs_mem_calloc(1, buf_len); \ |
974 | 4.93k | memcpy(Base, RegName, buf_len); \ |
975 | 4.93k | char *Dot = strchr(Base, '.'); \ |
976 | 4.93k | if (!Dot) { \ |
977 | 0 | SStream_concat0(O, RegName); \ |
978 | 0 | return; \ |
979 | 0 | } \ |
980 | 4.93k | *Dot = '\0'; /* Split string */ \ |
981 | 4.93k | char *Suffix = Dot + 1; \ |
982 | 4.93k | SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \ |
983 | 4.93k | SStream_concat1(O, '.'); \ |
984 | 4.93k | SStream_concat0(O, Suffix); \ |
985 | 4.93k | cs_mem_free(Base); \ |
986 | 4.93k | } Line | Count | Source | 958 | 2.50k | { \ | 959 | 2.50k | AArch64_add_cs_detail_1( \ | 960 | 2.50k | MI, \ | 961 | 2.50k | CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \ | 962 | 2.50k | OpNum, IsVertical); \ | 963 | 2.50k | MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \ | 964 | 2.50k | \ | 965 | 2.50k | const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \ | 966 | 2.50k | AArch64_NoRegAltName); \ | 967 | 2.50k | \ | 968 | 2.50k | /* Diet builds have no register-name table; skip printing. */ \ | 969 | 2.50k | if (!RegName) \ | 970 | 2.50k | return; \ | 971 | 2.50k | \ | 972 | 2.50k | unsigned buf_len = strlen(RegName) + 1; \ | 973 | 2.50k | char *Base = cs_mem_calloc(1, buf_len); \ | 974 | 2.50k | memcpy(Base, RegName, buf_len); \ | 975 | 2.50k | char *Dot = strchr(Base, '.'); \ | 976 | 2.50k | if (!Dot) { \ | 977 | 0 | SStream_concat0(O, RegName); \ | 978 | 0 | return; \ | 979 | 0 | } \ | 980 | 2.50k | *Dot = '\0'; /* Split string */ \ | 981 | 2.50k | char *Suffix = Dot + 1; \ | 982 | 2.50k | SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \ | 983 | 2.50k | SStream_concat1(O, '.'); \ | 984 | 2.50k | SStream_concat0(O, Suffix); \ | 985 | 2.50k | cs_mem_free(Base); \ | 986 | 2.50k | } |
Line | Count | Source | 958 | 2.43k | { \ | 959 | 2.43k | AArch64_add_cs_detail_1( \ | 960 | 2.43k | MI, \ | 961 | 2.43k | CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \ | 962 | 2.43k | OpNum, IsVertical); \ | 963 | 2.43k | MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \ | 964 | 2.43k | \ | 965 | 2.43k | const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \ | 966 | 2.43k | AArch64_NoRegAltName); \ | 967 | 2.43k | \ | 968 | 2.43k | /* Diet builds have no register-name table; skip printing. */ \ | 969 | 2.43k | if (!RegName) \ | 970 | 2.43k | return; \ | 971 | 2.43k | \ | 972 | 2.43k | unsigned buf_len = strlen(RegName) + 1; \ | 973 | 2.43k | char *Base = cs_mem_calloc(1, buf_len); \ | 974 | 2.43k | memcpy(Base, RegName, buf_len); \ | 975 | 2.43k | char *Dot = strchr(Base, '.'); \ | 976 | 2.43k | if (!Dot) { \ | 977 | 0 | SStream_concat0(O, RegName); \ | 978 | 0 | return; \ | 979 | 0 | } \ | 980 | 2.43k | *Dot = '\0'; /* Split string */ \ | 981 | 2.43k | char *Suffix = Dot + 1; \ | 982 | 2.43k | SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \ | 983 | 2.43k | SStream_concat1(O, '.'); \ | 984 | 2.43k | SStream_concat0(O, Suffix); \ | 985 | 2.43k | cs_mem_free(Base); \ | 986 | 2.43k | } |
|
987 | | DEFINE_printMatrixTileVector(0); |
988 | | DEFINE_printMatrixTileVector(1); |
989 | | |
990 | | void printMatrixTile(MCInst *MI, unsigned OpNum, SStream *O) |
991 | 1.53k | { |
992 | 1.53k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MatrixTile, OpNum); |
993 | 1.53k | MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); |
994 | | |
995 | 1.53k | printRegName(O, MCOperand_getReg(RegOp)); |
996 | 1.53k | } |
997 | | |
998 | | void printSVCROp(MCInst *MI, unsigned OpNum, SStream *O) |
999 | 0 | { |
1000 | 0 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SVCROp, OpNum); |
1001 | 0 | MCOperand *MO = MCInst_getOperand(MI, (OpNum)); |
1002 | |
|
1003 | 0 | unsigned svcrop = MCOperand_getImm(MO); |
1004 | 0 | const AArch64SVCR_SVCR *SVCR = AArch64SVCR_lookupSVCRByEncoding(svcrop); |
1005 | |
|
1006 | 0 | SStream_concat0(O, SVCR->Name); |
1007 | 0 | } |
1008 | | |
1009 | | void printOperand(MCInst *MI, unsigned OpNo, SStream *O) |
1010 | 328k | { |
1011 | 328k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Operand, OpNo); |
1012 | 328k | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); |
1013 | 328k | if (MCOperand_isReg(Op)) { |
1014 | 283k | unsigned Reg = MCOperand_getReg(Op); |
1015 | 283k | printRegName(O, Reg); |
1016 | 283k | } else if (MCOperand_isImm(Op)) { |
1017 | 45.1k | Op = MCInst_getOperand(MI, (OpNo)); |
1018 | 45.1k | SStream_concat(O, "%s", markup("<imm:")); |
1019 | 45.1k | printInt64Bang(O, MCOperand_getImm(Op)); |
1020 | 45.1k | SStream_concat0(O, markup(">")); |
1021 | 45.1k | } else { |
1022 | 0 | printUInt64Bang(O, MCInst_getOpVal(MI, OpNo)); |
1023 | 0 | } |
1024 | 328k | } |
1025 | | |
1026 | | void printImm(MCInst *MI, unsigned OpNo, SStream *O) |
1027 | 4.70k | { |
1028 | 4.70k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Imm, OpNo); |
1029 | 4.70k | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); |
1030 | 4.70k | SStream_concat(O, "%s", markup("<imm:")); |
1031 | 4.70k | printInt64Bang(O, MCOperand_getImm(Op)); |
1032 | 4.70k | SStream_concat0(O, markup(">")); |
1033 | 4.70k | } |
1034 | | |
1035 | | void printImmHex(MCInst *MI, unsigned OpNo, SStream *O) |
1036 | 98 | { |
1037 | 98 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ImmHex, OpNo); |
1038 | 98 | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); |
1039 | 98 | SStream_concat(O, "%s", markup("<imm:")); |
1040 | 98 | printInt64Bang(O, MCOperand_getImm(Op)); |
1041 | 98 | SStream_concat0(O, markup(">")); |
1042 | 98 | } |
1043 | | |
1044 | | #define DEFINE_printSImm(Size) \ |
1045 | | void CONCAT(printSImm, Size)(MCInst * MI, unsigned OpNo, SStream *O) \ |
1046 | 1.40k | { \ |
1047 | 1.40k | AArch64_add_cs_detail_1( \ |
1048 | 1.40k | MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \ |
1049 | 1.40k | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \ |
1050 | 1.40k | if (Size == 8) { \ |
1051 | 699 | SStream_concat(O, "%s", markup("<imm:")); \ |
1052 | 699 | printInt32Bang(O, MCOperand_getImm(Op)); \ |
1053 | 699 | SStream_concat0(O, markup(">")); \ |
1054 | 706 | } else if (Size == 16) { \ |
1055 | 706 | SStream_concat(O, "%s", markup("<imm:")); \ |
1056 | 706 | printInt32Bang(O, MCOperand_getImm(Op)); \ |
1057 | 706 | SStream_concat0(O, markup(">")); \ |
1058 | 706 | } else { \ |
1059 | 0 | SStream_concat(O, "%s", markup("<imm:")); \ |
1060 | 0 | printInt64Bang(O, MCOperand_getImm(Op)); \ |
1061 | 0 | SStream_concat0(O, markup(">")); \ |
1062 | 0 | } \ |
1063 | 1.40k | } Line | Count | Source | 1046 | 706 | { \ | 1047 | 706 | AArch64_add_cs_detail_1( \ | 1048 | 706 | MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \ | 1049 | 706 | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \ | 1050 | 706 | if (Size == 8) { \ | 1051 | 0 | SStream_concat(O, "%s", markup("<imm:")); \ | 1052 | 0 | printInt32Bang(O, MCOperand_getImm(Op)); \ | 1053 | 0 | SStream_concat0(O, markup(">")); \ | 1054 | 706 | } else if (Size == 16) { \ | 1055 | 706 | SStream_concat(O, "%s", markup("<imm:")); \ | 1056 | 706 | printInt32Bang(O, MCOperand_getImm(Op)); \ | 1057 | 706 | SStream_concat0(O, markup(">")); \ | 1058 | 706 | } else { \ | 1059 | 0 | SStream_concat(O, "%s", markup("<imm:")); \ | 1060 | 0 | printInt64Bang(O, MCOperand_getImm(Op)); \ | 1061 | 0 | SStream_concat0(O, markup(">")); \ | 1062 | 0 | } \ | 1063 | 706 | } |
Line | Count | Source | 1046 | 699 | { \ | 1047 | 699 | AArch64_add_cs_detail_1( \ | 1048 | 699 | MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \ | 1049 | 699 | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \ | 1050 | 699 | if (Size == 8) { \ | 1051 | 699 | SStream_concat(O, "%s", markup("<imm:")); \ | 1052 | 699 | printInt32Bang(O, MCOperand_getImm(Op)); \ | 1053 | 699 | SStream_concat0(O, markup(">")); \ | 1054 | 699 | } else if (Size == 16) { \ | 1055 | 0 | SStream_concat(O, "%s", markup("<imm:")); \ | 1056 | 0 | printInt32Bang(O, MCOperand_getImm(Op)); \ | 1057 | 0 | SStream_concat0(O, markup(">")); \ | 1058 | 0 | } else { \ | 1059 | 0 | SStream_concat(O, "%s", markup("<imm:")); \ | 1060 | 0 | printInt64Bang(O, MCOperand_getImm(Op)); \ | 1061 | 0 | SStream_concat0(O, markup(">")); \ | 1062 | 0 | } \ | 1063 | 699 | } |
|
1064 | | DEFINE_printSImm(16); |
1065 | | DEFINE_printSImm(8); |
1066 | | |
1067 | | void printPostIncOperand(MCInst *MI, unsigned OpNo, unsigned Imm, SStream *O) |
1068 | 7.39k | { |
1069 | 7.39k | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); |
1070 | 7.39k | if (MCOperand_isReg(Op)) { |
1071 | 7.39k | unsigned Reg = MCOperand_getReg(Op); |
1072 | 7.39k | if (Reg == AArch64_XZR) { |
1073 | 0 | SStream_concat(O, "%s", markup("<imm:")); |
1074 | 0 | printUInt64Bang(O, Imm); |
1075 | 0 | SStream_concat0(O, markup(">")); |
1076 | 0 | } else |
1077 | 7.39k | printRegName(O, Reg); |
1078 | 7.39k | } else |
1079 | 0 | CS_ASSERT_RET(0 && |
1080 | 7.39k | "unknown operand kind in printPostIncOperand64"); |
1081 | 7.39k | } |
1082 | | |
1083 | | void printVRegOperand(MCInst *MI, unsigned OpNo, SStream *O) |
1084 | 63.2k | { |
1085 | 63.2k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_VRegOperand, OpNo); |
1086 | 63.2k | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); |
1087 | | |
1088 | 63.2k | unsigned Reg = MCOperand_getReg(Op); |
1089 | 63.2k | printRegNameAlt(O, Reg, AArch64_vreg); |
1090 | 63.2k | } |
1091 | | |
1092 | | void printSysCROperand(MCInst *MI, unsigned OpNo, SStream *O) |
1093 | 6.08k | { |
1094 | 6.08k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SysCROperand, OpNo); |
1095 | 6.08k | MCOperand *Op = MCInst_getOperand(MI, (OpNo)); |
1096 | | |
1097 | 6.08k | SStream_concat(O, "%s", "c"); |
1098 | 6.08k | printUInt32(O, MCOperand_getImm(Op)); |
1099 | 6.08k | SStream_concat1(O, '\0'); |
1100 | 6.08k | } |
1101 | | |
1102 | | void printAddSubImm(MCInst *MI, unsigned OpNum, SStream *O) |
1103 | 2.71k | { |
1104 | 2.71k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AddSubImm, OpNum); |
1105 | 2.71k | MCOperand *MO = MCInst_getOperand(MI, (OpNum)); |
1106 | 2.71k | if (MCOperand_isImm(MO)) { |
1107 | 2.71k | unsigned Val = (MCOperand_getImm(MO) & 0xfff); |
1108 | | |
1109 | 2.71k | unsigned Shift = AArch64_AM_getShiftValue( |
1110 | 2.71k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1)))); |
1111 | 2.71k | SStream_concat(O, "%s", markup("<imm:")); |
1112 | 2.71k | printUInt32Bang(O, (Val)); |
1113 | 2.71k | SStream_concat0(O, markup(">")); |
1114 | 2.71k | if (Shift != 0) { |
1115 | 589 | printShifter(MI, OpNum + 1, O); |
1116 | 589 | } |
1117 | 2.71k | } else { |
1118 | 0 | printShifter(MI, OpNum + 1, O); |
1119 | 0 | } |
1120 | 2.71k | } |
1121 | | |
1122 | | #define DEFINE_printLogicalImm(T) \ |
1123 | | void CONCAT(printLogicalImm, T)(MCInst * MI, unsigned OpNum, \ |
1124 | | SStream *O) \ |
1125 | 6.22k | { \ |
1126 | 6.22k | AArch64_add_cs_detail_1( \ |
1127 | 6.22k | MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \ |
1128 | 6.22k | sizeof(T)); \ |
1129 | 6.22k | uint64_t Val = \ |
1130 | 6.22k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ |
1131 | 6.22k | SStream_concat(O, "%s", markup("<imm:")); \ |
1132 | 6.22k | printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \ |
1133 | 6.22k | Val, 8 * sizeof(T)))); \ |
1134 | 6.22k | SStream_concat0(O, markup(">")); \ |
1135 | 6.22k | } Line | Count | Source | 1125 | 2.26k | { \ | 1126 | 2.26k | AArch64_add_cs_detail_1( \ | 1127 | 2.26k | MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \ | 1128 | 2.26k | sizeof(T)); \ | 1129 | 2.26k | uint64_t Val = \ | 1130 | 2.26k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 1131 | 2.26k | SStream_concat(O, "%s", markup("<imm:")); \ | 1132 | 2.26k | printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \ | 1133 | 2.26k | Val, 8 * sizeof(T)))); \ | 1134 | 2.26k | SStream_concat0(O, markup(">")); \ | 1135 | 2.26k | } |
Line | Count | Source | 1125 | 1.50k | { \ | 1126 | 1.50k | AArch64_add_cs_detail_1( \ | 1127 | 1.50k | MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \ | 1128 | 1.50k | sizeof(T)); \ | 1129 | 1.50k | uint64_t Val = \ | 1130 | 1.50k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 1131 | 1.50k | SStream_concat(O, "%s", markup("<imm:")); \ | 1132 | 1.50k | printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \ | 1133 | 1.50k | Val, 8 * sizeof(T)))); \ | 1134 | 1.50k | SStream_concat0(O, markup(">")); \ | 1135 | 1.50k | } |
Line | Count | Source | 1125 | 1.43k | { \ | 1126 | 1.43k | AArch64_add_cs_detail_1( \ | 1127 | 1.43k | MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \ | 1128 | 1.43k | sizeof(T)); \ | 1129 | 1.43k | uint64_t Val = \ | 1130 | 1.43k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 1131 | 1.43k | SStream_concat(O, "%s", markup("<imm:")); \ | 1132 | 1.43k | printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \ | 1133 | 1.43k | Val, 8 * sizeof(T)))); \ | 1134 | 1.43k | SStream_concat0(O, markup(">")); \ | 1135 | 1.43k | } |
Line | Count | Source | 1125 | 1.01k | { \ | 1126 | 1.01k | AArch64_add_cs_detail_1( \ | 1127 | 1.01k | MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \ | 1128 | 1.01k | sizeof(T)); \ | 1129 | 1.01k | uint64_t Val = \ | 1130 | 1.01k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 1131 | 1.01k | SStream_concat(O, "%s", markup("<imm:")); \ | 1132 | 1.01k | printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \ | 1133 | 1.01k | Val, 8 * sizeof(T)))); \ | 1134 | 1.01k | SStream_concat0(O, markup(">")); \ | 1135 | 1.01k | } |
|
1136 | | DEFINE_printLogicalImm(int64_t); |
1137 | | DEFINE_printLogicalImm(int32_t); |
1138 | | DEFINE_printLogicalImm(int8_t); |
1139 | | DEFINE_printLogicalImm(int16_t); |
1140 | | |
1141 | | void printShifter(MCInst *MI, unsigned OpNum, SStream *O) |
1142 | 9.84k | { |
1143 | 9.84k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Shifter, OpNum); |
1144 | 9.84k | unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); |
1145 | | // LSL #0 should not be printed. |
1146 | 9.84k | if (AArch64_AM_getShiftType(Val) == AArch64_AM_LSL && |
1147 | 5.13k | AArch64_AM_getShiftValue(Val) == 0) |
1148 | 599 | return; |
1149 | 9.24k | SStream_concat( |
1150 | 9.24k | O, "%s%s%s%s#%u", ", ", |
1151 | 9.24k | AArch64_AM_getShiftExtendName(AArch64_AM_getShiftType(Val)), |
1152 | 9.24k | " ", markup("<imm:"), AArch64_AM_getShiftValue(Val)); |
1153 | 9.24k | SStream_concat0(O, markup(">")); |
1154 | 9.24k | } |
1155 | | |
1156 | | void printShiftedRegister(MCInst *MI, unsigned OpNum, SStream *O) |
1157 | 6.21k | { |
1158 | 6.21k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ShiftedRegister, OpNum); |
1159 | 6.21k | printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum)))); |
1160 | 6.21k | printShifter(MI, OpNum + 1, O); |
1161 | 6.21k | } |
1162 | | |
1163 | | void printExtendedRegister(MCInst *MI, unsigned OpNum, SStream *O) |
1164 | 1.78k | { |
1165 | 1.78k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ExtendedRegister, OpNum); |
1166 | 1.78k | printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum)))); |
1167 | 1.78k | printArithExtend(MI, OpNum + 1, O); |
1168 | 1.78k | } |
1169 | | |
1170 | | void printArithExtend(MCInst *MI, unsigned OpNum, SStream *O) |
1171 | 3.35k | { |
1172 | 3.35k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ArithExtend, OpNum); |
1173 | 3.35k | unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); |
1174 | 3.35k | AArch64_AM_ShiftExtendType ExtType = AArch64_AM_getArithExtendType(Val); |
1175 | 3.35k | unsigned ShiftVal = AArch64_AM_getArithShiftValue(Val); |
1176 | | |
1177 | | // If the destination or first source register operand is [W]SP, print |
1178 | | // UXTW/UXTX as LSL, and if the shift amount is also zero, print nothing at |
1179 | | // all. |
1180 | 3.35k | if (ExtType == AArch64_AM_UXTW || ExtType == AArch64_AM_UXTX) { |
1181 | 1.64k | unsigned Dest = MCOperand_getReg(MCInst_getOperand(MI, (0))); |
1182 | 1.64k | unsigned Src1 = MCOperand_getReg(MCInst_getOperand(MI, (1))); |
1183 | 1.64k | if (((Dest == AArch64_SP || Src1 == AArch64_SP) && |
1184 | 444 | ExtType == AArch64_AM_UXTX) || |
1185 | 1.21k | ((Dest == AArch64_WSP || Src1 == AArch64_WSP) && |
1186 | 513 | ExtType == AArch64_AM_UXTW)) { |
1187 | 513 | if (ShiftVal != 0) { |
1188 | 513 | SStream_concat(O, "%s%s", ", lsl ", |
1189 | 513 | markup("<imm:")); |
1190 | 513 | printUInt32Bang(O, ShiftVal); |
1191 | 513 | SStream_concat0(O, markup(">")); |
1192 | 513 | } |
1193 | 513 | return; |
1194 | 513 | } |
1195 | 1.64k | } |
1196 | 2.84k | SStream_concat(O, "%s", ", "); |
1197 | 2.84k | SStream_concat0(O, AArch64_AM_getShiftExtendName(ExtType)); |
1198 | 2.84k | if (ShiftVal != 0) { |
1199 | 2.08k | SStream_concat(O, "%s%s#%d", " ", markup("<imm:"), ShiftVal); |
1200 | 2.08k | SStream_concat0(O, markup(">")); |
1201 | 2.08k | } |
1202 | 2.84k | } |
1203 | | |
1204 | | static void printMemExtendImpl(bool SignExtend, bool DoShift, unsigned Width, |
1205 | | char SrcRegKind, SStream *O, bool getUseMarkup) |
1206 | 14.2k | { |
1207 | | // sxtw, sxtx, uxtw or lsl (== uxtx) |
1208 | 14.2k | bool IsLSL = !SignExtend && SrcRegKind == 'x'; |
1209 | 14.2k | if (IsLSL) |
1210 | 6.22k | SStream_concat0(O, "lsl"); |
1211 | 8.03k | else { |
1212 | 8.03k | SStream_concat(O, "%c%s", (SignExtend ? 's' : 'u'), "xt"); |
1213 | 8.03k | SStream_concat1(O, SrcRegKind); |
1214 | 8.03k | } |
1215 | | |
1216 | 14.2k | if (DoShift || IsLSL) { |
1217 | 11.5k | SStream_concat0(O, " "); |
1218 | 11.5k | if (getUseMarkup) |
1219 | 0 | SStream_concat0(O, "<imm:"); |
1220 | 11.5k | unsigned ShiftAmount = DoShift ? Log2_32(Width / 8) : 0; |
1221 | 11.5k | SStream_concat(O, "%s%u", "#", ShiftAmount); |
1222 | 11.5k | if (getUseMarkup) |
1223 | 0 | SStream_concat0(O, ">"); |
1224 | 11.5k | } |
1225 | 14.2k | } |
1226 | | |
1227 | | void printMemExtend(MCInst *MI, unsigned OpNum, SStream *O, char SrcRegKind, |
1228 | | unsigned Width) |
1229 | 2.38k | { |
1230 | 2.38k | bool SignExtend = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); |
1231 | 2.38k | bool DoShift = MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); |
1232 | 2.38k | printMemExtendImpl(SignExtend, DoShift, Width, SrcRegKind, O, |
1233 | 2.38k | getUseMarkup()); |
1234 | 2.38k | } |
1235 | | |
1236 | | #define DEFINE_printRegWithShiftExtend(SignExtend, ExtWidth, SrcRegKind, \ |
1237 | | Suffix) \ |
1238 | | void CONCAT(printRegWithShiftExtend, \ |
1239 | | CONCAT(SignExtend, \ |
1240 | | CONCAT(ExtWidth, CONCAT(SrcRegKind, Suffix))))( \ |
1241 | | MCInst * MI, unsigned OpNum, SStream *O) \ |
1242 | 15.1k | { \ |
1243 | 15.1k | AArch64_add_cs_detail_4( \ |
1244 | 15.1k | MI, \ |
1245 | 15.1k | CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \ |
1246 | 15.1k | SignExtend), \ |
1247 | 15.1k | ExtWidth), \ |
1248 | 15.1k | SrcRegKind), \ |
1249 | 15.1k | Suffix), \ |
1250 | 15.1k | OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \ |
1251 | 15.1k | CHAR(Suffix)); \ |
1252 | 15.1k | printOperand(MI, OpNum, O); \ |
1253 | 15.1k | if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \ |
1254 | 9.39k | SStream_concat1(O, '.'); \ |
1255 | 9.39k | SStream_concat1(O, CHAR(Suffix)); \ |
1256 | 9.39k | SStream_concat1(O, '\0'); \ |
1257 | 9.39k | } else \ |
1258 | 15.1k | CS_ASSERT_RET((CHAR(Suffix) == '0') && \ |
1259 | 15.1k | "Unsupported suffix size"); \ |
1260 | 15.1k | bool DoShift = ExtWidth != 8; \ |
1261 | 15.1k | if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \ |
1262 | 11.8k | SStream_concat0(O, ", "); \ |
1263 | 11.8k | printMemExtendImpl(SignExtend, DoShift, ExtWidth, \ |
1264 | 11.8k | CHAR(SrcRegKind), O, \ |
1265 | 11.8k | getUseMarkup()); \ |
1266 | 11.8k | } \ |
1267 | 15.1k | } |
1268 | 1.26k | DEFINE_printRegWithShiftExtend(false, 8, x, d); |
1269 | 788 | DEFINE_printRegWithShiftExtend(true, 8, w, d); |
1270 | 689 | DEFINE_printRegWithShiftExtend(false, 8, w, d); |
1271 | 1.98k | DEFINE_printRegWithShiftExtend(false, 8, x, 0); |
1272 | 484 | DEFINE_printRegWithShiftExtend(true, 8, w, s); |
1273 | 296 | DEFINE_printRegWithShiftExtend(false, 8, w, s); |
1274 | 810 | DEFINE_printRegWithShiftExtend(false, 64, x, d); |
1275 | 677 | DEFINE_printRegWithShiftExtend(true, 64, w, d); |
1276 | 955 | DEFINE_printRegWithShiftExtend(false, 64, w, d); |
1277 | 1.05k | DEFINE_printRegWithShiftExtend(false, 64, x, 0); |
1278 | 272 | DEFINE_printRegWithShiftExtend(true, 64, w, s); |
1279 | 33 | DEFINE_printRegWithShiftExtend(false, 64, w, s); |
1280 | 184 | DEFINE_printRegWithShiftExtend(false, 16, x, d); |
1281 | 490 | DEFINE_printRegWithShiftExtend(true, 16, w, d); |
1282 | 601 | DEFINE_printRegWithShiftExtend(false, 16, w, d); |
1283 | 1.31k | DEFINE_printRegWithShiftExtend(false, 16, x, 0); |
1284 | 78 | DEFINE_printRegWithShiftExtend(true, 16, w, s); |
1285 | 188 | DEFINE_printRegWithShiftExtend(false, 16, w, s); |
1286 | 370 | DEFINE_printRegWithShiftExtend(false, 32, x, d); |
1287 | 318 | DEFINE_printRegWithShiftExtend(true, 32, w, d); |
1288 | 424 | DEFINE_printRegWithShiftExtend(false, 32, w, d); |
1289 | 1.04k | DEFINE_printRegWithShiftExtend(false, 32, x, 0); |
1290 | 195 | DEFINE_printRegWithShiftExtend(true, 32, w, s); |
1291 | 150 | DEFINE_printRegWithShiftExtend(false, 32, w, s); |
1292 | 31 | DEFINE_printRegWithShiftExtend(false, 8, x, s); |
1293 | 52 | DEFINE_printRegWithShiftExtend(false, 16, x, s); |
1294 | 25 | DEFINE_printRegWithShiftExtend(false, 32, x, s); |
1295 | 26 | DEFINE_printRegWithShiftExtend(false, 64, x, s); |
1296 | 365 | DEFINE_printRegWithShiftExtend(false, 128, x, 0); |
1297 | | |
1298 | | #define DEFINE_printPredicateAsCounter(EltSize) \ |
1299 | | void CONCAT(printPredicateAsCounter, \ |
1300 | | EltSize)(MCInst * MI, unsigned OpNum, SStream *O) \ |
1301 | 5.02k | { \ |
1302 | 5.02k | AArch64_add_cs_detail_1( \ |
1303 | 5.02k | MI, \ |
1304 | 5.02k | CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \ |
1305 | 5.02k | OpNum, EltSize); \ |
1306 | 5.02k | unsigned Reg = \ |
1307 | 5.02k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ |
1308 | 5.02k | if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \ |
1309 | 5.02k | CS_ASSERT_RET( \ |
1310 | 5.02k | 0 && \ |
1311 | 5.02k | "Unsupported predicate-as-counter register"); \ |
1312 | 5.02k | SStream_concat(O, "%s", "pn"); \ |
1313 | 5.02k | SStream_concat(O, "%u", (Reg - AArch64_PN0)); \ |
1314 | 5.02k | switch (EltSize) { \ |
1315 | 3.99k | case 0: \ |
1316 | 3.99k | break; \ |
1317 | 108 | case 8: \ |
1318 | 108 | SStream_concat0(O, ".b"); \ |
1319 | 108 | break; \ |
1320 | 95 | case 16: \ |
1321 | 95 | SStream_concat0(O, ".h"); \ |
1322 | 95 | break; \ |
1323 | 132 | case 32: \ |
1324 | 132 | SStream_concat0(O, ".s"); \ |
1325 | 132 | break; \ |
1326 | 690 | case 64: \ |
1327 | 690 | SStream_concat0(O, ".d"); \ |
1328 | 690 | break; \ |
1329 | 0 | default: \ |
1330 | 0 | CS_ASSERT_RET(0 && "Unsupported element size"); \ |
1331 | 5.02k | } \ |
1332 | 5.02k | } printPredicateAsCounter_8 Line | Count | Source | 1301 | 108 | { \ | 1302 | 108 | AArch64_add_cs_detail_1( \ | 1303 | 108 | MI, \ | 1304 | 108 | CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \ | 1305 | 108 | OpNum, EltSize); \ | 1306 | 108 | unsigned Reg = \ | 1307 | 108 | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 1308 | 108 | if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \ | 1309 | 108 | CS_ASSERT_RET( \ | 1310 | 108 | 0 && \ | 1311 | 108 | "Unsupported predicate-as-counter register"); \ | 1312 | 108 | SStream_concat(O, "%s", "pn"); \ | 1313 | 108 | SStream_concat(O, "%u", (Reg - AArch64_PN0)); \ | 1314 | 108 | switch (EltSize) { \ | 1315 | 0 | case 0: \ | 1316 | 0 | break; \ | 1317 | 108 | case 8: \ | 1318 | 108 | SStream_concat0(O, ".b"); \ | 1319 | 108 | break; \ | 1320 | 0 | case 16: \ | 1321 | 0 | SStream_concat0(O, ".h"); \ | 1322 | 0 | break; \ | 1323 | 0 | case 32: \ | 1324 | 0 | SStream_concat0(O, ".s"); \ | 1325 | 0 | break; \ | 1326 | 0 | case 64: \ | 1327 | 0 | SStream_concat0(O, ".d"); \ | 1328 | 0 | break; \ | 1329 | 0 | default: \ | 1330 | 0 | CS_ASSERT_RET(0 && "Unsupported element size"); \ | 1331 | 108 | } \ | 1332 | 108 | } |
printPredicateAsCounter_64 Line | Count | Source | 1301 | 690 | { \ | 1302 | 690 | AArch64_add_cs_detail_1( \ | 1303 | 690 | MI, \ | 1304 | 690 | CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \ | 1305 | 690 | OpNum, EltSize); \ | 1306 | 690 | unsigned Reg = \ | 1307 | 690 | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 1308 | 690 | if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \ | 1309 | 690 | CS_ASSERT_RET( \ | 1310 | 690 | 0 && \ | 1311 | 690 | "Unsupported predicate-as-counter register"); \ | 1312 | 690 | SStream_concat(O, "%s", "pn"); \ | 1313 | 690 | SStream_concat(O, "%u", (Reg - AArch64_PN0)); \ | 1314 | 690 | switch (EltSize) { \ | 1315 | 0 | case 0: \ | 1316 | 0 | break; \ | 1317 | 0 | case 8: \ | 1318 | 0 | SStream_concat0(O, ".b"); \ | 1319 | 0 | break; \ | 1320 | 0 | case 16: \ | 1321 | 0 | SStream_concat0(O, ".h"); \ | 1322 | 0 | break; \ | 1323 | 0 | case 32: \ | 1324 | 0 | SStream_concat0(O, ".s"); \ | 1325 | 0 | break; \ | 1326 | 690 | case 64: \ | 1327 | 690 | SStream_concat0(O, ".d"); \ | 1328 | 690 | break; \ | 1329 | 0 | default: \ | 1330 | 0 | CS_ASSERT_RET(0 && "Unsupported element size"); \ | 1331 | 690 | } \ | 1332 | 690 | } |
printPredicateAsCounter_16 Line | Count | Source | 1301 | 95 | { \ | 1302 | 95 | AArch64_add_cs_detail_1( \ | 1303 | 95 | MI, \ | 1304 | 95 | CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \ | 1305 | 95 | OpNum, EltSize); \ | 1306 | 95 | unsigned Reg = \ | 1307 | 95 | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 1308 | 95 | if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \ | 1309 | 95 | CS_ASSERT_RET( \ | 1310 | 95 | 0 && \ | 1311 | 95 | "Unsupported predicate-as-counter register"); \ | 1312 | 95 | SStream_concat(O, "%s", "pn"); \ | 1313 | 95 | SStream_concat(O, "%u", (Reg - AArch64_PN0)); \ | 1314 | 95 | switch (EltSize) { \ | 1315 | 0 | case 0: \ | 1316 | 0 | break; \ | 1317 | 0 | case 8: \ | 1318 | 0 | SStream_concat0(O, ".b"); \ | 1319 | 0 | break; \ | 1320 | 95 | case 16: \ | 1321 | 95 | SStream_concat0(O, ".h"); \ | 1322 | 95 | break; \ | 1323 | 0 | case 32: \ | 1324 | 0 | SStream_concat0(O, ".s"); \ | 1325 | 0 | break; \ | 1326 | 0 | case 64: \ | 1327 | 0 | SStream_concat0(O, ".d"); \ | 1328 | 0 | break; \ | 1329 | 0 | default: \ | 1330 | 0 | CS_ASSERT_RET(0 && "Unsupported element size"); \ | 1331 | 95 | } \ | 1332 | 95 | } |
printPredicateAsCounter_32 Line | Count | Source | 1301 | 132 | { \ | 1302 | 132 | AArch64_add_cs_detail_1( \ | 1303 | 132 | MI, \ | 1304 | 132 | CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \ | 1305 | 132 | OpNum, EltSize); \ | 1306 | 132 | unsigned Reg = \ | 1307 | 132 | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 1308 | 132 | if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \ | 1309 | 132 | CS_ASSERT_RET( \ | 1310 | 132 | 0 && \ | 1311 | 132 | "Unsupported predicate-as-counter register"); \ | 1312 | 132 | SStream_concat(O, "%s", "pn"); \ | 1313 | 132 | SStream_concat(O, "%u", (Reg - AArch64_PN0)); \ | 1314 | 132 | switch (EltSize) { \ | 1315 | 0 | case 0: \ | 1316 | 0 | break; \ | 1317 | 0 | case 8: \ | 1318 | 0 | SStream_concat0(O, ".b"); \ | 1319 | 0 | break; \ | 1320 | 0 | case 16: \ | 1321 | 0 | SStream_concat0(O, ".h"); \ | 1322 | 0 | break; \ | 1323 | 132 | case 32: \ | 1324 | 132 | SStream_concat0(O, ".s"); \ | 1325 | 132 | break; \ | 1326 | 0 | case 64: \ | 1327 | 0 | SStream_concat0(O, ".d"); \ | 1328 | 0 | break; \ | 1329 | 0 | default: \ | 1330 | 0 | CS_ASSERT_RET(0 && "Unsupported element size"); \ | 1331 | 132 | } \ | 1332 | 132 | } |
printPredicateAsCounter_0 Line | Count | Source | 1301 | 3.99k | { \ | 1302 | 3.99k | AArch64_add_cs_detail_1( \ | 1303 | 3.99k | MI, \ | 1304 | 3.99k | CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \ | 1305 | 3.99k | OpNum, EltSize); \ | 1306 | 3.99k | unsigned Reg = \ | 1307 | 3.99k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 1308 | 3.99k | if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \ | 1309 | 3.99k | CS_ASSERT_RET( \ | 1310 | 3.99k | 0 && \ | 1311 | 3.99k | "Unsupported predicate-as-counter register"); \ | 1312 | 3.99k | SStream_concat(O, "%s", "pn"); \ | 1313 | 3.99k | SStream_concat(O, "%u", (Reg - AArch64_PN0)); \ | 1314 | 3.99k | switch (EltSize) { \ | 1315 | 3.99k | case 0: \ | 1316 | 3.99k | break; \ | 1317 | 0 | case 8: \ | 1318 | 0 | SStream_concat0(O, ".b"); \ | 1319 | 0 | break; \ | 1320 | 0 | case 16: \ | 1321 | 0 | SStream_concat0(O, ".h"); \ | 1322 | 0 | break; \ | 1323 | 0 | case 32: \ | 1324 | 0 | SStream_concat0(O, ".s"); \ | 1325 | 0 | break; \ | 1326 | 0 | case 64: \ | 1327 | 0 | SStream_concat0(O, ".d"); \ | 1328 | 0 | break; \ | 1329 | 0 | default: \ | 1330 | 0 | CS_ASSERT_RET(0 && "Unsupported element size"); \ | 1331 | 3.99k | } \ | 1332 | 3.99k | } |
|
1333 | | DEFINE_printPredicateAsCounter(8); |
1334 | | DEFINE_printPredicateAsCounter(64); |
1335 | | DEFINE_printPredicateAsCounter(16); |
1336 | | DEFINE_printPredicateAsCounter(32); |
1337 | | DEFINE_printPredicateAsCounter(0); |
1338 | | |
1339 | | void printCondCode(MCInst *MI, unsigned OpNum, SStream *O) |
1340 | 2.88k | { |
1341 | 2.88k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_CondCode, OpNum); |
1342 | 2.88k | AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm( |
1343 | 2.88k | MCInst_getOperand(MI, (OpNum))); |
1344 | 2.88k | SStream_concat0(O, AArch64CC_getCondCodeName(CC)); |
1345 | 2.88k | } |
1346 | | |
1347 | | void printInverseCondCode(MCInst *MI, unsigned OpNum, SStream *O) |
1348 | 161 | { |
1349 | 161 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_InverseCondCode, OpNum); |
1350 | 161 | AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm( |
1351 | 161 | MCInst_getOperand(MI, (OpNum))); |
1352 | 161 | SStream_concat0(O, AArch64CC_getCondCodeName( |
1353 | 161 | AArch64CC_getInvertedCondCode(CC))); |
1354 | 161 | } |
1355 | | |
1356 | | void printAMNoIndex(MCInst *MI, unsigned OpNum, SStream *O) |
1357 | 0 | { |
1358 | 0 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AMNoIndex, OpNum); |
1359 | 0 | SStream_concat0(O, "["); |
1360 | |
|
1361 | 0 | printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum)))); |
1362 | 0 | SStream_concat0(O, "]"); |
1363 | 0 | } |
1364 | | |
1365 | | #define DEFINE_printImmScale(Scale) \ |
1366 | | void CONCAT(printImmScale, Scale)(MCInst * MI, unsigned OpNum, \ |
1367 | | SStream *O) \ |
1368 | 17.3k | { \ |
1369 | 17.3k | AArch64_add_cs_detail_1( \ |
1370 | 17.3k | MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \ |
1371 | 17.3k | Scale); \ |
1372 | 17.3k | SStream_concat(O, "%s", markup("<imm:")); \ |
1373 | 17.3k | printInt32Bang(O, Scale * MCOperand_getImm(MCInst_getOperand( \ |
1374 | 17.3k | MI, (OpNum)))); \ |
1375 | 17.3k | SStream_concat0(O, markup(">")); \ |
1376 | 17.3k | } Line | Count | Source | 1368 | 4.60k | { \ | 1369 | 4.60k | AArch64_add_cs_detail_1( \ | 1370 | 4.60k | MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \ | 1371 | 4.60k | Scale); \ | 1372 | 4.60k | SStream_concat(O, "%s", markup("<imm:")); \ | 1373 | 4.60k | printInt32Bang(O, Scale * MCOperand_getImm(MCInst_getOperand( \ | 1374 | 4.60k | MI, (OpNum)))); \ | 1375 | 4.60k | SStream_concat0(O, markup(">")); \ | 1376 | 4.60k | } |
Line | Count | Source | 1368 | 1.25k | { \ | 1369 | 1.25k | AArch64_add_cs_detail_1( \ | 1370 | 1.25k | MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \ | 1371 | 1.25k | Scale); \ | 1372 | 1.25k | SStream_concat(O, "%s", markup("<imm:")); \ | 1373 | 1.25k | printInt32Bang(O, Scale * MCOperand_getImm(MCInst_getOperand( \ | 1374 | 1.25k | MI, (OpNum)))); \ | 1375 | 1.25k | SStream_concat0(O, markup(">")); \ | 1376 | 1.25k | } |
Line | Count | Source | 1368 | 6.78k | { \ | 1369 | 6.78k | AArch64_add_cs_detail_1( \ | 1370 | 6.78k | MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \ | 1371 | 6.78k | Scale); \ | 1372 | 6.78k | SStream_concat(O, "%s", markup("<imm:")); \ | 1373 | 6.78k | printInt32Bang(O, Scale * MCOperand_getImm(MCInst_getOperand( \ | 1374 | 6.78k | MI, (OpNum)))); \ | 1375 | 6.78k | SStream_concat0(O, markup(">")); \ | 1376 | 6.78k | } |
Line | Count | Source | 1368 | 3.96k | { \ | 1369 | 3.96k | AArch64_add_cs_detail_1( \ | 1370 | 3.96k | MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \ | 1371 | 3.96k | Scale); \ | 1372 | 3.96k | SStream_concat(O, "%s", markup("<imm:")); \ | 1373 | 3.96k | printInt32Bang(O, Scale * MCOperand_getImm(MCInst_getOperand( \ | 1374 | 3.96k | MI, (OpNum)))); \ | 1375 | 3.96k | SStream_concat0(O, markup(">")); \ | 1376 | 3.96k | } |
Line | Count | Source | 1368 | 65 | { \ | 1369 | 65 | AArch64_add_cs_detail_1( \ | 1370 | 65 | MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \ | 1371 | 65 | Scale); \ | 1372 | 65 | SStream_concat(O, "%s", markup("<imm:")); \ | 1373 | 65 | printInt32Bang(O, Scale * MCOperand_getImm(MCInst_getOperand( \ | 1374 | 65 | MI, (OpNum)))); \ | 1375 | 65 | SStream_concat0(O, markup(">")); \ | 1376 | 65 | } |
Line | Count | Source | 1368 | 665 | { \ | 1369 | 665 | AArch64_add_cs_detail_1( \ | 1370 | 665 | MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \ | 1371 | 665 | Scale); \ | 1372 | 665 | SStream_concat(O, "%s", markup("<imm:")); \ | 1373 | 665 | printInt32Bang(O, Scale * MCOperand_getImm(MCInst_getOperand( \ | 1374 | 665 | MI, (OpNum)))); \ | 1375 | 665 | SStream_concat0(O, markup(">")); \ | 1376 | 665 | } |
|
1377 | | DEFINE_printImmScale(8); |
1378 | | DEFINE_printImmScale(2); |
1379 | | DEFINE_printImmScale(4); |
1380 | | DEFINE_printImmScale(16); |
1381 | | DEFINE_printImmScale(32); |
1382 | | DEFINE_printImmScale(3); |
1383 | | |
1384 | | #define DEFINE_printImmRangeScale(Scale, Offset) \ |
1385 | | void CONCAT(printImmRangeScale, CONCAT(Scale, Offset))( \ |
1386 | | MCInst * MI, unsigned OpNum, SStream *O) \ |
1387 | 4.24k | { \ |
1388 | 4.24k | AArch64_add_cs_detail_2( \ |
1389 | 4.24k | MI, \ |
1390 | 4.24k | CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \ |
1391 | 4.24k | Offset), \ |
1392 | 4.24k | OpNum, Scale, Offset); \ |
1393 | 4.24k | unsigned FirstImm = \ |
1394 | 4.24k | Scale * \ |
1395 | 4.24k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ |
1396 | 4.24k | printUInt32(O, (FirstImm)); \ |
1397 | 4.24k | SStream_concat(O, "%s", ":"); \ |
1398 | 4.24k | printUInt32(O, (FirstImm + Offset)); \ |
1399 | 4.24k | SStream_concat1(O, '\0'); \ |
1400 | 4.24k | } Line | Count | Source | 1387 | 2.14k | { \ | 1388 | 2.14k | AArch64_add_cs_detail_2( \ | 1389 | 2.14k | MI, \ | 1390 | 2.14k | CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \ | 1391 | 2.14k | Offset), \ | 1392 | 2.14k | OpNum, Scale, Offset); \ | 1393 | 2.14k | unsigned FirstImm = \ | 1394 | 2.14k | Scale * \ | 1395 | 2.14k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 1396 | 2.14k | printUInt32(O, (FirstImm)); \ | 1397 | 2.14k | SStream_concat(O, "%s", ":"); \ | 1398 | 2.14k | printUInt32(O, (FirstImm + Offset)); \ | 1399 | 2.14k | SStream_concat1(O, '\0'); \ | 1400 | 2.14k | } |
Line | Count | Source | 1387 | 2.09k | { \ | 1388 | 2.09k | AArch64_add_cs_detail_2( \ | 1389 | 2.09k | MI, \ | 1390 | 2.09k | CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \ | 1391 | 2.09k | Offset), \ | 1392 | 2.09k | OpNum, Scale, Offset); \ | 1393 | 2.09k | unsigned FirstImm = \ | 1394 | 2.09k | Scale * \ | 1395 | 2.09k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 1396 | 2.09k | printUInt32(O, (FirstImm)); \ | 1397 | 2.09k | SStream_concat(O, "%s", ":"); \ | 1398 | 2.09k | printUInt32(O, (FirstImm + Offset)); \ | 1399 | 2.09k | SStream_concat1(O, '\0'); \ | 1400 | 2.09k | } |
|
1401 | | DEFINE_printImmRangeScale(2, 1); |
1402 | | DEFINE_printImmRangeScale(4, 3); |
1403 | | |
1404 | | void printUImm12Offset(MCInst *MI, unsigned OpNum, unsigned Scale, SStream *O) |
1405 | 5.62k | { |
1406 | 5.62k | MCOperand *MO = MCInst_getOperand(MI, (OpNum)); |
1407 | 5.62k | if (MCOperand_isImm(MO)) { |
1408 | 5.62k | SStream_concat(O, "%s", markup("<imm:")); |
1409 | 5.62k | printUInt32Bang(O, (MCOperand_getImm(MO) * Scale)); |
1410 | 5.62k | SStream_concat0(O, markup(">")); |
1411 | 5.62k | } else { |
1412 | 0 | printUInt64Bang(O, MCOperand_getImm(MO)); |
1413 | 0 | } |
1414 | 5.62k | } |
1415 | | |
1416 | | void printAMIndexedWB(MCInst *MI, unsigned OpNum, unsigned Scale, SStream *O) |
1417 | 0 | { |
1418 | 0 | MCOperand *MO1 = MCInst_getOperand(MI, (OpNum + 1)); |
1419 | 0 | SStream_concat0(O, "["); |
1420 | |
|
1421 | 0 | printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum)))); |
1422 | 0 | if (MCOperand_isImm(MO1)) { |
1423 | 0 | SStream_concat(O, "%s%s", ", ", markup("<imm:")); |
1424 | 0 | printUInt32Bang(O, MCOperand_getImm(MO1) * Scale); |
1425 | 0 | SStream_concat0(O, markup(">")); |
1426 | 0 | } else { |
1427 | 0 | printUInt64Bang(O, MCOperand_getImm(MO1)); |
1428 | 0 | } |
1429 | 0 | SStream_concat0(O, "]"); |
1430 | 0 | } |
1431 | | |
1432 | | void printRPRFMOperand(MCInst *MI, unsigned OpNum, SStream *O) |
1433 | 193 | { |
1434 | 193 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_RPRFMOperand, OpNum); |
1435 | 193 | unsigned prfop = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); |
1436 | 193 | const AArch64PRFM_PRFM *PRFM = |
1437 | 193 | AArch64RPRFM_lookupRPRFMByEncoding(prfop); |
1438 | 193 | if (PRFM) { |
1439 | 58 | SStream_concat0(O, PRFM->Name); |
1440 | 58 | return; |
1441 | 58 | } |
1442 | | |
1443 | 135 | printUInt32Bang(O, (prfop)); |
1444 | 135 | SStream_concat1(O, '\0'); |
1445 | 135 | } |
1446 | | |
1447 | | #define DEFINE_printPrefetchOp(IsSVEPrefetch) \ |
1448 | | void CONCAT(printPrefetchOp, \ |
1449 | | IsSVEPrefetch)(MCInst * MI, unsigned OpNum, SStream *O) \ |
1450 | 6.15k | { \ |
1451 | 6.15k | AArch64_add_cs_detail_1(MI, \ |
1452 | 6.15k | CONCAT(AArch64_OP_GROUP_PrefetchOp, \ |
1453 | 6.15k | IsSVEPrefetch), \ |
1454 | 6.15k | OpNum, IsSVEPrefetch); \ |
1455 | 6.15k | unsigned prfop = \ |
1456 | 6.15k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ |
1457 | 6.15k | if (IsSVEPrefetch) { \ |
1458 | 3.79k | const AArch64SVEPRFM_SVEPRFM *PRFM = \ |
1459 | 3.79k | AArch64SVEPRFM_lookupSVEPRFMByEncoding(prfop); \ |
1460 | 3.79k | if (PRFM) { \ |
1461 | 3.49k | SStream_concat0(O, PRFM->Name); \ |
1462 | 3.49k | return; \ |
1463 | 3.49k | } \ |
1464 | 3.79k | } else { \ |
1465 | 2.35k | const AArch64PRFM_PRFM *PRFM = \ |
1466 | 2.35k | AArch64PRFM_lookupPRFMByEncoding(prfop); \ |
1467 | 2.35k | if (PRFM && \ |
1468 | 2.35k | AArch64_testFeatureList(MI->csh->mode, \ |
1469 | 1.50k | PRFM->FeaturesRequired)) { \ |
1470 | 1.50k | SStream_concat0(O, PRFM->Name); \ |
1471 | 1.50k | return; \ |
1472 | 1.50k | } \ |
1473 | 2.35k | } \ |
1474 | 6.15k | \ |
1475 | 6.15k | SStream_concat(O, "%s", markup("<imm:")); \ |
1476 | 1.14k | printUInt32Bang(O, (prfop)); \ |
1477 | 1.14k | SStream_concat0(O, markup(">")); \ |
1478 | 1.14k | } Line | Count | Source | 1450 | 2.35k | { \ | 1451 | 2.35k | AArch64_add_cs_detail_1(MI, \ | 1452 | 2.35k | CONCAT(AArch64_OP_GROUP_PrefetchOp, \ | 1453 | 2.35k | IsSVEPrefetch), \ | 1454 | 2.35k | OpNum, IsSVEPrefetch); \ | 1455 | 2.35k | unsigned prfop = \ | 1456 | 2.35k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 1457 | 2.35k | if (IsSVEPrefetch) { \ | 1458 | 0 | const AArch64SVEPRFM_SVEPRFM *PRFM = \ | 1459 | 0 | AArch64SVEPRFM_lookupSVEPRFMByEncoding(prfop); \ | 1460 | 0 | if (PRFM) { \ | 1461 | 0 | SStream_concat0(O, PRFM->Name); \ | 1462 | 0 | return; \ | 1463 | 0 | } \ | 1464 | 2.35k | } else { \ | 1465 | 2.35k | const AArch64PRFM_PRFM *PRFM = \ | 1466 | 2.35k | AArch64PRFM_lookupPRFMByEncoding(prfop); \ | 1467 | 2.35k | if (PRFM && \ | 1468 | 2.35k | AArch64_testFeatureList(MI->csh->mode, \ | 1469 | 1.50k | PRFM->FeaturesRequired)) { \ | 1470 | 1.50k | SStream_concat0(O, PRFM->Name); \ | 1471 | 1.50k | return; \ | 1472 | 1.50k | } \ | 1473 | 2.35k | } \ | 1474 | 2.35k | \ | 1475 | 2.35k | SStream_concat(O, "%s", markup("<imm:")); \ | 1476 | 849 | printUInt32Bang(O, (prfop)); \ | 1477 | 849 | SStream_concat0(O, markup(">")); \ | 1478 | 849 | } |
Line | Count | Source | 1450 | 3.79k | { \ | 1451 | 3.79k | AArch64_add_cs_detail_1(MI, \ | 1452 | 3.79k | CONCAT(AArch64_OP_GROUP_PrefetchOp, \ | 1453 | 3.79k | IsSVEPrefetch), \ | 1454 | 3.79k | OpNum, IsSVEPrefetch); \ | 1455 | 3.79k | unsigned prfop = \ | 1456 | 3.79k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 1457 | 3.79k | if (IsSVEPrefetch) { \ | 1458 | 3.79k | const AArch64SVEPRFM_SVEPRFM *PRFM = \ | 1459 | 3.79k | AArch64SVEPRFM_lookupSVEPRFMByEncoding(prfop); \ | 1460 | 3.79k | if (PRFM) { \ | 1461 | 3.49k | SStream_concat0(O, PRFM->Name); \ | 1462 | 3.49k | return; \ | 1463 | 3.49k | } \ | 1464 | 3.79k | } else { \ | 1465 | 0 | const AArch64PRFM_PRFM *PRFM = \ | 1466 | 0 | AArch64PRFM_lookupPRFMByEncoding(prfop); \ | 1467 | 0 | if (PRFM && \ | 1468 | 0 | AArch64_testFeatureList(MI->csh->mode, \ | 1469 | 0 | PRFM->FeaturesRequired)) { \ | 1470 | 0 | SStream_concat0(O, PRFM->Name); \ | 1471 | 0 | return; \ | 1472 | 0 | } \ | 1473 | 0 | } \ | 1474 | 3.79k | \ | 1475 | 3.79k | SStream_concat(O, "%s", markup("<imm:")); \ | 1476 | 295 | printUInt32Bang(O, (prfop)); \ | 1477 | 295 | SStream_concat0(O, markup(">")); \ | 1478 | 295 | } |
|
1479 | | DEFINE_printPrefetchOp(false); |
1480 | | DEFINE_printPrefetchOp(true); |
1481 | | |
1482 | | void printPSBHintOp(MCInst *MI, unsigned OpNum, SStream *O) |
1483 | 333 | { |
1484 | 333 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_PSBHintOp, OpNum); |
1485 | 333 | unsigned psbhintop = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); |
1486 | 333 | const AArch64PSBHint_PSB *PSB = |
1487 | 333 | AArch64PSBHint_lookupPSBByEncoding(psbhintop); |
1488 | 333 | if (PSB) |
1489 | 333 | SStream_concat0(O, PSB->Name); |
1490 | 0 | else { |
1491 | 0 | SStream_concat(O, "%s", markup("<imm:")); |
1492 | 0 | SStream_concat1(O, '#'); |
1493 | 0 | printUInt32Bang(O, (psbhintop)); |
1494 | 0 | SStream_concat0(O, markup(">")); |
1495 | 0 | } |
1496 | 333 | } |
1497 | | |
1498 | | void printBTIHintOp(MCInst *MI, unsigned OpNum, SStream *O) |
1499 | 119 | { |
1500 | 119 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BTIHintOp, OpNum); |
1501 | 119 | unsigned btihintop = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))) ^ |
1502 | 119 | 32; |
1503 | 119 | const AArch64BTIHint_BTI *BTI = |
1504 | 119 | AArch64BTIHint_lookupBTIByEncoding(btihintop); |
1505 | 119 | if (BTI) |
1506 | 119 | SStream_concat0(O, BTI->Name); |
1507 | 0 | else { |
1508 | 0 | SStream_concat(O, "%s", markup("<imm:")); |
1509 | 0 | printUInt32Bang(O, (btihintop)); |
1510 | 0 | SStream_concat0(O, markup(">")); |
1511 | 0 | } |
1512 | 119 | } |
1513 | | |
1514 | | static void printFPImmOperand(MCInst *MI, unsigned OpNum, SStream *O) |
1515 | 736 | { |
1516 | 736 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_FPImmOperand, OpNum); |
1517 | 736 | MCOperand *MO = MCInst_getOperand(MI, (OpNum)); |
1518 | 736 | float FPImm = MCOperand_isDFPImm(MO) ? |
1519 | 0 | BitsToDouble(MCOperand_getImm(MO)) : |
1520 | 736 | AArch64_AM_getFPImmFloat(MCOperand_getImm(MO)); |
1521 | | |
1522 | | // 8 decimal places are enough to perfectly represent permitted floats. |
1523 | 736 | SStream_concat(O, "%s", markup("<imm:")); |
1524 | 736 | SStream_concat(O, "#%.8f", FPImm); |
1525 | 736 | SStream_concat0(O, markup(">")); |
1526 | 736 | } |
1527 | | |
1528 | | static unsigned getNextVectorRegister(unsigned Reg, unsigned Stride /* = 1 */) |
1529 | 106k | { |
1530 | 266k | while (Stride--) { |
1531 | 160k | switch (Reg) { |
1532 | 0 | default: |
1533 | 0 | CS_ASSERT_RET_VAL(0 && "Vector register expected!", 0); |
1534 | 5.21k | case AArch64_Q0: |
1535 | 5.21k | Reg = AArch64_Q1; |
1536 | 5.21k | break; |
1537 | 4.25k | case AArch64_Q1: |
1538 | 4.25k | Reg = AArch64_Q2; |
1539 | 4.25k | break; |
1540 | 2.21k | case AArch64_Q2: |
1541 | 2.21k | Reg = AArch64_Q3; |
1542 | 2.21k | break; |
1543 | 1.66k | case AArch64_Q3: |
1544 | 1.66k | Reg = AArch64_Q4; |
1545 | 1.66k | break; |
1546 | 1.64k | case AArch64_Q4: |
1547 | 1.64k | Reg = AArch64_Q5; |
1548 | 1.64k | break; |
1549 | 2.06k | case AArch64_Q5: |
1550 | 2.06k | Reg = AArch64_Q6; |
1551 | 2.06k | break; |
1552 | 948 | case AArch64_Q6: |
1553 | 948 | Reg = AArch64_Q7; |
1554 | 948 | break; |
1555 | 821 | case AArch64_Q7: |
1556 | 821 | Reg = AArch64_Q8; |
1557 | 821 | break; |
1558 | 906 | case AArch64_Q8: |
1559 | 906 | Reg = AArch64_Q9; |
1560 | 906 | break; |
1561 | 1.21k | case AArch64_Q9: |
1562 | 1.21k | Reg = AArch64_Q10; |
1563 | 1.21k | break; |
1564 | 1.48k | case AArch64_Q10: |
1565 | 1.48k | Reg = AArch64_Q11; |
1566 | 1.48k | break; |
1567 | 1.33k | case AArch64_Q11: |
1568 | 1.33k | Reg = AArch64_Q12; |
1569 | 1.33k | break; |
1570 | 2.96k | case AArch64_Q12: |
1571 | 2.96k | Reg = AArch64_Q13; |
1572 | 2.96k | break; |
1573 | 2.46k | case AArch64_Q13: |
1574 | 2.46k | Reg = AArch64_Q14; |
1575 | 2.46k | break; |
1576 | 2.42k | case AArch64_Q14: |
1577 | 2.42k | Reg = AArch64_Q15; |
1578 | 2.42k | break; |
1579 | 509 | case AArch64_Q15: |
1580 | 509 | Reg = AArch64_Q16; |
1581 | 509 | break; |
1582 | 1.20k | case AArch64_Q16: |
1583 | 1.20k | Reg = AArch64_Q17; |
1584 | 1.20k | break; |
1585 | 1.20k | case AArch64_Q17: |
1586 | 1.20k | Reg = AArch64_Q18; |
1587 | 1.20k | break; |
1588 | 1.30k | case AArch64_Q18: |
1589 | 1.30k | Reg = AArch64_Q19; |
1590 | 1.30k | break; |
1591 | 1.91k | case AArch64_Q19: |
1592 | 1.91k | Reg = AArch64_Q20; |
1593 | 1.91k | break; |
1594 | 3.19k | case AArch64_Q20: |
1595 | 3.19k | Reg = AArch64_Q21; |
1596 | 3.19k | break; |
1597 | 2.41k | case AArch64_Q21: |
1598 | 2.41k | Reg = AArch64_Q22; |
1599 | 2.41k | break; |
1600 | 2.69k | case AArch64_Q22: |
1601 | 2.69k | Reg = AArch64_Q23; |
1602 | 2.69k | break; |
1603 | 2.07k | case AArch64_Q23: |
1604 | 2.07k | Reg = AArch64_Q24; |
1605 | 2.07k | break; |
1606 | 2.13k | case AArch64_Q24: |
1607 | 2.13k | Reg = AArch64_Q25; |
1608 | 2.13k | break; |
1609 | 1.81k | case AArch64_Q25: |
1610 | 1.81k | Reg = AArch64_Q26; |
1611 | 1.81k | break; |
1612 | 1.48k | case AArch64_Q26: |
1613 | 1.48k | Reg = AArch64_Q27; |
1614 | 1.48k | break; |
1615 | 655 | case AArch64_Q27: |
1616 | 655 | Reg = AArch64_Q28; |
1617 | 655 | break; |
1618 | 498 | case AArch64_Q28: |
1619 | 498 | Reg = AArch64_Q29; |
1620 | 498 | break; |
1621 | 648 | case AArch64_Q29: |
1622 | 648 | Reg = AArch64_Q30; |
1623 | 648 | break; |
1624 | 451 | case AArch64_Q30: |
1625 | 451 | Reg = AArch64_Q31; |
1626 | 451 | break; |
1627 | | // Vector lists can wrap around. |
1628 | 2.00k | case AArch64_Q31: |
1629 | 2.00k | Reg = AArch64_Q0; |
1630 | 2.00k | break; |
1631 | 8.60k | case AArch64_Z0: |
1632 | 8.60k | Reg = AArch64_Z1; |
1633 | 8.60k | break; |
1634 | 4.97k | case AArch64_Z1: |
1635 | 4.97k | Reg = AArch64_Z2; |
1636 | 4.97k | break; |
1637 | 5.66k | case AArch64_Z2: |
1638 | 5.66k | Reg = AArch64_Z3; |
1639 | 5.66k | break; |
1640 | 2.07k | case AArch64_Z3: |
1641 | 2.07k | Reg = AArch64_Z4; |
1642 | 2.07k | break; |
1643 | 8.03k | case AArch64_Z4: |
1644 | 8.03k | Reg = AArch64_Z5; |
1645 | 8.03k | break; |
1646 | 7.03k | case AArch64_Z5: |
1647 | 7.03k | Reg = AArch64_Z6; |
1648 | 7.03k | break; |
1649 | 5.82k | case AArch64_Z6: |
1650 | 5.82k | Reg = AArch64_Z7; |
1651 | 5.82k | break; |
1652 | 2.48k | case AArch64_Z7: |
1653 | 2.48k | Reg = AArch64_Z8; |
1654 | 2.48k | break; |
1655 | 6.80k | case AArch64_Z8: |
1656 | 6.80k | Reg = AArch64_Z9; |
1657 | 6.80k | break; |
1658 | 4.55k | case AArch64_Z9: |
1659 | 4.55k | Reg = AArch64_Z10; |
1660 | 4.55k | break; |
1661 | 4.69k | case AArch64_Z10: |
1662 | 4.69k | Reg = AArch64_Z11; |
1663 | 4.69k | break; |
1664 | 1.77k | case AArch64_Z11: |
1665 | 1.77k | Reg = AArch64_Z12; |
1666 | 1.77k | break; |
1667 | 2.41k | case AArch64_Z12: |
1668 | 2.41k | Reg = AArch64_Z13; |
1669 | 2.41k | break; |
1670 | 2.21k | case AArch64_Z13: |
1671 | 2.21k | Reg = AArch64_Z14; |
1672 | 2.21k | break; |
1673 | 3.66k | case AArch64_Z14: |
1674 | 3.66k | Reg = AArch64_Z15; |
1675 | 3.66k | break; |
1676 | 1.96k | case AArch64_Z15: |
1677 | 1.96k | Reg = AArch64_Z16; |
1678 | 1.96k | break; |
1679 | 2.22k | case AArch64_Z16: |
1680 | 2.22k | Reg = AArch64_Z17; |
1681 | 2.22k | break; |
1682 | 821 | case AArch64_Z17: |
1683 | 821 | Reg = AArch64_Z18; |
1684 | 821 | break; |
1685 | 1.60k | case AArch64_Z18: |
1686 | 1.60k | Reg = AArch64_Z19; |
1687 | 1.60k | break; |
1688 | 956 | case AArch64_Z19: |
1689 | 956 | Reg = AArch64_Z20; |
1690 | 956 | break; |
1691 | 2.10k | case AArch64_Z20: |
1692 | 2.10k | Reg = AArch64_Z21; |
1693 | 2.10k | break; |
1694 | 2.18k | case AArch64_Z21: |
1695 | 2.18k | Reg = AArch64_Z22; |
1696 | 2.18k | break; |
1697 | 2.60k | case AArch64_Z22: |
1698 | 2.60k | Reg = AArch64_Z23; |
1699 | 2.60k | break; |
1700 | 1.07k | case AArch64_Z23: |
1701 | 1.07k | Reg = AArch64_Z24; |
1702 | 1.07k | break; |
1703 | 2.18k | case AArch64_Z24: |
1704 | 2.18k | Reg = AArch64_Z25; |
1705 | 2.18k | break; |
1706 | 2.21k | case AArch64_Z25: |
1707 | 2.21k | Reg = AArch64_Z26; |
1708 | 2.21k | break; |
1709 | 3.25k | case AArch64_Z26: |
1710 | 3.25k | Reg = AArch64_Z27; |
1711 | 3.25k | break; |
1712 | 1.55k | case AArch64_Z27: |
1713 | 1.55k | Reg = AArch64_Z28; |
1714 | 1.55k | break; |
1715 | 1.96k | case AArch64_Z28: |
1716 | 1.96k | Reg = AArch64_Z29; |
1717 | 1.96k | break; |
1718 | 1.10k | case AArch64_Z29: |
1719 | 1.10k | Reg = AArch64_Z30; |
1720 | 1.10k | break; |
1721 | 1.06k | case AArch64_Z30: |
1722 | 1.06k | Reg = AArch64_Z31; |
1723 | 1.06k | break; |
1724 | | // Vector lists can wrap around. |
1725 | 1.18k | case AArch64_Z31: |
1726 | 1.18k | Reg = AArch64_Z0; |
1727 | 1.18k | break; |
1728 | 60 | case AArch64_P0: |
1729 | 60 | Reg = AArch64_P1; |
1730 | 60 | break; |
1731 | 162 | case AArch64_P1: |
1732 | 162 | Reg = AArch64_P2; |
1733 | 162 | break; |
1734 | 68 | case AArch64_P2: |
1735 | 68 | Reg = AArch64_P3; |
1736 | 68 | break; |
1737 | 18 | case AArch64_P3: |
1738 | 18 | Reg = AArch64_P4; |
1739 | 18 | break; |
1740 | 26 | case AArch64_P4: |
1741 | 26 | Reg = AArch64_P5; |
1742 | 26 | break; |
1743 | 34 | case AArch64_P5: |
1744 | 34 | Reg = AArch64_P6; |
1745 | 34 | break; |
1746 | 80 | case AArch64_P6: |
1747 | 80 | Reg = AArch64_P7; |
1748 | 80 | break; |
1749 | 20 | case AArch64_P7: |
1750 | 20 | Reg = AArch64_P8; |
1751 | 20 | break; |
1752 | 170 | case AArch64_P8: |
1753 | 170 | Reg = AArch64_P9; |
1754 | 170 | break; |
1755 | 82 | case AArch64_P9: |
1756 | 82 | Reg = AArch64_P10; |
1757 | 82 | break; |
1758 | 462 | case AArch64_P10: |
1759 | 462 | Reg = AArch64_P11; |
1760 | 462 | break; |
1761 | 14 | case AArch64_P11: |
1762 | 14 | Reg = AArch64_P12; |
1763 | 14 | break; |
1764 | 32 | case AArch64_P12: |
1765 | 32 | Reg = AArch64_P13; |
1766 | 32 | break; |
1767 | 190 | case AArch64_P13: |
1768 | 190 | Reg = AArch64_P14; |
1769 | 190 | break; |
1770 | 60 | case AArch64_P14: |
1771 | 60 | Reg = AArch64_P15; |
1772 | 60 | break; |
1773 | | // Vector lists can wrap around. |
1774 | 76 | case AArch64_P15: |
1775 | 76 | Reg = AArch64_P0; |
1776 | 76 | break; |
1777 | 160k | } |
1778 | 160k | } |
1779 | 106k | return Reg; |
1780 | 106k | } |
1781 | | |
1782 | | #define DEFINE_printGPRSeqPairsClassOperand(size) \ |
1783 | | void CONCAT(printGPRSeqPairsClassOperand, \ |
1784 | | size)(MCInst * MI, unsigned OpNum, SStream *O) \ |
1785 | 1.88k | { \ |
1786 | 1.88k | AArch64_add_cs_detail_1( \ |
1787 | 1.88k | MI, \ |
1788 | 1.88k | CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \ |
1789 | 1.88k | size), \ |
1790 | 1.88k | OpNum, size); \ |
1791 | 1.88k | CS_ASSERT_RET((size == 64 || size == 32) && \ |
1792 | 1.88k | "Template parameter must be either 32 or 64"); \ |
1793 | 1.88k | unsigned Reg = \ |
1794 | 1.88k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ |
1795 | 1.88k | \ |
1796 | 1.88k | unsigned Sube = (size == 32) ? AArch64_sube32 : \ |
1797 | 1.88k | AArch64_sube64; \ |
1798 | 1.88k | unsigned Subo = (size == 32) ? AArch64_subo32 : \ |
1799 | 1.88k | AArch64_subo64; \ |
1800 | 1.88k | \ |
1801 | 1.88k | unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \ |
1802 | 1.88k | unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \ |
1803 | 1.88k | printRegName(O, Even); \ |
1804 | 1.88k | SStream_concat0(O, ", "); \ |
1805 | 1.88k | printRegName(O, Odd); \ |
1806 | 1.88k | } printGPRSeqPairsClassOperand_32 Line | Count | Source | 1785 | 214 | { \ | 1786 | 214 | AArch64_add_cs_detail_1( \ | 1787 | 214 | MI, \ | 1788 | 214 | CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \ | 1789 | 214 | size), \ | 1790 | 214 | OpNum, size); \ | 1791 | 214 | CS_ASSERT_RET((size == 64 || size == 32) && \ | 1792 | 214 | "Template parameter must be either 32 or 64"); \ | 1793 | 214 | unsigned Reg = \ | 1794 | 214 | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 1795 | 214 | \ | 1796 | 214 | unsigned Sube = (size == 32) ? AArch64_sube32 : \ | 1797 | 214 | AArch64_sube64; \ | 1798 | 214 | unsigned Subo = (size == 32) ? AArch64_subo32 : \ | 1799 | 214 | AArch64_subo64; \ | 1800 | 214 | \ | 1801 | 214 | unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \ | 1802 | 214 | unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \ | 1803 | 214 | printRegName(O, Even); \ | 1804 | 214 | SStream_concat0(O, ", "); \ | 1805 | 214 | printRegName(O, Odd); \ | 1806 | 214 | } |
printGPRSeqPairsClassOperand_64 Line | Count | Source | 1785 | 1.66k | { \ | 1786 | 1.66k | AArch64_add_cs_detail_1( \ | 1787 | 1.66k | MI, \ | 1788 | 1.66k | CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \ | 1789 | 1.66k | size), \ | 1790 | 1.66k | OpNum, size); \ | 1791 | 1.66k | CS_ASSERT_RET((size == 64 || size == 32) && \ | 1792 | 1.66k | "Template parameter must be either 32 or 64"); \ | 1793 | 1.66k | unsigned Reg = \ | 1794 | 1.66k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 1795 | 1.66k | \ | 1796 | 1.66k | unsigned Sube = (size == 32) ? AArch64_sube32 : \ | 1797 | 1.66k | AArch64_sube64; \ | 1798 | 1.66k | unsigned Subo = (size == 32) ? AArch64_subo32 : \ | 1799 | 1.66k | AArch64_subo64; \ | 1800 | 1.66k | \ | 1801 | 1.66k | unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \ | 1802 | 1.66k | unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \ | 1803 | 1.66k | printRegName(O, Even); \ | 1804 | 1.66k | SStream_concat0(O, ", "); \ | 1805 | 1.66k | printRegName(O, Odd); \ | 1806 | 1.66k | } |
|
1807 | | DEFINE_printGPRSeqPairsClassOperand(32); |
1808 | | DEFINE_printGPRSeqPairsClassOperand(64); |
1809 | | |
1810 | | #define DEFINE_printMatrixIndex(Scale) \ |
1811 | | void CONCAT(printMatrixIndex, Scale)(MCInst * MI, unsigned OpNum, \ |
1812 | | SStream *O) \ |
1813 | 7.86k | { \ |
1814 | 7.86k | AArch64_add_cs_detail_1( \ |
1815 | 7.86k | MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \ |
1816 | 7.86k | OpNum, Scale); \ |
1817 | 7.86k | printInt64(O, Scale * MCOperand_getImm(MCInst_getOperand( \ |
1818 | 7.86k | MI, (OpNum)))); \ |
1819 | 7.86k | } Line | Count | Source | 1813 | 238 | { \ | 1814 | 238 | AArch64_add_cs_detail_1( \ | 1815 | 238 | MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \ | 1816 | 238 | OpNum, Scale); \ | 1817 | 238 | printInt64(O, Scale * MCOperand_getImm(MCInst_getOperand( \ | 1818 | 238 | MI, (OpNum)))); \ | 1819 | 238 | } |
Unexecuted instantiation: printMatrixIndex_0 Line | Count | Source | 1813 | 7.62k | { \ | 1814 | 7.62k | AArch64_add_cs_detail_1( \ | 1815 | 7.62k | MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \ | 1816 | 7.62k | OpNum, Scale); \ | 1817 | 7.62k | printInt64(O, Scale * MCOperand_getImm(MCInst_getOperand( \ | 1818 | 7.62k | MI, (OpNum)))); \ | 1819 | 7.62k | } |
|
1820 | | DEFINE_printMatrixIndex(8); |
1821 | | DEFINE_printMatrixIndex(0); |
1822 | | DEFINE_printMatrixIndex(1); |
1823 | | |
1824 | | void printMatrixTileList(MCInst *MI, unsigned OpNum, SStream *O) |
1825 | 425 | { |
1826 | 425 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MatrixTileList, OpNum); |
1827 | 425 | unsigned MaxRegs = 8; |
1828 | 425 | unsigned RegMask = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); |
1829 | | |
1830 | 425 | unsigned NumRegs = 0; |
1831 | 3.82k | for (unsigned I = 0; I < MaxRegs; ++I) |
1832 | 3.40k | if ((RegMask & (1 << I)) != 0) |
1833 | 1.39k | ++NumRegs; |
1834 | | |
1835 | 425 | SStream_concat0(O, "{"); |
1836 | 425 | unsigned Printed = 0; |
1837 | 3.82k | for (unsigned I = 0; I < MaxRegs; ++I) { |
1838 | 3.40k | unsigned Reg = RegMask & (1 << I); |
1839 | 3.40k | if (Reg == 0) |
1840 | 2.01k | continue; |
1841 | 1.39k | printRegName(O, AArch64_ZAD0 + I); |
1842 | 1.39k | if (Printed + 1 != NumRegs) |
1843 | 968 | SStream_concat0(O, ", "); |
1844 | 1.39k | ++Printed; |
1845 | 1.39k | } |
1846 | 425 | SStream_concat0(O, "}"); |
1847 | 425 | } |
1848 | | |
1849 | | void printVectorList(MCInst *MI, unsigned OpNum, SStream *O, |
1850 | | const char *LayoutSuffix) |
1851 | 50.5k | { |
1852 | 50.5k | unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); |
1853 | | |
1854 | 50.5k | SStream_concat0(O, "{ "); |
1855 | | |
1856 | | // Work out how many registers there are in the list (if there is an actual |
1857 | | // list). |
1858 | 50.5k | unsigned NumRegs = 1; |
1859 | 50.5k | if (MCRegisterClass_contains( |
1860 | 50.5k | MCRegisterInfo_getRegClass(MI->MRI, AArch64_DDRegClassID), |
1861 | 50.5k | Reg) || |
1862 | 50.0k | MCRegisterClass_contains( |
1863 | 50.0k | MCRegisterInfo_getRegClass(MI->MRI, AArch64_ZPR2RegClassID), |
1864 | 50.0k | Reg) || |
1865 | 40.8k | MCRegisterClass_contains( |
1866 | 40.8k | MCRegisterInfo_getRegClass(MI->MRI, AArch64_QQRegClassID), |
1867 | 40.8k | Reg) || |
1868 | 36.4k | MCRegisterClass_contains( |
1869 | 36.4k | MCRegisterInfo_getRegClass(MI->MRI, AArch64_PPR2RegClassID), |
1870 | 36.4k | Reg) || |
1871 | 35.7k | MCRegisterClass_contains( |
1872 | 35.7k | MCRegisterInfo_getRegClass(MI->MRI, |
1873 | 35.7k | AArch64_ZPR2StridedRegClassID), |
1874 | 35.7k | Reg)) |
1875 | 16.3k | NumRegs = 2; |
1876 | 34.1k | else if (MCRegisterClass_contains( |
1877 | 34.1k | MCRegisterInfo_getRegClass(MI->MRI, |
1878 | 34.1k | AArch64_DDDRegClassID), |
1879 | 34.1k | Reg) || |
1880 | 32.3k | MCRegisterClass_contains( |
1881 | 32.3k | MCRegisterInfo_getRegClass(MI->MRI, |
1882 | 32.3k | AArch64_ZPR3RegClassID), |
1883 | 32.3k | Reg) || |
1884 | 31.6k | MCRegisterClass_contains( |
1885 | 31.6k | MCRegisterInfo_getRegClass(MI->MRI, |
1886 | 31.6k | AArch64_QQQRegClassID), |
1887 | 31.6k | Reg)) |
1888 | 8.97k | NumRegs = 3; |
1889 | 25.2k | else if (MCRegisterClass_contains( |
1890 | 25.2k | MCRegisterInfo_getRegClass(MI->MRI, |
1891 | 25.2k | AArch64_DDDDRegClassID), |
1892 | 25.2k | Reg) || |
1893 | 25.0k | MCRegisterClass_contains( |
1894 | 25.0k | MCRegisterInfo_getRegClass(MI->MRI, |
1895 | 25.0k | AArch64_ZPR4RegClassID), |
1896 | 25.0k | Reg) || |
1897 | 20.1k | MCRegisterClass_contains( |
1898 | 20.1k | MCRegisterInfo_getRegClass(MI->MRI, |
1899 | 20.1k | AArch64_QQQQRegClassID), |
1900 | 20.1k | Reg) || |
1901 | 15.5k | MCRegisterClass_contains( |
1902 | 15.5k | MCRegisterInfo_getRegClass( |
1903 | 15.5k | MI->MRI, AArch64_ZPR4StridedRegClassID), |
1904 | 15.5k | Reg)) |
1905 | 10.5k | NumRegs = 4; |
1906 | | |
1907 | 50.5k | unsigned Stride = 1; |
1908 | 50.5k | if (MCRegisterClass_contains( |
1909 | 50.5k | MCRegisterInfo_getRegClass(MI->MRI, |
1910 | 50.5k | AArch64_ZPR2StridedRegClassID), |
1911 | 50.5k | Reg)) |
1912 | 1.56k | Stride = 8; |
1913 | 48.9k | else if (MCRegisterClass_contains( |
1914 | 48.9k | MCRegisterInfo_getRegClass( |
1915 | 48.9k | MI->MRI, AArch64_ZPR4StridedRegClassID), |
1916 | 48.9k | Reg)) |
1917 | 943 | Stride = 4; |
1918 | | |
1919 | | // Now forget about the list and find out what the first register is. |
1920 | 50.5k | if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_dsub0)) |
1921 | 2.48k | Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_dsub0); |
1922 | 48.0k | else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_qsub0)) |
1923 | 15.4k | Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_qsub0); |
1924 | 32.5k | else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_zsub0)) |
1925 | 17.2k | Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_zsub0); |
1926 | 15.3k | else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_psub0)) |
1927 | 758 | Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_psub0); |
1928 | | |
1929 | | // If it's a D-reg, we need to promote it to the equivalent Q-reg before |
1930 | | // printing (otherwise getRegisterName fails). |
1931 | 50.5k | if (MCRegisterClass_contains(MCRegisterInfo_getRegClass( |
1932 | 50.5k | MI->MRI, AArch64_FPR64RegClassID), |
1933 | 50.5k | Reg)) { |
1934 | 2.85k | const MCRegisterClass *FPR128RC = MCRegisterInfo_getRegClass( |
1935 | 2.85k | MI->MRI, AArch64_FPR128RegClassID); |
1936 | 2.85k | Reg = MCRegisterInfo_getMatchingSuperReg( |
1937 | 2.85k | MI->MRI, Reg, AArch64_dsub, FPR128RC); |
1938 | 2.85k | } |
1939 | | |
1940 | 50.5k | if ((MCRegisterClass_contains( |
1941 | 50.5k | MCRegisterInfo_getRegClass(MI->MRI, AArch64_ZPRRegClassID), |
1942 | 50.5k | Reg) || |
1943 | 22.7k | MCRegisterClass_contains( |
1944 | 22.7k | MCRegisterInfo_getRegClass(MI->MRI, AArch64_PPRRegClassID), |
1945 | 22.7k | Reg)) && |
1946 | 28.5k | NumRegs > 1 && Stride == 1 && |
1947 | | // Do not print the range when the last register is lower than the |
1948 | | // first. Because it is a wrap-around register. |
1949 | 15.4k | Reg < getNextVectorRegister(Reg, NumRegs - 1)) { |
1950 | 15.3k | printRegName(O, Reg); |
1951 | 15.3k | SStream_concat0(O, LayoutSuffix); |
1952 | 15.3k | if (NumRegs > 1) { |
1953 | | // Set of two sve registers should be separated by ',' |
1954 | 15.3k | const char *split_char = NumRegs == 2 ? ", " : " - "; |
1955 | 15.3k | SStream_concat0(O, split_char); |
1956 | 15.3k | printRegName(O, |
1957 | 15.3k | (getNextVectorRegister(Reg, NumRegs - 1))); |
1958 | 15.3k | SStream_concat0(O, LayoutSuffix); |
1959 | 15.3k | } |
1960 | 35.1k | } else { |
1961 | 110k | for (unsigned i = 0; i < NumRegs; |
1962 | 75.5k | ++i, Reg = getNextVectorRegister(Reg, Stride)) { |
1963 | | // wrap-around sve register |
1964 | 75.5k | if (MCRegisterClass_contains( |
1965 | 75.5k | MCRegisterInfo_getRegClass( |
1966 | 75.5k | MI->MRI, AArch64_ZPRRegClassID), |
1967 | 75.5k | Reg) || |
1968 | 57.9k | MCRegisterClass_contains( |
1969 | 57.9k | MCRegisterInfo_getRegClass( |
1970 | 57.9k | MI->MRI, AArch64_PPRRegClassID), |
1971 | 57.9k | Reg)) |
1972 | 17.6k | printRegName(O, Reg); |
1973 | 57.8k | else |
1974 | 57.8k | printRegNameAlt(O, Reg, AArch64_vreg); |
1975 | 75.5k | SStream_concat0(O, LayoutSuffix); |
1976 | 75.5k | if (i + 1 != NumRegs) |
1977 | 40.3k | SStream_concat0(O, ", "); |
1978 | 75.5k | } |
1979 | 35.1k | } |
1980 | 50.5k | SStream_concat0(O, " }"); |
1981 | 50.5k | } |
1982 | | |
1983 | | void printImplicitlyTypedVectorList(MCInst *MI, unsigned OpNum, SStream *O) |
1984 | 0 | { |
1985 | 0 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ImplicitlyTypedVectorList, |
1986 | 0 | OpNum); |
1987 | 0 | printVectorList(MI, OpNum, O, ""); |
1988 | 0 | } |
1989 | | |
1990 | | #define DEFINE_printTypedVectorList(NumLanes, LaneKind) \ |
1991 | | void CONCAT(printTypedVectorList, CONCAT(NumLanes, LaneKind))( \ |
1992 | | MCInst * MI, unsigned OpNum, SStream *O) \ |
1993 | 50.5k | { \ |
1994 | 50.5k | AArch64_add_cs_detail_2( \ |
1995 | 50.5k | MI, \ |
1996 | 50.5k | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ |
1997 | 50.5k | NumLanes), \ |
1998 | 50.5k | LaneKind), \ |
1999 | 50.5k | OpNum, NumLanes, CHAR(LaneKind)); \ |
2000 | 50.5k | if (CHAR(LaneKind) == '0') { \ |
2001 | 86 | printVectorList(MI, OpNum, O, ""); \ |
2002 | 86 | return; \ |
2003 | 86 | } \ |
2004 | 50.5k | char Suffix[32]; \ |
2005 | 50.4k | if (NumLanes) \ |
2006 | 50.4k | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ |
2007 | 7.97k | CHAR(LaneKind)); \ |
2008 | 50.4k | else \ |
2009 | 50.4k | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ |
2010 | 42.4k | CHAR(LaneKind)); \ |
2011 | 50.4k | \ |
2012 | 50.4k | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ |
2013 | 50.4k | } Line | Count | Source | 1993 | 9.53k | { \ | 1994 | 9.53k | AArch64_add_cs_detail_2( \ | 1995 | 9.53k | MI, \ | 1996 | 9.53k | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 9.53k | NumLanes), \ | 1998 | 9.53k | LaneKind), \ | 1999 | 9.53k | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 9.53k | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 9.53k | char Suffix[32]; \ | 2005 | 9.53k | if (NumLanes) \ | 2006 | 9.53k | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 0 | CHAR(LaneKind)); \ | 2008 | 9.53k | else \ | 2009 | 9.53k | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 9.53k | CHAR(LaneKind)); \ | 2011 | 9.53k | \ | 2012 | 9.53k | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 9.53k | } |
Line | Count | Source | 1993 | 12.9k | { \ | 1994 | 12.9k | AArch64_add_cs_detail_2( \ | 1995 | 12.9k | MI, \ | 1996 | 12.9k | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 12.9k | NumLanes), \ | 1998 | 12.9k | LaneKind), \ | 1999 | 12.9k | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 12.9k | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 12.9k | char Suffix[32]; \ | 2005 | 12.9k | if (NumLanes) \ | 2006 | 12.9k | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 0 | CHAR(LaneKind)); \ | 2008 | 12.9k | else \ | 2009 | 12.9k | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 12.9k | CHAR(LaneKind)); \ | 2011 | 12.9k | \ | 2012 | 12.9k | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 12.9k | } |
Line | Count | Source | 1993 | 9.69k | { \ | 1994 | 9.69k | AArch64_add_cs_detail_2( \ | 1995 | 9.69k | MI, \ | 1996 | 9.69k | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 9.69k | NumLanes), \ | 1998 | 9.69k | LaneKind), \ | 1999 | 9.69k | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 9.69k | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 9.69k | char Suffix[32]; \ | 2005 | 9.69k | if (NumLanes) \ | 2006 | 9.69k | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 0 | CHAR(LaneKind)); \ | 2008 | 9.69k | else \ | 2009 | 9.69k | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 9.69k | CHAR(LaneKind)); \ | 2011 | 9.69k | \ | 2012 | 9.69k | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 9.69k | } |
Line | Count | Source | 1993 | 9.99k | { \ | 1994 | 9.99k | AArch64_add_cs_detail_2( \ | 1995 | 9.99k | MI, \ | 1996 | 9.99k | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 9.99k | NumLanes), \ | 1998 | 9.99k | LaneKind), \ | 1999 | 9.99k | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 9.99k | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 9.99k | char Suffix[32]; \ | 2005 | 9.99k | if (NumLanes) \ | 2006 | 9.99k | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 0 | CHAR(LaneKind)); \ | 2008 | 9.99k | else \ | 2009 | 9.99k | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 9.99k | CHAR(LaneKind)); \ | 2011 | 9.99k | \ | 2012 | 9.99k | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 9.99k | } |
Line | Count | Source | 1993 | 254 | { \ | 1994 | 254 | AArch64_add_cs_detail_2( \ | 1995 | 254 | MI, \ | 1996 | 254 | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 254 | NumLanes), \ | 1998 | 254 | LaneKind), \ | 1999 | 254 | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 254 | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 254 | char Suffix[32]; \ | 2005 | 254 | if (NumLanes) \ | 2006 | 254 | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 0 | CHAR(LaneKind)); \ | 2008 | 254 | else \ | 2009 | 254 | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 254 | CHAR(LaneKind)); \ | 2011 | 254 | \ | 2012 | 254 | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 254 | } |
printTypedVectorList_16_b Line | Count | Source | 1993 | 1.99k | { \ | 1994 | 1.99k | AArch64_add_cs_detail_2( \ | 1995 | 1.99k | MI, \ | 1996 | 1.99k | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 1.99k | NumLanes), \ | 1998 | 1.99k | LaneKind), \ | 1999 | 1.99k | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 1.99k | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 1.99k | char Suffix[32]; \ | 2005 | 1.99k | if (NumLanes) \ | 2006 | 1.99k | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 1.99k | CHAR(LaneKind)); \ | 2008 | 1.99k | else \ | 2009 | 1.99k | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 0 | CHAR(LaneKind)); \ | 2011 | 1.99k | \ | 2012 | 1.99k | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 1.99k | } |
Line | Count | Source | 1993 | 802 | { \ | 1994 | 802 | AArch64_add_cs_detail_2( \ | 1995 | 802 | MI, \ | 1996 | 802 | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 802 | NumLanes), \ | 1998 | 802 | LaneKind), \ | 1999 | 802 | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 802 | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 802 | char Suffix[32]; \ | 2005 | 802 | if (NumLanes) \ | 2006 | 802 | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 802 | CHAR(LaneKind)); \ | 2008 | 802 | else \ | 2009 | 802 | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 0 | CHAR(LaneKind)); \ | 2011 | 802 | \ | 2012 | 802 | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 802 | } |
Line | Count | Source | 1993 | 1.19k | { \ | 1994 | 1.19k | AArch64_add_cs_detail_2( \ | 1995 | 1.19k | MI, \ | 1996 | 1.19k | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 1.19k | NumLanes), \ | 1998 | 1.19k | LaneKind), \ | 1999 | 1.19k | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 1.19k | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 1.19k | char Suffix[32]; \ | 2005 | 1.19k | if (NumLanes) \ | 2006 | 1.19k | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 1.19k | CHAR(LaneKind)); \ | 2008 | 1.19k | else \ | 2009 | 1.19k | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 0 | CHAR(LaneKind)); \ | 2011 | 1.19k | \ | 2012 | 1.19k | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 1.19k | } |
Line | Count | Source | 1993 | 612 | { \ | 1994 | 612 | AArch64_add_cs_detail_2( \ | 1995 | 612 | MI, \ | 1996 | 612 | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 612 | NumLanes), \ | 1998 | 612 | LaneKind), \ | 1999 | 612 | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 612 | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 612 | char Suffix[32]; \ | 2005 | 612 | if (NumLanes) \ | 2006 | 612 | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 612 | CHAR(LaneKind)); \ | 2008 | 612 | else \ | 2009 | 612 | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 0 | CHAR(LaneKind)); \ | 2011 | 612 | \ | 2012 | 612 | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 612 | } |
Line | Count | Source | 1993 | 373 | { \ | 1994 | 373 | AArch64_add_cs_detail_2( \ | 1995 | 373 | MI, \ | 1996 | 373 | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 373 | NumLanes), \ | 1998 | 373 | LaneKind), \ | 1999 | 373 | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 373 | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 373 | char Suffix[32]; \ | 2005 | 373 | if (NumLanes) \ | 2006 | 373 | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 373 | CHAR(LaneKind)); \ | 2008 | 373 | else \ | 2009 | 373 | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 0 | CHAR(LaneKind)); \ | 2011 | 373 | \ | 2012 | 373 | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 373 | } |
Line | Count | Source | 1993 | 722 | { \ | 1994 | 722 | AArch64_add_cs_detail_2( \ | 1995 | 722 | MI, \ | 1996 | 722 | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 722 | NumLanes), \ | 1998 | 722 | LaneKind), \ | 1999 | 722 | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 722 | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 722 | char Suffix[32]; \ | 2005 | 722 | if (NumLanes) \ | 2006 | 722 | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 722 | CHAR(LaneKind)); \ | 2008 | 722 | else \ | 2009 | 722 | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 0 | CHAR(LaneKind)); \ | 2011 | 722 | \ | 2012 | 722 | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 722 | } |
Line | Count | Source | 1993 | 1.06k | { \ | 1994 | 1.06k | AArch64_add_cs_detail_2( \ | 1995 | 1.06k | MI, \ | 1996 | 1.06k | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 1.06k | NumLanes), \ | 1998 | 1.06k | LaneKind), \ | 1999 | 1.06k | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 1.06k | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 1.06k | char Suffix[32]; \ | 2005 | 1.06k | if (NumLanes) \ | 2006 | 1.06k | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 1.06k | CHAR(LaneKind)); \ | 2008 | 1.06k | else \ | 2009 | 1.06k | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 0 | CHAR(LaneKind)); \ | 2011 | 1.06k | \ | 2012 | 1.06k | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 1.06k | } |
Line | Count | Source | 1993 | 1.21k | { \ | 1994 | 1.21k | AArch64_add_cs_detail_2( \ | 1995 | 1.21k | MI, \ | 1996 | 1.21k | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 1.21k | NumLanes), \ | 1998 | 1.21k | LaneKind), \ | 1999 | 1.21k | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 1.21k | if (CHAR(LaneKind) == '0') { \ | 2001 | 0 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 0 | return; \ | 2003 | 0 | } \ | 2004 | 1.21k | char Suffix[32]; \ | 2005 | 1.21k | if (NumLanes) \ | 2006 | 1.21k | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 1.21k | CHAR(LaneKind)); \ | 2008 | 1.21k | else \ | 2009 | 1.21k | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 0 | CHAR(LaneKind)); \ | 2011 | 1.21k | \ | 2012 | 1.21k | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 1.21k | } |
Line | Count | Source | 1993 | 86 | { \ | 1994 | 86 | AArch64_add_cs_detail_2( \ | 1995 | 86 | MI, \ | 1996 | 86 | CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \ | 1997 | 86 | NumLanes), \ | 1998 | 86 | LaneKind), \ | 1999 | 86 | OpNum, NumLanes, CHAR(LaneKind)); \ | 2000 | 86 | if (CHAR(LaneKind) == '0') { \ | 2001 | 86 | printVectorList(MI, OpNum, O, ""); \ | 2002 | 86 | return; \ | 2003 | 86 | } \ | 2004 | 86 | char Suffix[32]; \ | 2005 | 0 | if (NumLanes) \ | 2006 | 0 | cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \ | 2007 | 0 | CHAR(LaneKind)); \ | 2008 | 0 | else \ | 2009 | 0 | cs_snprintf(Suffix, sizeof(Suffix), ".%c", \ | 2010 | 0 | CHAR(LaneKind)); \ | 2011 | 0 | \ | 2012 | 0 | printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \ | 2013 | 0 | } |
|
2014 | | DEFINE_printTypedVectorList(0, b); |
2015 | | DEFINE_printTypedVectorList(0, d); |
2016 | | DEFINE_printTypedVectorList(0, h); |
2017 | | DEFINE_printTypedVectorList(0, s); |
2018 | | DEFINE_printTypedVectorList(0, q); |
2019 | | DEFINE_printTypedVectorList(16, b); |
2020 | | DEFINE_printTypedVectorList(1, d); |
2021 | | DEFINE_printTypedVectorList(2, d); |
2022 | | DEFINE_printTypedVectorList(2, s); |
2023 | | DEFINE_printTypedVectorList(4, h); |
2024 | | DEFINE_printTypedVectorList(4, s); |
2025 | | DEFINE_printTypedVectorList(8, b); |
2026 | | DEFINE_printTypedVectorList(8, h); |
2027 | | DEFINE_printTypedVectorList(0, 0); |
2028 | | |
2029 | | #define DEFINE_printVectorIndex(Scale) \ |
2030 | | void CONCAT(printVectorIndex, Scale)(MCInst * MI, unsigned OpNum, \ |
2031 | | SStream *O) \ |
2032 | 30.4k | { \ |
2033 | 30.4k | AArch64_add_cs_detail_1( \ |
2034 | 30.4k | MI, CONCAT(AArch64_OP_GROUP_VectorIndex, Scale), \ |
2035 | 30.4k | OpNum, Scale); \ |
2036 | 30.4k | SStream_concat(O, "%s", "["); \ |
2037 | 30.4k | printUInt64(O, Scale * MCOperand_getImm(MCInst_getOperand( \ |
2038 | 30.4k | MI, (OpNum)))); \ |
2039 | 30.4k | SStream_concat0(O, "]"); \ |
2040 | 30.4k | } Line | Count | Source | 2032 | 30.4k | { \ | 2033 | 30.4k | AArch64_add_cs_detail_1( \ | 2034 | 30.4k | MI, CONCAT(AArch64_OP_GROUP_VectorIndex, Scale), \ | 2035 | 30.4k | OpNum, Scale); \ | 2036 | 30.4k | SStream_concat(O, "%s", "["); \ | 2037 | 30.4k | printUInt64(O, Scale * MCOperand_getImm(MCInst_getOperand( \ | 2038 | 30.4k | MI, (OpNum)))); \ | 2039 | 30.4k | SStream_concat0(O, "]"); \ | 2040 | 30.4k | } |
Unexecuted instantiation: printVectorIndex_8 |
2041 | | DEFINE_printVectorIndex(1); |
2042 | | DEFINE_printVectorIndex(8); |
2043 | | |
2044 | | void printAlignedLabel(MCInst *MI, uint64_t Address, unsigned OpNum, SStream *O) |
2045 | 9.88k | { |
2046 | 9.88k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AlignedLabel, OpNum); |
2047 | 9.88k | MCOperand *Op = MCInst_getOperand(MI, (OpNum)); |
2048 | | |
2049 | | // If the label has already been resolved to an immediate offset (say, when |
2050 | | // we're running the disassembler), just print the immediate. |
2051 | 9.88k | if (MCOperand_isImm(Op)) { |
2052 | 9.80k | SStream_concat0(O, markup("<imm:")); |
2053 | 9.80k | int64_t Offset = MCOperand_getImm(Op) * 4; |
2054 | 9.80k | if (MI->csh->PrintBranchImmAsAddress) |
2055 | 9.80k | printUInt64(O, (Address + Offset)); |
2056 | 0 | else { |
2057 | 0 | printUInt64Bang(O, (Offset)); |
2058 | 0 | } |
2059 | 9.80k | SStream_concat0(O, markup(">")); |
2060 | 9.80k | return; |
2061 | 9.80k | } |
2062 | | |
2063 | 76 | printUInt64Bang(O, MCOperand_getImm(Op)); |
2064 | 76 | } |
2065 | | |
2066 | | void printAdrLabel(MCInst *MI, uint64_t Address, unsigned OpNum, SStream *O) |
2067 | 0 | { |
2068 | 0 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AdrLabel, OpNum); |
2069 | 0 | MCOperand *Op = MCInst_getOperand(MI, (OpNum)); |
2070 | | |
2071 | | // If the label has already been resolved to an immediate offset (say, when |
2072 | | // we're running the disassembler), just print the immediate. |
2073 | 0 | if (MCOperand_isImm(Op)) { |
2074 | 0 | const int64_t Offset = MCOperand_getImm(Op); |
2075 | 0 | SStream_concat0(O, markup("<imm:")); |
2076 | 0 | if (MI->csh->PrintBranchImmAsAddress) |
2077 | 0 | printUInt64(O, ((Address & -4) + Offset)); |
2078 | 0 | else { |
2079 | 0 | printUInt64Bang(O, Offset); |
2080 | 0 | } |
2081 | 0 | SStream_concat0(O, markup(">")); |
2082 | 0 | return; |
2083 | 0 | } |
2084 | | |
2085 | 0 | printUInt64Bang(O, MCOperand_getImm(Op)); |
2086 | 0 | } |
2087 | | |
2088 | | void printAdrpLabel(MCInst *MI, uint64_t Address, unsigned OpNum, SStream *O) |
2089 | 0 | { |
2090 | 0 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AdrpLabel, OpNum); |
2091 | 0 | MCOperand *Op = MCInst_getOperand(MI, (OpNum)); |
2092 | | |
2093 | | // If the label has already been resolved to an immediate offset (say, when |
2094 | | // we're running the disassembler), just print the immediate. |
2095 | 0 | if (MCOperand_isImm(Op)) { |
2096 | 0 | const int64_t Offset = MCOperand_getImm(Op) * 4096; |
2097 | 0 | SStream_concat0(O, markup("<imm:")); |
2098 | 0 | if (MI->csh->PrintBranchImmAsAddress) |
2099 | 0 | printUInt64(O, ((Address & -4096) + Offset)); |
2100 | 0 | else { |
2101 | 0 | printUInt64Bang(O, Offset); |
2102 | 0 | } |
2103 | 0 | SStream_concat0(O, markup(">")); |
2104 | 0 | return; |
2105 | 0 | } |
2106 | | |
2107 | 0 | printUInt64Bang(O, MCOperand_getImm(Op)); |
2108 | 0 | } |
2109 | | |
2110 | | void printAdrAdrpLabel(MCInst *MI, uint64_t Address, unsigned OpNum, SStream *O) |
2111 | 6.37k | { |
2112 | 6.37k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AdrAdrpLabel, OpNum); |
2113 | 6.37k | MCOperand *Op = MCInst_getOperand(MI, (OpNum)); |
2114 | | |
2115 | | // If the label has already been resolved to an immediate offset (say, when |
2116 | | // we're running the disassembler), just print the immediate. |
2117 | 6.37k | if (MCOperand_isImm(Op)) { |
2118 | 6.37k | int64_t Offset = MCOperand_getImm(Op); |
2119 | 6.37k | if (MCInst_getOpcode(MI) == AArch64_ADRP) { |
2120 | 1.57k | Offset = Offset * 4096; |
2121 | 1.57k | Address = Address & -4096; |
2122 | 1.57k | } |
2123 | 6.37k | SStream_concat0(O, markup(">")); |
2124 | 6.37k | if (MI->csh->PrintBranchImmAsAddress) |
2125 | 6.37k | printUInt64(O, (Address + Offset)); |
2126 | 0 | else { |
2127 | 0 | printUInt64Bang(O, Offset); |
2128 | 0 | } |
2129 | 6.37k | SStream_concat0(O, markup(">")); |
2130 | 6.37k | return; |
2131 | 6.37k | } |
2132 | | |
2133 | 0 | printUInt64Bang(O, MCOperand_getImm(Op)); |
2134 | 0 | } |
2135 | | |
2136 | | /// Not part of upstream LLVM. |
2137 | | /// Just prints the barrier options as documented in |
2138 | | /// https://github.com/AsahiLinux/docs/blob/main/docs/hw/cpu/apple-instructions.md |
2139 | | void printAppleSysBarrierOption(MCInst *MI, unsigned OpNo, SStream *O) |
2140 | 118 | { |
2141 | 118 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AppleSysBarrierOption, |
2142 | 118 | OpNo); |
2143 | 118 | unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); |
2144 | 118 | switch (Val) { |
2145 | 8 | default: |
2146 | 8 | SStream_concat0(O, "<undefined>"); |
2147 | 8 | break; |
2148 | 0 | case 0: |
2149 | 0 | SStream_concat0(O, "osh"); |
2150 | 0 | break; |
2151 | 0 | case 1: |
2152 | 0 | SStream_concat0(O, "nsh"); |
2153 | 0 | break; |
2154 | 110 | case 2: |
2155 | 110 | SStream_concat0(O, "ish"); |
2156 | 110 | break; |
2157 | 0 | case 3: |
2158 | 0 | SStream_concat0(O, "sy"); |
2159 | 0 | break; |
2160 | 118 | } |
2161 | 118 | } |
2162 | | |
2163 | | void printBarrierOption(MCInst *MI, unsigned OpNo, SStream *O) |
2164 | 364 | { |
2165 | 364 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BarrierOption, OpNo); |
2166 | 364 | unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); |
2167 | 364 | unsigned Opcode = MCInst_getOpcode(MI); |
2168 | | |
2169 | 364 | const char *Name; |
2170 | 364 | if (Opcode == AArch64_ISB) { |
2171 | 118 | const AArch64ISB_ISB *ISB = AArch64ISB_lookupISBByEncoding(Val); |
2172 | 118 | Name = ISB ? ISB->Name : ""; |
2173 | 246 | } else if (Opcode == AArch64_TSB) { |
2174 | 107 | const AArch64TSB_TSB *TSB = AArch64TSB_lookupTSBByEncoding(Val); |
2175 | 107 | Name = TSB ? TSB->Name : ""; |
2176 | 139 | } else { |
2177 | 139 | const AArch64DB_DB *DB = AArch64DB_lookupDBByEncoding(Val); |
2178 | 139 | Name = DB ? DB->Name : ""; |
2179 | 139 | } |
2180 | 364 | if (Name[0] != '\0') |
2181 | 206 | SStream_concat0(O, Name); |
2182 | 158 | else { |
2183 | 158 | SStream_concat(O, "%s", markup("<imm:")); |
2184 | 158 | printUInt32Bang(O, Val); |
2185 | 158 | SStream_concat0(O, markup(">")); |
2186 | 158 | } |
2187 | 364 | } |
2188 | | |
2189 | | void printBarriernXSOption(MCInst *MI, unsigned OpNo, SStream *O) |
2190 | 99 | { |
2191 | 99 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BarriernXSOption, OpNo); |
2192 | 99 | unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); |
2193 | | |
2194 | 99 | const char *Name; |
2195 | 99 | const AArch64DBnXS_DBnXS *DB = AArch64DBnXS_lookupDBnXSByEncoding(Val); |
2196 | 99 | Name = DB ? DB->Name : ""; |
2197 | | |
2198 | 99 | if (Name[0] != '\0') |
2199 | 99 | SStream_concat0(O, Name); |
2200 | 0 | else { |
2201 | 0 | SStream_concat(O, "%s%s%s", markup("<imm:"), "#", Val); |
2202 | 0 | SStream_concat0(O, markup(">")); |
2203 | 0 | } |
2204 | 99 | } |
2205 | | |
2206 | | static bool isValidSysReg(const AArch64SysReg_SysReg *Reg, bool Read, |
2207 | | unsigned mode) |
2208 | 3.84k | { |
2209 | 3.84k | return (Reg && (Read ? Reg->Readable : Reg->Writeable) && |
2210 | 756 | AArch64_testFeatureList(mode, Reg->FeaturesRequired)); |
2211 | 3.84k | } |
2212 | | |
2213 | | // Looks up a system register either by encoding or by name. Some system |
2214 | | // registers share the same encoding between different architectures, |
2215 | | // therefore a tablegen lookup by encoding will return an entry regardless |
2216 | | // of the register's predication on a specific subtarget feature. To work |
2217 | | // around this problem we keep an alternative name for such registers and |
2218 | | // look them up by that name if the first lookup was unsuccessful. |
2219 | | static const AArch64SysReg_SysReg *lookupSysReg(unsigned Val, bool Read, |
2220 | | unsigned mode) |
2221 | 3.03k | { |
2222 | 3.03k | const AArch64SysReg_SysReg *Reg = |
2223 | 3.03k | AArch64SysReg_lookupSysRegByEncoding(Val); |
2224 | | |
2225 | 3.03k | if (Reg && !isValidSysReg(Reg, Read, mode)) |
2226 | 438 | Reg = AArch64SysReg_lookupSysRegByName(Reg->AltName); |
2227 | | |
2228 | 3.03k | return Reg; |
2229 | 3.03k | } |
2230 | | |
2231 | | void printMRSSystemRegister(MCInst *MI, unsigned OpNo, SStream *O) |
2232 | 1.03k | { |
2233 | 1.03k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MRSSystemRegister, OpNo); |
2234 | 1.03k | unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); |
2235 | | |
2236 | | // Horrible hack for the one register that has identical encodings but |
2237 | | // different names in MSR and MRS. Because of this, one of MRS and MSR is |
2238 | | // going to get the wrong entry |
2239 | 1.03k | if (Val == AARCH64_SYSREG_DBGDTRRX_EL0) { |
2240 | 289 | SStream_concat0(O, "DBGDTRRX_EL0"); |
2241 | 289 | return; |
2242 | 289 | } |
2243 | | |
2244 | | // Horrible hack for two different registers having the same encoding. |
2245 | 744 | if (Val == AARCH64_SYSREG_TRCEXTINSELR) { |
2246 | 19 | SStream_concat0(O, "TRCEXTINSELR"); |
2247 | 19 | return; |
2248 | 19 | } |
2249 | | |
2250 | 725 | const AArch64SysReg_SysReg *Reg = |
2251 | 725 | lookupSysReg(Val, true /*Read*/, MI->csh->mode); |
2252 | | |
2253 | 725 | if (isValidSysReg(Reg, true /*Read*/, MI->csh->mode)) |
2254 | 99 | SStream_concat0(O, Reg->Name); |
2255 | 626 | else { |
2256 | 626 | char result[AARCH64_GRS_LEN + 1] = { 0 }; |
2257 | 626 | AArch64SysReg_genericRegisterString(Val, result); |
2258 | 626 | SStream_concat0(O, result); |
2259 | 626 | } |
2260 | 725 | } |
2261 | | |
2262 | | void printMSRSystemRegister(MCInst *MI, unsigned OpNo, SStream *O) |
2263 | 2.59k | { |
2264 | 2.59k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MSRSystemRegister, OpNo); |
2265 | 2.59k | unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); |
2266 | | |
2267 | | // Horrible hack for the one register that has identical encodings but |
2268 | | // different names in MSR and MRS. Because of this, one of MRS and MSR is |
2269 | | // going to get the wrong entry |
2270 | 2.59k | if (Val == AARCH64_SYSREG_DBGDTRTX_EL0) { |
2271 | 265 | SStream_concat0(O, "DBGDTRTX_EL0"); |
2272 | 265 | return; |
2273 | 265 | } |
2274 | | |
2275 | | // Horrible hack for two different registers having the same encoding. |
2276 | 2.32k | if (Val == AARCH64_SYSREG_TRCEXTINSELR) { |
2277 | 18 | SStream_concat0(O, "TRCEXTINSELR"); |
2278 | 18 | return; |
2279 | 18 | } |
2280 | | |
2281 | 2.30k | const AArch64SysReg_SysReg *Reg = |
2282 | 2.30k | lookupSysReg(Val, false /*Read*/, MI->csh->mode); |
2283 | | |
2284 | 2.30k | if (isValidSysReg(Reg, false /*Read*/, MI->csh->mode)) |
2285 | 279 | SStream_concat0(O, Reg->Name); |
2286 | 2.02k | else { |
2287 | 2.02k | char result[AARCH64_GRS_LEN + 1] = { 0 }; |
2288 | 2.02k | AArch64SysReg_genericRegisterString(Val, result); |
2289 | 2.02k | SStream_concat0(O, result); |
2290 | 2.02k | } |
2291 | 2.30k | } |
2292 | | |
2293 | | void printSystemPStateField(MCInst *MI, unsigned OpNo, SStream *O) |
2294 | 285 | { |
2295 | 285 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SystemPStateField, OpNo); |
2296 | 285 | unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); |
2297 | | |
2298 | 285 | const AArch64PState_PStateImm0_15 *PStateImm15 = |
2299 | 285 | AArch64PState_lookupPStateImm0_15ByEncoding(Val); |
2300 | 285 | const AArch64PState_PStateImm0_1 *PStateImm1 = |
2301 | 285 | AArch64PState_lookupPStateImm0_1ByEncoding(Val); |
2302 | 285 | if (PStateImm15 && |
2303 | 244 | AArch64_testFeatureList(MI->csh->mode, |
2304 | 244 | PStateImm15->FeaturesRequired)) |
2305 | 244 | SStream_concat0(O, PStateImm15->Name); |
2306 | 41 | else if (PStateImm1 && |
2307 | 41 | AArch64_testFeatureList(MI->csh->mode, |
2308 | 41 | PStateImm1->FeaturesRequired)) |
2309 | 41 | SStream_concat0(O, PStateImm1->Name); |
2310 | 0 | else { |
2311 | 0 | printUInt32Bang(O, (Val)); |
2312 | 0 | SStream_concat1(O, '\0'); |
2313 | 0 | } |
2314 | 285 | } |
2315 | | |
2316 | | void printSIMDType10Operand(MCInst *MI, unsigned OpNo, SStream *O) |
2317 | 586 | { |
2318 | 586 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SIMDType10Operand, OpNo); |
2319 | 586 | unsigned RawVal = MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); |
2320 | 586 | uint64_t Val = AArch64_AM_decodeAdvSIMDModImmType10(RawVal); |
2321 | 586 | SStream_concat(O, "%s#%#016llx", markup("<imm:"), Val); |
2322 | 586 | SStream_concat0(O, markup(">")); |
2323 | 586 | } |
2324 | | |
2325 | | #define DEFINE_printComplexRotationOp(Angle, Remainder) \ |
2326 | | static void CONCAT(printComplexRotationOp, CONCAT(Angle, Remainder))( \ |
2327 | | MCInst * MI, unsigned OpNo, SStream *O) \ |
2328 | 2.32k | { \ |
2329 | 2.32k | AArch64_add_cs_detail_2( \ |
2330 | 2.32k | MI, \ |
2331 | 2.32k | CONCAT(CONCAT(AArch64_OP_GROUP_ComplexRotationOp, \ |
2332 | 2.32k | Angle), \ |
2333 | 2.32k | Remainder), \ |
2334 | 2.32k | OpNo, Angle, Remainder); \ |
2335 | 2.32k | unsigned Val = \ |
2336 | 2.32k | MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \ |
2337 | 2.32k | SStream_concat(O, "%s", markup("<imm:")); \ |
2338 | 2.32k | SStream_concat(O, "#%" PRId32, \ |
2339 | 2.32k | (int32_t)((Val * Angle) + Remainder)); \ |
2340 | 2.32k | SStream_concat0(O, markup(">")); \ |
2341 | 2.32k | } |
2342 | 444 | DEFINE_printComplexRotationOp(180, 90); |
2343 | 1.87k | DEFINE_printComplexRotationOp(90, 0); |
2344 | | |
2345 | | void printSVEPattern(MCInst *MI, unsigned OpNum, SStream *O) |
2346 | 3.99k | { |
2347 | 3.99k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SVEPattern, OpNum); |
2348 | 3.99k | unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); |
2349 | 3.99k | const AArch64SVEPredPattern_SVEPREDPAT *Pat = |
2350 | 3.99k | AArch64SVEPredPattern_lookupSVEPREDPATByEncoding(Val); |
2351 | 3.99k | if (Pat) |
2352 | 2.71k | SStream_concat0(O, Pat->Name); |
2353 | 1.28k | else |
2354 | 1.28k | printUInt32Bang(O, Val); |
2355 | 3.99k | } |
2356 | | |
2357 | | void printSVEVecLenSpecifier(MCInst *MI, unsigned OpNum, SStream *O) |
2358 | 988 | { |
2359 | 988 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SVEVecLenSpecifier, OpNum); |
2360 | 988 | unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); |
2361 | | // Pattern has only 1 bit |
2362 | 988 | if (Val > 1) |
2363 | 0 | CS_ASSERT_RET(0 && "Invalid vector length specifier"); |
2364 | 988 | const AArch64SVEVecLenSpecifier_SVEVECLENSPECIFIER *Pat = |
2365 | 988 | AArch64SVEVecLenSpecifier_lookupSVEVECLENSPECIFIERByEncoding( |
2366 | 988 | Val); |
2367 | 988 | if (Pat) |
2368 | 988 | SStream_concat0(O, Pat->Name); |
2369 | 988 | } |
2370 | | |
2371 | | #define DEFINE_printSVERegOp(suffix) \ |
2372 | | void CONCAT(printSVERegOp, suffix)(MCInst * MI, unsigned OpNum, \ |
2373 | | SStream *O) \ |
2374 | 135k | { \ |
2375 | 135k | AArch64_add_cs_detail_1( \ |
2376 | 135k | MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \ |
2377 | 135k | CHAR(suffix)); \ |
2378 | 135k | switch (CHAR(suffix)) { \ |
2379 | 40.2k | case '0': \ |
2380 | 62.4k | case 'b': \ |
2381 | 94.0k | case 'h': \ |
2382 | 113k | case 's': \ |
2383 | 133k | case 'd': \ |
2384 | 135k | case 'q': \ |
2385 | 135k | break; \ |
2386 | 133k | default: \ |
2387 | 0 | CS_ASSERT_RET(0 && "Invalid kind specifier."); \ |
2388 | 135k | } \ |
2389 | 135k | \ |
2390 | 135k | unsigned Reg = \ |
2391 | 135k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ |
2392 | 135k | printRegName(O, Reg); \ |
2393 | 135k | if (CHAR(suffix) != '0') { \ |
2394 | 94.8k | SStream_concat1(O, '.'); \ |
2395 | 94.8k | SStream_concat1(O, CHAR(suffix)); \ |
2396 | 94.8k | } \ |
2397 | 135k | } Line | Count | Source | 2374 | 22.1k | { \ | 2375 | 22.1k | AArch64_add_cs_detail_1( \ | 2376 | 22.1k | MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \ | 2377 | 22.1k | CHAR(suffix)); \ | 2378 | 22.1k | switch (CHAR(suffix)) { \ | 2379 | 0 | case '0': \ | 2380 | 22.1k | case 'b': \ | 2381 | 22.1k | case 'h': \ | 2382 | 22.1k | case 's': \ | 2383 | 22.1k | case 'd': \ | 2384 | 22.1k | case 'q': \ | 2385 | 22.1k | break; \ | 2386 | 22.1k | default: \ | 2387 | 0 | CS_ASSERT_RET(0 && "Invalid kind specifier."); \ | 2388 | 22.1k | } \ | 2389 | 22.1k | \ | 2390 | 22.1k | unsigned Reg = \ | 2391 | 22.1k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 2392 | 22.1k | printRegName(O, Reg); \ | 2393 | 22.1k | if (CHAR(suffix) != '0') { \ | 2394 | 22.1k | SStream_concat1(O, '.'); \ | 2395 | 22.1k | SStream_concat1(O, CHAR(suffix)); \ | 2396 | 22.1k | } \ | 2397 | 22.1k | } |
Line | Count | Source | 2374 | 19.4k | { \ | 2375 | 19.4k | AArch64_add_cs_detail_1( \ | 2376 | 19.4k | MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \ | 2377 | 19.4k | CHAR(suffix)); \ | 2378 | 19.4k | switch (CHAR(suffix)) { \ | 2379 | 0 | case '0': \ | 2380 | 0 | case 'b': \ | 2381 | 0 | case 'h': \ | 2382 | 0 | case 's': \ | 2383 | 19.4k | case 'd': \ | 2384 | 19.4k | case 'q': \ | 2385 | 19.4k | break; \ | 2386 | 19.4k | default: \ | 2387 | 0 | CS_ASSERT_RET(0 && "Invalid kind specifier."); \ | 2388 | 19.4k | } \ | 2389 | 19.4k | \ | 2390 | 19.4k | unsigned Reg = \ | 2391 | 19.4k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 2392 | 19.4k | printRegName(O, Reg); \ | 2393 | 19.4k | if (CHAR(suffix) != '0') { \ | 2394 | 19.4k | SStream_concat1(O, '.'); \ | 2395 | 19.4k | SStream_concat1(O, CHAR(suffix)); \ | 2396 | 19.4k | } \ | 2397 | 19.4k | } |
Line | Count | Source | 2374 | 31.6k | { \ | 2375 | 31.6k | AArch64_add_cs_detail_1( \ | 2376 | 31.6k | MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \ | 2377 | 31.6k | CHAR(suffix)); \ | 2378 | 31.6k | switch (CHAR(suffix)) { \ | 2379 | 0 | case '0': \ | 2380 | 0 | case 'b': \ | 2381 | 31.6k | case 'h': \ | 2382 | 31.6k | case 's': \ | 2383 | 31.6k | case 'd': \ | 2384 | 31.6k | case 'q': \ | 2385 | 31.6k | break; \ | 2386 | 31.6k | default: \ | 2387 | 0 | CS_ASSERT_RET(0 && "Invalid kind specifier."); \ | 2388 | 31.6k | } \ | 2389 | 31.6k | \ | 2390 | 31.6k | unsigned Reg = \ | 2391 | 31.6k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 2392 | 31.6k | printRegName(O, Reg); \ | 2393 | 31.6k | if (CHAR(suffix) != '0') { \ | 2394 | 31.6k | SStream_concat1(O, '.'); \ | 2395 | 31.6k | SStream_concat1(O, CHAR(suffix)); \ | 2396 | 31.6k | } \ | 2397 | 31.6k | } |
Line | Count | Source | 2374 | 19.9k | { \ | 2375 | 19.9k | AArch64_add_cs_detail_1( \ | 2376 | 19.9k | MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \ | 2377 | 19.9k | CHAR(suffix)); \ | 2378 | 19.9k | switch (CHAR(suffix)) { \ | 2379 | 0 | case '0': \ | 2380 | 0 | case 'b': \ | 2381 | 0 | case 'h': \ | 2382 | 19.9k | case 's': \ | 2383 | 19.9k | case 'd': \ | 2384 | 19.9k | case 'q': \ | 2385 | 19.9k | break; \ | 2386 | 19.9k | default: \ | 2387 | 0 | CS_ASSERT_RET(0 && "Invalid kind specifier."); \ | 2388 | 19.9k | } \ | 2389 | 19.9k | \ | 2390 | 19.9k | unsigned Reg = \ | 2391 | 19.9k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 2392 | 19.9k | printRegName(O, Reg); \ | 2393 | 19.9k | if (CHAR(suffix) != '0') { \ | 2394 | 19.9k | SStream_concat1(O, '.'); \ | 2395 | 19.9k | SStream_concat1(O, CHAR(suffix)); \ | 2396 | 19.9k | } \ | 2397 | 19.9k | } |
Line | Count | Source | 2374 | 40.2k | { \ | 2375 | 40.2k | AArch64_add_cs_detail_1( \ | 2376 | 40.2k | MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \ | 2377 | 40.2k | CHAR(suffix)); \ | 2378 | 40.2k | switch (CHAR(suffix)) { \ | 2379 | 40.2k | case '0': \ | 2380 | 40.2k | case 'b': \ | 2381 | 40.2k | case 'h': \ | 2382 | 40.2k | case 's': \ | 2383 | 40.2k | case 'd': \ | 2384 | 40.2k | case 'q': \ | 2385 | 40.2k | break; \ | 2386 | 40.2k | default: \ | 2387 | 0 | CS_ASSERT_RET(0 && "Invalid kind specifier."); \ | 2388 | 40.2k | } \ | 2389 | 40.2k | \ | 2390 | 40.2k | unsigned Reg = \ | 2391 | 40.2k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 2392 | 40.2k | printRegName(O, Reg); \ | 2393 | 40.2k | if (CHAR(suffix) != '0') { \ | 2394 | 0 | SStream_concat1(O, '.'); \ | 2395 | 0 | SStream_concat1(O, CHAR(suffix)); \ | 2396 | 0 | } \ | 2397 | 40.2k | } |
Line | Count | Source | 2374 | 1.58k | { \ | 2375 | 1.58k | AArch64_add_cs_detail_1( \ | 2376 | 1.58k | MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \ | 2377 | 1.58k | CHAR(suffix)); \ | 2378 | 1.58k | switch (CHAR(suffix)) { \ | 2379 | 0 | case '0': \ | 2380 | 0 | case 'b': \ | 2381 | 0 | case 'h': \ | 2382 | 0 | case 's': \ | 2383 | 0 | case 'd': \ | 2384 | 1.58k | case 'q': \ | 2385 | 1.58k | break; \ | 2386 | 0 | default: \ | 2387 | 0 | CS_ASSERT_RET(0 && "Invalid kind specifier."); \ | 2388 | 1.58k | } \ | 2389 | 1.58k | \ | 2390 | 1.58k | unsigned Reg = \ | 2391 | 1.58k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 2392 | 1.58k | printRegName(O, Reg); \ | 2393 | 1.58k | if (CHAR(suffix) != '0') { \ | 2394 | 1.58k | SStream_concat1(O, '.'); \ | 2395 | 1.58k | SStream_concat1(O, CHAR(suffix)); \ | 2396 | 1.58k | } \ | 2397 | 1.58k | } |
|
2398 | | DEFINE_printSVERegOp(b); |
2399 | | DEFINE_printSVERegOp(d); |
2400 | | DEFINE_printSVERegOp(h); |
2401 | | DEFINE_printSVERegOp(s); |
2402 | | DEFINE_printSVERegOp(0); |
2403 | | DEFINE_printSVERegOp(q); |
2404 | | |
2405 | | #define DECLARE_printImmSVE_S32(T) \ |
2406 | | void CONCAT(printImmSVE, T)(T Val, SStream * O) \ |
2407 | 2.01k | { \ |
2408 | 2.01k | printInt32Bang(O, Val); \ |
2409 | 2.01k | } Line | Count | Source | 2407 | 1.10k | { \ | 2408 | 1.10k | printInt32Bang(O, Val); \ | 2409 | 1.10k | } |
Line | Count | Source | 2407 | 319 | { \ | 2408 | 319 | printInt32Bang(O, Val); \ | 2409 | 319 | } |
Line | Count | Source | 2407 | 584 | { \ | 2408 | 584 | printInt32Bang(O, Val); \ | 2409 | 584 | } |
|
2410 | | DECLARE_printImmSVE_S32(int16_t); |
2411 | | DECLARE_printImmSVE_S32(int8_t); |
2412 | | DECLARE_printImmSVE_S32(int32_t); |
2413 | | |
2414 | | #define DECLARE_printImmSVE_U32(T) \ |
2415 | | void CONCAT(printImmSVE, T)(T Val, SStream * O) \ |
2416 | 276 | { \ |
2417 | 276 | printUInt32Bang(O, Val); \ |
2418 | 276 | } Line | Count | Source | 2416 | 149 | { \ | 2417 | 149 | printUInt32Bang(O, Val); \ | 2418 | 149 | } |
Line | Count | Source | 2416 | 61 | { \ | 2417 | 61 | printUInt32Bang(O, Val); \ | 2418 | 61 | } |
Line | Count | Source | 2416 | 66 | { \ | 2417 | 66 | printUInt32Bang(O, Val); \ | 2418 | 66 | } |
|
2419 | | DECLARE_printImmSVE_U32(uint16_t); |
2420 | | DECLARE_printImmSVE_U32(uint8_t); |
2421 | | DECLARE_printImmSVE_U32(uint32_t); |
2422 | | |
2423 | | #define DECLARE_printImmSVE_S64(T) \ |
2424 | | void CONCAT(printImmSVE, T)(T Val, SStream * O) \ |
2425 | 575 | { \ |
2426 | 575 | printInt64Bang(O, Val); \ |
2427 | 575 | } |
2428 | | DECLARE_printImmSVE_S64(int64_t); |
2429 | | |
2430 | | #define DECLARE_printImmSVE_U64(T) \ |
2431 | | void CONCAT(printImmSVE, T)(T Val, SStream * O) \ |
2432 | 86 | { \ |
2433 | 86 | printUInt64Bang(O, Val); \ |
2434 | 86 | } |
2435 | | DECLARE_printImmSVE_U64(uint64_t); |
2436 | | |
2437 | | #define DEFINE_isSignedType(T) \ |
2438 | | static inline bool CONCAT(isSignedType, T)() \ |
2439 | 1.23k | { \ |
2440 | 1.23k | return CHAR(T) == 'i'; \ |
2441 | 1.23k | } AArch64InstPrinter.c:isSignedType_int16_t Line | Count | Source | 2439 | 109 | { \ | 2440 | 109 | return CHAR(T) == 'i'; \ | 2441 | 109 | } |
AArch64InstPrinter.c:isSignedType_int8_t Line | Count | Source | 2439 | 319 | { \ | 2440 | 319 | return CHAR(T) == 'i'; \ | 2441 | 319 | } |
AArch64InstPrinter.c:isSignedType_int64_t Line | Count | Source | 2439 | 233 | { \ | 2440 | 233 | return CHAR(T) == 'i'; \ | 2441 | 233 | } |
AArch64InstPrinter.c:isSignedType_int32_t Line | Count | Source | 2439 | 213 | { \ | 2440 | 213 | return CHAR(T) == 'i'; \ | 2441 | 213 | } |
AArch64InstPrinter.c:isSignedType_uint16_t Line | Count | Source | 2439 | 149 | { \ | 2440 | 149 | return CHAR(T) == 'i'; \ | 2441 | 149 | } |
AArch64InstPrinter.c:isSignedType_uint8_t Line | Count | Source | 2439 | 61 | { \ | 2440 | 61 | return CHAR(T) == 'i'; \ | 2441 | 61 | } |
AArch64InstPrinter.c:isSignedType_uint64_t Line | Count | Source | 2439 | 86 | { \ | 2440 | 86 | return CHAR(T) == 'i'; \ | 2441 | 86 | } |
AArch64InstPrinter.c:isSignedType_uint32_t Line | Count | Source | 2439 | 66 | { \ | 2440 | 66 | return CHAR(T) == 'i'; \ | 2441 | 66 | } |
|
2442 | | DEFINE_isSignedType(int8_t); |
2443 | | DEFINE_isSignedType(int16_t); |
2444 | | DEFINE_isSignedType(int32_t); |
2445 | | DEFINE_isSignedType(int64_t); |
2446 | | DEFINE_isSignedType(uint8_t); |
2447 | | DEFINE_isSignedType(uint16_t); |
2448 | | DEFINE_isSignedType(uint32_t); |
2449 | | DEFINE_isSignedType(uint64_t); |
2450 | | |
2451 | | #define DEFINE_printImm8OptLsl(T) \ |
2452 | | void CONCAT(printImm8OptLsl, T)(MCInst * MI, unsigned OpNum, \ |
2453 | | SStream *O) \ |
2454 | 1.67k | { \ |
2455 | 1.67k | AArch64_add_cs_detail_1( \ |
2456 | 1.67k | MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \ |
2457 | 1.67k | sizeof(T)); \ |
2458 | 1.67k | unsigned UnscaledVal = \ |
2459 | 1.67k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ |
2460 | 1.67k | unsigned Shift = \ |
2461 | 1.67k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \ |
2462 | 1.67k | \ |
2463 | 1.67k | if ((UnscaledVal == 0) && \ |
2464 | 1.67k | (AArch64_AM_getShiftValue(Shift) != 0)) { \ |
2465 | 443 | SStream_concat(O, "%s", markup("<imm:")); \ |
2466 | 443 | SStream_concat1(O, '#'); \ |
2467 | 443 | printUInt64(O, (UnscaledVal)); \ |
2468 | 443 | SStream_concat0(O, markup(">")); \ |
2469 | 443 | printShifter(MI, OpNum + 1, O); \ |
2470 | 443 | return; \ |
2471 | 443 | } \ |
2472 | 1.67k | \ |
2473 | 1.67k | T Val; \ |
2474 | 1.23k | if (CONCAT(isSignedType, T)()) \ |
2475 | 1.23k | Val = (int8_t)UnscaledVal * \ |
2476 | 874 | (1 << AArch64_AM_getShiftValue(Shift)); \ |
2477 | 1.23k | else \ |
2478 | 1.23k | Val = (uint8_t)UnscaledVal * \ |
2479 | 362 | (1 << AArch64_AM_getShiftValue(Shift)); \ |
2480 | 1.23k | \ |
2481 | 1.23k | CONCAT(printImmSVE, T)(Val, O); \ |
2482 | 1.23k | } Line | Count | Source | 2454 | 214 | { \ | 2455 | 214 | AArch64_add_cs_detail_1( \ | 2456 | 214 | MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \ | 2457 | 214 | sizeof(T)); \ | 2458 | 214 | unsigned UnscaledVal = \ | 2459 | 214 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2460 | 214 | unsigned Shift = \ | 2461 | 214 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \ | 2462 | 214 | \ | 2463 | 214 | if ((UnscaledVal == 0) && \ | 2464 | 214 | (AArch64_AM_getShiftValue(Shift) != 0)) { \ | 2465 | 105 | SStream_concat(O, "%s", markup("<imm:")); \ | 2466 | 105 | SStream_concat1(O, '#'); \ | 2467 | 105 | printUInt64(O, (UnscaledVal)); \ | 2468 | 105 | SStream_concat0(O, markup(">")); \ | 2469 | 105 | printShifter(MI, OpNum + 1, O); \ | 2470 | 105 | return; \ | 2471 | 105 | } \ | 2472 | 214 | \ | 2473 | 214 | T Val; \ | 2474 | 109 | if (CONCAT(isSignedType, T)()) \ | 2475 | 109 | Val = (int8_t)UnscaledVal * \ | 2476 | 109 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2477 | 109 | else \ | 2478 | 109 | Val = (uint8_t)UnscaledVal * \ | 2479 | 0 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2480 | 109 | \ | 2481 | 109 | CONCAT(printImmSVE, T)(Val, O); \ | 2482 | 109 | } |
Line | Count | Source | 2454 | 319 | { \ | 2455 | 319 | AArch64_add_cs_detail_1( \ | 2456 | 319 | MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \ | 2457 | 319 | sizeof(T)); \ | 2458 | 319 | unsigned UnscaledVal = \ | 2459 | 319 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2460 | 319 | unsigned Shift = \ | 2461 | 319 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \ | 2462 | 319 | \ | 2463 | 319 | if ((UnscaledVal == 0) && \ | 2464 | 319 | (AArch64_AM_getShiftValue(Shift) != 0)) { \ | 2465 | 0 | SStream_concat(O, "%s", markup("<imm:")); \ | 2466 | 0 | SStream_concat1(O, '#'); \ | 2467 | 0 | printUInt64(O, (UnscaledVal)); \ | 2468 | 0 | SStream_concat0(O, markup(">")); \ | 2469 | 0 | printShifter(MI, OpNum + 1, O); \ | 2470 | 0 | return; \ | 2471 | 0 | } \ | 2472 | 319 | \ | 2473 | 319 | T Val; \ | 2474 | 319 | if (CONCAT(isSignedType, T)()) \ | 2475 | 319 | Val = (int8_t)UnscaledVal * \ | 2476 | 319 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2477 | 319 | else \ | 2478 | 319 | Val = (uint8_t)UnscaledVal * \ | 2479 | 0 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2480 | 319 | \ | 2481 | 319 | CONCAT(printImmSVE, T)(Val, O); \ | 2482 | 319 | } |
Line | Count | Source | 2454 | 314 | { \ | 2455 | 314 | AArch64_add_cs_detail_1( \ | 2456 | 314 | MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \ | 2457 | 314 | sizeof(T)); \ | 2458 | 314 | unsigned UnscaledVal = \ | 2459 | 314 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2460 | 314 | unsigned Shift = \ | 2461 | 314 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \ | 2462 | 314 | \ | 2463 | 314 | if ((UnscaledVal == 0) && \ | 2464 | 314 | (AArch64_AM_getShiftValue(Shift) != 0)) { \ | 2465 | 81 | SStream_concat(O, "%s", markup("<imm:")); \ | 2466 | 81 | SStream_concat1(O, '#'); \ | 2467 | 81 | printUInt64(O, (UnscaledVal)); \ | 2468 | 81 | SStream_concat0(O, markup(">")); \ | 2469 | 81 | printShifter(MI, OpNum + 1, O); \ | 2470 | 81 | return; \ | 2471 | 81 | } \ | 2472 | 314 | \ | 2473 | 314 | T Val; \ | 2474 | 233 | if (CONCAT(isSignedType, T)()) \ | 2475 | 233 | Val = (int8_t)UnscaledVal * \ | 2476 | 233 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2477 | 233 | else \ | 2478 | 233 | Val = (uint8_t)UnscaledVal * \ | 2479 | 0 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2480 | 233 | \ | 2481 | 233 | CONCAT(printImmSVE, T)(Val, O); \ | 2482 | 233 | } |
Line | Count | Source | 2454 | 254 | { \ | 2455 | 254 | AArch64_add_cs_detail_1( \ | 2456 | 254 | MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \ | 2457 | 254 | sizeof(T)); \ | 2458 | 254 | unsigned UnscaledVal = \ | 2459 | 254 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2460 | 254 | unsigned Shift = \ | 2461 | 254 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \ | 2462 | 254 | \ | 2463 | 254 | if ((UnscaledVal == 0) && \ | 2464 | 254 | (AArch64_AM_getShiftValue(Shift) != 0)) { \ | 2465 | 41 | SStream_concat(O, "%s", markup("<imm:")); \ | 2466 | 41 | SStream_concat1(O, '#'); \ | 2467 | 41 | printUInt64(O, (UnscaledVal)); \ | 2468 | 41 | SStream_concat0(O, markup(">")); \ | 2469 | 41 | printShifter(MI, OpNum + 1, O); \ | 2470 | 41 | return; \ | 2471 | 41 | } \ | 2472 | 254 | \ | 2473 | 254 | T Val; \ | 2474 | 213 | if (CONCAT(isSignedType, T)()) \ | 2475 | 213 | Val = (int8_t)UnscaledVal * \ | 2476 | 213 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2477 | 213 | else \ | 2478 | 213 | Val = (uint8_t)UnscaledVal * \ | 2479 | 0 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2480 | 213 | \ | 2481 | 213 | CONCAT(printImmSVE, T)(Val, O); \ | 2482 | 213 | } |
Line | Count | Source | 2454 | 231 | { \ | 2455 | 231 | AArch64_add_cs_detail_1( \ | 2456 | 231 | MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \ | 2457 | 231 | sizeof(T)); \ | 2458 | 231 | unsigned UnscaledVal = \ | 2459 | 231 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2460 | 231 | unsigned Shift = \ | 2461 | 231 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \ | 2462 | 231 | \ | 2463 | 231 | if ((UnscaledVal == 0) && \ | 2464 | 231 | (AArch64_AM_getShiftValue(Shift) != 0)) { \ | 2465 | 82 | SStream_concat(O, "%s", markup("<imm:")); \ | 2466 | 82 | SStream_concat1(O, '#'); \ | 2467 | 82 | printUInt64(O, (UnscaledVal)); \ | 2468 | 82 | SStream_concat0(O, markup(">")); \ | 2469 | 82 | printShifter(MI, OpNum + 1, O); \ | 2470 | 82 | return; \ | 2471 | 82 | } \ | 2472 | 231 | \ | 2473 | 231 | T Val; \ | 2474 | 149 | if (CONCAT(isSignedType, T)()) \ | 2475 | 149 | Val = (int8_t)UnscaledVal * \ | 2476 | 0 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2477 | 149 | else \ | 2478 | 149 | Val = (uint8_t)UnscaledVal * \ | 2479 | 149 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2480 | 149 | \ | 2481 | 149 | CONCAT(printImmSVE, T)(Val, O); \ | 2482 | 149 | } |
Line | Count | Source | 2454 | 61 | { \ | 2455 | 61 | AArch64_add_cs_detail_1( \ | 2456 | 61 | MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \ | 2457 | 61 | sizeof(T)); \ | 2458 | 61 | unsigned UnscaledVal = \ | 2459 | 61 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2460 | 61 | unsigned Shift = \ | 2461 | 61 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \ | 2462 | 61 | \ | 2463 | 61 | if ((UnscaledVal == 0) && \ | 2464 | 61 | (AArch64_AM_getShiftValue(Shift) != 0)) { \ | 2465 | 0 | SStream_concat(O, "%s", markup("<imm:")); \ | 2466 | 0 | SStream_concat1(O, '#'); \ | 2467 | 0 | printUInt64(O, (UnscaledVal)); \ | 2468 | 0 | SStream_concat0(O, markup(">")); \ | 2469 | 0 | printShifter(MI, OpNum + 1, O); \ | 2470 | 0 | return; \ | 2471 | 0 | } \ | 2472 | 61 | \ | 2473 | 61 | T Val; \ | 2474 | 61 | if (CONCAT(isSignedType, T)()) \ | 2475 | 61 | Val = (int8_t)UnscaledVal * \ | 2476 | 0 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2477 | 61 | else \ | 2478 | 61 | Val = (uint8_t)UnscaledVal * \ | 2479 | 61 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2480 | 61 | \ | 2481 | 61 | CONCAT(printImmSVE, T)(Val, O); \ | 2482 | 61 | } |
Line | Count | Source | 2454 | 131 | { \ | 2455 | 131 | AArch64_add_cs_detail_1( \ | 2456 | 131 | MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \ | 2457 | 131 | sizeof(T)); \ | 2458 | 131 | unsigned UnscaledVal = \ | 2459 | 131 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2460 | 131 | unsigned Shift = \ | 2461 | 131 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \ | 2462 | 131 | \ | 2463 | 131 | if ((UnscaledVal == 0) && \ | 2464 | 131 | (AArch64_AM_getShiftValue(Shift) != 0)) { \ | 2465 | 45 | SStream_concat(O, "%s", markup("<imm:")); \ | 2466 | 45 | SStream_concat1(O, '#'); \ | 2467 | 45 | printUInt64(O, (UnscaledVal)); \ | 2468 | 45 | SStream_concat0(O, markup(">")); \ | 2469 | 45 | printShifter(MI, OpNum + 1, O); \ | 2470 | 45 | return; \ | 2471 | 45 | } \ | 2472 | 131 | \ | 2473 | 131 | T Val; \ | 2474 | 86 | if (CONCAT(isSignedType, T)()) \ | 2475 | 86 | Val = (int8_t)UnscaledVal * \ | 2476 | 0 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2477 | 86 | else \ | 2478 | 86 | Val = (uint8_t)UnscaledVal * \ | 2479 | 86 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2480 | 86 | \ | 2481 | 86 | CONCAT(printImmSVE, T)(Val, O); \ | 2482 | 86 | } |
Line | Count | Source | 2454 | 155 | { \ | 2455 | 155 | AArch64_add_cs_detail_1( \ | 2456 | 155 | MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \ | 2457 | 155 | sizeof(T)); \ | 2458 | 155 | unsigned UnscaledVal = \ | 2459 | 155 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2460 | 155 | unsigned Shift = \ | 2461 | 155 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \ | 2462 | 155 | \ | 2463 | 155 | if ((UnscaledVal == 0) && \ | 2464 | 155 | (AArch64_AM_getShiftValue(Shift) != 0)) { \ | 2465 | 89 | SStream_concat(O, "%s", markup("<imm:")); \ | 2466 | 89 | SStream_concat1(O, '#'); \ | 2467 | 89 | printUInt64(O, (UnscaledVal)); \ | 2468 | 89 | SStream_concat0(O, markup(">")); \ | 2469 | 89 | printShifter(MI, OpNum + 1, O); \ | 2470 | 89 | return; \ | 2471 | 89 | } \ | 2472 | 155 | \ | 2473 | 155 | T Val; \ | 2474 | 66 | if (CONCAT(isSignedType, T)()) \ | 2475 | 66 | Val = (int8_t)UnscaledVal * \ | 2476 | 0 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2477 | 66 | else \ | 2478 | 66 | Val = (uint8_t)UnscaledVal * \ | 2479 | 66 | (1 << AArch64_AM_getShiftValue(Shift)); \ | 2480 | 66 | \ | 2481 | 66 | CONCAT(printImmSVE, T)(Val, O); \ | 2482 | 66 | } |
|
2483 | | DEFINE_printImm8OptLsl(int16_t); |
2484 | | DEFINE_printImm8OptLsl(int8_t); |
2485 | | DEFINE_printImm8OptLsl(int64_t); |
2486 | | DEFINE_printImm8OptLsl(int32_t); |
2487 | | DEFINE_printImm8OptLsl(uint16_t); |
2488 | | DEFINE_printImm8OptLsl(uint8_t); |
2489 | | DEFINE_printImm8OptLsl(uint64_t); |
2490 | | DEFINE_printImm8OptLsl(uint32_t); |
2491 | | |
2492 | | #define DEFINE_printSVELogicalImm(T) \ |
2493 | | void CONCAT(printSVELogicalImm, T)(MCInst * MI, unsigned OpNum, \ |
2494 | | SStream *O) \ |
2495 | 2.10k | { \ |
2496 | 2.10k | AArch64_add_cs_detail_1( \ |
2497 | 2.10k | MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \ |
2498 | 2.10k | sizeof(T)); \ |
2499 | 2.10k | typedef T SignedT; \ |
2500 | 2.10k | typedef CONCATS(u, T) UnsignedT; \ |
2501 | 2.10k | \ |
2502 | 2.10k | uint64_t Val = \ |
2503 | 2.10k | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ |
2504 | 2.10k | UnsignedT PrintVal = \ |
2505 | 2.10k | AArch64_AM_decodeLogicalImmediate(Val, 64); \ |
2506 | 2.10k | \ |
2507 | 2.10k | if ((int16_t)PrintVal == (SignedT)PrintVal) \ |
2508 | 2.10k | CONCAT(printImmSVE, T)((T)PrintVal, O); \ |
2509 | 2.10k | else if ((uint16_t)PrintVal == PrintVal) \ |
2510 | 609 | CONCAT(printImmSVE, T)(PrintVal, O); \ |
2511 | 609 | else { \ |
2512 | 392 | SStream_concat(O, "%s", markup("<imm:")); \ |
2513 | 392 | printUInt64Bang(O, ((uint64_t)PrintVal)); \ |
2514 | 392 | SStream_concat0(O, markup(">")); \ |
2515 | 392 | } \ |
2516 | 2.10k | } printSVELogicalImm_int16_t Line | Count | Source | 2495 | 998 | { \ | 2496 | 998 | AArch64_add_cs_detail_1( \ | 2497 | 998 | MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \ | 2498 | 998 | sizeof(T)); \ | 2499 | 998 | typedef T SignedT; \ | 2500 | 998 | typedef CONCATS(u, T) UnsignedT; \ | 2501 | 998 | \ | 2502 | 998 | uint64_t Val = \ | 2503 | 998 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2504 | 998 | UnsignedT PrintVal = \ | 2505 | 998 | AArch64_AM_decodeLogicalImmediate(Val, 64); \ | 2506 | 998 | \ | 2507 | 998 | if ((int16_t)PrintVal == (SignedT)PrintVal) \ | 2508 | 998 | CONCAT(printImmSVE, T)((T)PrintVal, O); \ | 2509 | 998 | else if ((uint16_t)PrintVal == PrintVal) \ | 2510 | 0 | CONCAT(printImmSVE, T)(PrintVal, O); \ | 2511 | 0 | else { \ | 2512 | 0 | SStream_concat(O, "%s", markup("<imm:")); \ | 2513 | 0 | printUInt64Bang(O, ((uint64_t)PrintVal)); \ | 2514 | 0 | SStream_concat0(O, markup(">")); \ | 2515 | 0 | } \ | 2516 | 998 | } |
printSVELogicalImm_int32_t Line | Count | Source | 2495 | 505 | { \ | 2496 | 505 | AArch64_add_cs_detail_1( \ | 2497 | 505 | MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \ | 2498 | 505 | sizeof(T)); \ | 2499 | 505 | typedef T SignedT; \ | 2500 | 505 | typedef CONCATS(u, T) UnsignedT; \ | 2501 | 505 | \ | 2502 | 505 | uint64_t Val = \ | 2503 | 505 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2504 | 505 | UnsignedT PrintVal = \ | 2505 | 505 | AArch64_AM_decodeLogicalImmediate(Val, 64); \ | 2506 | 505 | \ | 2507 | 505 | if ((int16_t)PrintVal == (SignedT)PrintVal) \ | 2508 | 505 | CONCAT(printImmSVE, T)((T)PrintVal, O); \ | 2509 | 505 | else if ((uint16_t)PrintVal == PrintVal) \ | 2510 | 149 | CONCAT(printImmSVE, T)(PrintVal, O); \ | 2511 | 149 | else { \ | 2512 | 134 | SStream_concat(O, "%s", markup("<imm:")); \ | 2513 | 134 | printUInt64Bang(O, ((uint64_t)PrintVal)); \ | 2514 | 134 | SStream_concat0(O, markup(">")); \ | 2515 | 134 | } \ | 2516 | 505 | } |
printSVELogicalImm_int64_t Line | Count | Source | 2495 | 600 | { \ | 2496 | 600 | AArch64_add_cs_detail_1( \ | 2497 | 600 | MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \ | 2498 | 600 | sizeof(T)); \ | 2499 | 600 | typedef T SignedT; \ | 2500 | 600 | typedef CONCATS(u, T) UnsignedT; \ | 2501 | 600 | \ | 2502 | 600 | uint64_t Val = \ | 2503 | 600 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2504 | 600 | UnsignedT PrintVal = \ | 2505 | 600 | AArch64_AM_decodeLogicalImmediate(Val, 64); \ | 2506 | 600 | \ | 2507 | 600 | if ((int16_t)PrintVal == (SignedT)PrintVal) \ | 2508 | 600 | CONCAT(printImmSVE, T)((T)PrintVal, O); \ | 2509 | 600 | else if ((uint16_t)PrintVal == PrintVal) \ | 2510 | 460 | CONCAT(printImmSVE, T)(PrintVal, O); \ | 2511 | 460 | else { \ | 2512 | 258 | SStream_concat(O, "%s", markup("<imm:")); \ | 2513 | 258 | printUInt64Bang(O, ((uint64_t)PrintVal)); \ | 2514 | 258 | SStream_concat0(O, markup(">")); \ | 2515 | 258 | } \ | 2516 | 600 | } |
|
2517 | | DEFINE_printSVELogicalImm(int16_t); |
2518 | | DEFINE_printSVELogicalImm(int32_t); |
2519 | | DEFINE_printSVELogicalImm(int64_t); |
2520 | | |
2521 | | #define DEFINE_printZPRasFPR(Width) \ |
2522 | | void CONCAT(printZPRasFPR, Width)(MCInst * MI, unsigned OpNum, \ |
2523 | | SStream *O) \ |
2524 | 2.02k | { \ |
2525 | 2.02k | AArch64_add_cs_detail_1( \ |
2526 | 2.02k | MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \ |
2527 | 2.02k | Width); \ |
2528 | 2.02k | unsigned Base; \ |
2529 | 2.02k | switch (Width) { \ |
2530 | 178 | case 8: \ |
2531 | 178 | Base = AArch64_B0; \ |
2532 | 178 | break; \ |
2533 | 788 | case 16: \ |
2534 | 788 | Base = AArch64_H0; \ |
2535 | 788 | break; \ |
2536 | 252 | case 32: \ |
2537 | 252 | Base = AArch64_S0; \ |
2538 | 252 | break; \ |
2539 | 754 | case 64: \ |
2540 | 754 | Base = AArch64_D0; \ |
2541 | 754 | break; \ |
2542 | 53 | case 128: \ |
2543 | 53 | Base = AArch64_Q0; \ |
2544 | 53 | break; \ |
2545 | 0 | default: \ |
2546 | 0 | CS_ASSERT_RET(0 && "Unsupported width"); \ |
2547 | 2.02k | } \ |
2548 | 2.02k | unsigned Reg = \ |
2549 | 2.02k | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ |
2550 | 2.02k | printRegName(O, Reg - AArch64_Z0 + Base); \ |
2551 | 2.02k | } Line | Count | Source | 2524 | 178 | { \ | 2525 | 178 | AArch64_add_cs_detail_1( \ | 2526 | 178 | MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \ | 2527 | 178 | Width); \ | 2528 | 178 | unsigned Base; \ | 2529 | 178 | switch (Width) { \ | 2530 | 178 | case 8: \ | 2531 | 178 | Base = AArch64_B0; \ | 2532 | 178 | break; \ | 2533 | 0 | case 16: \ | 2534 | 0 | Base = AArch64_H0; \ | 2535 | 0 | break; \ | 2536 | 0 | case 32: \ | 2537 | 0 | Base = AArch64_S0; \ | 2538 | 0 | break; \ | 2539 | 0 | case 64: \ | 2540 | 0 | Base = AArch64_D0; \ | 2541 | 0 | break; \ | 2542 | 0 | case 128: \ | 2543 | 0 | Base = AArch64_Q0; \ | 2544 | 0 | break; \ | 2545 | 0 | default: \ | 2546 | 0 | CS_ASSERT_RET(0 && "Unsupported width"); \ | 2547 | 178 | } \ | 2548 | 178 | unsigned Reg = \ | 2549 | 178 | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 2550 | 178 | printRegName(O, Reg - AArch64_Z0 + Base); \ | 2551 | 178 | } |
Line | Count | Source | 2524 | 754 | { \ | 2525 | 754 | AArch64_add_cs_detail_1( \ | 2526 | 754 | MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \ | 2527 | 754 | Width); \ | 2528 | 754 | unsigned Base; \ | 2529 | 754 | switch (Width) { \ | 2530 | 0 | case 8: \ | 2531 | 0 | Base = AArch64_B0; \ | 2532 | 0 | break; \ | 2533 | 0 | case 16: \ | 2534 | 0 | Base = AArch64_H0; \ | 2535 | 0 | break; \ | 2536 | 0 | case 32: \ | 2537 | 0 | Base = AArch64_S0; \ | 2538 | 0 | break; \ | 2539 | 754 | case 64: \ | 2540 | 754 | Base = AArch64_D0; \ | 2541 | 754 | break; \ | 2542 | 0 | case 128: \ | 2543 | 0 | Base = AArch64_Q0; \ | 2544 | 0 | break; \ | 2545 | 0 | default: \ | 2546 | 0 | CS_ASSERT_RET(0 && "Unsupported width"); \ | 2547 | 754 | } \ | 2548 | 754 | unsigned Reg = \ | 2549 | 754 | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 2550 | 754 | printRegName(O, Reg - AArch64_Z0 + Base); \ | 2551 | 754 | } |
Line | Count | Source | 2524 | 788 | { \ | 2525 | 788 | AArch64_add_cs_detail_1( \ | 2526 | 788 | MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \ | 2527 | 788 | Width); \ | 2528 | 788 | unsigned Base; \ | 2529 | 788 | switch (Width) { \ | 2530 | 0 | case 8: \ | 2531 | 0 | Base = AArch64_B0; \ | 2532 | 0 | break; \ | 2533 | 788 | case 16: \ | 2534 | 788 | Base = AArch64_H0; \ | 2535 | 788 | break; \ | 2536 | 0 | case 32: \ | 2537 | 0 | Base = AArch64_S0; \ | 2538 | 0 | break; \ | 2539 | 0 | case 64: \ | 2540 | 0 | Base = AArch64_D0; \ | 2541 | 0 | break; \ | 2542 | 0 | case 128: \ | 2543 | 0 | Base = AArch64_Q0; \ | 2544 | 0 | break; \ | 2545 | 0 | default: \ | 2546 | 0 | CS_ASSERT_RET(0 && "Unsupported width"); \ | 2547 | 788 | } \ | 2548 | 788 | unsigned Reg = \ | 2549 | 788 | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 2550 | 788 | printRegName(O, Reg - AArch64_Z0 + Base); \ | 2551 | 788 | } |
Line | Count | Source | 2524 | 252 | { \ | 2525 | 252 | AArch64_add_cs_detail_1( \ | 2526 | 252 | MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \ | 2527 | 252 | Width); \ | 2528 | 252 | unsigned Base; \ | 2529 | 252 | switch (Width) { \ | 2530 | 0 | case 8: \ | 2531 | 0 | Base = AArch64_B0; \ | 2532 | 0 | break; \ | 2533 | 0 | case 16: \ | 2534 | 0 | Base = AArch64_H0; \ | 2535 | 0 | break; \ | 2536 | 252 | case 32: \ | 2537 | 252 | Base = AArch64_S0; \ | 2538 | 252 | break; \ | 2539 | 0 | case 64: \ | 2540 | 0 | Base = AArch64_D0; \ | 2541 | 0 | break; \ | 2542 | 0 | case 128: \ | 2543 | 0 | Base = AArch64_Q0; \ | 2544 | 0 | break; \ | 2545 | 0 | default: \ | 2546 | 0 | CS_ASSERT_RET(0 && "Unsupported width"); \ | 2547 | 252 | } \ | 2548 | 252 | unsigned Reg = \ | 2549 | 252 | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 2550 | 252 | printRegName(O, Reg - AArch64_Z0 + Base); \ | 2551 | 252 | } |
Line | Count | Source | 2524 | 53 | { \ | 2525 | 53 | AArch64_add_cs_detail_1( \ | 2526 | 53 | MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \ | 2527 | 53 | Width); \ | 2528 | 53 | unsigned Base; \ | 2529 | 53 | switch (Width) { \ | 2530 | 0 | case 8: \ | 2531 | 0 | Base = AArch64_B0; \ | 2532 | 0 | break; \ | 2533 | 0 | case 16: \ | 2534 | 0 | Base = AArch64_H0; \ | 2535 | 0 | break; \ | 2536 | 0 | case 32: \ | 2537 | 0 | Base = AArch64_S0; \ | 2538 | 0 | break; \ | 2539 | 0 | case 64: \ | 2540 | 0 | Base = AArch64_D0; \ | 2541 | 0 | break; \ | 2542 | 53 | case 128: \ | 2543 | 53 | Base = AArch64_Q0; \ | 2544 | 53 | break; \ | 2545 | 0 | default: \ | 2546 | 0 | CS_ASSERT_RET(0 && "Unsupported width"); \ | 2547 | 53 | } \ | 2548 | 53 | unsigned Reg = \ | 2549 | 53 | MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \ | 2550 | 53 | printRegName(O, Reg - AArch64_Z0 + Base); \ | 2551 | 53 | } |
|
2552 | | DEFINE_printZPRasFPR(8); |
2553 | | DEFINE_printZPRasFPR(64); |
2554 | | DEFINE_printZPRasFPR(16); |
2555 | | DEFINE_printZPRasFPR(32); |
2556 | | DEFINE_printZPRasFPR(128); |
2557 | | |
2558 | | #define DEFINE_printExactFPImm(ImmIs0, ImmIs1) \ |
2559 | | void CONCAT(printExactFPImm, CONCAT(ImmIs0, ImmIs1))( \ |
2560 | | MCInst * MI, unsigned OpNum, SStream *O) \ |
2561 | 428 | { \ |
2562 | 428 | AArch64_add_cs_detail_2( \ |
2563 | 428 | MI, \ |
2564 | 428 | CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \ |
2565 | 428 | ImmIs1), \ |
2566 | 428 | OpNum, ImmIs0, ImmIs1); \ |
2567 | 428 | const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \ |
2568 | 428 | AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \ |
2569 | 428 | const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \ |
2570 | 428 | AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \ |
2571 | 428 | unsigned Val = \ |
2572 | 428 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ |
2573 | 428 | SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \ |
2574 | 428 | (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \ |
2575 | 428 | SStream_concat0(O, markup(">")); \ |
2576 | 428 | } printExactFPImm_AArch64ExactFPImm_half_AArch64ExactFPImm_one Line | Count | Source | 2561 | 151 | { \ | 2562 | 151 | AArch64_add_cs_detail_2( \ | 2563 | 151 | MI, \ | 2564 | 151 | CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \ | 2565 | 151 | ImmIs1), \ | 2566 | 151 | OpNum, ImmIs0, ImmIs1); \ | 2567 | 151 | const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \ | 2568 | 151 | AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \ | 2569 | 151 | const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \ | 2570 | 151 | AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \ | 2571 | 151 | unsigned Val = \ | 2572 | 151 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2573 | 151 | SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \ | 2574 | 151 | (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \ | 2575 | 151 | SStream_concat0(O, markup(">")); \ | 2576 | 151 | } |
printExactFPImm_AArch64ExactFPImm_zero_AArch64ExactFPImm_one Line | Count | Source | 2561 | 195 | { \ | 2562 | 195 | AArch64_add_cs_detail_2( \ | 2563 | 195 | MI, \ | 2564 | 195 | CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \ | 2565 | 195 | ImmIs1), \ | 2566 | 195 | OpNum, ImmIs0, ImmIs1); \ | 2567 | 195 | const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \ | 2568 | 195 | AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \ | 2569 | 195 | const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \ | 2570 | 195 | AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \ | 2571 | 195 | unsigned Val = \ | 2572 | 195 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2573 | 195 | SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \ | 2574 | 195 | (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \ | 2575 | 195 | SStream_concat0(O, markup(">")); \ | 2576 | 195 | } |
printExactFPImm_AArch64ExactFPImm_half_AArch64ExactFPImm_two Line | Count | Source | 2561 | 82 | { \ | 2562 | 82 | AArch64_add_cs_detail_2( \ | 2563 | 82 | MI, \ | 2564 | 82 | CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \ | 2565 | 82 | ImmIs1), \ | 2566 | 82 | OpNum, ImmIs0, ImmIs1); \ | 2567 | 82 | const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \ | 2568 | 82 | AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \ | 2569 | 82 | const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \ | 2570 | 82 | AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \ | 2571 | 82 | unsigned Val = \ | 2572 | 82 | MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \ | 2573 | 82 | SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \ | 2574 | 82 | (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \ | 2575 | 82 | SStream_concat0(O, markup(">")); \ | 2576 | 82 | } |
|
2577 | | DEFINE_printExactFPImm(AArch64ExactFPImm_half, AArch64ExactFPImm_one); |
2578 | | DEFINE_printExactFPImm(AArch64ExactFPImm_zero, AArch64ExactFPImm_one); |
2579 | | DEFINE_printExactFPImm(AArch64ExactFPImm_half, AArch64ExactFPImm_two); |
2580 | | |
2581 | | void printGPR64as32(MCInst *MI, unsigned OpNum, SStream *O) |
2582 | 2.76k | { |
2583 | 2.76k | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_GPR64as32, OpNum); |
2584 | 2.76k | unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); |
2585 | 2.76k | printRegName(O, getWRegFromXReg(Reg)); |
2586 | 2.76k | } |
2587 | | |
2588 | | void printGPR64x8(MCInst *MI, unsigned OpNum, SStream *O) |
2589 | 140 | { |
2590 | 140 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_GPR64x8, OpNum); |
2591 | 140 | unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); |
2592 | 140 | printRegName(O, |
2593 | 140 | MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_x8sub_0)); |
2594 | 140 | } |
2595 | | |
2596 | | void printSyspXzrPair(MCInst *MI, unsigned OpNum, SStream *O) |
2597 | 886 | { |
2598 | 886 | AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SyspXzrPair, OpNum); |
2599 | 886 | unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); |
2600 | | |
2601 | 886 | SStream_concat(O, "%s%s", getRegisterName(Reg, AArch64_NoRegAltName), |
2602 | 886 | ", "); |
2603 | 886 | SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName)); |
2604 | 886 | } |
2605 | | |
2606 | | const char *AArch64_LLVM_getRegisterName(unsigned RegNo, unsigned AltIdx) |
2607 | 144k | { |
2608 | 144k | return getRegisterName(RegNo, AltIdx); |
2609 | 144k | } |
2610 | | |
2611 | | void AArch64_LLVM_printInstruction(MCInst *MI, SStream *O, |
2612 | | void * /* MCRegisterInfo* */ info) |
2613 | 250k | { |
2614 | 250k | printInst(MI, MI->address, "", O); |
2615 | 250k | } |