Coverage Report

Created: 2025-12-05 06:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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
453k
#define CONCAT(a, b) CONCAT_(a, b)
49
453k
#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
737k
{
81
737k
  SStream_concat(OS, "%s%s", markup("<reg:"),
82
737k
           getRegisterName(Reg, AArch64_NoRegAltName));
83
737k
  SStream_concat0(OS, markup(">"));
84
737k
}
85
86
void printRegNameAlt(SStream *OS, unsigned Reg, unsigned AltIdx)
87
172k
{
88
172k
  SStream_concat(OS, "%s%s", markup("<reg:"),
89
172k
           getRegisterName(Reg, AltIdx));
90
172k
  SStream_concat0(OS, markup(">"));
91
172k
}
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
365k
{
100
365k
  bool isAlias = false;
101
365k
  bool useAliasDetails = map_use_alias_details(MI);
102
365k
  map_set_fill_detail_ops(MI, useAliasDetails);
103
104
365k
  unsigned Opcode = MCInst_getOpcode(MI);
105
106
365k
  if (Opcode == AArch64_SYSxt) {
107
5.39k
    if (printSysAlias(MI, O)) {
108
2.40k
      isAlias = true;
109
2.40k
      MCInst_setIsAlias(MI, isAlias);
110
2.40k
      if (useAliasDetails)
111
2.40k
        return;
112
2.40k
    }
113
5.39k
  }
114
115
363k
  if (Opcode == AArch64_SYSPxt || Opcode == AArch64_SYSPxt_XZR) {
116
3.49k
    if (printSyspAlias(MI, O)) {
117
1.84k
      isAlias = true;
118
1.84k
      MCInst_setIsAlias(MI, isAlias);
119
1.84k
      if (useAliasDetails)
120
1.84k
        return;
121
1.84k
    }
122
3.49k
  }
123
124
  // RPRFM overlaps PRFM (reg), so try to print it as RPRFM here.
125
361k
  if ((Opcode == AArch64_PRFMroX) || (Opcode == AArch64_PRFMroW)) {
126
401
    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
401
  }
133
134
  // SBFM/UBFM should print to a nicer aliased form if possible.
135
361k
  if (Opcode == AArch64_SBFMXri || Opcode == AArch64_SBFMWri ||
136
357k
      Opcode == AArch64_UBFMXri || Opcode == AArch64_UBFMWri) {
137
5.30k
    MCOperand *Op0 = MCInst_getOperand(MI, (0));
138
5.30k
    MCOperand *Op1 = MCInst_getOperand(MI, (1));
139
5.30k
    MCOperand *Op2 = MCInst_getOperand(MI, (2));
140
5.30k
    MCOperand *Op3 = MCInst_getOperand(MI, (3));
141
142
5.30k
    bool IsSigned = (Opcode == AArch64_SBFMXri ||
143
1.96k
         Opcode == AArch64_SBFMWri);
144
5.30k
    bool Is64Bit = (Opcode == AArch64_SBFMXri ||
145
1.96k
        Opcode == AArch64_UBFMXri);
146
5.30k
    if (MCOperand_isImm(Op2) && MCOperand_getImm(Op2) == 0 &&
147
4.10k
        MCOperand_isImm(Op3)) {
148
4.10k
      const char *AsmMnemonic = NULL;
149
150
4.10k
      switch (MCOperand_getImm(Op3)) {
151
885
      default:
152
885
        break;
153
1.09k
      case 7:
154
1.09k
        if (IsSigned)
155
866
          AsmMnemonic = "sxtb";
156
227
        else if (!Is64Bit)
157
39
          AsmMnemonic = "uxtb";
158
1.09k
        break;
159
994
      case 15:
160
994
        if (IsSigned)
161
437
          AsmMnemonic = "sxth";
162
557
        else if (!Is64Bit)
163
411
          AsmMnemonic = "uxth";
164
994
        break;
165
1.13k
      case 31:
166
        // *xtw is only valid for signed 64-bit operations.
167
1.13k
        if (Is64Bit && IsSigned)
168
1.06k
          AsmMnemonic = "sxtw";
169
1.13k
        break;
170
4.10k
      }
171
172
4.10k
      if (AsmMnemonic) {
173
2.82k
        SStream_concat(O, "%s", AsmMnemonic);
174
2.82k
        SStream_concat0(O, " ");
175
176
2.82k
        printRegName(O, MCOperand_getReg(Op0));
177
2.82k
        SStream_concat0(O, ", ");
178
2.82k
        printRegName(O, getWRegFromXReg(
179
2.82k
              MCOperand_getReg(Op1)));
180
2.82k
        if (detail_is_set(MI) && useAliasDetails) {
181
2.82k
          AArch64_set_detail_op_reg(
182
2.82k
            MI, 0, MCOperand_getReg(Op0));
183
2.82k
          AArch64_set_detail_op_reg(
184
2.82k
            MI, 1,
185
2.82k
            getWRegFromXReg(
186
2.82k
              MCOperand_getReg(Op1)));
187
2.82k
          if (strings_match(AsmMnemonic, "uxtb"))
188
39
            AArch64_get_detail_op(MI, -1)
189
39
              ->ext =
190
39
              AARCH64_EXT_UXTB;
191
2.78k
          else if (strings_match(AsmMnemonic,
192
2.78k
                     "sxtb"))
193
866
            AArch64_get_detail_op(MI, -1)
194
866
              ->ext =
195
866
              AARCH64_EXT_SXTB;
196
1.91k
          else if (strings_match(AsmMnemonic,
197
1.91k
                     "uxth"))
198
411
            AArch64_get_detail_op(MI, -1)
199
411
              ->ext =
200
411
              AARCH64_EXT_UXTH;
201
1.50k
          else if (strings_match(AsmMnemonic,
202
1.50k
                     "sxth"))
203
437
            AArch64_get_detail_op(MI, -1)
204
437
              ->ext =
205
437
              AARCH64_EXT_SXTH;
206
1.06k
          else if (strings_match(AsmMnemonic,
207
1.06k
                     "sxtw"))
208
1.06k
            AArch64_get_detail_op(MI, -1)
209
1.06k
              ->ext =
210
1.06k
              AARCH64_EXT_SXTW;
211
0
          else
212
0
            AArch64_get_detail_op(MI, -1)
213
0
              ->ext =
214
0
              AARCH64_EXT_INVALID;
215
2.82k
        }
216
2.82k
        isAlias = true;
217
2.82k
        MCInst_setIsAlias(MI, isAlias);
218
2.82k
        if (useAliasDetails)
219
2.82k
          return;
220
0
        else
221
0
          goto add_real_detail;
222
2.82k
      }
223
4.10k
    }
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
2.48k
    if (MCOperand_isImm(Op2) && MCOperand_isImm(Op3)) {
229
2.48k
      const char *AsmMnemonic = NULL;
230
2.48k
      int shift = 0;
231
2.48k
      int64_t immr = MCOperand_getImm(Op2);
232
2.48k
      int64_t imms = MCOperand_getImm(Op3);
233
2.48k
      if (Opcode == AArch64_UBFMWri && imms != 0x1F &&
234
202
          ((imms + 1) == immr)) {
235
100
        AsmMnemonic = "lsl";
236
100
        shift = 31 - imms;
237
2.38k
      } else if (Opcode == AArch64_UBFMXri && imms != 0x3f &&
238
736
           ((imms + 1 == immr))) {
239
45
        AsmMnemonic = "lsl";
240
45
        shift = 63 - imms;
241
2.34k
      } else if (Opcode == AArch64_UBFMWri && imms == 0x1f) {
242
45
        AsmMnemonic = "lsr";
243
45
        shift = immr;
244
2.29k
      } else if (Opcode == AArch64_UBFMXri && imms == 0x3f) {
245
38
        AsmMnemonic = "lsr";
246
38
        shift = immr;
247
2.25k
      } else if (Opcode == AArch64_SBFMWri && imms == 0x1f) {
248
36
        AsmMnemonic = "asr";
249
36
        shift = immr;
250
2.22k
      } else if (Opcode == AArch64_SBFMXri && imms == 0x3f) {
251
226
        AsmMnemonic = "asr";
252
226
        shift = immr;
253
226
      }
254
2.48k
      if (AsmMnemonic) {
255
490
        SStream_concat(O, "%s", AsmMnemonic);
256
490
        SStream_concat0(O, " ");
257
258
490
        printRegName(O, MCOperand_getReg(Op0));
259
490
        SStream_concat0(O, ", ");
260
490
        printRegName(O, MCOperand_getReg(Op1));
261
490
        SStream_concat(O, "%s%s#%d", ", ",
262
490
                 markup("<imm:"), shift);
263
490
        SStream_concat0(O, markup(">"));
264
490
        if (detail_is_set(MI) && useAliasDetails) {
265
490
          AArch64_set_detail_op_reg(
266
490
            MI, 0, MCOperand_getReg(Op0));
267
490
          AArch64_set_detail_op_reg(
268
490
            MI, 1, MCOperand_getReg(Op1));
269
490
          if (strings_match(AsmMnemonic, "lsl"))
270
145
            AArch64_get_detail_op(MI, -1)
271
145
              ->shift.type =
272
145
              AARCH64_SFT_LSL;
273
345
          else if (strings_match(AsmMnemonic,
274
345
                     "lsr"))
275
83
            AArch64_get_detail_op(MI, -1)
276
83
              ->shift.type =
277
83
              AARCH64_SFT_LSR;
278
262
          else if (strings_match(AsmMnemonic,
279
262
                     "asr"))
280
262
            AArch64_get_detail_op(MI, -1)
281
262
              ->shift.type =
282
262
              AARCH64_SFT_ASR;
283
0
          else
284
0
            AArch64_get_detail_op(MI, -1)
285
0
              ->shift.type =
286
0
              AARCH64_SFT_INVALID;
287
490
          AArch64_get_detail_op(MI, -1)
288
490
            ->shift.value = shift;
289
490
        }
290
490
        isAlias = true;
291
490
        MCInst_setIsAlias(MI, isAlias);
292
490
        if (useAliasDetails)
293
490
          return;
294
0
        else
295
0
          goto add_real_detail;
296
490
      }
297
2.48k
    }
298
299
    // SBFIZ/UBFIZ aliases
300
1.99k
    if (MCOperand_getImm(Op2) > MCOperand_getImm(Op3)) {
301
834
      SStream_concat(O, "%s", (IsSigned ? "sbfiz" : "ubfiz"));
302
834
      SStream_concat0(O, " ");
303
304
834
      printRegName(O, MCOperand_getReg(Op0));
305
834
      SStream_concat0(O, ", ");
306
834
      printRegName(O, MCOperand_getReg(Op1));
307
834
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
308
834
      printUInt32Bang(O, (Is64Bit ? 64 : 32) -
309
834
               MCOperand_getImm(Op2));
310
834
      SStream_concat(O, "%s%s%s", markup(">"), ", ",
311
834
               markup("<imm:"));
312
834
      printInt64Bang(O, MCOperand_getImm(Op3) + 1);
313
834
      SStream_concat0(O, markup(">"));
314
834
      if (detail_is_set(MI) && useAliasDetails) {
315
834
        AArch64_set_detail_op_reg(
316
834
          MI, 0, MCOperand_getReg(Op0));
317
834
        AArch64_set_detail_op_reg(
318
834
          MI, 1, MCOperand_getReg(Op1));
319
834
        AArch64_set_detail_op_imm(
320
834
          MI, 2, AARCH64_OP_IMM,
321
834
          (Is64Bit ? 64 : 32) -
322
834
            MCOperand_getImm(Op2));
323
834
        AArch64_set_detail_op_imm(
324
834
          MI, 3, AARCH64_OP_IMM,
325
834
          MCOperand_getImm(Op3) + 1);
326
834
      }
327
834
      isAlias = true;
328
834
      MCInst_setIsAlias(MI, isAlias);
329
834
      if (useAliasDetails)
330
834
        return;
331
0
      else
332
0
        goto add_real_detail;
333
834
    }
334
335
    // Otherwise SBFX/UBFX is the preferred form
336
1.16k
    SStream_concat(O, "%s", (IsSigned ? "sbfx" : "ubfx"));
337
1.16k
    SStream_concat0(O, " ");
338
339
1.16k
    printRegName(O, MCOperand_getReg(Op0));
340
1.16k
    SStream_concat0(O, ", ");
341
1.16k
    printRegName(O, MCOperand_getReg(Op1));
342
1.16k
    SStream_concat(O, "%s%s", ", ", markup("<imm:"));
343
1.16k
    printInt64Bang(O, MCOperand_getImm(Op2));
344
1.16k
    SStream_concat(O, "%s%s%s", markup(">"), ", ", markup("<imm:"));
345
1.16k
    printInt64Bang(O, MCOperand_getImm(Op3) -
346
1.16k
            MCOperand_getImm(Op2) + 1);
347
1.16k
    SStream_concat0(O, markup(">"));
348
1.16k
    if (detail_is_set(MI) && useAliasDetails) {
349
1.16k
      AArch64_set_detail_op_reg(MI, 0, MCOperand_getReg(Op0));
350
1.16k
      AArch64_set_detail_op_reg(MI, 1, MCOperand_getReg(Op1));
351
1.16k
      AArch64_set_detail_op_imm(MI, 2, AARCH64_OP_IMM,
352
1.16k
              MCOperand_getImm(Op2));
353
1.16k
      AArch64_set_detail_op_imm(
354
1.16k
        MI, 3, AARCH64_OP_IMM,
355
1.16k
        MCOperand_getImm(Op3) - MCOperand_getImm(Op2) +
356
1.16k
          1);
357
1.16k
    }
358
1.16k
    isAlias = true;
359
1.16k
    MCInst_setIsAlias(MI, isAlias);
360
1.16k
    if (useAliasDetails)
361
1.16k
      return;
362
0
    else
363
0
      goto add_real_detail;
364
1.16k
  }
365
366
356k
  if (Opcode == AArch64_BFMXri || Opcode == AArch64_BFMWri) {
367
1.41k
    isAlias = true;
368
1.41k
    MCInst_setIsAlias(MI, isAlias);
369
1.41k
    MCOperand *Op0 = MCInst_getOperand(MI, (0)); // Op1 == Op0
370
1.41k
    MCOperand *Op2 = MCInst_getOperand(MI, (2));
371
1.41k
    int ImmR = MCOperand_getImm(MCInst_getOperand(MI, (3)));
372
1.41k
    int ImmS = MCOperand_getImm(MCInst_getOperand(MI, (4)));
373
374
1.41k
    if ((MCOperand_getReg(Op2) == AArch64_WZR ||
375
1.38k
         MCOperand_getReg(Op2) == AArch64_XZR) &&
376
695
        (ImmR == 0 || ImmS < ImmR) &&
377
428
        (AArch64_getFeatureBits(MI->csh->mode,
378
428
              AArch64_FeatureAll) ||
379
0
         AArch64_getFeatureBits(MI->csh->mode,
380
428
              AArch64_HasV8_2aOps))) {
381
      // BFC takes precedence over its entire range, sligtly differently
382
      // to BFI.
383
428
      int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32;
384
428
      int LSB = (BitWidth - ImmR) % BitWidth;
385
428
      int Width = ImmS + 1;
386
387
428
      SStream_concat0(O, "bfc ");
388
428
      printRegName(O, MCOperand_getReg(Op0));
389
428
      SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"),
390
428
               LSB);
391
428
      SStream_concat(O, "%s%s%s#%d", markup(">"), ", ",
392
428
               markup("<imm:"), Width);
393
428
      SStream_concat0(O, markup(">"));
394
428
      if (detail_is_set(MI) && useAliasDetails) {
395
428
        AArch64_set_detail_op_reg(
396
428
          MI, 0, MCOperand_getReg(Op0));
397
428
        AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM,
398
428
                LSB);
399
428
        AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM,
400
428
                Width);
401
428
      }
402
403
428
      if (useAliasDetails)
404
428
        return;
405
0
      else
406
0
        goto add_real_detail;
407
988
    } else if (ImmS < ImmR) {
408
      // BFI alias
409
460
      int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32;
410
460
      int LSB = (BitWidth - ImmR) % BitWidth;
411
460
      int Width = ImmS + 1;
412
413
460
      SStream_concat0(O, "bfi ");
414
460
      printRegName(O, MCOperand_getReg(Op0));
415
460
      SStream_concat0(O, ", ");
416
460
      printRegName(O, MCOperand_getReg(Op2));
417
460
      SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"),
418
460
               LSB);
419
460
      SStream_concat(O, "%s%s%s#%d", markup(">"), ", ",
420
460
               markup("<imm:"), Width);
421
460
      SStream_concat0(O, markup(">"));
422
460
      if (detail_is_set(MI) && useAliasDetails) {
423
460
        AArch64_set_detail_op_reg(
424
460
          MI, 0, MCOperand_getReg(Op0));
425
460
        AArch64_set_detail_op_reg(
426
460
          MI, 2, MCOperand_getReg(Op2));
427
460
        AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM,
428
460
                LSB);
429
460
        AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM,
430
460
                Width);
431
460
      }
432
460
      if (useAliasDetails)
433
460
        return;
434
0
      else
435
0
        goto add_real_detail;
436
460
    }
437
438
528
    int LSB = ImmR;
439
528
    int Width = ImmS - ImmR + 1;
440
    // Otherwise BFXIL the preferred form
441
528
    SStream_concat0(O, "bfxil ");
442
528
    printRegName(O, MCOperand_getReg(Op0));
443
528
    SStream_concat0(O, ", ");
444
528
    printRegName(O, MCOperand_getReg(Op2));
445
528
    SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"), LSB);
446
528
    SStream_concat(O, "%s%s%s#%d", markup(">"), ", ",
447
528
             markup("<imm:"), Width);
448
528
    SStream_concat0(O, markup(">"));
449
528
    if (detail_is_set(MI) && useAliasDetails) {
450
528
      AArch64_set_detail_op_reg(MI, 0, MCOperand_getReg(Op0));
451
528
      AArch64_set_detail_op_reg(MI, 2, MCOperand_getReg(Op2));
452
528
      AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM, LSB);
453
528
      AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM, Width);
454
528
    }
455
528
    if (useAliasDetails)
456
528
      return;
457
528
  }
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
354k
  if ((Opcode == AArch64_MOVZXi || Opcode == AArch64_MOVZWi ||
463
354k
       Opcode == AArch64_MOVNXi || Opcode == AArch64_MOVNWi) &&
464
1.50k
      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
354k
  if ((Opcode == AArch64_MOVKXi || Opcode == AArch64_MOVKWi) &&
473
826
      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
354k
  if ((Opcode == AArch64_MOVZXi || Opcode == AArch64_MOVZWi) &&
487
883
      MCOperand_isImm(MCInst_getOperand(MI, (1))) &&
488
883
      MCOperand_isImm(MCInst_getOperand(MI, (2)))) {
489
883
    int RegWidth = Opcode == AArch64_MOVZXi ? 64 : 32;
490
883
    int Shift = MCOperand_getImm(MCInst_getOperand(MI, (2)));
491
883
    uint64_t Value =
492
883
      (uint64_t)MCOperand_getImm(MCInst_getOperand(MI, (1)))
493
883
      << Shift;
494
495
883
    if (AArch64_AM_isMOVZMovAlias(
496
883
          Value, Shift, Opcode == AArch64_MOVZXi ? 64 : 32)) {
497
723
      isAlias = true;
498
723
      MCInst_setIsAlias(MI, isAlias);
499
723
      SStream_concat0(O, "mov ");
500
723
      printRegName(O, MCOperand_getReg(
501
723
            MCInst_getOperand(MI, (0))));
502
723
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
503
723
      printInt64Bang(O, SignExtend64(Value, RegWidth));
504
723
      SStream_concat0(O, markup(">"));
505
723
      if (detail_is_set(MI) && useAliasDetails) {
506
723
        AArch64_set_detail_op_reg(
507
723
          MI, 0, MCInst_getOpVal(MI, 0));
508
723
        AArch64_set_detail_op_imm(
509
723
          MI, 1, AARCH64_OP_IMM,
510
723
          SignExtend64(Value, RegWidth));
511
723
      }
512
723
      if (useAliasDetails)
513
723
        return;
514
723
    }
515
883
  }
516
517
354k
  if ((Opcode == AArch64_MOVNXi || Opcode == AArch64_MOVNWi) &&
518
620
      MCOperand_isImm(MCInst_getOperand(MI, (1))) &&
519
620
      MCOperand_isImm(MCInst_getOperand(MI, (2)))) {
520
620
    int RegWidth = Opcode == AArch64_MOVNXi ? 64 : 32;
521
620
    int Shift = MCOperand_getImm(MCInst_getOperand(MI, (2)));
522
620
    uint64_t Value =
523
620
      ~((uint64_t)MCOperand_getImm(MCInst_getOperand(MI, (1)))
524
620
        << Shift);
525
620
    if (RegWidth == 32)
526
213
      Value = Value & 0xffffffff;
527
528
620
    if (AArch64_AM_isMOVNMovAlias(Value, Shift, RegWidth)) {
529
513
      isAlias = true;
530
513
      MCInst_setIsAlias(MI, isAlias);
531
513
      SStream_concat0(O, "mov ");
532
513
      printRegName(O, MCOperand_getReg(
533
513
            MCInst_getOperand(MI, (0))));
534
513
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
535
513
      printInt64Bang(O, SignExtend64(Value, RegWidth));
536
513
      SStream_concat0(O, markup(">"));
537
513
      if (detail_is_set(MI) && useAliasDetails) {
538
513
        AArch64_set_detail_op_reg(
539
513
          MI, 0, MCInst_getOpVal(MI, 0));
540
513
        AArch64_set_detail_op_imm(
541
513
          MI, 1, AARCH64_OP_IMM,
542
513
          SignExtend64(Value, RegWidth));
543
513
      }
544
513
      if (useAliasDetails)
545
513
        return;
546
513
    }
547
620
  }
548
549
353k
  if ((Opcode == AArch64_ORRXri || Opcode == AArch64_ORRWri) &&
550
3.17k
      (MCOperand_getReg(MCInst_getOperand(MI, (1))) == AArch64_XZR ||
551
1.44k
       MCOperand_getReg(MCInst_getOperand(MI, (1))) == AArch64_WZR) &&
552
2.05k
      MCOperand_isImm(MCInst_getOperand(MI, (2)))) {
553
2.05k
    int RegWidth = Opcode == AArch64_ORRXri ? 64 : 32;
554
2.05k
    uint64_t Value = AArch64_AM_decodeLogicalImmediate(
555
2.05k
      MCOperand_getImm(MCInst_getOperand(MI, (2))), RegWidth);
556
2.05k
    if (!AArch64_AM_isAnyMOVWMovAlias(Value, RegWidth)) {
557
1.21k
      isAlias = true;
558
1.21k
      MCInst_setIsAlias(MI, isAlias);
559
1.21k
      SStream_concat0(O, "mov ");
560
1.21k
      printRegName(O, MCOperand_getReg(
561
1.21k
            MCInst_getOperand(MI, (0))));
562
1.21k
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
563
1.21k
      printInt64Bang(O, SignExtend64(Value, RegWidth));
564
1.21k
      SStream_concat0(O, markup(">"));
565
1.21k
      if (detail_is_set(MI) && useAliasDetails) {
566
1.21k
        AArch64_set_detail_op_reg(
567
1.21k
          MI, 0, MCInst_getOpVal(MI, 0));
568
1.21k
        AArch64_set_detail_op_imm(
569
1.21k
          MI, 2, AARCH64_OP_IMM,
570
1.21k
          SignExtend64(Value, RegWidth));
571
1.21k
      }
572
1.21k
      if (useAliasDetails)
573
1.21k
        return;
574
1.21k
    }
575
2.05k
  }
576
577
352k
  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
352k
  if (!isAlias)
592
352k
    isAlias |= printAliasInstr(MI, Address, O);
593
594
352k
add_real_detail:
595
352k
  MCInst_setIsAlias(MI, isAlias);
596
597
352k
  if (!isAlias || !useAliasDetails) {
598
310k
    map_set_fill_detail_ops(MI, !(isAlias && useAliasDetails));
599
310k
    if (isAlias)
600
0
      SStream_Close(O);
601
310k
    printInstruction(MI, Address, O);
602
310k
    if (isAlias)
603
0
      SStream_Open(O);
604
310k
  }
605
352k
}
606
607
bool printRangePrefetchAlias(MCInst *MI, SStream *O, const char *Annot)
608
401
{
609
401
  unsigned Opcode = MCInst_getOpcode(MI);
610
611
401
#ifndef NDEBUG
612
613
401
#endif
614
615
401
  unsigned PRFOp = MCOperand_getImm(MCInst_getOperand(MI, (0)));
616
401
  unsigned Mask = 0x18; // 0b11000
617
401
  if ((PRFOp & Mask) != Mask)
618
401
    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
401
}
655
656
bool printSysAlias(MCInst *MI, SStream *O)
657
5.39k
{
658
5.39k
  MCOperand *Op1 = MCInst_getOperand(MI, (0));
659
5.39k
  MCOperand *Cn = MCInst_getOperand(MI, (1));
660
5.39k
  MCOperand *Cm = MCInst_getOperand(MI, (2));
661
5.39k
  MCOperand *Op2 = MCInst_getOperand(MI, (3));
662
663
5.39k
  unsigned Op1Val = MCOperand_getImm(Op1);
664
5.39k
  unsigned CnVal = MCOperand_getImm(Cn);
665
5.39k
  unsigned CmVal = MCOperand_getImm(Cm);
666
5.39k
  unsigned Op2Val = MCOperand_getImm(Op2);
667
668
5.39k
  uint16_t Encoding = Op2Val;
669
5.39k
  Encoding |= CmVal << 3;
670
5.39k
  Encoding |= CnVal << 7;
671
5.39k
  Encoding |= Op1Val << 11;
672
673
5.39k
  bool NeedsReg;
674
5.39k
  const char *Ins;
675
5.39k
  const char *Name;
676
677
5.39k
  if (CnVal == 7) {
678
3.89k
    switch (CmVal) {
679
117
    default:
680
117
      return false;
681
    // Maybe IC, maybe Prediction Restriction
682
436
    case 1:
683
436
      switch (Op1Val) {
684
71
      default:
685
71
        return false;
686
326
      case 0:
687
326
        goto Search_IC;
688
39
      case 3:
689
39
        goto Search_PRCTX;
690
436
      }
691
    // Prediction Restriction aliases
692
1.92k
    case 3: {
693
1.96k
Search_PRCTX:
694
1.96k
      if (Op1Val != 3 || CnVal != 7 || CmVal != 3)
695
76
        return false;
696
697
1.88k
      unsigned int Requires =
698
1.88k
        Op2Val == 6 ? AArch64_FeatureSPECRES2 :
699
1.88k
                AArch64_FeaturePredRes;
700
1.88k
      if (!(AArch64_getFeatureBits(MI->csh->mode,
701
1.88k
                 AArch64_FeatureAll) ||
702
0
            AArch64_getFeatureBits(MI->csh->mode, Requires)))
703
0
        return false;
704
705
1.88k
      NeedsReg = true;
706
1.88k
      switch (Op2Val) {
707
116
      default:
708
116
        return false;
709
588
      case 4:
710
588
        Ins = "cfp ";
711
588
        break;
712
935
      case 5:
713
935
        Ins = "dvp ";
714
935
        break;
715
58
      case 6:
716
58
        Ins = "cosp ";
717
58
        break;
718
188
      case 7:
719
188
        Ins = "cpp ";
720
188
        break;
721
1.88k
      }
722
1.76k
      Name = "RCTX";
723
1.76k
    } break;
724
    // IC aliases
725
392
    case 5: {
726
718
Search_IC: {
727
718
  const AArch64IC_IC *IC = AArch64IC_lookupICByEncoding(Encoding);
728
718
  if (!IC ||
729
401
      !AArch64_testFeatureList(MI->csh->mode, IC->FeaturesRequired))
730
317
    return false;
731
401
  if (detail_is_set(MI)) {
732
401
    aarch64_sysop sysop = { 0 };
733
401
    sysop.reg = IC->SysReg;
734
401
    sysop.sub_type = AARCH64_OP_IC;
735
401
    AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG;
736
401
    AArch64_get_detail_op(MI, 0)->sysop = sysop;
737
401
    AArch64_inc_op_count(MI);
738
401
  }
739
740
401
  NeedsReg = IC->NeedsReg;
741
401
  Ins = "ic ";
742
401
  Name = IC->Name;
743
401
}
744
401
    } break;
745
    // DC aliases
746
252
    case 4:
747
286
    case 6:
748
327
    case 10:
749
381
    case 11:
750
461
    case 12:
751
530
    case 13:
752
794
    case 14: {
753
794
      const AArch64DC_DC *DC =
754
794
        AArch64DC_lookupDCByEncoding(Encoding);
755
794
      if (!DC || !AArch64_testFeatureList(
756
82
             MI->csh->mode, DC->FeaturesRequired))
757
712
        return false;
758
82
      if (detail_is_set(MI)) {
759
82
        aarch64_sysop sysop = { 0 };
760
82
        sysop.alias = DC->SysAlias;
761
82
        sysop.sub_type = AARCH64_OP_DC;
762
82
        AArch64_get_detail_op(MI, 0)->type =
763
82
          AARCH64_OP_SYSALIAS;
764
82
        AArch64_get_detail_op(MI, 0)->sysop = sysop;
765
82
        AArch64_inc_op_count(MI);
766
82
      }
767
768
82
      NeedsReg = true;
769
82
      Ins = "dc ";
770
82
      Name = DC->Name;
771
82
    } break;
772
    // AT aliases
773
76
    case 8:
774
236
    case 9: {
775
236
      const AArch64AT_AT *AT =
776
236
        AArch64AT_lookupATByEncoding(Encoding);
777
236
      if (!AT || !AArch64_testFeatureList(
778
34
             MI->csh->mode, AT->FeaturesRequired))
779
202
        return false;
780
781
34
      if (detail_is_set(MI)) {
782
34
        aarch64_sysop sysop = { 0 };
783
34
        sysop.alias = AT->SysAlias;
784
34
        sysop.sub_type = AARCH64_OP_AT;
785
34
        AArch64_get_detail_op(MI, 0)->type =
786
34
          AARCH64_OP_SYSALIAS;
787
34
        AArch64_get_detail_op(MI, 0)->sysop = sysop;
788
34
        AArch64_inc_op_count(MI);
789
34
      }
790
34
      NeedsReg = true;
791
34
      Ins = "at ";
792
34
      Name = AT->Name;
793
34
    } break;
794
3.89k
    }
795
3.89k
  } else if (CnVal == 8 || CnVal == 9) {
796
    // TLBI aliases
797
381
    const AArch64TLBI_TLBI *TLBI =
798
381
      AArch64TLBI_lookupTLBIByEncoding(Encoding);
799
381
    if (!TLBI || !AArch64_testFeatureList(MI->csh->mode,
800
120
                  TLBI->FeaturesRequired))
801
261
      return false;
802
803
120
    if (detail_is_set(MI)) {
804
120
      aarch64_sysop sysop = { 0 };
805
120
      sysop.reg = TLBI->SysReg;
806
120
      sysop.sub_type = AARCH64_OP_TLBI;
807
120
      AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG;
808
120
      AArch64_get_detail_op(MI, 0)->sysop = sysop;
809
120
      AArch64_inc_op_count(MI);
810
120
    }
811
120
    NeedsReg = TLBI->NeedsReg;
812
120
    Ins = "tlbi ";
813
120
    Name = TLBI->Name;
814
120
  } else
815
1.12k
    return false;
816
817
4.81k
#define TMP_STR_LEN 32
818
2.40k
  char Str[TMP_STR_LEN] = { 0 };
819
2.40k
  append_to_str_lower(Str, TMP_STR_LEN, Ins);
820
2.40k
  append_to_str_lower(Str, TMP_STR_LEN, Name);
821
2.40k
#undef TMP_STR_LEN
822
823
2.40k
  SStream_concat1(O, ' ');
824
2.40k
  SStream_concat0(O, Str);
825
2.40k
  if (NeedsReg) {
826
2.00k
    SStream_concat0(O, ", ");
827
2.00k
    printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (4))));
828
2.00k
    AArch64_set_detail_op_reg(MI, 4, MCInst_getOpVal(MI, 4));
829
2.00k
  }
830
831
2.40k
  return true;
832
5.39k
}
833
834
bool printSyspAlias(MCInst *MI, SStream *O)
835
3.49k
{
836
3.49k
  MCOperand *Op1 = MCInst_getOperand(MI, (0));
837
3.49k
  MCOperand *Cn = MCInst_getOperand(MI, (1));
838
3.49k
  MCOperand *Cm = MCInst_getOperand(MI, (2));
839
3.49k
  MCOperand *Op2 = MCInst_getOperand(MI, (3));
840
841
3.49k
  unsigned Op1Val = MCOperand_getImm(Op1);
842
3.49k
  unsigned CnVal = MCOperand_getImm(Cn);
843
3.49k
  unsigned CmVal = MCOperand_getImm(Cm);
844
3.49k
  unsigned Op2Val = MCOperand_getImm(Op2);
845
846
3.49k
  uint16_t Encoding = Op2Val;
847
3.49k
  Encoding |= CmVal << 3;
848
3.49k
  Encoding |= CnVal << 7;
849
3.49k
  Encoding |= Op1Val << 11;
850
851
3.49k
  const char *Ins;
852
3.49k
  const char *Name;
853
854
3.49k
  if (CnVal == 8 || CnVal == 9) {
855
    // TLBIP aliases
856
857
2.36k
    if (CnVal == 9) {
858
600
      if (!AArch64_getFeatureBits(MI->csh->mode,
859
600
                AArch64_FeatureAll) ||
860
600
          !AArch64_getFeatureBits(MI->csh->mode,
861
600
                AArch64_FeatureXS))
862
0
        return false;
863
600
      Encoding &= ~(1 << 7);
864
600
    }
865
866
2.36k
    const AArch64TLBI_TLBI *TLBI =
867
2.36k
      AArch64TLBI_lookupTLBIByEncoding(Encoding);
868
2.36k
    if (!TLBI || !AArch64_testFeatureList(MI->csh->mode,
869
1.84k
                  TLBI->FeaturesRequired))
870
522
      return false;
871
872
1.84k
    if (detail_is_set(MI)) {
873
1.84k
      aarch64_sysop sysop = { 0 };
874
1.84k
      sysop.reg = TLBI->SysReg;
875
1.84k
      sysop.sub_type = AARCH64_OP_TLBI;
876
1.84k
      AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG;
877
1.84k
      AArch64_get_detail_op(MI, 0)->sysop = sysop;
878
1.84k
      AArch64_inc_op_count(MI);
879
1.84k
    }
880
1.84k
    Ins = "tlbip ";
881
1.84k
    Name = TLBI->Name;
882
1.84k
  } else
883
1.13k
    return false;
884
885
4.27k
#define TMP_STR_LEN 32
886
1.84k
  char Str[TMP_STR_LEN] = { 0 };
887
1.84k
  append_to_str_lower(Str, TMP_STR_LEN, Ins);
888
1.84k
  append_to_str_lower(Str, TMP_STR_LEN, Name);
889
890
1.84k
  if (CnVal == 9) {
891
588
    append_to_str_lower(Str, TMP_STR_LEN, "nxs");
892
588
  }
893
1.84k
#undef TMP_STR_LEN
894
895
1.84k
  SStream_concat1(O, ' ');
896
1.84k
  SStream_concat0(O, Str);
897
1.84k
  SStream_concat0(O, ", ");
898
1.84k
  if (MCOperand_getReg(MCInst_getOperand(MI, (4))) == AArch64_XZR)
899
1.17k
    printSyspXzrPair(MI, 4, O);
900
666
  else
901
666
    CONCAT(printGPRSeqPairsClassOperand, 64)(MI, 4, O);
902
903
1.84k
  return true;
904
3.49k
}
905
906
#define DEFINE_printMatrix(EltSize) \
907
  void CONCAT(printMatrix, EltSize)(MCInst * MI, unsigned OpNum, \
908
            SStream *O) \
909
9.40k
  { \
910
9.40k
    AArch64_add_cs_detail_1( \
911
9.40k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
912
9.40k
      EltSize); \
913
9.40k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
914
9.40k
\
915
9.40k
    printRegName(O, MCOperand_getReg(RegOp)); \
916
9.40k
    switch (EltSize) { \
917
183
    case 0: \
918
183
      break; \
919
0
    case 8: \
920
0
      SStream_concat0(O, ".b"); \
921
0
      break; \
922
1.24k
    case 16: \
923
1.24k
      SStream_concat0(O, ".h"); \
924
1.24k
      break; \
925
4.11k
    case 32: \
926
4.11k
      SStream_concat0(O, ".s"); \
927
4.11k
      break; \
928
3.87k
    case 64: \
929
3.87k
      SStream_concat0(O, ".d"); \
930
3.87k
      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
9.40k
    } \
937
9.40k
  }
printMatrix_64
Line
Count
Source
909
3.87k
  { \
910
3.87k
    AArch64_add_cs_detail_1( \
911
3.87k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
912
3.87k
      EltSize); \
913
3.87k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
914
3.87k
\
915
3.87k
    printRegName(O, MCOperand_getReg(RegOp)); \
916
3.87k
    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
3.87k
    case 64: \
929
3.87k
      SStream_concat0(O, ".d"); \
930
3.87k
      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.87k
    } \
937
3.87k
  }
printMatrix_32
Line
Count
Source
909
4.11k
  { \
910
4.11k
    AArch64_add_cs_detail_1( \
911
4.11k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
912
4.11k
      EltSize); \
913
4.11k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
914
4.11k
\
915
4.11k
    printRegName(O, MCOperand_getReg(RegOp)); \
916
4.11k
    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
4.11k
    case 32: \
926
4.11k
      SStream_concat0(O, ".s"); \
927
4.11k
      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
4.11k
    } \
937
4.11k
  }
printMatrix_16
Line
Count
Source
909
1.24k
  { \
910
1.24k
    AArch64_add_cs_detail_1( \
911
1.24k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
912
1.24k
      EltSize); \
913
1.24k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
914
1.24k
\
915
1.24k
    printRegName(O, MCOperand_getReg(RegOp)); \
916
1.24k
    switch (EltSize) { \
917
0
    case 0: \
918
0
      break; \
919
0
    case 8: \
920
0
      SStream_concat0(O, ".b"); \
921
0
      break; \
922
1.24k
    case 16: \
923
1.24k
      SStream_concat0(O, ".h"); \
924
1.24k
      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
1.24k
    } \
937
1.24k
  }
printMatrix_0
Line
Count
Source
909
183
  { \
910
183
    AArch64_add_cs_detail_1( \
911
183
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
912
183
      EltSize); \
913
183
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
914
183
\
915
183
    printRegName(O, MCOperand_getReg(RegOp)); \
916
183
    switch (EltSize) { \
917
183
    case 0: \
918
183
      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
183
    } \
937
183
  }
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
8.77k
  { \
947
8.77k
    AArch64_add_cs_detail_1( \
948
8.77k
      MI, \
949
8.77k
      CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \
950
8.77k
      OpNum, IsVertical); \
951
8.77k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
952
8.77k
\
953
8.77k
    const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \
954
8.77k
                  AArch64_NoRegAltName); \
955
8.77k
\
956
8.77k
    unsigned buf_len = strlen(RegName) + 1; \
957
8.77k
    char *Base = cs_mem_calloc(1, buf_len); \
958
8.77k
    memcpy(Base, RegName, buf_len); \
959
8.77k
    char *Dot = strchr(Base, '.'); \
960
8.77k
    if (!Dot) { \
961
0
      SStream_concat0(O, RegName); \
962
0
      return; \
963
0
    } \
964
8.77k
    *Dot = '\0'; /* Split string */ \
965
8.77k
    char *Suffix = Dot + 1; \
966
8.77k
    SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \
967
8.77k
    SStream_concat1(O, '.'); \
968
8.77k
    SStream_concat0(O, Suffix); \
969
8.77k
    cs_mem_free(Base); \
970
8.77k
  }
printMatrixTileVector_0
Line
Count
Source
946
5.55k
  { \
947
5.55k
    AArch64_add_cs_detail_1( \
948
5.55k
      MI, \
949
5.55k
      CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \
950
5.55k
      OpNum, IsVertical); \
951
5.55k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
952
5.55k
\
953
5.55k
    const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \
954
5.55k
                  AArch64_NoRegAltName); \
955
5.55k
\
956
5.55k
    unsigned buf_len = strlen(RegName) + 1; \
957
5.55k
    char *Base = cs_mem_calloc(1, buf_len); \
958
5.55k
    memcpy(Base, RegName, buf_len); \
959
5.55k
    char *Dot = strchr(Base, '.'); \
960
5.55k
    if (!Dot) { \
961
0
      SStream_concat0(O, RegName); \
962
0
      return; \
963
0
    } \
964
5.55k
    *Dot = '\0'; /* Split string */ \
965
5.55k
    char *Suffix = Dot + 1; \
966
5.55k
    SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \
967
5.55k
    SStream_concat1(O, '.'); \
968
5.55k
    SStream_concat0(O, Suffix); \
969
5.55k
    cs_mem_free(Base); \
970
5.55k
  }
printMatrixTileVector_1
Line
Count
Source
946
3.21k
  { \
947
3.21k
    AArch64_add_cs_detail_1( \
948
3.21k
      MI, \
949
3.21k
      CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \
950
3.21k
      OpNum, IsVertical); \
951
3.21k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
952
3.21k
\
953
3.21k
    const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \
954
3.21k
                  AArch64_NoRegAltName); \
955
3.21k
\
956
3.21k
    unsigned buf_len = strlen(RegName) + 1; \
957
3.21k
    char *Base = cs_mem_calloc(1, buf_len); \
958
3.21k
    memcpy(Base, RegName, buf_len); \
959
3.21k
    char *Dot = strchr(Base, '.'); \
960
3.21k
    if (!Dot) { \
961
0
      SStream_concat0(O, RegName); \
962
0
      return; \
963
0
    } \
964
3.21k
    *Dot = '\0'; /* Split string */ \
965
3.21k
    char *Suffix = Dot + 1; \
966
3.21k
    SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \
967
3.21k
    SStream_concat1(O, '.'); \
968
3.21k
    SStream_concat0(O, Suffix); \
969
3.21k
    cs_mem_free(Base); \
970
3.21k
  }
971
DEFINE_printMatrixTileVector(0);
972
DEFINE_printMatrixTileVector(1);
973
974
void printMatrixTile(MCInst *MI, unsigned OpNum, SStream *O)
975
2.25k
{
976
2.25k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MatrixTile, OpNum);
977
2.25k
  MCOperand *RegOp = MCInst_getOperand(MI, (OpNum));
978
979
2.25k
  printRegName(O, MCOperand_getReg(RegOp));
980
2.25k
}
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
466k
{
995
466k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Operand, OpNo);
996
466k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
997
466k
  if (MCOperand_isReg(Op)) {
998
396k
    unsigned Reg = MCOperand_getReg(Op);
999
396k
    printRegName(O, Reg);
1000
396k
  } else if (MCOperand_isImm(Op)) {
1001
70.5k
    Op = MCInst_getOperand(MI, (OpNo));
1002
70.5k
    SStream_concat(O, "%s", markup("<imm:"));
1003
70.5k
    printInt64Bang(O, MCOperand_getImm(Op));
1004
70.5k
    SStream_concat0(O, markup(">"));
1005
70.5k
  } else {
1006
0
    printUInt64Bang(O, MCInst_getOpVal(MI, OpNo));
1007
0
  }
1008
466k
}
1009
1010
void printImm(MCInst *MI, unsigned OpNo, SStream *O)
1011
5.55k
{
1012
5.55k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Imm, OpNo);
1013
5.55k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1014
5.55k
  SStream_concat(O, "%s", markup("<imm:"));
1015
5.55k
  printInt64Bang(O, MCOperand_getImm(Op));
1016
5.55k
  SStream_concat0(O, markup(">"));
1017
5.55k
}
1018
1019
void printImmHex(MCInst *MI, unsigned OpNo, SStream *O)
1020
685
{
1021
685
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ImmHex, OpNo);
1022
685
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1023
685
  SStream_concat(O, "%s", markup("<imm:"));
1024
685
  printInt64Bang(O, MCOperand_getImm(Op));
1025
685
  SStream_concat0(O, markup(">"));
1026
685
}
1027
1028
#define DEFINE_printSImm(Size) \
1029
  void CONCAT(printSImm, Size)(MCInst * MI, unsigned OpNo, SStream *O) \
1030
2.46k
  { \
1031
2.46k
    AArch64_add_cs_detail_1( \
1032
2.46k
      MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \
1033
2.46k
    MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \
1034
2.46k
    if (Size == 8) { \
1035
822
      SStream_concat(O, "%s", markup("<imm:")); \
1036
822
      printInt32Bang(O, MCOperand_getImm(Op)); \
1037
822
      SStream_concat0(O, markup(">")); \
1038
1.64k
    } else if (Size == 16) { \
1039
1.64k
      SStream_concat(O, "%s", markup("<imm:")); \
1040
1.64k
      printInt32Bang(O, MCOperand_getImm(Op)); \
1041
1.64k
      SStream_concat0(O, markup(">")); \
1042
1.64k
    } 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
2.46k
  }
printSImm_16
Line
Count
Source
1030
1.64k
  { \
1031
1.64k
    AArch64_add_cs_detail_1( \
1032
1.64k
      MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \
1033
1.64k
    MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \
1034
1.64k
    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
1.64k
    } else if (Size == 16) { \
1039
1.64k
      SStream_concat(O, "%s", markup("<imm:")); \
1040
1.64k
      printInt32Bang(O, MCOperand_getImm(Op)); \
1041
1.64k
      SStream_concat0(O, markup(">")); \
1042
1.64k
    } 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
1.64k
  }
printSImm_8
Line
Count
Source
1030
822
  { \
1031
822
    AArch64_add_cs_detail_1( \
1032
822
      MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \
1033
822
    MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \
1034
822
    if (Size == 8) { \
1035
822
      SStream_concat(O, "%s", markup("<imm:")); \
1036
822
      printInt32Bang(O, MCOperand_getImm(Op)); \
1037
822
      SStream_concat0(O, markup(">")); \
1038
822
    } 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
822
  }
1048
DEFINE_printSImm(16);
1049
DEFINE_printSImm(8);
1050
1051
void printPostIncOperand(MCInst *MI, unsigned OpNo, unsigned Imm, SStream *O)
1052
14.7k
{
1053
14.7k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1054
14.7k
  if (MCOperand_isReg(Op)) {
1055
14.7k
    unsigned Reg = MCOperand_getReg(Op);
1056
14.7k
    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
14.7k
      printRegName(O, Reg);
1062
14.7k
  } else
1063
0
    CS_ASSERT_RET(0 &&
1064
14.7k
            "unknown operand kind in printPostIncOperand64");
1065
14.7k
}
1066
1067
void printVRegOperand(MCInst *MI, unsigned OpNo, SStream *O)
1068
81.1k
{
1069
81.1k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_VRegOperand, OpNo);
1070
81.1k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1071
1072
81.1k
  unsigned Reg = MCOperand_getReg(Op);
1073
81.1k
  printRegNameAlt(O, Reg, AArch64_vreg);
1074
81.1k
}
1075
1076
void printSysCROperand(MCInst *MI, unsigned OpNo, SStream *O)
1077
9.49k
{
1078
9.49k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SysCROperand, OpNo);
1079
9.49k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1080
1081
9.49k
  SStream_concat(O, "%s", "c");
1082
9.49k
  printUInt32(O, MCOperand_getImm(Op));
1083
9.49k
  SStream_concat1(O, '\0');
1084
9.49k
}
1085
1086
void printAddSubImm(MCInst *MI, unsigned OpNum, SStream *O)
1087
3.52k
{
1088
3.52k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AddSubImm, OpNum);
1089
3.52k
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
1090
3.52k
  if (MCOperand_isImm(MO)) {
1091
3.52k
    unsigned Val = (MCOperand_getImm(MO) & 0xfff);
1092
1093
3.52k
    unsigned Shift = AArch64_AM_getShiftValue(
1094
3.52k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))));
1095
3.52k
    SStream_concat(O, "%s", markup("<imm:"));
1096
3.52k
    printUInt32Bang(O, (Val));
1097
3.52k
    SStream_concat0(O, markup(">"));
1098
3.52k
    if (Shift != 0) {
1099
1.13k
      printShifter(MI, OpNum + 1, O);
1100
1.13k
    }
1101
3.52k
  } else {
1102
0
    printShifter(MI, OpNum + 1, O);
1103
0
  }
1104
3.52k
}
1105
1106
#define DEFINE_printLogicalImm(T) \
1107
  void CONCAT(printLogicalImm, T)(MCInst * MI, unsigned OpNum, \
1108
          SStream *O) \
1109
8.15k
  { \
1110
8.15k
    AArch64_add_cs_detail_1( \
1111
8.15k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \
1112
8.15k
      sizeof(T)); \
1113
8.15k
    uint64_t Val = \
1114
8.15k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1115
8.15k
    SStream_concat(O, "%s", markup("<imm:")); \
1116
8.15k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1117
8.15k
             Val, 8 * sizeof(T)))); \
1118
8.15k
    SStream_concat0(O, markup(">")); \
1119
8.15k
  }
printLogicalImm_int64_t
Line
Count
Source
1109
3.22k
  { \
1110
3.22k
    AArch64_add_cs_detail_1( \
1111
3.22k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \
1112
3.22k
      sizeof(T)); \
1113
3.22k
    uint64_t Val = \
1114
3.22k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1115
3.22k
    SStream_concat(O, "%s", markup("<imm:")); \
1116
3.22k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1117
3.22k
             Val, 8 * sizeof(T)))); \
1118
3.22k
    SStream_concat0(O, markup(">")); \
1119
3.22k
  }
printLogicalImm_int32_t
Line
Count
Source
1109
1.67k
  { \
1110
1.67k
    AArch64_add_cs_detail_1( \
1111
1.67k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \
1112
1.67k
      sizeof(T)); \
1113
1.67k
    uint64_t Val = \
1114
1.67k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1115
1.67k
    SStream_concat(O, "%s", markup("<imm:")); \
1116
1.67k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1117
1.67k
             Val, 8 * sizeof(T)))); \
1118
1.67k
    SStream_concat0(O, markup(">")); \
1119
1.67k
  }
printLogicalImm_int8_t
Line
Count
Source
1109
1.65k
  { \
1110
1.65k
    AArch64_add_cs_detail_1( \
1111
1.65k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \
1112
1.65k
      sizeof(T)); \
1113
1.65k
    uint64_t Val = \
1114
1.65k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1115
1.65k
    SStream_concat(O, "%s", markup("<imm:")); \
1116
1.65k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1117
1.65k
             Val, 8 * sizeof(T)))); \
1118
1.65k
    SStream_concat0(O, markup(">")); \
1119
1.65k
  }
printLogicalImm_int16_t
Line
Count
Source
1109
1.60k
  { \
1110
1.60k
    AArch64_add_cs_detail_1( \
1111
1.60k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \
1112
1.60k
      sizeof(T)); \
1113
1.60k
    uint64_t Val = \
1114
1.60k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1115
1.60k
    SStream_concat(O, "%s", markup("<imm:")); \
1116
1.60k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1117
1.60k
             Val, 8 * sizeof(T)))); \
1118
1.60k
    SStream_concat0(O, markup(">")); \
1119
1.60k
  }
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
13.9k
{
1127
13.9k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Shifter, OpNum);
1128
13.9k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1129
  // LSL #0 should not be printed.
1130
13.9k
  if (AArch64_AM_getShiftType(Val) == AArch64_AM_LSL &&
1131
8.10k
      AArch64_AM_getShiftValue(Val) == 0)
1132
1.57k
    return;
1133
12.4k
  SStream_concat(
1134
12.4k
    O, "%s%s%s%s#%d", ", ",
1135
12.4k
    AArch64_AM_getShiftExtendName(AArch64_AM_getShiftType(Val)),
1136
12.4k
    " ", markup("<imm:"), AArch64_AM_getShiftValue(Val));
1137
12.4k
  SStream_concat0(O, markup(">"));
1138
12.4k
}
1139
1140
void printShiftedRegister(MCInst *MI, unsigned OpNum, SStream *O)
1141
7.29k
{
1142
7.29k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ShiftedRegister, OpNum);
1143
7.29k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1144
7.29k
  printShifter(MI, OpNum + 1, O);
1145
7.29k
}
1146
1147
void printExtendedRegister(MCInst *MI, unsigned OpNum, SStream *O)
1148
4.31k
{
1149
4.31k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ExtendedRegister, OpNum);
1150
4.31k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1151
4.31k
  printArithExtend(MI, OpNum + 1, O);
1152
4.31k
}
1153
1154
void printArithExtend(MCInst *MI, unsigned OpNum, SStream *O)
1155
6.14k
{
1156
6.14k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ArithExtend, OpNum);
1157
6.14k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1158
6.14k
  AArch64_AM_ShiftExtendType ExtType = AArch64_AM_getArithExtendType(Val);
1159
6.14k
  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
6.14k
  if (ExtType == AArch64_AM_UXTW || ExtType == AArch64_AM_UXTX) {
1165
2.65k
    unsigned Dest = MCOperand_getReg(MCInst_getOperand(MI, (0)));
1166
2.65k
    unsigned Src1 = MCOperand_getReg(MCInst_getOperand(MI, (1)));
1167
2.65k
    if (((Dest == AArch64_SP || Src1 == AArch64_SP) &&
1168
427
         ExtType == AArch64_AM_UXTX) ||
1169
2.58k
        ((Dest == AArch64_WSP || Src1 == AArch64_WSP) &&
1170
1.33k
         ExtType == AArch64_AM_UXTW)) {
1171
548
      if (ShiftVal != 0) {
1172
548
        SStream_concat(O, "%s%s", ", lsl ",
1173
548
                 markup("<imm:"));
1174
548
        printUInt32Bang(O, ShiftVal);
1175
548
        SStream_concat0(O, markup(">"));
1176
548
      }
1177
548
      return;
1178
548
    }
1179
2.65k
  }
1180
5.59k
  SStream_concat(O, "%s", ", ");
1181
5.59k
  SStream_concat0(O, AArch64_AM_getShiftExtendName(ExtType));
1182
5.59k
  if (ShiftVal != 0) {
1183
4.84k
    SStream_concat(O, "%s%s#%d", " ", markup("<imm:"), ShiftVal);
1184
4.84k
    SStream_concat0(O, markup(">"));
1185
4.84k
  }
1186
5.59k
}
1187
1188
static void printMemExtendImpl(bool SignExtend, bool DoShift, unsigned Width,
1189
             char SrcRegKind, SStream *O, bool getUseMarkup)
1190
18.5k
{
1191
  // sxtw, sxtx, uxtw or lsl (== uxtx)
1192
18.5k
  bool IsLSL = !SignExtend && SrcRegKind == 'x';
1193
18.5k
  if (IsLSL)
1194
7.76k
    SStream_concat0(O, "lsl");
1195
10.8k
  else {
1196
10.8k
    SStream_concat(O, "%c%s", (SignExtend ? 's' : 'u'), "xt");
1197
10.8k
    SStream_concat1(O, SrcRegKind);
1198
10.8k
  }
1199
1200
18.5k
  if (DoShift || IsLSL) {
1201
14.3k
    SStream_concat0(O, " ");
1202
14.3k
    if (getUseMarkup)
1203
0
      SStream_concat0(O, "<imm:");
1204
14.3k
    unsigned ShiftAmount = DoShift ? Log2_32(Width / 8) : 0;
1205
14.3k
    SStream_concat(O, "%s%d", "#", ShiftAmount);
1206
14.3k
    if (getUseMarkup)
1207
0
      SStream_concat0(O, ">");
1208
14.3k
  }
1209
18.5k
}
1210
1211
void printMemExtend(MCInst *MI, unsigned OpNum, SStream *O, char SrcRegKind,
1212
        unsigned Width)
1213
3.19k
{
1214
3.19k
  bool SignExtend = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1215
3.19k
  bool DoShift = MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1)));
1216
3.19k
  printMemExtendImpl(SignExtend, DoShift, Width, SrcRegKind, O,
1217
3.19k
         getUseMarkup());
1218
3.19k
}
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
19.9k
  { \
1227
19.9k
    AArch64_add_cs_detail_4( \
1228
19.9k
      MI, \
1229
19.9k
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1230
19.9k
                SignExtend), \
1231
19.9k
               ExtWidth), \
1232
19.9k
              SrcRegKind), \
1233
19.9k
             Suffix), \
1234
19.9k
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1235
19.9k
      CHAR(Suffix)); \
1236
19.9k
    printOperand(MI, OpNum, O); \
1237
19.9k
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1238
10.9k
      SStream_concat1(O, '.'); \
1239
10.9k
      SStream_concat1(O, CHAR(Suffix)); \
1240
10.9k
      SStream_concat1(O, '\0'); \
1241
10.9k
    } else \
1242
19.9k
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1243
19.9k
              "Unsupported suffix size"); \
1244
19.9k
    bool DoShift = ExtWidth != 8; \
1245
19.9k
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1246
15.3k
      SStream_concat0(O, ", "); \
1247
15.3k
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1248
15.3k
             CHAR(SrcRegKind), O, \
1249
15.3k
             getUseMarkup()); \
1250
15.3k
    } \
1251
19.9k
  }
1252
704
DEFINE_printRegWithShiftExtend(false, 8, x, d);
1253
623
DEFINE_printRegWithShiftExtend(true, 8, w, d);
1254
1.27k
DEFINE_printRegWithShiftExtend(false, 8, w, d);
1255
3.85k
DEFINE_printRegWithShiftExtend(false, 8, x, 0);
1256
397
DEFINE_printRegWithShiftExtend(true, 8, w, s);
1257
836
DEFINE_printRegWithShiftExtend(false, 8, w, s);
1258
277
DEFINE_printRegWithShiftExtend(false, 64, x, d);
1259
660
DEFINE_printRegWithShiftExtend(true, 64, w, d);
1260
245
DEFINE_printRegWithShiftExtend(false, 64, w, d);
1261
815
DEFINE_printRegWithShiftExtend(false, 64, x, 0);
1262
214
DEFINE_printRegWithShiftExtend(true, 64, w, s);
1263
82
DEFINE_printRegWithShiftExtend(false, 64, w, s);
1264
557
DEFINE_printRegWithShiftExtend(false, 16, x, d);
1265
801
DEFINE_printRegWithShiftExtend(true, 16, w, d);
1266
796
DEFINE_printRegWithShiftExtend(false, 16, w, d);
1267
2.38k
DEFINE_printRegWithShiftExtend(false, 16, x, 0);
1268
579
DEFINE_printRegWithShiftExtend(true, 16, w, s);
1269
188
DEFINE_printRegWithShiftExtend(false, 16, w, s);
1270
514
DEFINE_printRegWithShiftExtend(false, 32, x, d);
1271
155
DEFINE_printRegWithShiftExtend(true, 32, w, d);
1272
912
DEFINE_printRegWithShiftExtend(false, 32, w, d);
1273
1.68k
DEFINE_printRegWithShiftExtend(false, 32, x, 0);
1274
554
DEFINE_printRegWithShiftExtend(true, 32, w, s);
1275
262
DEFINE_printRegWithShiftExtend(false, 32, w, s);
1276
36
DEFINE_printRegWithShiftExtend(false, 8, x, s);
1277
167
DEFINE_printRegWithShiftExtend(false, 16, x, s);
1278
53
DEFINE_printRegWithShiftExtend(false, 32, x, s);
1279
75
DEFINE_printRegWithShiftExtend(false, 64, x, s);
1280
302
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
12.6k
  { \
1286
12.6k
    AArch64_add_cs_detail_1( \
1287
12.6k
      MI, \
1288
12.6k
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
12.6k
      OpNum, EltSize); \
1290
12.6k
    unsigned Reg = \
1291
12.6k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
12.6k
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
12.6k
      CS_ASSERT_RET( \
1294
12.6k
        0 && \
1295
12.6k
        "Unsupported predicate-as-counter register"); \
1296
12.6k
    SStream_concat(O, "%s", "pn"); \
1297
12.6k
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
12.6k
    switch (EltSize) { \
1299
11.8k
    case 0: \
1300
11.8k
      break; \
1301
242
    case 8: \
1302
242
      SStream_concat0(O, ".b"); \
1303
242
      break; \
1304
181
    case 16: \
1305
181
      SStream_concat0(O, ".h"); \
1306
181
      break; \
1307
179
    case 32: \
1308
179
      SStream_concat0(O, ".s"); \
1309
179
      break; \
1310
248
    case 64: \
1311
248
      SStream_concat0(O, ".d"); \
1312
248
      break; \
1313
0
    default: \
1314
0
      CS_ASSERT_RET(0 && "Unsupported element size"); \
1315
12.6k
    } \
1316
12.6k
  }
printPredicateAsCounter_8
Line
Count
Source
1285
242
  { \
1286
242
    AArch64_add_cs_detail_1( \
1287
242
      MI, \
1288
242
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
242
      OpNum, EltSize); \
1290
242
    unsigned Reg = \
1291
242
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
242
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
242
      CS_ASSERT_RET( \
1294
242
        0 && \
1295
242
        "Unsupported predicate-as-counter register"); \
1296
242
    SStream_concat(O, "%s", "pn"); \
1297
242
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
242
    switch (EltSize) { \
1299
0
    case 0: \
1300
0
      break; \
1301
242
    case 8: \
1302
242
      SStream_concat0(O, ".b"); \
1303
242
      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
242
    } \
1316
242
  }
printPredicateAsCounter_64
Line
Count
Source
1285
248
  { \
1286
248
    AArch64_add_cs_detail_1( \
1287
248
      MI, \
1288
248
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
248
      OpNum, EltSize); \
1290
248
    unsigned Reg = \
1291
248
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
248
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
248
      CS_ASSERT_RET( \
1294
248
        0 && \
1295
248
        "Unsupported predicate-as-counter register"); \
1296
248
    SStream_concat(O, "%s", "pn"); \
1297
248
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
248
    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
248
    case 64: \
1311
248
      SStream_concat0(O, ".d"); \
1312
248
      break; \
1313
0
    default: \
1314
0
      CS_ASSERT_RET(0 && "Unsupported element size"); \
1315
248
    } \
1316
248
  }
printPredicateAsCounter_16
Line
Count
Source
1285
181
  { \
1286
181
    AArch64_add_cs_detail_1( \
1287
181
      MI, \
1288
181
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
181
      OpNum, EltSize); \
1290
181
    unsigned Reg = \
1291
181
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
181
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
181
      CS_ASSERT_RET( \
1294
181
        0 && \
1295
181
        "Unsupported predicate-as-counter register"); \
1296
181
    SStream_concat(O, "%s", "pn"); \
1297
181
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
181
    switch (EltSize) { \
1299
0
    case 0: \
1300
0
      break; \
1301
0
    case 8: \
1302
0
      SStream_concat0(O, ".b"); \
1303
0
      break; \
1304
181
    case 16: \
1305
181
      SStream_concat0(O, ".h"); \
1306
181
      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
181
    } \
1316
181
  }
printPredicateAsCounter_32
Line
Count
Source
1285
179
  { \
1286
179
    AArch64_add_cs_detail_1( \
1287
179
      MI, \
1288
179
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
179
      OpNum, EltSize); \
1290
179
    unsigned Reg = \
1291
179
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
179
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
179
      CS_ASSERT_RET( \
1294
179
        0 && \
1295
179
        "Unsupported predicate-as-counter register"); \
1296
179
    SStream_concat(O, "%s", "pn"); \
1297
179
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
179
    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
179
    case 32: \
1308
179
      SStream_concat0(O, ".s"); \
1309
179
      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
179
    } \
1316
179
  }
printPredicateAsCounter_0
Line
Count
Source
1285
11.8k
  { \
1286
11.8k
    AArch64_add_cs_detail_1( \
1287
11.8k
      MI, \
1288
11.8k
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
11.8k
      OpNum, EltSize); \
1290
11.8k
    unsigned Reg = \
1291
11.8k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
11.8k
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
11.8k
      CS_ASSERT_RET( \
1294
11.8k
        0 && \
1295
11.8k
        "Unsupported predicate-as-counter register"); \
1296
11.8k
    SStream_concat(O, "%s", "pn"); \
1297
11.8k
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
11.8k
    switch (EltSize) { \
1299
11.8k
    case 0: \
1300
11.8k
      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
11.8k
    } \
1316
11.8k
  }
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.19k
{
1325
2.19k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_CondCode, OpNum);
1326
2.19k
  AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm(
1327
2.19k
    MCInst_getOperand(MI, (OpNum)));
1328
2.19k
  SStream_concat0(O, AArch64CC_getCondCodeName(CC));
1329
2.19k
}
1330
1331
void printInverseCondCode(MCInst *MI, unsigned OpNum, SStream *O)
1332
298
{
1333
298
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_InverseCondCode, OpNum);
1334
298
  AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm(
1335
298
    MCInst_getOperand(MI, (OpNum)));
1336
298
  SStream_concat0(O, AArch64CC_getCondCodeName(
1337
298
           AArch64CC_getInvertedCondCode(CC)));
1338
298
}
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
24.6k
  { \
1353
24.6k
    AArch64_add_cs_detail_1( \
1354
24.6k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
24.6k
      Scale); \
1356
24.6k
    SStream_concat(O, "%s", markup("<imm:")); \
1357
24.6k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
24.6k
            MCInst_getOperand(MI, (OpNum)))); \
1359
24.6k
    SStream_concat0(O, markup(">")); \
1360
24.6k
  }
printImmScale_8
Line
Count
Source
1352
8.34k
  { \
1353
8.34k
    AArch64_add_cs_detail_1( \
1354
8.34k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
8.34k
      Scale); \
1356
8.34k
    SStream_concat(O, "%s", markup("<imm:")); \
1357
8.34k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
8.34k
            MCInst_getOperand(MI, (OpNum)))); \
1359
8.34k
    SStream_concat0(O, markup(">")); \
1360
8.34k
  }
printImmScale_2
Line
Count
Source
1352
842
  { \
1353
842
    AArch64_add_cs_detail_1( \
1354
842
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
842
      Scale); \
1356
842
    SStream_concat(O, "%s", markup("<imm:")); \
1357
842
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
842
            MCInst_getOperand(MI, (OpNum)))); \
1359
842
    SStream_concat0(O, markup(">")); \
1360
842
  }
printImmScale_4
Line
Count
Source
1352
9.28k
  { \
1353
9.28k
    AArch64_add_cs_detail_1( \
1354
9.28k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
9.28k
      Scale); \
1356
9.28k
    SStream_concat(O, "%s", markup("<imm:")); \
1357
9.28k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
9.28k
            MCInst_getOperand(MI, (OpNum)))); \
1359
9.28k
    SStream_concat0(O, markup(">")); \
1360
9.28k
  }
printImmScale_16
Line
Count
Source
1352
5.85k
  { \
1353
5.85k
    AArch64_add_cs_detail_1( \
1354
5.85k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
5.85k
      Scale); \
1356
5.85k
    SStream_concat(O, "%s", markup("<imm:")); \
1357
5.85k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
5.85k
            MCInst_getOperand(MI, (OpNum)))); \
1359
5.85k
    SStream_concat0(O, markup(">")); \
1360
5.85k
  }
printImmScale_32
Line
Count
Source
1352
178
  { \
1353
178
    AArch64_add_cs_detail_1( \
1354
178
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
178
      Scale); \
1356
178
    SStream_concat(O, "%s", markup("<imm:")); \
1357
178
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
178
            MCInst_getOperand(MI, (OpNum)))); \
1359
178
    SStream_concat0(O, markup(">")); \
1360
178
  }
printImmScale_3
Line
Count
Source
1352
145
  { \
1353
145
    AArch64_add_cs_detail_1( \
1354
145
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
145
      Scale); \
1356
145
    SStream_concat(O, "%s", markup("<imm:")); \
1357
145
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
145
            MCInst_getOperand(MI, (OpNum)))); \
1359
145
    SStream_concat0(O, markup(">")); \
1360
145
  }
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
8.23k
  { \
1372
8.23k
    AArch64_add_cs_detail_2( \
1373
8.23k
      MI, \
1374
8.23k
      CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \
1375
8.23k
             Offset), \
1376
8.23k
      OpNum, Scale, Offset); \
1377
8.23k
    unsigned FirstImm = \
1378
8.23k
      Scale * \
1379
8.23k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1380
8.23k
    printUInt32(O, (FirstImm)); \
1381
8.23k
    SStream_concat(O, "%s", ":"); \
1382
8.23k
    printUInt32(O, (FirstImm + Offset)); \
1383
8.23k
    SStream_concat1(O, '\0'); \
1384
8.23k
  }
printImmRangeScale_2_1
Line
Count
Source
1371
4.05k
  { \
1372
4.05k
    AArch64_add_cs_detail_2( \
1373
4.05k
      MI, \
1374
4.05k
      CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \
1375
4.05k
             Offset), \
1376
4.05k
      OpNum, Scale, Offset); \
1377
4.05k
    unsigned FirstImm = \
1378
4.05k
      Scale * \
1379
4.05k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1380
4.05k
    printUInt32(O, (FirstImm)); \
1381
4.05k
    SStream_concat(O, "%s", ":"); \
1382
4.05k
    printUInt32(O, (FirstImm + Offset)); \
1383
4.05k
    SStream_concat1(O, '\0'); \
1384
4.05k
  }
printImmRangeScale_4_3
Line
Count
Source
1371
4.18k
  { \
1372
4.18k
    AArch64_add_cs_detail_2( \
1373
4.18k
      MI, \
1374
4.18k
      CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \
1375
4.18k
             Offset), \
1376
4.18k
      OpNum, Scale, Offset); \
1377
4.18k
    unsigned FirstImm = \
1378
4.18k
      Scale * \
1379
4.18k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1380
4.18k
    printUInt32(O, (FirstImm)); \
1381
4.18k
    SStream_concat(O, "%s", ":"); \
1382
4.18k
    printUInt32(O, (FirstImm + Offset)); \
1383
4.18k
    SStream_concat1(O, '\0'); \
1384
4.18k
  }
1385
DEFINE_printImmRangeScale(2, 1);
1386
DEFINE_printImmRangeScale(4, 3);
1387
1388
void printUImm12Offset(MCInst *MI, unsigned OpNum, unsigned Scale, SStream *O)
1389
6.73k
{
1390
6.73k
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
1391
6.73k
  if (MCOperand_isImm(MO)) {
1392
6.73k
    SStream_concat(O, "%s", markup("<imm:"));
1393
6.73k
    printUInt32Bang(O, (MCOperand_getImm(MO) * Scale));
1394
6.73k
    SStream_concat0(O, markup(">"));
1395
6.73k
  } else {
1396
0
    printUInt64Bang(O, MCOperand_getImm(MO));
1397
0
  }
1398
6.73k
}
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
1.15k
{
1418
1.15k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_RPRFMOperand, OpNum);
1419
1.15k
  unsigned prfop = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1420
1.15k
  const AArch64PRFM_PRFM *PRFM =
1421
1.15k
    AArch64RPRFM_lookupRPRFMByEncoding(prfop);
1422
1.15k
  if (PRFM) {
1423
887
    SStream_concat0(O, PRFM->Name);
1424
887
    return;
1425
887
  }
1426
1427
266
  printUInt32Bang(O, (prfop));
1428
266
  SStream_concat1(O, '\0');
1429
266
}
1430
1431
#define DEFINE_printPrefetchOp(IsSVEPrefetch) \
1432
  void CONCAT(printPrefetchOp, \
1433
        IsSVEPrefetch)(MCInst * MI, unsigned OpNum, SStream *O) \
1434
8.41k
  { \
1435
8.41k
    AArch64_add_cs_detail_1(MI, \
1436
8.41k
          CONCAT(AArch64_OP_GROUP_PrefetchOp, \
1437
8.41k
                 IsSVEPrefetch), \
1438
8.41k
          OpNum, IsSVEPrefetch); \
1439
8.41k
    unsigned prfop = \
1440
8.41k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1441
8.41k
    if (IsSVEPrefetch) { \
1442
6.65k
      const AArch64SVEPRFM_SVEPRFM *PRFM = \
1443
6.65k
        AArch64SVEPRFM_lookupSVEPRFMByEncoding(prfop); \
1444
6.65k
      if (PRFM) { \
1445
5.58k
        SStream_concat0(O, PRFM->Name); \
1446
5.58k
        return; \
1447
5.58k
      } \
1448
6.65k
    } else { \
1449
1.76k
      const AArch64PRFM_PRFM *PRFM = \
1450
1.76k
        AArch64PRFM_lookupPRFMByEncoding(prfop); \
1451
1.76k
      if (PRFM && \
1452
1.76k
          AArch64_testFeatureList(MI->csh->mode, \
1453
1.19k
                PRFM->FeaturesRequired)) { \
1454
1.19k
        SStream_concat0(O, PRFM->Name); \
1455
1.19k
        return; \
1456
1.19k
      } \
1457
1.76k
    } \
1458
8.41k
\
1459
8.41k
    SStream_concat(O, "%s", markup("<imm:")); \
1460
1.64k
    printUInt32Bang(O, (prfop)); \
1461
1.64k
    SStream_concat0(O, markup(">")); \
1462
1.64k
  }
printPrefetchOp_0
Line
Count
Source
1434
1.76k
  { \
1435
1.76k
    AArch64_add_cs_detail_1(MI, \
1436
1.76k
          CONCAT(AArch64_OP_GROUP_PrefetchOp, \
1437
1.76k
                 IsSVEPrefetch), \
1438
1.76k
          OpNum, IsSVEPrefetch); \
1439
1.76k
    unsigned prfop = \
1440
1.76k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1441
1.76k
    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.76k
    } else { \
1449
1.76k
      const AArch64PRFM_PRFM *PRFM = \
1450
1.76k
        AArch64PRFM_lookupPRFMByEncoding(prfop); \
1451
1.76k
      if (PRFM && \
1452
1.76k
          AArch64_testFeatureList(MI->csh->mode, \
1453
1.19k
                PRFM->FeaturesRequired)) { \
1454
1.19k
        SStream_concat0(O, PRFM->Name); \
1455
1.19k
        return; \
1456
1.19k
      } \
1457
1.76k
    } \
1458
1.76k
\
1459
1.76k
    SStream_concat(O, "%s", markup("<imm:")); \
1460
574
    printUInt32Bang(O, (prfop)); \
1461
574
    SStream_concat0(O, markup(">")); \
1462
574
  }
printPrefetchOp_1
Line
Count
Source
1434
6.65k
  { \
1435
6.65k
    AArch64_add_cs_detail_1(MI, \
1436
6.65k
          CONCAT(AArch64_OP_GROUP_PrefetchOp, \
1437
6.65k
                 IsSVEPrefetch), \
1438
6.65k
          OpNum, IsSVEPrefetch); \
1439
6.65k
    unsigned prfop = \
1440
6.65k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1441
6.65k
    if (IsSVEPrefetch) { \
1442
6.65k
      const AArch64SVEPRFM_SVEPRFM *PRFM = \
1443
6.65k
        AArch64SVEPRFM_lookupSVEPRFMByEncoding(prfop); \
1444
6.65k
      if (PRFM) { \
1445
5.58k
        SStream_concat0(O, PRFM->Name); \
1446
5.58k
        return; \
1447
5.58k
      } \
1448
6.65k
    } 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
6.65k
\
1459
6.65k
    SStream_concat(O, "%s", markup("<imm:")); \
1460
1.06k
    printUInt32Bang(O, (prfop)); \
1461
1.06k
    SStream_concat0(O, markup(">")); \
1462
1.06k
  }
1463
DEFINE_printPrefetchOp(false);
1464
DEFINE_printPrefetchOp(true);
1465
1466
void printPSBHintOp(MCInst *MI, unsigned OpNum, SStream *O)
1467
255
{
1468
255
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_PSBHintOp, OpNum);
1469
255
  unsigned psbhintop = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1470
255
  const AArch64PSBHint_PSB *PSB =
1471
255
    AArch64PSBHint_lookupPSBByEncoding(psbhintop);
1472
255
  if (PSB)
1473
255
    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
255
}
1481
1482
void printBTIHintOp(MCInst *MI, unsigned OpNum, SStream *O)
1483
658
{
1484
658
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BTIHintOp, OpNum);
1485
658
  unsigned btihintop = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))) ^
1486
658
           32;
1487
658
  const AArch64BTIHint_BTI *BTI =
1488
658
    AArch64BTIHint_lookupBTIByEncoding(btihintop);
1489
658
  if (BTI)
1490
658
    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
658
}
1497
1498
static void printFPImmOperand(MCInst *MI, unsigned OpNum, SStream *O)
1499
539
{
1500
539
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_FPImmOperand, OpNum);
1501
539
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
1502
539
  float FPImm = MCOperand_isDFPImm(MO) ?
1503
0
            BitsToDouble(MCOperand_getImm(MO)) :
1504
539
            AArch64_AM_getFPImmFloat(MCOperand_getImm(MO));
1505
1506
  // 8 decimal places are enough to perfectly represent permitted floats.
1507
539
  SStream_concat(O, "%s", markup("<imm:"));
1508
539
  SStream_concat(O, "#%.8f", FPImm);
1509
539
  SStream_concat0(O, markup(">"));
1510
539
}
1511
1512
static unsigned getNextVectorRegister(unsigned Reg, unsigned Stride /* = 1 */)
1513
170k
{
1514
456k
  while (Stride--) {
1515
285k
    switch (Reg) {
1516
0
    default:
1517
0
      CS_ASSERT_RET_VAL(0 && "Vector register expected!", 0);
1518
5.91k
    case AArch64_Q0:
1519
5.91k
      Reg = AArch64_Q1;
1520
5.91k
      break;
1521
5.45k
    case AArch64_Q1:
1522
5.45k
      Reg = AArch64_Q2;
1523
5.45k
      break;
1524
2.92k
    case AArch64_Q2:
1525
2.92k
      Reg = AArch64_Q3;
1526
2.92k
      break;
1527
2.29k
    case AArch64_Q3:
1528
2.29k
      Reg = AArch64_Q4;
1529
2.29k
      break;
1530
1.93k
    case AArch64_Q4:
1531
1.93k
      Reg = AArch64_Q5;
1532
1.93k
      break;
1533
1.91k
    case AArch64_Q5:
1534
1.91k
      Reg = AArch64_Q6;
1535
1.91k
      break;
1536
1.31k
    case AArch64_Q6:
1537
1.31k
      Reg = AArch64_Q7;
1538
1.31k
      break;
1539
2.30k
    case AArch64_Q7:
1540
2.30k
      Reg = AArch64_Q8;
1541
2.30k
      break;
1542
1.83k
    case AArch64_Q8:
1543
1.83k
      Reg = AArch64_Q9;
1544
1.83k
      break;
1545
1.67k
    case AArch64_Q9:
1546
1.67k
      Reg = AArch64_Q10;
1547
1.67k
      break;
1548
2.42k
    case AArch64_Q10:
1549
2.42k
      Reg = AArch64_Q11;
1550
2.42k
      break;
1551
2.64k
    case AArch64_Q11:
1552
2.64k
      Reg = AArch64_Q12;
1553
2.64k
      break;
1554
4.51k
    case AArch64_Q12:
1555
4.51k
      Reg = AArch64_Q13;
1556
4.51k
      break;
1557
3.40k
    case AArch64_Q13:
1558
3.40k
      Reg = AArch64_Q14;
1559
3.40k
      break;
1560
3.48k
    case AArch64_Q14:
1561
3.48k
      Reg = AArch64_Q15;
1562
3.48k
      break;
1563
2.87k
    case AArch64_Q15:
1564
2.87k
      Reg = AArch64_Q16;
1565
2.87k
      break;
1566
3.13k
    case AArch64_Q16:
1567
3.13k
      Reg = AArch64_Q17;
1568
3.13k
      break;
1569
3.26k
    case AArch64_Q17:
1570
3.26k
      Reg = AArch64_Q18;
1571
3.26k
      break;
1572
2.59k
    case AArch64_Q18:
1573
2.59k
      Reg = AArch64_Q19;
1574
2.59k
      break;
1575
3.25k
    case AArch64_Q19:
1576
3.25k
      Reg = AArch64_Q20;
1577
3.25k
      break;
1578
5.72k
    case AArch64_Q20:
1579
5.72k
      Reg = AArch64_Q21;
1580
5.72k
      break;
1581
3.31k
    case AArch64_Q21:
1582
3.31k
      Reg = AArch64_Q22;
1583
3.31k
      break;
1584
3.36k
    case AArch64_Q22:
1585
3.36k
      Reg = AArch64_Q23;
1586
3.36k
      break;
1587
2.75k
    case AArch64_Q23:
1588
2.75k
      Reg = AArch64_Q24;
1589
2.75k
      break;
1590
2.66k
    case AArch64_Q24:
1591
2.66k
      Reg = AArch64_Q25;
1592
2.66k
      break;
1593
2.59k
    case AArch64_Q25:
1594
2.59k
      Reg = AArch64_Q26;
1595
2.59k
      break;
1596
2.14k
    case AArch64_Q26:
1597
2.14k
      Reg = AArch64_Q27;
1598
2.14k
      break;
1599
2.50k
    case AArch64_Q27:
1600
2.50k
      Reg = AArch64_Q28;
1601
2.50k
      break;
1602
1.49k
    case AArch64_Q28:
1603
1.49k
      Reg = AArch64_Q29;
1604
1.49k
      break;
1605
1.62k
    case AArch64_Q29:
1606
1.62k
      Reg = AArch64_Q30;
1607
1.62k
      break;
1608
1.28k
    case AArch64_Q30:
1609
1.28k
      Reg = AArch64_Q31;
1610
1.28k
      break;
1611
    // Vector lists can wrap around.
1612
2.87k
    case AArch64_Q31:
1613
2.87k
      Reg = AArch64_Q0;
1614
2.87k
      break;
1615
16.6k
    case AArch64_Z0:
1616
16.6k
      Reg = AArch64_Z1;
1617
16.6k
      break;
1618
11.5k
    case AArch64_Z1:
1619
11.5k
      Reg = AArch64_Z2;
1620
11.5k
      break;
1621
11.7k
    case AArch64_Z2:
1622
11.7k
      Reg = AArch64_Z3;
1623
11.7k
      break;
1624
3.32k
    case AArch64_Z3:
1625
3.32k
      Reg = AArch64_Z4;
1626
3.32k
      break;
1627
13.2k
    case AArch64_Z4:
1628
13.2k
      Reg = AArch64_Z5;
1629
13.2k
      break;
1630
7.76k
    case AArch64_Z5:
1631
7.76k
      Reg = AArch64_Z6;
1632
7.76k
      break;
1633
10.0k
    case AArch64_Z6:
1634
10.0k
      Reg = AArch64_Z7;
1635
10.0k
      break;
1636
2.88k
    case AArch64_Z7:
1637
2.88k
      Reg = AArch64_Z8;
1638
2.88k
      break;
1639
6.50k
    case AArch64_Z8:
1640
6.50k
      Reg = AArch64_Z9;
1641
6.50k
      break;
1642
5.12k
    case AArch64_Z9:
1643
5.12k
      Reg = AArch64_Z10;
1644
5.12k
      break;
1645
5.33k
    case AArch64_Z10:
1646
5.33k
      Reg = AArch64_Z11;
1647
5.33k
      break;
1648
2.86k
    case AArch64_Z11:
1649
2.86k
      Reg = AArch64_Z12;
1650
2.86k
      break;
1651
3.63k
    case AArch64_Z12:
1652
3.63k
      Reg = AArch64_Z13;
1653
3.63k
      break;
1654
3.65k
    case AArch64_Z13:
1655
3.65k
      Reg = AArch64_Z14;
1656
3.65k
      break;
1657
5.46k
    case AArch64_Z14:
1658
5.46k
      Reg = AArch64_Z15;
1659
5.46k
      break;
1660
2.74k
    case AArch64_Z15:
1661
2.74k
      Reg = AArch64_Z16;
1662
2.74k
      break;
1663
3.30k
    case AArch64_Z16:
1664
3.30k
      Reg = AArch64_Z17;
1665
3.30k
      break;
1666
1.73k
    case AArch64_Z17:
1667
1.73k
      Reg = AArch64_Z18;
1668
1.73k
      break;
1669
2.04k
    case AArch64_Z18:
1670
2.04k
      Reg = AArch64_Z19;
1671
2.04k
      break;
1672
3.04k
    case AArch64_Z19:
1673
3.04k
      Reg = AArch64_Z20;
1674
3.04k
      break;
1675
9.23k
    case AArch64_Z20:
1676
9.23k
      Reg = AArch64_Z21;
1677
9.23k
      break;
1678
7.72k
    case AArch64_Z21:
1679
7.72k
      Reg = AArch64_Z22;
1680
7.72k
      break;
1681
7.74k
    case AArch64_Z22:
1682
7.74k
      Reg = AArch64_Z23;
1683
7.74k
      break;
1684
3.34k
    case AArch64_Z23:
1685
3.34k
      Reg = AArch64_Z24;
1686
3.34k
      break;
1687
5.17k
    case AArch64_Z24:
1688
5.17k
      Reg = AArch64_Z25;
1689
5.17k
      break;
1690
5.02k
    case AArch64_Z25:
1691
5.02k
      Reg = AArch64_Z26;
1692
5.02k
      break;
1693
5.20k
    case AArch64_Z26:
1694
5.20k
      Reg = AArch64_Z27;
1695
5.20k
      break;
1696
3.65k
    case AArch64_Z27:
1697
3.65k
      Reg = AArch64_Z28;
1698
3.65k
      break;
1699
3.73k
    case AArch64_Z28:
1700
3.73k
      Reg = AArch64_Z29;
1701
3.73k
      break;
1702
3.92k
    case AArch64_Z29:
1703
3.92k
      Reg = AArch64_Z30;
1704
3.92k
      break;
1705
3.95k
    case AArch64_Z30:
1706
3.95k
      Reg = AArch64_Z31;
1707
3.95k
      break;
1708
    // Vector lists can wrap around.
1709
3.72k
    case AArch64_Z31:
1710
3.72k
      Reg = AArch64_Z0;
1711
3.72k
      break;
1712
837
    case AArch64_P0:
1713
837
      Reg = AArch64_P1;
1714
837
      break;
1715
630
    case AArch64_P1:
1716
630
      Reg = AArch64_P2;
1717
630
      break;
1718
692
    case AArch64_P2:
1719
692
      Reg = AArch64_P3;
1720
692
      break;
1721
544
    case AArch64_P3:
1722
544
      Reg = AArch64_P4;
1723
544
      break;
1724
512
    case AArch64_P4:
1725
512
      Reg = AArch64_P5;
1726
512
      break;
1727
568
    case AArch64_P5:
1728
568
      Reg = AArch64_P6;
1729
568
      break;
1730
1.15k
    case AArch64_P6:
1731
1.15k
      Reg = AArch64_P7;
1732
1.15k
      break;
1733
130
    case AArch64_P7:
1734
130
      Reg = AArch64_P8;
1735
130
      break;
1736
724
    case AArch64_P8:
1737
724
      Reg = AArch64_P9;
1738
724
      break;
1739
150
    case AArch64_P9:
1740
150
      Reg = AArch64_P10;
1741
150
      break;
1742
426
    case AArch64_P10:
1743
426
      Reg = AArch64_P11;
1744
426
      break;
1745
434
    case AArch64_P11:
1746
434
      Reg = AArch64_P12;
1747
434
      break;
1748
302
    case AArch64_P12:
1749
302
      Reg = AArch64_P13;
1750
302
      break;
1751
1.18k
    case AArch64_P13:
1752
1.18k
      Reg = AArch64_P14;
1753
1.18k
      break;
1754
282
    case AArch64_P14:
1755
282
      Reg = AArch64_P15;
1756
282
      break;
1757
    // Vector lists can wrap around.
1758
526
    case AArch64_P15:
1759
526
      Reg = AArch64_P0;
1760
526
      break;
1761
285k
    }
1762
285k
  }
1763
170k
  return Reg;
1764
170k
}
1765
1766
#define DEFINE_printGPRSeqPairsClassOperand(size) \
1767
  void CONCAT(printGPRSeqPairsClassOperand, \
1768
        size)(MCInst * MI, unsigned OpNum, SStream *O) \
1769
2.67k
  { \
1770
2.67k
    AArch64_add_cs_detail_1( \
1771
2.67k
      MI, \
1772
2.67k
      CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \
1773
2.67k
             size), \
1774
2.67k
      OpNum, size); \
1775
2.67k
    CS_ASSERT_RET((size == 64 || size == 32) && \
1776
2.67k
            "Template parameter must be either 32 or 64"); \
1777
2.67k
    unsigned Reg = \
1778
2.67k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1779
2.67k
\
1780
2.67k
    unsigned Sube = (size == 32) ? AArch64_sube32 : \
1781
2.67k
                 AArch64_sube64; \
1782
2.67k
    unsigned Subo = (size == 32) ? AArch64_subo32 : \
1783
2.67k
                 AArch64_subo64; \
1784
2.67k
\
1785
2.67k
    unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \
1786
2.67k
    unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \
1787
2.67k
    printRegName(O, Even); \
1788
2.67k
    SStream_concat0(O, ", "); \
1789
2.67k
    printRegName(O, Odd); \
1790
2.67k
  }
printGPRSeqPairsClassOperand_32
Line
Count
Source
1769
278
  { \
1770
278
    AArch64_add_cs_detail_1( \
1771
278
      MI, \
1772
278
      CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \
1773
278
             size), \
1774
278
      OpNum, size); \
1775
278
    CS_ASSERT_RET((size == 64 || size == 32) && \
1776
278
            "Template parameter must be either 32 or 64"); \
1777
278
    unsigned Reg = \
1778
278
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1779
278
\
1780
278
    unsigned Sube = (size == 32) ? AArch64_sube32 : \
1781
278
                 AArch64_sube64; \
1782
278
    unsigned Subo = (size == 32) ? AArch64_subo32 : \
1783
278
                 AArch64_subo64; \
1784
278
\
1785
278
    unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \
1786
278
    unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \
1787
278
    printRegName(O, Even); \
1788
278
    SStream_concat0(O, ", "); \
1789
278
    printRegName(O, Odd); \
1790
278
  }
printGPRSeqPairsClassOperand_64
Line
Count
Source
1769
2.40k
  { \
1770
2.40k
    AArch64_add_cs_detail_1( \
1771
2.40k
      MI, \
1772
2.40k
      CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \
1773
2.40k
             size), \
1774
2.40k
      OpNum, size); \
1775
2.40k
    CS_ASSERT_RET((size == 64 || size == 32) && \
1776
2.40k
            "Template parameter must be either 32 or 64"); \
1777
2.40k
    unsigned Reg = \
1778
2.40k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1779
2.40k
\
1780
2.40k
    unsigned Sube = (size == 32) ? AArch64_sube32 : \
1781
2.40k
                 AArch64_sube64; \
1782
2.40k
    unsigned Subo = (size == 32) ? AArch64_subo32 : \
1783
2.40k
                 AArch64_subo64; \
1784
2.40k
\
1785
2.40k
    unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \
1786
2.40k
    unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \
1787
2.40k
    printRegName(O, Even); \
1788
2.40k
    SStream_concat0(O, ", "); \
1789
2.40k
    printRegName(O, Odd); \
1790
2.40k
  }
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
12.7k
  { \
1798
12.7k
    AArch64_add_cs_detail_1( \
1799
12.7k
      MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \
1800
12.7k
      OpNum, Scale); \
1801
12.7k
    printInt64(O, Scale *MCOperand_getImm( \
1802
12.7k
              MCInst_getOperand(MI, (OpNum)))); \
1803
12.7k
  }
printMatrixIndex_8
Line
Count
Source
1797
1.42k
  { \
1798
1.42k
    AArch64_add_cs_detail_1( \
1799
1.42k
      MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \
1800
1.42k
      OpNum, Scale); \
1801
1.42k
    printInt64(O, Scale *MCOperand_getImm( \
1802
1.42k
              MCInst_getOperand(MI, (OpNum)))); \
1803
1.42k
  }
Unexecuted instantiation: printMatrixIndex_0
printMatrixIndex_1
Line
Count
Source
1797
11.3k
  { \
1798
11.3k
    AArch64_add_cs_detail_1( \
1799
11.3k
      MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \
1800
11.3k
      OpNum, Scale); \
1801
11.3k
    printInt64(O, Scale *MCOperand_getImm( \
1802
11.3k
              MCInst_getOperand(MI, (OpNum)))); \
1803
11.3k
  }
1804
DEFINE_printMatrixIndex(8);
1805
DEFINE_printMatrixIndex(0);
1806
DEFINE_printMatrixIndex(1);
1807
1808
void printMatrixTileList(MCInst *MI, unsigned OpNum, SStream *O)
1809
790
{
1810
790
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MatrixTileList, OpNum);
1811
790
  unsigned MaxRegs = 8;
1812
790
  unsigned RegMask = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1813
1814
790
  unsigned NumRegs = 0;
1815
7.11k
  for (unsigned I = 0; I < MaxRegs; ++I)
1816
6.32k
    if ((RegMask & (1 << I)) != 0)
1817
2.89k
      ++NumRegs;
1818
1819
790
  SStream_concat0(O, "{");
1820
790
  unsigned Printed = 0;
1821
7.11k
  for (unsigned I = 0; I < MaxRegs; ++I) {
1822
6.32k
    unsigned Reg = RegMask & (1 << I);
1823
6.32k
    if (Reg == 0)
1824
3.42k
      continue;
1825
2.89k
    printRegName(O, AArch64_ZAD0 + I);
1826
2.89k
    if (Printed + 1 != NumRegs)
1827
2.11k
      SStream_concat0(O, ", ");
1828
2.89k
    ++Printed;
1829
2.89k
  }
1830
790
  SStream_concat0(O, "}");
1831
790
}
1832
1833
void printVectorList(MCInst *MI, unsigned OpNum, SStream *O,
1834
         const char *LayoutSuffix)
1835
77.1k
{
1836
77.1k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
1837
1838
77.1k
  SStream_concat0(O, "{ ");
1839
1840
  // Work out how many registers there are in the list (if there is an actual
1841
  // list).
1842
77.1k
  unsigned NumRegs = 1;
1843
77.1k
  if (MCRegisterClass_contains(
1844
77.1k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_DDRegClassID),
1845
77.1k
        Reg) ||
1846
75.4k
      MCRegisterClass_contains(
1847
75.4k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_ZPR2RegClassID),
1848
75.4k
        Reg) ||
1849
62.4k
      MCRegisterClass_contains(
1850
62.4k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_QQRegClassID),
1851
62.4k
        Reg) ||
1852
55.8k
      MCRegisterClass_contains(
1853
55.8k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_PPR2RegClassID),
1854
55.8k
        Reg) ||
1855
51.3k
      MCRegisterClass_contains(
1856
51.3k
        MCRegisterInfo_getRegClass(MI->MRI,
1857
51.3k
                 AArch64_ZPR2StridedRegClassID),
1858
51.3k
        Reg))
1859
29.7k
    NumRegs = 2;
1860
47.4k
  else if (MCRegisterClass_contains(
1861
47.4k
       MCRegisterInfo_getRegClass(MI->MRI,
1862
47.4k
                AArch64_DDDRegClassID),
1863
47.4k
       Reg) ||
1864
46.8k
     MCRegisterClass_contains(
1865
46.8k
       MCRegisterInfo_getRegClass(MI->MRI,
1866
46.8k
                AArch64_ZPR3RegClassID),
1867
46.8k
       Reg) ||
1868
46.6k
     MCRegisterClass_contains(
1869
46.6k
       MCRegisterInfo_getRegClass(MI->MRI,
1870
46.6k
                AArch64_QQQRegClassID),
1871
46.6k
       Reg))
1872
9.56k
    NumRegs = 3;
1873
37.8k
  else if (MCRegisterClass_contains(
1874
37.8k
       MCRegisterInfo_getRegClass(MI->MRI,
1875
37.8k
                AArch64_DDDDRegClassID),
1876
37.8k
       Reg) ||
1877
36.9k
     MCRegisterClass_contains(
1878
36.9k
       MCRegisterInfo_getRegClass(MI->MRI,
1879
36.9k
                AArch64_ZPR4RegClassID),
1880
36.9k
       Reg) ||
1881
27.4k
     MCRegisterClass_contains(
1882
27.4k
       MCRegisterInfo_getRegClass(MI->MRI,
1883
27.4k
                AArch64_QQQQRegClassID),
1884
27.4k
       Reg) ||
1885
18.4k
     MCRegisterClass_contains(
1886
18.4k
       MCRegisterInfo_getRegClass(
1887
18.4k
         MI->MRI, AArch64_ZPR4StridedRegClassID),
1888
18.4k
       Reg))
1889
21.1k
    NumRegs = 4;
1890
1891
77.1k
  unsigned Stride = 1;
1892
77.1k
  if (MCRegisterClass_contains(
1893
77.1k
        MCRegisterInfo_getRegClass(MI->MRI,
1894
77.1k
                 AArch64_ZPR2StridedRegClassID),
1895
77.1k
        Reg))
1896
3.99k
    Stride = 8;
1897
73.1k
  else if (MCRegisterClass_contains(
1898
73.1k
       MCRegisterInfo_getRegClass(
1899
73.1k
         MI->MRI, AArch64_ZPR4StridedRegClassID),
1900
73.1k
       Reg))
1901
1.72k
    Stride = 4;
1902
1903
  // Now forget about the list and find out what the first register is.
1904
77.1k
  if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_dsub0))
1905
3.17k
    Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_dsub0);
1906
73.9k
  else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_qsub0))
1907
24.3k
    Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_qsub0);
1908
49.5k
  else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_zsub0))
1909
28.4k
    Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_zsub0);
1910
21.1k
  else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_psub0))
1911
4.41k
    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
77.1k
  if (MCRegisterClass_contains(MCRegisterInfo_getRegClass(
1916
77.1k
               MI->MRI, AArch64_FPR64RegClassID),
1917
77.1k
             Reg)) {
1918
3.50k
    const MCRegisterClass *FPR128RC = MCRegisterInfo_getRegClass(
1919
3.50k
      MI->MRI, AArch64_FPR128RegClassID);
1920
3.50k
    Reg = MCRegisterInfo_getMatchingSuperReg(
1921
3.50k
      MI->MRI, Reg, AArch64_dsub, FPR128RC);
1922
3.50k
  }
1923
1924
77.1k
  if ((MCRegisterClass_contains(
1925
77.1k
         MCRegisterInfo_getRegClass(MI->MRI, AArch64_ZPRRegClassID),
1926
77.1k
         Reg) ||
1927
39.2k
       MCRegisterClass_contains(
1928
39.2k
         MCRegisterInfo_getRegClass(MI->MRI, AArch64_PPRRegClassID),
1929
39.2k
         Reg)) &&
1930
42.3k
      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
27.1k
      Reg < getNextVectorRegister(Reg, NumRegs - 1)) {
1934
26.7k
    printRegName(O, Reg);
1935
26.7k
    SStream_concat0(O, LayoutSuffix);
1936
26.7k
    if (NumRegs > 1) {
1937
      // Set of two sve registers should be separated by ','
1938
26.7k
      const char *split_char = NumRegs == 2 ? ", " : " - ";
1939
26.7k
      SStream_concat0(O, split_char);
1940
26.7k
      printRegName(O,
1941
26.7k
             (getNextVectorRegister(Reg, NumRegs - 1)));
1942
26.7k
      SStream_concat0(O, LayoutSuffix);
1943
26.7k
    }
1944
50.4k
  } else {
1945
167k
    for (unsigned i = 0; i < NumRegs;
1946
116k
         ++i, Reg = getNextVectorRegister(Reg, Stride)) {
1947
      // wrap-around sve register
1948
116k
      if (MCRegisterClass_contains(
1949
116k
            MCRegisterInfo_getRegClass(
1950
116k
              MI->MRI, AArch64_ZPRRegClassID),
1951
116k
            Reg) ||
1952
92.0k
          MCRegisterClass_contains(
1953
92.0k
            MCRegisterInfo_getRegClass(
1954
92.0k
              MI->MRI, AArch64_PPRRegClassID),
1955
92.0k
            Reg))
1956
25.3k
        printRegName(O, Reg);
1957
91.4k
      else
1958
91.4k
        printRegNameAlt(O, Reg, AArch64_vreg);
1959
116k
      SStream_concat0(O, LayoutSuffix);
1960
116k
      if (i + 1 != NumRegs)
1961
66.4k
        SStream_concat0(O, ", ");
1962
116k
    }
1963
50.4k
  }
1964
77.1k
  SStream_concat0(O, " }");
1965
77.1k
}
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
77.1k
  { \
1978
77.1k
    AArch64_add_cs_detail_2( \
1979
77.1k
      MI, \
1980
77.1k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
77.1k
              NumLanes), \
1982
77.1k
             LaneKind), \
1983
77.1k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
77.1k
    if (CHAR(LaneKind) == '0') { \
1985
56
      printVectorList(MI, OpNum, O, ""); \
1986
56
      return; \
1987
56
    } \
1988
77.1k
    char Suffix[32]; \
1989
77.0k
    if (NumLanes) \
1990
77.0k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
11.3k
            CHAR(LaneKind)); \
1992
77.0k
    else \
1993
77.0k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
65.7k
            CHAR(LaneKind)); \
1995
77.0k
\
1996
77.0k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
77.0k
  }
printTypedVectorList_0_b
Line
Count
Source
1977
16.3k
  { \
1978
16.3k
    AArch64_add_cs_detail_2( \
1979
16.3k
      MI, \
1980
16.3k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
16.3k
              NumLanes), \
1982
16.3k
             LaneKind), \
1983
16.3k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
16.3k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
16.3k
    char Suffix[32]; \
1989
16.3k
    if (NumLanes) \
1990
16.3k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
0
            CHAR(LaneKind)); \
1992
16.3k
    else \
1993
16.3k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
16.3k
            CHAR(LaneKind)); \
1995
16.3k
\
1996
16.3k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
16.3k
  }
printTypedVectorList_0_d
Line
Count
Source
1977
17.3k
  { \
1978
17.3k
    AArch64_add_cs_detail_2( \
1979
17.3k
      MI, \
1980
17.3k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
17.3k
              NumLanes), \
1982
17.3k
             LaneKind), \
1983
17.3k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
17.3k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
17.3k
    char Suffix[32]; \
1989
17.3k
    if (NumLanes) \
1990
17.3k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
0
            CHAR(LaneKind)); \
1992
17.3k
    else \
1993
17.3k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
17.3k
            CHAR(LaneKind)); \
1995
17.3k
\
1996
17.3k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
17.3k
  }
printTypedVectorList_0_h
Line
Count
Source
1977
16.4k
  { \
1978
16.4k
    AArch64_add_cs_detail_2( \
1979
16.4k
      MI, \
1980
16.4k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
16.4k
              NumLanes), \
1982
16.4k
             LaneKind), \
1983
16.4k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
16.4k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
16.4k
    char Suffix[32]; \
1989
16.4k
    if (NumLanes) \
1990
16.4k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
0
            CHAR(LaneKind)); \
1992
16.4k
    else \
1993
16.4k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
16.4k
            CHAR(LaneKind)); \
1995
16.4k
\
1996
16.4k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
16.4k
  }
printTypedVectorList_0_s
Line
Count
Source
1977
15.3k
  { \
1978
15.3k
    AArch64_add_cs_detail_2( \
1979
15.3k
      MI, \
1980
15.3k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
15.3k
              NumLanes), \
1982
15.3k
             LaneKind), \
1983
15.3k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
15.3k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
15.3k
    char Suffix[32]; \
1989
15.3k
    if (NumLanes) \
1990
15.3k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
0
            CHAR(LaneKind)); \
1992
15.3k
    else \
1993
15.3k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
15.3k
            CHAR(LaneKind)); \
1995
15.3k
\
1996
15.3k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
15.3k
  }
printTypedVectorList_0_q
Line
Count
Source
1977
338
  { \
1978
338
    AArch64_add_cs_detail_2( \
1979
338
      MI, \
1980
338
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
338
              NumLanes), \
1982
338
             LaneKind), \
1983
338
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
338
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
338
    char Suffix[32]; \
1989
338
    if (NumLanes) \
1990
338
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
0
            CHAR(LaneKind)); \
1992
338
    else \
1993
338
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
338
            CHAR(LaneKind)); \
1995
338
\
1996
338
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
338
  }
printTypedVectorList_16_b
Line
Count
Source
1977
3.14k
  { \
1978
3.14k
    AArch64_add_cs_detail_2( \
1979
3.14k
      MI, \
1980
3.14k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
3.14k
              NumLanes), \
1982
3.14k
             LaneKind), \
1983
3.14k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
3.14k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
3.14k
    char Suffix[32]; \
1989
3.14k
    if (NumLanes) \
1990
3.14k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
3.14k
            CHAR(LaneKind)); \
1992
3.14k
    else \
1993
3.14k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
3.14k
\
1996
3.14k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
3.14k
  }
printTypedVectorList_1_d
Line
Count
Source
1977
222
  { \
1978
222
    AArch64_add_cs_detail_2( \
1979
222
      MI, \
1980
222
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
222
              NumLanes), \
1982
222
             LaneKind), \
1983
222
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
222
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
222
    char Suffix[32]; \
1989
222
    if (NumLanes) \
1990
222
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
222
            CHAR(LaneKind)); \
1992
222
    else \
1993
222
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
222
\
1996
222
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
222
  }
printTypedVectorList_2_d
Line
Count
Source
1977
1.94k
  { \
1978
1.94k
    AArch64_add_cs_detail_2( \
1979
1.94k
      MI, \
1980
1.94k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
1.94k
              NumLanes), \
1982
1.94k
             LaneKind), \
1983
1.94k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
1.94k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
1.94k
    char Suffix[32]; \
1989
1.94k
    if (NumLanes) \
1990
1.94k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
1.94k
            CHAR(LaneKind)); \
1992
1.94k
    else \
1993
1.94k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
1.94k
\
1996
1.94k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
1.94k
  }
printTypedVectorList_2_s
Line
Count
Source
1977
1.17k
  { \
1978
1.17k
    AArch64_add_cs_detail_2( \
1979
1.17k
      MI, \
1980
1.17k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
1.17k
              NumLanes), \
1982
1.17k
             LaneKind), \
1983
1.17k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
1.17k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
1.17k
    char Suffix[32]; \
1989
1.17k
    if (NumLanes) \
1990
1.17k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
1.17k
            CHAR(LaneKind)); \
1992
1.17k
    else \
1993
1.17k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
1.17k
\
1996
1.17k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
1.17k
  }
printTypedVectorList_4_h
Line
Count
Source
1977
937
  { \
1978
937
    AArch64_add_cs_detail_2( \
1979
937
      MI, \
1980
937
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
937
              NumLanes), \
1982
937
             LaneKind), \
1983
937
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
937
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
937
    char Suffix[32]; \
1989
937
    if (NumLanes) \
1990
937
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
937
            CHAR(LaneKind)); \
1992
937
    else \
1993
937
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
937
\
1996
937
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
937
  }
printTypedVectorList_4_s
Line
Count
Source
1977
1.32k
  { \
1978
1.32k
    AArch64_add_cs_detail_2( \
1979
1.32k
      MI, \
1980
1.32k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
1.32k
              NumLanes), \
1982
1.32k
             LaneKind), \
1983
1.32k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
1.32k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
1.32k
    char Suffix[32]; \
1989
1.32k
    if (NumLanes) \
1990
1.32k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
1.32k
            CHAR(LaneKind)); \
1992
1.32k
    else \
1993
1.32k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
1.32k
\
1996
1.32k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
1.32k
  }
printTypedVectorList_8_b
Line
Count
Source
1977
1.17k
  { \
1978
1.17k
    AArch64_add_cs_detail_2( \
1979
1.17k
      MI, \
1980
1.17k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
1.17k
              NumLanes), \
1982
1.17k
             LaneKind), \
1983
1.17k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
1.17k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
1.17k
    char Suffix[32]; \
1989
1.17k
    if (NumLanes) \
1990
1.17k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
1.17k
            CHAR(LaneKind)); \
1992
1.17k
    else \
1993
1.17k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
1.17k
\
1996
1.17k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
1.17k
  }
printTypedVectorList_8_h
Line
Count
Source
1977
1.41k
  { \
1978
1.41k
    AArch64_add_cs_detail_2( \
1979
1.41k
      MI, \
1980
1.41k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
1.41k
              NumLanes), \
1982
1.41k
             LaneKind), \
1983
1.41k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
1.41k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
1.41k
    char Suffix[32]; \
1989
1.41k
    if (NumLanes) \
1990
1.41k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
1.41k
            CHAR(LaneKind)); \
1992
1.41k
    else \
1993
1.41k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
1.41k
\
1996
1.41k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
1.41k
  }
printTypedVectorList_0_0
Line
Count
Source
1977
56
  { \
1978
56
    AArch64_add_cs_detail_2( \
1979
56
      MI, \
1980
56
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
56
              NumLanes), \
1982
56
             LaneKind), \
1983
56
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
56
    if (CHAR(LaneKind) == '0') { \
1985
56
      printVectorList(MI, OpNum, O, ""); \
1986
56
      return; \
1987
56
    } \
1988
56
    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
46.5k
  { \
2017
46.5k
    AArch64_add_cs_detail_1( \
2018
46.5k
      MI, CONCAT(AArch64_OP_GROUP_VectorIndex, Scale), \
2019
46.5k
      OpNum, Scale); \
2020
46.5k
    SStream_concat(O, "%s", "["); \
2021
46.5k
    printUInt64(O, Scale *MCOperand_getImm( \
2022
46.5k
               MCInst_getOperand(MI, (OpNum)))); \
2023
46.5k
    SStream_concat0(O, "]"); \
2024
46.5k
  }
printVectorIndex_1
Line
Count
Source
2016
46.5k
  { \
2017
46.5k
    AArch64_add_cs_detail_1( \
2018
46.5k
      MI, CONCAT(AArch64_OP_GROUP_VectorIndex, Scale), \
2019
46.5k
      OpNum, Scale); \
2020
46.5k
    SStream_concat(O, "%s", "["); \
2021
46.5k
    printUInt64(O, Scale *MCOperand_getImm( \
2022
46.5k
               MCInst_getOperand(MI, (OpNum)))); \
2023
46.5k
    SStream_concat0(O, "]"); \
2024
46.5k
  }
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
12.6k
{
2030
12.6k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AlignedLabel, OpNum);
2031
12.6k
  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
12.6k
  if (MCOperand_isImm(Op)) {
2036
12.6k
    SStream_concat0(O, markup("<imm:"));
2037
12.6k
    int64_t Offset = MCOperand_getImm(Op) * 4;
2038
12.6k
    if (MI->csh->PrintBranchImmAsAddress)
2039
12.6k
      printUInt64(O, (Address + Offset));
2040
0
    else {
2041
0
      printUInt64Bang(O, (Offset));
2042
0
    }
2043
12.6k
    SStream_concat0(O, markup(">"));
2044
12.6k
    return;
2045
12.6k
  }
2046
2047
84
  printUInt64Bang(O, MCOperand_getImm(Op));
2048
84
}
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
5.17k
{
2096
5.17k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AdrAdrpLabel, OpNum);
2097
5.17k
  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
5.17k
  if (MCOperand_isImm(Op)) {
2102
5.17k
    int64_t Offset = MCOperand_getImm(Op);
2103
5.17k
    if (MCInst_getOpcode(MI) == AArch64_ADRP) {
2104
1.75k
      Offset = Offset * 4096;
2105
1.75k
      Address = Address & -4096;
2106
1.75k
    }
2107
5.17k
    SStream_concat0(O, markup(">"));
2108
5.17k
    if (MI->csh->PrintBranchImmAsAddress)
2109
5.17k
      printUInt64(O, (Address + Offset));
2110
0
    else {
2111
0
      printUInt64Bang(O, Offset);
2112
0
    }
2113
5.17k
    SStream_concat0(O, markup(">"));
2114
5.17k
    return;
2115
5.17k
  }
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
916
{
2125
916
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AppleSysBarrierOption,
2126
916
        OpNo);
2127
916
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2128
916
  switch (Val) {
2129
540
  default:
2130
540
    SStream_concat0(O, "<undefined>");
2131
540
    break;
2132
9
  case 0:
2133
9
    SStream_concat0(O, "osh");
2134
9
    break;
2135
187
  case 1:
2136
187
    SStream_concat0(O, "nsh");
2137
187
    break;
2138
68
  case 2:
2139
68
    SStream_concat0(O, "ish");
2140
68
    break;
2141
112
  case 3:
2142
112
    SStream_concat0(O, "sy");
2143
112
    break;
2144
916
  }
2145
916
}
2146
2147
void printBarrierOption(MCInst *MI, unsigned OpNo, SStream *O)
2148
1.01k
{
2149
1.01k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BarrierOption, OpNo);
2150
1.01k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2151
1.01k
  unsigned Opcode = MCInst_getOpcode(MI);
2152
2153
1.01k
  const char *Name;
2154
1.01k
  if (Opcode == AArch64_ISB) {
2155
34
    const AArch64ISB_ISB *ISB = AArch64ISB_lookupISBByEncoding(Val);
2156
34
    Name = ISB ? ISB->Name : "";
2157
982
  } else if (Opcode == AArch64_TSB) {
2158
34
    const AArch64TSB_TSB *TSB = AArch64TSB_lookupTSBByEncoding(Val);
2159
34
    Name = TSB ? TSB->Name : "";
2160
948
  } else {
2161
948
    const AArch64DB_DB *DB = AArch64DB_lookupDBByEncoding(Val);
2162
948
    Name = DB ? DB->Name : "";
2163
948
  }
2164
1.01k
  if (Name[0] != '\0')
2165
450
    SStream_concat0(O, Name);
2166
566
  else {
2167
566
    SStream_concat(O, "%s", markup("<imm:"));
2168
566
    printUInt32Bang(O, Val);
2169
566
    SStream_concat0(O, markup(">"));
2170
566
  }
2171
1.01k
}
2172
2173
void printBarriernXSOption(MCInst *MI, unsigned OpNo, SStream *O)
2174
392
{
2175
392
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BarriernXSOption, OpNo);
2176
392
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2177
2178
392
  const char *Name;
2179
392
  const AArch64DBnXS_DBnXS *DB = AArch64DBnXS_lookupDBnXSByEncoding(Val);
2180
392
  Name = DB ? DB->Name : "";
2181
2182
392
  if (Name[0] != '\0')
2183
392
    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
392
}
2189
2190
static bool isValidSysReg(const AArch64SysReg_SysReg *Reg, bool Read,
2191
        unsigned mode)
2192
7.88k
{
2193
7.88k
  return (Reg && (Read ? Reg->Readable : Reg->Writeable) &&
2194
714
    AArch64_testFeatureList(mode, Reg->FeaturesRequired));
2195
7.88k
}
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
6.17k
{
2206
6.17k
  const AArch64SysReg_SysReg *Reg =
2207
6.17k
    AArch64SysReg_lookupSysRegByEncoding(Val);
2208
2209
6.17k
  if (Reg && !isValidSysReg(Reg, Read, mode))
2210
1.34k
    Reg = AArch64SysReg_lookupSysRegByName(Reg->AltName);
2211
2212
6.17k
  return Reg;
2213
6.17k
}
2214
2215
void printMRSSystemRegister(MCInst *MI, unsigned OpNo, SStream *O)
2216
1.95k
{
2217
1.95k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MRSSystemRegister, OpNo);
2218
1.95k
  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
1.95k
  if (Val == AARCH64_SYSREG_DBGDTRRX_EL0) {
2224
240
    SStream_concat0(O, "DBGDTRRX_EL0");
2225
240
    return;
2226
240
  }
2227
2228
  // Horrible hack for two different registers having the same encoding.
2229
1.71k
  if (Val == AARCH64_SYSREG_TRCEXTINSELR) {
2230
162
    SStream_concat0(O, "TRCEXTINSELR");
2231
162
    return;
2232
162
  }
2233
2234
1.55k
  const AArch64SysReg_SysReg *Reg =
2235
1.55k
    lookupSysReg(Val, true /*Read*/, MI->csh->mode);
2236
2237
1.55k
  if (isValidSysReg(Reg, true /*Read*/, MI->csh->mode))
2238
60
    SStream_concat0(O, Reg->Name);
2239
1.49k
  else {
2240
1.49k
    char result[AARCH64_GRS_LEN + 1] = { 0 };
2241
1.49k
    AArch64SysReg_genericRegisterString(Val, result);
2242
1.49k
    SStream_concat0(O, result);
2243
1.49k
  }
2244
1.55k
}
2245
2246
void printMSRSystemRegister(MCInst *MI, unsigned OpNo, SStream *O)
2247
4.75k
{
2248
4.75k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MSRSystemRegister, OpNo);
2249
4.75k
  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
4.75k
  if (Val == AARCH64_SYSREG_DBGDTRTX_EL0) {
2255
108
    SStream_concat0(O, "DBGDTRTX_EL0");
2256
108
    return;
2257
108
  }
2258
2259
  // Horrible hack for two different registers having the same encoding.
2260
4.64k
  if (Val == AARCH64_SYSREG_TRCEXTINSELR) {
2261
19
    SStream_concat0(O, "TRCEXTINSELR");
2262
19
    return;
2263
19
  }
2264
2265
4.62k
  const AArch64SysReg_SysReg *Reg =
2266
4.62k
    lookupSysReg(Val, false /*Read*/, MI->csh->mode);
2267
2268
4.62k
  if (isValidSysReg(Reg, false /*Read*/, MI->csh->mode))
2269
297
    SStream_concat0(O, Reg->Name);
2270
4.33k
  else {
2271
4.33k
    char result[AARCH64_GRS_LEN + 1] = { 0 };
2272
4.33k
    AArch64SysReg_genericRegisterString(Val, result);
2273
4.33k
    SStream_concat0(O, result);
2274
4.33k
  }
2275
4.62k
}
2276
2277
void printSystemPStateField(MCInst *MI, unsigned OpNo, SStream *O)
2278
1.13k
{
2279
1.13k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SystemPStateField, OpNo);
2280
1.13k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2281
2282
1.13k
  const AArch64PState_PStateImm0_15 *PStateImm15 =
2283
1.13k
    AArch64PState_lookupPStateImm0_15ByEncoding(Val);
2284
1.13k
  const AArch64PState_PStateImm0_1 *PStateImm1 =
2285
1.13k
    AArch64PState_lookupPStateImm0_1ByEncoding(Val);
2286
1.13k
  if (PStateImm15 &&
2287
945
      AArch64_testFeatureList(MI->csh->mode,
2288
945
            PStateImm15->FeaturesRequired))
2289
945
    SStream_concat0(O, PStateImm15->Name);
2290
188
  else if (PStateImm1 &&
2291
188
     AArch64_testFeatureList(MI->csh->mode,
2292
188
           PStateImm1->FeaturesRequired))
2293
188
    SStream_concat0(O, PStateImm1->Name);
2294
0
  else {
2295
0
    printUInt32Bang(O, (Val));
2296
0
    SStream_concat1(O, '\0');
2297
0
  }
2298
1.13k
}
2299
2300
void printSIMDType10Operand(MCInst *MI, unsigned OpNo, SStream *O)
2301
1.65k
{
2302
1.65k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SIMDType10Operand, OpNo);
2303
1.65k
  unsigned RawVal = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2304
1.65k
  uint64_t Val = AArch64_AM_decodeAdvSIMDModImmType10(RawVal);
2305
1.65k
  SStream_concat(O, "%s#%#016llx", markup("<imm:"), Val);
2306
1.65k
  SStream_concat0(O, markup(">"));
2307
1.65k
}
2308
2309
#define DEFINE_printComplexRotationOp(Angle, Remainder) \
2310
  static void CONCAT(printComplexRotationOp, CONCAT(Angle, Remainder))( \
2311
    MCInst * MI, unsigned OpNo, SStream *O) \
2312
3.37k
  { \
2313
3.37k
    AArch64_add_cs_detail_2( \
2314
3.37k
      MI, \
2315
3.37k
      CONCAT(CONCAT(AArch64_OP_GROUP_ComplexRotationOp, \
2316
3.37k
              Angle), \
2317
3.37k
             Remainder), \
2318
3.37k
      OpNo, Angle, Remainder); \
2319
3.37k
    unsigned Val = \
2320
3.37k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
2321
3.37k
    SStream_concat(O, "%s", markup("<imm:")); \
2322
3.37k
    SStream_concat(O, "#%d", (Val * Angle) + Remainder); \
2323
3.37k
    SStream_concat0(O, markup(">")); \
2324
3.37k
  }
AArch64InstPrinter.c:printComplexRotationOp_180_90
Line
Count
Source
2312
865
  { \
2313
865
    AArch64_add_cs_detail_2( \
2314
865
      MI, \
2315
865
      CONCAT(CONCAT(AArch64_OP_GROUP_ComplexRotationOp, \
2316
865
              Angle), \
2317
865
             Remainder), \
2318
865
      OpNo, Angle, Remainder); \
2319
865
    unsigned Val = \
2320
865
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
2321
865
    SStream_concat(O, "%s", markup("<imm:")); \
2322
865
    SStream_concat(O, "#%d", (Val * Angle) + Remainder); \
2323
865
    SStream_concat0(O, markup(">")); \
2324
865
  }
AArch64InstPrinter.c:printComplexRotationOp_90_0
Line
Count
Source
2312
2.51k
  { \
2313
2.51k
    AArch64_add_cs_detail_2( \
2314
2.51k
      MI, \
2315
2.51k
      CONCAT(CONCAT(AArch64_OP_GROUP_ComplexRotationOp, \
2316
2.51k
              Angle), \
2317
2.51k
             Remainder), \
2318
2.51k
      OpNo, Angle, Remainder); \
2319
2.51k
    unsigned Val = \
2320
2.51k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
2321
2.51k
    SStream_concat(O, "%s", markup("<imm:")); \
2322
2.51k
    SStream_concat(O, "#%d", (Val * Angle) + Remainder); \
2323
2.51k
    SStream_concat0(O, markup(">")); \
2324
2.51k
  }
2325
DEFINE_printComplexRotationOp(180, 90);
2326
DEFINE_printComplexRotationOp(90, 0);
2327
2328
void printSVEPattern(MCInst *MI, unsigned OpNum, SStream *O)
2329
7.96k
{
2330
7.96k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SVEPattern, OpNum);
2331
7.96k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
2332
7.96k
  const AArch64SVEPredPattern_SVEPREDPAT *Pat =
2333
7.96k
    AArch64SVEPredPattern_lookupSVEPREDPATByEncoding(Val);
2334
7.96k
  if (Pat)
2335
5.53k
    SStream_concat0(O, Pat->Name);
2336
2.42k
  else
2337
2.42k
    printUInt32Bang(O, Val);
2338
7.96k
}
2339
2340
void printSVEVecLenSpecifier(MCInst *MI, unsigned OpNum, SStream *O)
2341
777
{
2342
777
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SVEVecLenSpecifier, OpNum);
2343
777
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
2344
  // Pattern has only 1 bit
2345
777
  if (Val > 1)
2346
0
    CS_ASSERT_RET(0 && "Invalid vector length specifier");
2347
777
  const AArch64SVEVecLenSpecifier_SVEVECLENSPECIFIER *Pat =
2348
777
    AArch64SVEVecLenSpecifier_lookupSVEVECLENSPECIFIERByEncoding(
2349
777
      Val);
2350
777
  if (Pat)
2351
777
    SStream_concat0(O, Pat->Name);
2352
777
}
2353
2354
#define DEFINE_printSVERegOp(suffix) \
2355
  void CONCAT(printSVERegOp, suffix)(MCInst * MI, unsigned OpNum, \
2356
             SStream *O) \
2357
189k
  { \
2358
189k
    AArch64_add_cs_detail_1( \
2359
189k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
189k
      CHAR(suffix)); \
2361
189k
    switch (CHAR(suffix)) { \
2362
53.0k
    case '0': \
2363
88.4k
    case 'b': \
2364
128k
    case 'h': \
2365
154k
    case 's': \
2366
187k
    case 'd': \
2367
189k
    case 'q': \
2368
189k
      break; \
2369
187k
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
189k
    } \
2372
189k
\
2373
189k
    unsigned Reg = \
2374
189k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
189k
    printRegName(O, Reg); \
2376
189k
    if (CHAR(suffix) != '0') { \
2377
136k
      SStream_concat1(O, '.'); \
2378
136k
      SStream_concat1(O, CHAR(suffix)); \
2379
136k
    } \
2380
189k
  }
printSVERegOp_b
Line
Count
Source
2357
35.4k
  { \
2358
35.4k
    AArch64_add_cs_detail_1( \
2359
35.4k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
35.4k
      CHAR(suffix)); \
2361
35.4k
    switch (CHAR(suffix)) { \
2362
0
    case '0': \
2363
35.4k
    case 'b': \
2364
35.4k
    case 'h': \
2365
35.4k
    case 's': \
2366
35.4k
    case 'd': \
2367
35.4k
    case 'q': \
2368
35.4k
      break; \
2369
35.4k
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
35.4k
    } \
2372
35.4k
\
2373
35.4k
    unsigned Reg = \
2374
35.4k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
35.4k
    printRegName(O, Reg); \
2376
35.4k
    if (CHAR(suffix) != '0') { \
2377
35.4k
      SStream_concat1(O, '.'); \
2378
35.4k
      SStream_concat1(O, CHAR(suffix)); \
2379
35.4k
    } \
2380
35.4k
  }
printSVERegOp_d
Line
Count
Source
2357
33.1k
  { \
2358
33.1k
    AArch64_add_cs_detail_1( \
2359
33.1k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
33.1k
      CHAR(suffix)); \
2361
33.1k
    switch (CHAR(suffix)) { \
2362
0
    case '0': \
2363
0
    case 'b': \
2364
0
    case 'h': \
2365
0
    case 's': \
2366
33.1k
    case 'd': \
2367
33.1k
    case 'q': \
2368
33.1k
      break; \
2369
33.1k
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
33.1k
    } \
2372
33.1k
\
2373
33.1k
    unsigned Reg = \
2374
33.1k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
33.1k
    printRegName(O, Reg); \
2376
33.1k
    if (CHAR(suffix) != '0') { \
2377
33.1k
      SStream_concat1(O, '.'); \
2378
33.1k
      SStream_concat1(O, CHAR(suffix)); \
2379
33.1k
    } \
2380
33.1k
  }
printSVERegOp_h
Line
Count
Source
2357
39.5k
  { \
2358
39.5k
    AArch64_add_cs_detail_1( \
2359
39.5k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
39.5k
      CHAR(suffix)); \
2361
39.5k
    switch (CHAR(suffix)) { \
2362
0
    case '0': \
2363
0
    case 'b': \
2364
39.5k
    case 'h': \
2365
39.5k
    case 's': \
2366
39.5k
    case 'd': \
2367
39.5k
    case 'q': \
2368
39.5k
      break; \
2369
39.5k
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
39.5k
    } \
2372
39.5k
\
2373
39.5k
    unsigned Reg = \
2374
39.5k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
39.5k
    printRegName(O, Reg); \
2376
39.5k
    if (CHAR(suffix) != '0') { \
2377
39.5k
      SStream_concat1(O, '.'); \
2378
39.5k
      SStream_concat1(O, CHAR(suffix)); \
2379
39.5k
    } \
2380
39.5k
  }
printSVERegOp_s
Line
Count
Source
2357
26.8k
  { \
2358
26.8k
    AArch64_add_cs_detail_1( \
2359
26.8k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
26.8k
      CHAR(suffix)); \
2361
26.8k
    switch (CHAR(suffix)) { \
2362
0
    case '0': \
2363
0
    case 'b': \
2364
0
    case 'h': \
2365
26.8k
    case 's': \
2366
26.8k
    case 'd': \
2367
26.8k
    case 'q': \
2368
26.8k
      break; \
2369
26.8k
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
26.8k
    } \
2372
26.8k
\
2373
26.8k
    unsigned Reg = \
2374
26.8k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
26.8k
    printRegName(O, Reg); \
2376
26.8k
    if (CHAR(suffix) != '0') { \
2377
26.8k
      SStream_concat1(O, '.'); \
2378
26.8k
      SStream_concat1(O, CHAR(suffix)); \
2379
26.8k
    } \
2380
26.8k
  }
printSVERegOp_0
Line
Count
Source
2357
53.0k
  { \
2358
53.0k
    AArch64_add_cs_detail_1( \
2359
53.0k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
53.0k
      CHAR(suffix)); \
2361
53.0k
    switch (CHAR(suffix)) { \
2362
53.0k
    case '0': \
2363
53.0k
    case 'b': \
2364
53.0k
    case 'h': \
2365
53.0k
    case 's': \
2366
53.0k
    case 'd': \
2367
53.0k
    case 'q': \
2368
53.0k
      break; \
2369
53.0k
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
53.0k
    } \
2372
53.0k
\
2373
53.0k
    unsigned Reg = \
2374
53.0k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
53.0k
    printRegName(O, Reg); \
2376
53.0k
    if (CHAR(suffix) != '0') { \
2377
0
      SStream_concat1(O, '.'); \
2378
0
      SStream_concat1(O, CHAR(suffix)); \
2379
0
    } \
2380
53.0k
  }
printSVERegOp_q
Line
Count
Source
2357
1.23k
  { \
2358
1.23k
    AArch64_add_cs_detail_1( \
2359
1.23k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
1.23k
      CHAR(suffix)); \
2361
1.23k
    switch (CHAR(suffix)) { \
2362
0
    case '0': \
2363
0
    case 'b': \
2364
0
    case 'h': \
2365
0
    case 's': \
2366
0
    case 'd': \
2367
1.23k
    case 'q': \
2368
1.23k
      break; \
2369
0
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
1.23k
    } \
2372
1.23k
\
2373
1.23k
    unsigned Reg = \
2374
1.23k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
1.23k
    printRegName(O, Reg); \
2376
1.23k
    if (CHAR(suffix) != '0') { \
2377
1.23k
      SStream_concat1(O, '.'); \
2378
1.23k
      SStream_concat1(O, CHAR(suffix)); \
2379
1.23k
    } \
2380
1.23k
  }
2381
DEFINE_printSVERegOp(b);
2382
DEFINE_printSVERegOp(d);
2383
DEFINE_printSVERegOp(h);
2384
DEFINE_printSVERegOp(s);
2385
DEFINE_printSVERegOp(0);
2386
DEFINE_printSVERegOp(q);
2387
2388
#define DECLARE_printImmSVE_S32(T) \
2389
  void CONCAT(printImmSVE, T)(T Val, SStream * O) \
2390
2.95k
  { \
2391
2.95k
    printInt32Bang(O, Val); \
2392
2.95k
  }
printImmSVE_int16_t
Line
Count
Source
2390
1.36k
  { \
2391
1.36k
    printInt32Bang(O, Val); \
2392
1.36k
  }
printImmSVE_int8_t
Line
Count
Source
2390
1.02k
  { \
2391
1.02k
    printInt32Bang(O, Val); \
2392
1.02k
  }
printImmSVE_int32_t
Line
Count
Source
2390
559
  { \
2391
559
    printInt32Bang(O, Val); \
2392
559
  }
2393
DECLARE_printImmSVE_S32(int16_t);
2394
DECLARE_printImmSVE_S32(int8_t);
2395
DECLARE_printImmSVE_S32(int32_t);
2396
2397
#define DECLARE_printImmSVE_U32(T) \
2398
  void CONCAT(printImmSVE, T)(T Val, SStream * O) \
2399
437
  { \
2400
437
    printUInt32Bang(O, Val); \
2401
437
  }
printImmSVE_uint16_t
Line
Count
Source
2399
166
  { \
2400
166
    printUInt32Bang(O, Val); \
2401
166
  }
printImmSVE_uint8_t
Line
Count
Source
2399
108
  { \
2400
108
    printUInt32Bang(O, Val); \
2401
108
  }
printImmSVE_uint32_t
Line
Count
Source
2399
163
  { \
2400
163
    printUInt32Bang(O, Val); \
2401
163
  }
2402
DECLARE_printImmSVE_U32(uint16_t);
2403
DECLARE_printImmSVE_U32(uint8_t);
2404
DECLARE_printImmSVE_U32(uint32_t);
2405
2406
#define DECLARE_printImmSVE_S64(T) \
2407
  void CONCAT(printImmSVE, T)(T Val, SStream * O) \
2408
1.30k
  { \
2409
1.30k
    printInt64Bang(O, Val); \
2410
1.30k
  }
2411
DECLARE_printImmSVE_S64(int64_t);
2412
2413
#define DECLARE_printImmSVE_U64(T) \
2414
  void CONCAT(printImmSVE, T)(T Val, SStream * O) \
2415
268
  { \
2416
268
    printUInt64Bang(O, Val); \
2417
268
  }
2418
DECLARE_printImmSVE_U64(uint64_t);
2419
2420
#define DEFINE_isSignedType(T) \
2421
  static inline bool CONCAT(isSignedType, T)() \
2422
2.23k
  { \
2423
2.23k
    return CHAR(T) == 'i'; \
2424
2.23k
  }
AArch64InstPrinter.c:isSignedType_int16_t
Line
Count
Source
2422
181
  { \
2423
181
    return CHAR(T) == 'i'; \
2424
181
  }
AArch64InstPrinter.c:isSignedType_int8_t
Line
Count
Source
2422
1.02k
  { \
2423
1.02k
    return CHAR(T) == 'i'; \
2424
1.02k
  }
AArch64InstPrinter.c:isSignedType_int64_t
Line
Count
Source
2422
236
  { \
2423
236
    return CHAR(T) == 'i'; \
2424
236
  }
AArch64InstPrinter.c:isSignedType_int32_t
Line
Count
Source
2422
93
  { \
2423
93
    return CHAR(T) == 'i'; \
2424
93
  }
AArch64InstPrinter.c:isSignedType_uint16_t
Line
Count
Source
2422
166
  { \
2423
166
    return CHAR(T) == 'i'; \
2424
166
  }
AArch64InstPrinter.c:isSignedType_uint8_t
Line
Count
Source
2422
108
  { \
2423
108
    return CHAR(T) == 'i'; \
2424
108
  }
AArch64InstPrinter.c:isSignedType_uint64_t
Line
Count
Source
2422
268
  { \
2423
268
    return CHAR(T) == 'i'; \
2424
268
  }
AArch64InstPrinter.c:isSignedType_uint32_t
Line
Count
Source
2422
163
  { \
2423
163
    return CHAR(T) == 'i'; \
2424
163
  }
2425
DEFINE_isSignedType(int8_t);
2426
DEFINE_isSignedType(int16_t);
2427
DEFINE_isSignedType(int32_t);
2428
DEFINE_isSignedType(int64_t);
2429
DEFINE_isSignedType(uint8_t);
2430
DEFINE_isSignedType(uint16_t);
2431
DEFINE_isSignedType(uint32_t);
2432
DEFINE_isSignedType(uint64_t);
2433
2434
#define DEFINE_printImm8OptLsl(T) \
2435
  void CONCAT(printImm8OptLsl, T)(MCInst * MI, unsigned OpNum, \
2436
          SStream *O) \
2437
3.29k
  { \
2438
3.29k
    AArch64_add_cs_detail_1( \
2439
3.29k
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
3.29k
      sizeof(T)); \
2441
3.29k
    unsigned UnscaledVal = \
2442
3.29k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
3.29k
    unsigned Shift = \
2444
3.29k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
3.29k
\
2446
3.29k
    if ((UnscaledVal == 0) && \
2447
3.29k
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
1.05k
      SStream_concat(O, "%s", markup("<imm:")); \
2449
1.05k
      SStream_concat1(O, '#'); \
2450
1.05k
      printUInt64(O, (UnscaledVal)); \
2451
1.05k
      SStream_concat0(O, markup(">")); \
2452
1.05k
      printShifter(MI, OpNum + 1, O); \
2453
1.05k
      return; \
2454
1.05k
    } \
2455
3.29k
\
2456
3.29k
    T Val; \
2457
2.23k
    if (CONCAT(isSignedType, T)()) \
2458
2.23k
      Val = (int8_t)UnscaledVal * \
2459
1.53k
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
2.23k
    else \
2461
2.23k
      Val = (uint8_t)UnscaledVal * \
2462
705
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
2.23k
\
2464
2.23k
    CONCAT(printImmSVE, T)(Val, O); \
2465
2.23k
  }
printImm8OptLsl_int16_t
Line
Count
Source
2437
259
  { \
2438
259
    AArch64_add_cs_detail_1( \
2439
259
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
259
      sizeof(T)); \
2441
259
    unsigned UnscaledVal = \
2442
259
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
259
    unsigned Shift = \
2444
259
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
259
\
2446
259
    if ((UnscaledVal == 0) && \
2447
259
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
78
      SStream_concat(O, "%s", markup("<imm:")); \
2449
78
      SStream_concat1(O, '#'); \
2450
78
      printUInt64(O, (UnscaledVal)); \
2451
78
      SStream_concat0(O, markup(">")); \
2452
78
      printShifter(MI, OpNum + 1, O); \
2453
78
      return; \
2454
78
    } \
2455
259
\
2456
259
    T Val; \
2457
181
    if (CONCAT(isSignedType, T)()) \
2458
181
      Val = (int8_t)UnscaledVal * \
2459
181
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
181
    else \
2461
181
      Val = (uint8_t)UnscaledVal * \
2462
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
181
\
2464
181
    CONCAT(printImmSVE, T)(Val, O); \
2465
181
  }
printImm8OptLsl_int8_t
Line
Count
Source
2437
1.02k
  { \
2438
1.02k
    AArch64_add_cs_detail_1( \
2439
1.02k
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
1.02k
      sizeof(T)); \
2441
1.02k
    unsigned UnscaledVal = \
2442
1.02k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
1.02k
    unsigned Shift = \
2444
1.02k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
1.02k
\
2446
1.02k
    if ((UnscaledVal == 0) && \
2447
1.02k
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
0
      SStream_concat(O, "%s", markup("<imm:")); \
2449
0
      SStream_concat1(O, '#'); \
2450
0
      printUInt64(O, (UnscaledVal)); \
2451
0
      SStream_concat0(O, markup(">")); \
2452
0
      printShifter(MI, OpNum + 1, O); \
2453
0
      return; \
2454
0
    } \
2455
1.02k
\
2456
1.02k
    T Val; \
2457
1.02k
    if (CONCAT(isSignedType, T)()) \
2458
1.02k
      Val = (int8_t)UnscaledVal * \
2459
1.02k
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
1.02k
    else \
2461
1.02k
      Val = (uint8_t)UnscaledVal * \
2462
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
1.02k
\
2464
1.02k
    CONCAT(printImmSVE, T)(Val, O); \
2465
1.02k
  }
printImm8OptLsl_int64_t
Line
Count
Source
2437
262
  { \
2438
262
    AArch64_add_cs_detail_1( \
2439
262
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
262
      sizeof(T)); \
2441
262
    unsigned UnscaledVal = \
2442
262
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
262
    unsigned Shift = \
2444
262
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
262
\
2446
262
    if ((UnscaledVal == 0) && \
2447
262
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
26
      SStream_concat(O, "%s", markup("<imm:")); \
2449
26
      SStream_concat1(O, '#'); \
2450
26
      printUInt64(O, (UnscaledVal)); \
2451
26
      SStream_concat0(O, markup(">")); \
2452
26
      printShifter(MI, OpNum + 1, O); \
2453
26
      return; \
2454
26
    } \
2455
262
\
2456
262
    T Val; \
2457
236
    if (CONCAT(isSignedType, T)()) \
2458
236
      Val = (int8_t)UnscaledVal * \
2459
236
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
236
    else \
2461
236
      Val = (uint8_t)UnscaledVal * \
2462
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
236
\
2464
236
    CONCAT(printImmSVE, T)(Val, O); \
2465
236
  }
printImm8OptLsl_int32_t
Line
Count
Source
2437
163
  { \
2438
163
    AArch64_add_cs_detail_1( \
2439
163
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
163
      sizeof(T)); \
2441
163
    unsigned UnscaledVal = \
2442
163
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
163
    unsigned Shift = \
2444
163
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
163
\
2446
163
    if ((UnscaledVal == 0) && \
2447
163
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
70
      SStream_concat(O, "%s", markup("<imm:")); \
2449
70
      SStream_concat1(O, '#'); \
2450
70
      printUInt64(O, (UnscaledVal)); \
2451
70
      SStream_concat0(O, markup(">")); \
2452
70
      printShifter(MI, OpNum + 1, O); \
2453
70
      return; \
2454
70
    } \
2455
163
\
2456
163
    T Val; \
2457
93
    if (CONCAT(isSignedType, T)()) \
2458
93
      Val = (int8_t)UnscaledVal * \
2459
93
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
93
    else \
2461
93
      Val = (uint8_t)UnscaledVal * \
2462
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
93
\
2464
93
    CONCAT(printImmSVE, T)(Val, O); \
2465
93
  }
printImm8OptLsl_uint16_t
Line
Count
Source
2437
271
  { \
2438
271
    AArch64_add_cs_detail_1( \
2439
271
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
271
      sizeof(T)); \
2441
271
    unsigned UnscaledVal = \
2442
271
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
271
    unsigned Shift = \
2444
271
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
271
\
2446
271
    if ((UnscaledVal == 0) && \
2447
271
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
105
      SStream_concat(O, "%s", markup("<imm:")); \
2449
105
      SStream_concat1(O, '#'); \
2450
105
      printUInt64(O, (UnscaledVal)); \
2451
105
      SStream_concat0(O, markup(">")); \
2452
105
      printShifter(MI, OpNum + 1, O); \
2453
105
      return; \
2454
105
    } \
2455
271
\
2456
271
    T Val; \
2457
166
    if (CONCAT(isSignedType, T)()) \
2458
166
      Val = (int8_t)UnscaledVal * \
2459
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
166
    else \
2461
166
      Val = (uint8_t)UnscaledVal * \
2462
166
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
166
\
2464
166
    CONCAT(printImmSVE, T)(Val, O); \
2465
166
  }
printImm8OptLsl_uint8_t
Line
Count
Source
2437
108
  { \
2438
108
    AArch64_add_cs_detail_1( \
2439
108
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
108
      sizeof(T)); \
2441
108
    unsigned UnscaledVal = \
2442
108
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
108
    unsigned Shift = \
2444
108
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
108
\
2446
108
    if ((UnscaledVal == 0) && \
2447
108
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
0
      SStream_concat(O, "%s", markup("<imm:")); \
2449
0
      SStream_concat1(O, '#'); \
2450
0
      printUInt64(O, (UnscaledVal)); \
2451
0
      SStream_concat0(O, markup(">")); \
2452
0
      printShifter(MI, OpNum + 1, O); \
2453
0
      return; \
2454
0
    } \
2455
108
\
2456
108
    T Val; \
2457
108
    if (CONCAT(isSignedType, T)()) \
2458
108
      Val = (int8_t)UnscaledVal * \
2459
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
108
    else \
2461
108
      Val = (uint8_t)UnscaledVal * \
2462
108
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
108
\
2464
108
    CONCAT(printImmSVE, T)(Val, O); \
2465
108
  }
printImm8OptLsl_uint64_t
Line
Count
Source
2437
839
  { \
2438
839
    AArch64_add_cs_detail_1( \
2439
839
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
839
      sizeof(T)); \
2441
839
    unsigned UnscaledVal = \
2442
839
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
839
    unsigned Shift = \
2444
839
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
839
\
2446
839
    if ((UnscaledVal == 0) && \
2447
839
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
571
      SStream_concat(O, "%s", markup("<imm:")); \
2449
571
      SStream_concat1(O, '#'); \
2450
571
      printUInt64(O, (UnscaledVal)); \
2451
571
      SStream_concat0(O, markup(">")); \
2452
571
      printShifter(MI, OpNum + 1, O); \
2453
571
      return; \
2454
571
    } \
2455
839
\
2456
839
    T Val; \
2457
268
    if (CONCAT(isSignedType, T)()) \
2458
268
      Val = (int8_t)UnscaledVal * \
2459
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
268
    else \
2461
268
      Val = (uint8_t)UnscaledVal * \
2462
268
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
268
\
2464
268
    CONCAT(printImmSVE, T)(Val, O); \
2465
268
  }
printImm8OptLsl_uint32_t
Line
Count
Source
2437
371
  { \
2438
371
    AArch64_add_cs_detail_1( \
2439
371
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
371
      sizeof(T)); \
2441
371
    unsigned UnscaledVal = \
2442
371
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
371
    unsigned Shift = \
2444
371
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
371
\
2446
371
    if ((UnscaledVal == 0) && \
2447
371
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
208
      SStream_concat(O, "%s", markup("<imm:")); \
2449
208
      SStream_concat1(O, '#'); \
2450
208
      printUInt64(O, (UnscaledVal)); \
2451
208
      SStream_concat0(O, markup(">")); \
2452
208
      printShifter(MI, OpNum + 1, O); \
2453
208
      return; \
2454
208
    } \
2455
371
\
2456
371
    T Val; \
2457
163
    if (CONCAT(isSignedType, T)()) \
2458
163
      Val = (int8_t)UnscaledVal * \
2459
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
163
    else \
2461
163
      Val = (uint8_t)UnscaledVal * \
2462
163
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
163
\
2464
163
    CONCAT(printImmSVE, T)(Val, O); \
2465
163
  }
2466
DEFINE_printImm8OptLsl(int16_t);
2467
DEFINE_printImm8OptLsl(int8_t);
2468
DEFINE_printImm8OptLsl(int64_t);
2469
DEFINE_printImm8OptLsl(int32_t);
2470
DEFINE_printImm8OptLsl(uint16_t);
2471
DEFINE_printImm8OptLsl(uint8_t);
2472
DEFINE_printImm8OptLsl(uint64_t);
2473
DEFINE_printImm8OptLsl(uint32_t);
2474
2475
#define DEFINE_printSVELogicalImm(T) \
2476
  void CONCAT(printSVELogicalImm, T)(MCInst * MI, unsigned OpNum, \
2477
             SStream *O) \
2478
4.09k
  { \
2479
4.09k
    AArch64_add_cs_detail_1( \
2480
4.09k
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2481
4.09k
      sizeof(T)); \
2482
4.09k
    typedef T SignedT; \
2483
4.09k
    typedef CONCATS(u, T) UnsignedT; \
2484
4.09k
\
2485
4.09k
    uint64_t Val = \
2486
4.09k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2487
4.09k
    UnsignedT PrintVal = \
2488
4.09k
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2489
4.09k
\
2490
4.09k
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2491
4.09k
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2492
4.09k
    else if ((uint16_t)PrintVal == PrintVal) \
2493
2.47k
      CONCAT(printImmSVE, T)(PrintVal, O); \
2494
2.47k
    else { \
2495
1.36k
      SStream_concat(O, "%s", markup("<imm:")); \
2496
1.36k
      printUInt64Bang(O, ((uint64_t)PrintVal)); \
2497
1.36k
      SStream_concat0(O, markup(">")); \
2498
1.36k
    } \
2499
4.09k
  }
printSVELogicalImm_int16_t
Line
Count
Source
2478
1.18k
  { \
2479
1.18k
    AArch64_add_cs_detail_1( \
2480
1.18k
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2481
1.18k
      sizeof(T)); \
2482
1.18k
    typedef T SignedT; \
2483
1.18k
    typedef CONCATS(u, T) UnsignedT; \
2484
1.18k
\
2485
1.18k
    uint64_t Val = \
2486
1.18k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2487
1.18k
    UnsignedT PrintVal = \
2488
1.18k
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2489
1.18k
\
2490
1.18k
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2491
1.18k
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2492
1.18k
    else if ((uint16_t)PrintVal == PrintVal) \
2493
0
      CONCAT(printImmSVE, T)(PrintVal, O); \
2494
0
    else { \
2495
0
      SStream_concat(O, "%s", markup("<imm:")); \
2496
0
      printUInt64Bang(O, ((uint64_t)PrintVal)); \
2497
0
      SStream_concat0(O, markup(">")); \
2498
0
    } \
2499
1.18k
  }
printSVELogicalImm_int32_t
Line
Count
Source
2478
1.03k
  { \
2479
1.03k
    AArch64_add_cs_detail_1( \
2480
1.03k
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2481
1.03k
      sizeof(T)); \
2482
1.03k
    typedef T SignedT; \
2483
1.03k
    typedef CONCATS(u, T) UnsignedT; \
2484
1.03k
\
2485
1.03k
    uint64_t Val = \
2486
1.03k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2487
1.03k
    UnsignedT PrintVal = \
2488
1.03k
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2489
1.03k
\
2490
1.03k
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2491
1.03k
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2492
1.03k
    else if ((uint16_t)PrintVal == PrintVal) \
2493
755
      CONCAT(printImmSVE, T)(PrintVal, O); \
2494
755
    else { \
2495
573
      SStream_concat(O, "%s", markup("<imm:")); \
2496
573
      printUInt64Bang(O, ((uint64_t)PrintVal)); \
2497
573
      SStream_concat0(O, markup(">")); \
2498
573
    } \
2499
1.03k
  }
printSVELogicalImm_int64_t
Line
Count
Source
2478
1.86k
  { \
2479
1.86k
    AArch64_add_cs_detail_1( \
2480
1.86k
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2481
1.86k
      sizeof(T)); \
2482
1.86k
    typedef T SignedT; \
2483
1.86k
    typedef CONCATS(u, T) UnsignedT; \
2484
1.86k
\
2485
1.86k
    uint64_t Val = \
2486
1.86k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2487
1.86k
    UnsignedT PrintVal = \
2488
1.86k
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2489
1.86k
\
2490
1.86k
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2491
1.86k
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2492
1.86k
    else if ((uint16_t)PrintVal == PrintVal) \
2493
1.72k
      CONCAT(printImmSVE, T)(PrintVal, O); \
2494
1.72k
    else { \
2495
796
      SStream_concat(O, "%s", markup("<imm:")); \
2496
796
      printUInt64Bang(O, ((uint64_t)PrintVal)); \
2497
796
      SStream_concat0(O, markup(">")); \
2498
796
    } \
2499
1.86k
  }
2500
DEFINE_printSVELogicalImm(int16_t);
2501
DEFINE_printSVELogicalImm(int32_t);
2502
DEFINE_printSVELogicalImm(int64_t);
2503
2504
#define DEFINE_printZPRasFPR(Width) \
2505
  void CONCAT(printZPRasFPR, Width)(MCInst * MI, unsigned OpNum, \
2506
            SStream *O) \
2507
2.57k
  { \
2508
2.57k
    AArch64_add_cs_detail_1( \
2509
2.57k
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
2.57k
      Width); \
2511
2.57k
    unsigned Base; \
2512
2.57k
    switch (Width) { \
2513
315
    case 8: \
2514
315
      Base = AArch64_B0; \
2515
315
      break; \
2516
733
    case 16: \
2517
733
      Base = AArch64_H0; \
2518
733
      break; \
2519
588
    case 32: \
2520
588
      Base = AArch64_S0; \
2521
588
      break; \
2522
874
    case 64: \
2523
874
      Base = AArch64_D0; \
2524
874
      break; \
2525
67
    case 128: \
2526
67
      Base = AArch64_Q0; \
2527
67
      break; \
2528
0
    default: \
2529
0
      CS_ASSERT_RET(0 && "Unsupported width"); \
2530
2.57k
    } \
2531
2.57k
    unsigned Reg = \
2532
2.57k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
2.57k
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
2.57k
  }
printZPRasFPR_8
Line
Count
Source
2507
315
  { \
2508
315
    AArch64_add_cs_detail_1( \
2509
315
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
315
      Width); \
2511
315
    unsigned Base; \
2512
315
    switch (Width) { \
2513
315
    case 8: \
2514
315
      Base = AArch64_B0; \
2515
315
      break; \
2516
0
    case 16: \
2517
0
      Base = AArch64_H0; \
2518
0
      break; \
2519
0
    case 32: \
2520
0
      Base = AArch64_S0; \
2521
0
      break; \
2522
0
    case 64: \
2523
0
      Base = AArch64_D0; \
2524
0
      break; \
2525
0
    case 128: \
2526
0
      Base = AArch64_Q0; \
2527
0
      break; \
2528
0
    default: \
2529
0
      CS_ASSERT_RET(0 && "Unsupported width"); \
2530
315
    } \
2531
315
    unsigned Reg = \
2532
315
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
315
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
315
  }
printZPRasFPR_64
Line
Count
Source
2507
874
  { \
2508
874
    AArch64_add_cs_detail_1( \
2509
874
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
874
      Width); \
2511
874
    unsigned Base; \
2512
874
    switch (Width) { \
2513
0
    case 8: \
2514
0
      Base = AArch64_B0; \
2515
0
      break; \
2516
0
    case 16: \
2517
0
      Base = AArch64_H0; \
2518
0
      break; \
2519
0
    case 32: \
2520
0
      Base = AArch64_S0; \
2521
0
      break; \
2522
874
    case 64: \
2523
874
      Base = AArch64_D0; \
2524
874
      break; \
2525
0
    case 128: \
2526
0
      Base = AArch64_Q0; \
2527
0
      break; \
2528
0
    default: \
2529
0
      CS_ASSERT_RET(0 && "Unsupported width"); \
2530
874
    } \
2531
874
    unsigned Reg = \
2532
874
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
874
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
874
  }
printZPRasFPR_16
Line
Count
Source
2507
733
  { \
2508
733
    AArch64_add_cs_detail_1( \
2509
733
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
733
      Width); \
2511
733
    unsigned Base; \
2512
733
    switch (Width) { \
2513
0
    case 8: \
2514
0
      Base = AArch64_B0; \
2515
0
      break; \
2516
733
    case 16: \
2517
733
      Base = AArch64_H0; \
2518
733
      break; \
2519
0
    case 32: \
2520
0
      Base = AArch64_S0; \
2521
0
      break; \
2522
0
    case 64: \
2523
0
      Base = AArch64_D0; \
2524
0
      break; \
2525
0
    case 128: \
2526
0
      Base = AArch64_Q0; \
2527
0
      break; \
2528
0
    default: \
2529
0
      CS_ASSERT_RET(0 && "Unsupported width"); \
2530
733
    } \
2531
733
    unsigned Reg = \
2532
733
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
733
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
733
  }
printZPRasFPR_32
Line
Count
Source
2507
588
  { \
2508
588
    AArch64_add_cs_detail_1( \
2509
588
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
588
      Width); \
2511
588
    unsigned Base; \
2512
588
    switch (Width) { \
2513
0
    case 8: \
2514
0
      Base = AArch64_B0; \
2515
0
      break; \
2516
0
    case 16: \
2517
0
      Base = AArch64_H0; \
2518
0
      break; \
2519
588
    case 32: \
2520
588
      Base = AArch64_S0; \
2521
588
      break; \
2522
0
    case 64: \
2523
0
      Base = AArch64_D0; \
2524
0
      break; \
2525
0
    case 128: \
2526
0
      Base = AArch64_Q0; \
2527
0
      break; \
2528
0
    default: \
2529
0
      CS_ASSERT_RET(0 && "Unsupported width"); \
2530
588
    } \
2531
588
    unsigned Reg = \
2532
588
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
588
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
588
  }
printZPRasFPR_128
Line
Count
Source
2507
67
  { \
2508
67
    AArch64_add_cs_detail_1( \
2509
67
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
67
      Width); \
2511
67
    unsigned Base; \
2512
67
    switch (Width) { \
2513
0
    case 8: \
2514
0
      Base = AArch64_B0; \
2515
0
      break; \
2516
0
    case 16: \
2517
0
      Base = AArch64_H0; \
2518
0
      break; \
2519
0
    case 32: \
2520
0
      Base = AArch64_S0; \
2521
0
      break; \
2522
0
    case 64: \
2523
0
      Base = AArch64_D0; \
2524
0
      break; \
2525
67
    case 128: \
2526
67
      Base = AArch64_Q0; \
2527
67
      break; \
2528
0
    default: \
2529
0
      CS_ASSERT_RET(0 && "Unsupported width"); \
2530
67
    } \
2531
67
    unsigned Reg = \
2532
67
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
67
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
67
  }
2535
DEFINE_printZPRasFPR(8);
2536
DEFINE_printZPRasFPR(64);
2537
DEFINE_printZPRasFPR(16);
2538
DEFINE_printZPRasFPR(32);
2539
DEFINE_printZPRasFPR(128);
2540
2541
#define DEFINE_printExactFPImm(ImmIs0, ImmIs1) \
2542
  void CONCAT(printExactFPImm, CONCAT(ImmIs0, ImmIs1))( \
2543
    MCInst * MI, unsigned OpNum, SStream *O) \
2544
1.40k
  { \
2545
1.40k
    AArch64_add_cs_detail_2( \
2546
1.40k
      MI, \
2547
1.40k
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2548
1.40k
             ImmIs1), \
2549
1.40k
      OpNum, ImmIs0, ImmIs1); \
2550
1.40k
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2551
1.40k
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2552
1.40k
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2553
1.40k
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2554
1.40k
    unsigned Val = \
2555
1.40k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2556
1.40k
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2557
1.40k
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2558
1.40k
    SStream_concat0(O, markup(">")); \
2559
1.40k
  }
printExactFPImm_AArch64ExactFPImm_half_AArch64ExactFPImm_one
Line
Count
Source
2544
184
  { \
2545
184
    AArch64_add_cs_detail_2( \
2546
184
      MI, \
2547
184
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2548
184
             ImmIs1), \
2549
184
      OpNum, ImmIs0, ImmIs1); \
2550
184
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2551
184
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2552
184
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2553
184
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2554
184
    unsigned Val = \
2555
184
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2556
184
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2557
184
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2558
184
    SStream_concat0(O, markup(">")); \
2559
184
  }
printExactFPImm_AArch64ExactFPImm_zero_AArch64ExactFPImm_one
Line
Count
Source
2544
188
  { \
2545
188
    AArch64_add_cs_detail_2( \
2546
188
      MI, \
2547
188
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2548
188
             ImmIs1), \
2549
188
      OpNum, ImmIs0, ImmIs1); \
2550
188
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2551
188
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2552
188
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2553
188
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2554
188
    unsigned Val = \
2555
188
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2556
188
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2557
188
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2558
188
    SStream_concat0(O, markup(">")); \
2559
188
  }
printExactFPImm_AArch64ExactFPImm_half_AArch64ExactFPImm_two
Line
Count
Source
2544
1.03k
  { \
2545
1.03k
    AArch64_add_cs_detail_2( \
2546
1.03k
      MI, \
2547
1.03k
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2548
1.03k
             ImmIs1), \
2549
1.03k
      OpNum, ImmIs0, ImmIs1); \
2550
1.03k
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2551
1.03k
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2552
1.03k
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2553
1.03k
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2554
1.03k
    unsigned Val = \
2555
1.03k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2556
1.03k
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2557
1.03k
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2558
1.03k
    SStream_concat0(O, markup(">")); \
2559
1.03k
  }
2560
DEFINE_printExactFPImm(AArch64ExactFPImm_half, AArch64ExactFPImm_one);
2561
DEFINE_printExactFPImm(AArch64ExactFPImm_zero, AArch64ExactFPImm_one);
2562
DEFINE_printExactFPImm(AArch64ExactFPImm_half, AArch64ExactFPImm_two);
2563
2564
void printGPR64as32(MCInst *MI, unsigned OpNum, SStream *O)
2565
6.40k
{
2566
6.40k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_GPR64as32, OpNum);
2567
6.40k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
2568
6.40k
  printRegName(O, getWRegFromXReg(Reg));
2569
6.40k
}
2570
2571
void printGPR64x8(MCInst *MI, unsigned OpNum, SStream *O)
2572
931
{
2573
931
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_GPR64x8, OpNum);
2574
931
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
2575
931
  printRegName(O,
2576
931
         MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_x8sub_0));
2577
931
}
2578
2579
void printSyspXzrPair(MCInst *MI, unsigned OpNum, SStream *O)
2580
1.17k
{
2581
1.17k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SyspXzrPair, OpNum);
2582
1.17k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
2583
2584
1.17k
  SStream_concat(O, "%s%s", getRegisterName(Reg, AArch64_NoRegAltName),
2585
1.17k
           ", ");
2586
1.17k
  SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
2587
1.17k
}
2588
2589
const char *AArch64_LLVM_getRegisterName(unsigned RegNo, unsigned AltIdx)
2590
210k
{
2591
210k
  return getRegisterName(RegNo, AltIdx);
2592
210k
}
2593
2594
void AArch64_LLVM_printInstruction(MCInst *MI, SStream *O,
2595
           void * /* MCRegisterInfo* */ info)
2596
365k
{
2597
365k
  printInst(MI, MI->address, "", O);
2598
365k
}