Coverage Report

Created: 2026-08-31 06:58

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