Coverage Report

Created: 2025-07-01 07:03

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