Coverage Report

Created: 2025-07-09 06:32

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