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