Coverage Report

Created: 2025-08-28 06:43

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