Coverage Report

Created: 2026-01-17 06:58

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