Coverage Report

Created: 2026-07-12 06:49

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