Coverage Report

Created: 2026-09-03 07:09

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