Coverage Report

Created: 2025-08-29 06:29

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